blob: e8d08bf8965aa7bdff8935173fcb1549dcbab815 [file] [log] [blame]
Kukjin Kim3db3ae52011-02-14 16:22:36 +09001/* linux/arch/arm/mach-exynos4/setup-sdhci-gpio.c
Hyuk Lee19315112010-10-06 11:09:42 +09002 *
Kukjin Kim3db3ae52011-02-14 16:22:36 +09003 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
Hyuk Lee19315112010-10-06 11:09:42 +09005 *
Kukjin Kim3db3ae52011-02-14 16:22:36 +09006 * EXYNOS4 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
Hyuk Lee19315112010-10-06 11:09:42 +09007 *
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
Kukjin Kim3db3ae52011-02-14 16:22:36 +090026void exynos4_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
Hyuk Lee19315112010-10-06 11:09:42 +090027{
28 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
29 unsigned int gpio;
30
31 /* Set all the necessary GPK0[0:1] pins to special-function 2 */
Kukjin Kim3db3ae52011-02-14 16:22:36 +090032 for (gpio = EXYNOS4_GPK0(0); gpio < EXYNOS4_GPK0(2); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +090033 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
34 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
35 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
36 }
37
38 switch (width) {
39 case 8:
Kukjin Kim3db3ae52011-02-14 16:22:36 +090040 for (gpio = EXYNOS4_GPK1(3); gpio <= EXYNOS4_GPK1(6); gpio++) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -030041 /* Data pin GPK1[3:6] to special-function 3 */
Hyuk Lee19315112010-10-06 11:09:42 +090042 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
43 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
44 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
45 }
46 case 4:
Kukjin Kim3db3ae52011-02-14 16:22:36 +090047 for (gpio = EXYNOS4_GPK0(3); gpio <= EXYNOS4_GPK0(6); gpio++) {
Lucas De Marchi25985ed2011-03-30 22:57:33 -030048 /* Data pin GPK0[3:6] to special-function 2 */
Hyuk Lee19315112010-10-06 11:09:42 +090049 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
50 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
51 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
52 }
53 default:
54 break;
55 }
56
57 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
Kukjin Kim3db3ae52011-02-14 16:22:36 +090058 s3c_gpio_cfgpin(EXYNOS4_GPK0(2), S3C_GPIO_SFN(2));
59 s3c_gpio_setpull(EXYNOS4_GPK0(2), S3C_GPIO_PULL_UP);
Hyuk Lee19315112010-10-06 11:09:42 +090060 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
61 }
62}
63
Kukjin Kim3db3ae52011-02-14 16:22:36 +090064void exynos4_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
Hyuk Lee19315112010-10-06 11:09:42 +090065{
66 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
67 unsigned int gpio;
68
69 /* Set all the necessary GPK1[0:1] pins to special-function 2 */
Kukjin Kim3db3ae52011-02-14 16:22:36 +090070 for (gpio = EXYNOS4_GPK1(0); gpio < EXYNOS4_GPK1(2); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +090071 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
72 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
73 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
74 }
75
Kukjin Kim3db3ae52011-02-14 16:22:36 +090076 for (gpio = EXYNOS4_GPK1(3); gpio <= EXYNOS4_GPK1(6); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +090077 /* Data pin GPK1[3:6] to special-function 2 */
78 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
79 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
80 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
81 }
82
83 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
Kukjin Kim3db3ae52011-02-14 16:22:36 +090084 s3c_gpio_cfgpin(EXYNOS4_GPK1(2), S3C_GPIO_SFN(2));
85 s3c_gpio_setpull(EXYNOS4_GPK1(2), S3C_GPIO_PULL_UP);
Hyuk Lee19315112010-10-06 11:09:42 +090086 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
87 }
88}
89
Kukjin Kim3db3ae52011-02-14 16:22:36 +090090void exynos4_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
Hyuk Lee19315112010-10-06 11:09:42 +090091{
92 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
93 unsigned int gpio;
94
95 /* Set all the necessary GPK2[0:1] pins to special-function 2 */
Kukjin Kim3db3ae52011-02-14 16:22:36 +090096 for (gpio = EXYNOS4_GPK2(0); gpio < EXYNOS4_GPK2(2); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +090097 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
98 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
99 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
100 }
101
102 switch (width) {
103 case 8:
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900104 for (gpio = EXYNOS4_GPK3(3); gpio <= EXYNOS4_GPK3(6); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +0900105 /* Data pin GPK3[3:6] to special-function 3 */
106 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
107 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
108 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
109 }
110 case 4:
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900111 for (gpio = EXYNOS4_GPK2(3); gpio <= EXYNOS4_GPK2(6); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +0900112 /* Data pin GPK2[3:6] to special-function 2 */
113 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
114 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
115 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
116 }
117 default:
118 break;
119 }
120
121 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900122 s3c_gpio_cfgpin(EXYNOS4_GPK2(2), S3C_GPIO_SFN(2));
123 s3c_gpio_setpull(EXYNOS4_GPK2(2), S3C_GPIO_PULL_UP);
Hyuk Lee19315112010-10-06 11:09:42 +0900124 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
125 }
126}
127
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900128void exynos4_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
Hyuk Lee19315112010-10-06 11:09:42 +0900129{
130 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
131 unsigned int gpio;
132
133 /* Set all the necessary GPK3[0:1] pins to special-function 2 */
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900134 for (gpio = EXYNOS4_GPK3(0); gpio < EXYNOS4_GPK3(2); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +0900135 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
136 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
137 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
138 }
139
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900140 for (gpio = EXYNOS4_GPK3(3); gpio <= EXYNOS4_GPK3(6); gpio++) {
Hyuk Lee19315112010-10-06 11:09:42 +0900141 /* Data pin GPK3[3:6] to special-function 2 */
142 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
143 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
144 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
145 }
146
147 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900148 s3c_gpio_cfgpin(EXYNOS4_GPK3(2), S3C_GPIO_SFN(2));
149 s3c_gpio_setpull(EXYNOS4_GPK3(2), S3C_GPIO_PULL_UP);
Hyuk Lee19315112010-10-06 11:09:42 +0900150 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
151 }
152}