upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / 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  * S5PV310 - 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/mmc/host.h>
19 #include <linux/mmc/card.h>
20
21 #include <mach/gpio.h>
22 #include <mach/map.h>
23 #include <plat/gpio-cfg.h>
24 #include <plat/regs-sdhci.h>
25
26 void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27 {
28         unsigned int gpio;
29
30         /* Set all the necessary GPK0/GPK1 pins to special-function 2 */
31         for (gpio = S5PV310_GPK0(0); gpio < S5PV310_GPK0(2); gpio++) {
32                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
33                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
34                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
35         }
36         switch (width) {
37         case 8:
38                 /* GPK1[3:6] special-funtion 3 */
39                 for (gpio = S5PV310_GPK1(3); gpio <= S5PV310_GPK1(6); gpio++) {
40                         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
41                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
42                         s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
43                 }
44         case 4:
45                 /* GPK0[3:6] special-funtion 2 */
46                 for (gpio = S5PV310_GPK0(3); gpio <= S5PV310_GPK0(6); gpio++) {
47                         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
48                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
49                         s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
50                 }
51         default:
52                 break;
53         }
54 }
55
56 void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
57 {
58         unsigned int gpio;
59
60         /* Set all the necessary GPK1[0:1] pins to special-function 2 */
61         for (gpio = S5PV310_GPK1(0); gpio < S5PV310_GPK1(2); gpio++) {
62                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
63                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
64                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
65         }
66
67         /* Data pin GPK1[3:6] to special-function 2 */
68         for (gpio = S5PV310_GPK1(3); gpio <= S5PV310_GPK1(6); gpio++) {
69                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
70                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
71                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
72         }
73 }
74
75 void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
76 {
77         unsigned int gpio;
78
79         /* Set all the necessary GPK2[0:1] pins to special-function 2 */
80         for (gpio = S5PV310_GPK2(0); gpio < S5PV310_GPK2(2); gpio++) {
81                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
82                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
83                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
84         }
85
86         switch (width) {
87         case 8:
88                 /* Data pin GPK3[3:6] to special-function 3 */
89                 for (gpio = S5PV310_GPK3(3); gpio <= S5PV310_GPK3(6); gpio++) {
90                         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
91                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
92                         s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
93                 }
94         case 4:
95                 /* Data pin GPK2[3:6] to special-function 2 */
96                 for (gpio = S5PV310_GPK2(3); gpio <= S5PV310_GPK2(6); gpio++) {
97                         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
98                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
99                         s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
100                 }
101         default:
102                 break;
103         }
104 }
105
106 void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
107 {
108         unsigned int gpio;
109
110         /* Set all the necessary GPK1[0:1] pins to special-function 2 */
111         for (gpio = S5PV310_GPK3(0); gpio < S5PV310_GPK3(2); gpio++) {
112                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
113                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
114                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
115         }
116
117         /* Data pin GPK1[3:6] to special-function 2 */
118         for (gpio = S5PV310_GPK3(3); gpio <= S5PV310_GPK3(6); gpio++) {
119                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
120                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
121                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
122         }
123 }