Linux 3.11-rc3
[cris-mirror.git] / arch / arm / mach-s5pv210 / setup-sdhci-gpio.c
blob0512ada00522f73155b4918a0a8645b364ee6f39
1 /* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * S5PV210 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
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.
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>
22 #include <plat/gpio-cfg.h>
23 #include <plat/sdhci.h>
25 void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
29 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
30 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
32 switch (width) {
33 case 8:
34 /* GPG1[3:6] special-function 3 */
35 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
36 case 4:
37 /* GPG0[3:6] special-function 2 */
38 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
39 default:
40 break;
43 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
44 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
45 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
49 void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
51 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
53 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
54 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
56 /* Data pin GPG1[3:6] to special-function 2 */
57 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
59 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
60 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
61 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
65 void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
67 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
69 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
70 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
72 switch (width) {
73 case 8:
74 /* Data pin GPG3[3:6] to special-function 3 */
75 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
76 case 4:
77 /* Data pin GPG2[3:6] to special-function 2 */
78 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
79 default:
80 break;
83 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
84 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
85 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
89 void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
91 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
93 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
94 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
96 /* Data pin GPG3[3:6] to special-function 2 */
97 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
99 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
100 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
101 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));