]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/mach-s5pc100/setup-sdhci-gpio.c
79b031f5f4345350d4668a51e072f756e3a5a4ec
[net-next-2.6.git] / arch / arm / mach-s5pc100 / setup-sdhci-gpio.c
1 /* linux/arch/arm/plat-s5pc100/setup-sdhci-gpio.c
2  *
3  * Copyright 2009 Samsung Eletronics
4  *
5  * S5PC100 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10 */
11
12 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/io.h>
17 #include <linux/gpio.h>
18 #include <linux/mmc/host.h>
19 #include <linux/mmc/card.h>
20
21 #include <plat/gpio-cfg.h>
22 #include <plat/regs-sdhci.h>
23 #include <plat/sdhci.h>
24
25 void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
26 {
27         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
28         unsigned int gpio;
29         unsigned int end;
30         unsigned int num;
31
32         num = width;
33         /* In case of 8 width, we should decrease the 2 */
34         if (width == 8)
35                 num = width - 2;
36
37         end = S5PC100_GPG0(2 + num);
38
39         /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
40         s3c_gpio_cfgpin_range(S5PC100_GPG0(0), 2 + num, S3C_GPIO_SFN(2));
41         for (gpio = S5PC100_GPG0(0); gpio < end; gpio++)
42                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
43
44         if (width == 8) {
45                 for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) {
46                         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
47                         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
48                 }
49         }
50
51         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
52                 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
53                 s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
54         }
55 }
56
57 void s5pc100_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         unsigned int end;
62
63         end = S5PC100_GPG2(2 + width);
64
65         /* Set all the necessary GPG2 pins to special-function 2 */
66         s3c_gpio_cfgpin_range(S5PC100_GPG2(0), 2 + width, S3C_GPIO_SFN(2));
67         for (gpio = S5PC100_GPG2(0); gpio < end; gpio++)
68                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
69
70         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
71                 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
72                 s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
73         }
74 }
75
76 void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
77 {
78         struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
79         unsigned int gpio;
80         unsigned int end;
81
82         end = S5PC100_GPG3(2 + width);
83
84         /* Set all the necessary GPG3 pins to special-function 2 */
85         s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 2 + width, S3C_GPIO_SFN(2));
86         for (gpio = S5PC100_GPG3(0); gpio < end; gpio++)
87                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
88
89         if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
90                 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
91                 s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
92         }
93 }