]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-s5pv210/setup-sdhci-gpio.c
Merge branches 'sh/pio-death', 'sh/nommu', 'sh/clkfwk', 'sh/core' and 'sh/intc-extens...
[net-next-2.6.git] / arch / arm / mach-s5pv210 / setup-sdhci-gpio.c
CommitLineData
e6f66a9f
MS
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>
1c739c7f 18#include <linux/gpio.h>
e6f66a9f
MS
19#include <linux/mmc/host.h>
20#include <linux/mmc/card.h>
21
e6f66a9f
MS
22#include <plat/gpio-cfg.h>
23#include <plat/regs-sdhci.h>
19206b17 24#include <plat/sdhci.h>
e6f66a9f
MS
25
26void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27{
19206b17 28 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
e6f66a9f
MS
29
30 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
a7aac9d5 31 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
64c5bd84 32
e6f66a9f
MS
33 switch (width) {
34 case 8:
35 /* GPG1[3:6] special-funtion 3 */
5a350da4 36 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
e6f66a9f
MS
37 case 4:
38 /* GPG0[3:6] special-funtion 2 */
5a350da4 39 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
e6f66a9f
MS
40 default:
41 break;
42 }
43
19206b17
MS
44 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
45 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
46 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
47 }
e6f66a9f
MS
48}
49
50void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
51{
19206b17 52 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
e6f66a9f
MS
53
54 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
5a350da4 55 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
e6f66a9f
MS
56
57 /* Data pin GPG1[3:6] to special-function 2 */
5a350da4 58 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
e6f66a9f 59
19206b17
MS
60 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
61 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
62 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
63 }
e6f66a9f
MS
64}
65
66void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
67{
19206b17 68 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
e6f66a9f
MS
69
70 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
5a350da4 71 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
e6f66a9f
MS
72
73 switch (width) {
74 case 8:
75 /* Data pin GPG3[3:6] to special-function 3 */
5a350da4 76 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
e6f66a9f
MS
77 case 4:
78 /* Data pin GPG2[3:6] to special-function 2 */
5a350da4 79 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
e6f66a9f
MS
80 default:
81 break;
82 }
83
19206b17
MS
84 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
85 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
86 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
87 }
e6f66a9f 88}
976a62f2
HL
89
90void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
91{
a68fefe0 92 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
976a62f2 93
64c5bd84 94 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
a7aac9d5 95 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
976a62f2
HL
96
97 /* Data pin GPG3[3:6] to special-function 2 */
a7aac9d5 98 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
976a62f2 99
a68fefe0
KK
100 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
101 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
102 s3c_gpio_cfgpin(S5PV210_GPG3(2), S3C_GPIO_SFN(2));
103 }
976a62f2 104}