]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/mach-s5pv210/setup-sdhci-gpio.c
ARM: S5PV210: Change to using s3c_gpio_cfgrange_nopull()
[net-next-2.6.git] / arch / arm / mach-s5pv210 / setup-sdhci-gpio.c
1 /* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
2  *
3  * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV210 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/platform_device.h>
17 #include <linux/io.h>
18 #include <linux/gpio.h>
19 #include <linux/mmc/host.h>
20 #include <linux/mmc/card.h>
21
22 #include <plat/gpio-cfg.h>
23 #include <plat/regs-sdhci.h>
24 #include <plat/sdhci.h>
25
26 void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27 {
28         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
29
30         /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
31         s3c_gpio_cfgall_range(S5PV210_GPG0(0), 2,
32                               S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
33
34         switch (width) {
35         case 8:
36                 /* GPG1[3:6] special-funtion 3 */
37                 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
38         case 4:
39                 /* GPG0[3:6] special-funtion 2 */
40                 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
41         default:
42                 break;
43         }
44
45         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
46                 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
47                 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
48         }
49 }
50
51 void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
52 {
53         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
54
55         /* Set all the necessary GPG1[0:1] pins to special-function 2 */
56         s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
57
58         /* Data pin GPG1[3:6] to special-function 2 */
59         s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
60
61         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
62                 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
63                 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
64         }
65 }
66
67 void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
68 {
69         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
70
71         /* Set all the necessary GPG2[0:1] pins to special-function 2 */
72         s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
73
74         switch (width) {
75         case 8:
76                 /* Data pin GPG3[3:6] to special-function 3 */
77                 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
78         case 4:
79                 /* Data pin GPG2[3:6] to special-function 2 */
80                 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
81         default:
82                 break;
83         }
84
85         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
86                 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
87                 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
88         }
89 }
90
91 void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
92 {
93         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
94
95         /* Set all the necessary GPG3[0:1] pins to special-function 2 */
96         s3c_gpio_cfgall_range(S5PV210_GPG3(0), 2,
97                               S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
98
99         /* Data pin GPG3[3:6] to special-function 2 */
100         s3c_gpio_cfgall_range(S5PV210_GPG3(3), 4,
101                               S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE);
102
103         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
104                 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
105                 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
106         }
107 }