Commit | Line | Data |
---|---|---|
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 | 22 | #include <plat/gpio-cfg.h> |
19206b17 | 23 | #include <plat/sdhci.h> |
e6f66a9f MS |
24 | |
25 | void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) | |
26 | { | |
19206b17 | 27 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
e6f66a9f MS |
28 | |
29 | /* Set all the necessary GPG0/GPG1 pins to special-function 2 */ | |
a7aac9d5 | 30 | s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2)); |
64c5bd84 | 31 | |
e6f66a9f MS |
32 | switch (width) { |
33 | case 8: | |
25985edc | 34 | /* GPG1[3:6] special-function 3 */ |
5a350da4 | 35 | s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3)); |
e6f66a9f | 36 | case 4: |
25985edc | 37 | /* GPG0[3:6] special-function 2 */ |
5a350da4 | 38 | s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2)); |
e6f66a9f MS |
39 | default: |
40 | break; | |
41 | } | |
42 | ||
19206b17 MS |
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)); | |
46 | } | |
e6f66a9f MS |
47 | } |
48 | ||
49 | void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) | |
50 | { | |
19206b17 | 51 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
e6f66a9f MS |
52 | |
53 | /* Set all the necessary GPG1[0:1] pins to special-function 2 */ | |
5a350da4 | 54 | s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2)); |
e6f66a9f MS |
55 | |
56 | /* Data pin GPG1[3:6] to special-function 2 */ | |
5a350da4 | 57 | s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2)); |
e6f66a9f | 58 | |
19206b17 MS |
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)); | |
62 | } | |
e6f66a9f MS |
63 | } |
64 | ||
65 | void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) | |
66 | { | |
19206b17 | 67 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
e6f66a9f MS |
68 | |
69 | /* Set all the necessary GPG2[0:1] pins to special-function 2 */ | |
5a350da4 | 70 | s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2)); |
e6f66a9f MS |
71 | |
72 | switch (width) { | |
73 | case 8: | |
74 | /* Data pin GPG3[3:6] to special-function 3 */ | |
5a350da4 | 75 | s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3)); |
e6f66a9f MS |
76 | case 4: |
77 | /* Data pin GPG2[3:6] to special-function 2 */ | |
5a350da4 | 78 | s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2)); |
e6f66a9f MS |
79 | default: |
80 | break; | |
81 | } | |
82 | ||
19206b17 MS |
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)); | |
86 | } | |
e6f66a9f | 87 | } |
976a62f2 HL |
88 | |
89 | void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width) | |
90 | { | |
a68fefe0 | 91 | struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; |
976a62f2 | 92 | |
64c5bd84 | 93 | /* Set all the necessary GPG3[0:1] pins to special-function 2 */ |
a7aac9d5 | 94 | s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2)); |
976a62f2 HL |
95 | |
96 | /* Data pin GPG3[3:6] to special-function 2 */ | |
a7aac9d5 | 97 | s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2)); |
976a62f2 | 98 | |
a68fefe0 KK |
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)); | |
102 | } | |
976a62f2 | 103 | } |