]> 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_cfgpin_range()
[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         unsigned int gpio;
30
31         /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
32         s3c_gpio_cfgpin_range(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
33         for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++)
34                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
35
36         switch (width) {
37         case 8:
38                 /* GPG1[3:6] special-funtion 3 */
39                 s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
40                 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
41                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
42         case 4:
43                 /* GPG0[3:6] special-funtion 2 */
44                 s3c_gpio_cfgpin_range(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
45                 for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++)
46                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
47         default:
48                 break;
49         }
50
51         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
52                 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
53                 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
54         }
55 }
56
57 void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
58 {
59         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
60         unsigned int gpio;
61
62         /* Set all the necessary GPG1[0:1] pins to special-function 2 */
63         s3c_gpio_cfgpin_range(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
64         for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++)
65                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
66
67         /* Data pin GPG1[3:6] to special-function 2 */
68         s3c_gpio_cfgpin_range(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
69         for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++)
70                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
71
72         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
73                 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
74                 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
75         }
76 }
77
78 void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
79 {
80         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
81         unsigned int gpio;
82
83         /* Set all the necessary GPG2[0:1] pins to special-function 2 */
84         s3c_gpio_cfgpin_range(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
85         for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++)
86                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
87
88         switch (width) {
89         case 8:
90                 /* Data pin GPG3[3:6] to special-function 3 */
91                 s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
92                 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
93                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
94         case 4:
95                 /* Data pin GPG2[3:6] to special-function 2 */
96                 s3c_gpio_cfgpin_range(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
97                 for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++)
98                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
99         default:
100                 break;
101         }
102
103         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
104                 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
105                 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
106         }
107 }
108
109 void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
110 {
111         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
112         unsigned int gpio;
113
114         /* Set all the necessary GPG3[0:1] pins to special-function 2 */
115         s3c_gpio_cfgpin_range(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
116         for (gpio = S5PV210_GPG3(0); gpio < S5PV210_GPG3(2); gpio++)
117                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
118
119         /* Data pin GPG3[3:6] to special-function 2 */
120         s3c_gpio_cfgpin_range(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
121         for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++)
122                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
123
124         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
125                 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
126                 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
127         }
128 }