aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/p852/board-p852-sdhci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/p852/board-p852-sdhci.c')
-rw-r--r--arch/arm/mach-tegra/p852/board-p852-sdhci.c199
1 files changed, 199 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/p852/board-p852-sdhci.c b/arch/arm/mach-tegra/p852/board-p852-sdhci.c
new file mode 100644
index 00000000000..dc5b81fa372
--- /dev/null
+++ b/arch/arm/mach-tegra/p852/board-p852-sdhci.c
@@ -0,0 +1,199 @@
1/*
2 * arch/arm/mach-tegra/board-p852-sdhci.c
3 *
4 * Copyright (c) 2010-2011, NVIDIA Corporation.
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/resource.h>
18#include <linux/platform_device.h>
19#include <linux/delay.h>
20#include <linux/gpio.h>
21
22#include <asm/mach-types.h>
23#include <mach/irqs.h>
24#include <mach/iomap.h>
25#include <mach/sdhci.h>
26#include <mach/pinmux.h>
27#include <asm/mach-types.h>
28
29#include "board-p852.h"
30
31static struct resource sdhci_resource1[] = {
32 [0] = {
33 .start = INT_SDMMC1,
34 .end = INT_SDMMC1,
35 .flags = IORESOURCE_IRQ,
36 },
37 [1] = {
38 .start = TEGRA_SDMMC1_BASE,
39 .end = TEGRA_SDMMC1_BASE + TEGRA_SDMMC1_SIZE - 1,
40 .flags = IORESOURCE_MEM,
41 },
42};
43
44static struct resource sdhci_resource2[] = {
45 [0] = {
46 .start = INT_SDMMC2,
47 .end = INT_SDMMC2,
48 .flags = IORESOURCE_IRQ,
49 },
50 [1] = {
51 .start = TEGRA_SDMMC2_BASE,
52 .end = TEGRA_SDMMC2_BASE + TEGRA_SDMMC2_SIZE - 1,
53 .flags = IORESOURCE_MEM,
54 },
55};
56
57static struct resource sdhci_resource3[] = {
58 [0] = {
59 .start = INT_SDMMC3,
60 .end = INT_SDMMC3,
61 .flags = IORESOURCE_IRQ,
62 },
63 [1] = {
64 .start = TEGRA_SDMMC3_BASE,
65 .end = TEGRA_SDMMC3_BASE + TEGRA_SDMMC3_SIZE - 1,
66 .flags = IORESOURCE_MEM,
67 },
68};
69
70static struct resource sdhci_resource4[] = {
71 [0] = {
72 .start = INT_SDMMC4,
73 .end = INT_SDMMC4,
74 .flags = IORESOURCE_IRQ,
75 },
76 [1] = {
77 .start = TEGRA_SDMMC4_BASE,
78 .end = TEGRA_SDMMC4_BASE + TEGRA_SDMMC4_SIZE - 1,
79 .flags = IORESOURCE_MEM,
80 },
81};
82
83struct tegra_sdhci_platform_data p852_sdhci_platform_data[] = {
84 {
85 .cd_gpio = -1,
86 .wp_gpio = -1,
87 .power_gpio = -1,
88 },
89 {
90 .cd_gpio = -1,
91 .wp_gpio = -1,
92 .power_gpio = -1,
93 },
94 {
95 .cd_gpio = -1,
96 .wp_gpio = -1,
97 .power_gpio = -1,
98 },
99 {
100 .cd_gpio = -1,
101 .wp_gpio = -1,
102 .power_gpio = -1,
103 },
104};
105
106static struct platform_device tegra_sdhci_device[] = {
107 {
108 .name = "sdhci-tegra",
109 .id = 0,
110 .resource = sdhci_resource1,
111 .num_resources = ARRAY_SIZE(sdhci_resource1),
112 .dev = {
113 .platform_data = &p852_sdhci_platform_data[0],
114 },
115 },
116 {
117 .name = "sdhci-tegra",
118 .id = 1,
119 .resource = sdhci_resource2,
120 .num_resources = ARRAY_SIZE(sdhci_resource2),
121 .dev = {
122 .platform_data = &p852_sdhci_platform_data[1],
123 },
124 },
125 {
126 .name = "sdhci-tegra",
127 .id = 2,
128 .resource = sdhci_resource3,
129 .num_resources = ARRAY_SIZE(sdhci_resource3),
130 .dev = {
131 .platform_data = &p852_sdhci_platform_data[2],
132 },
133 },
134 {
135 .name = "sdhci-tegra",
136 .id = 3,
137 .resource = sdhci_resource4,
138 .num_resources = ARRAY_SIZE(sdhci_resource4),
139 .dev = {
140 .platform_data = &p852_sdhci_platform_data[3],
141 },
142 },
143
144};
145
146void __init p852_sdhci_init(void)
147{
148
149 int i, count = 10;
150 int cd = 0, wp = 0, pw = 0;
151 static char gpio_name[12][10];
152 unsigned int sdhci_config = 0;
153
154 if (p852_sku_peripherals & P852_SKU_SDHCI_ENABLE)
155 for (i = 0; i < P852_MAX_SDHCI; i++) {
156 sdhci_config =
157 (p852_sdhci_peripherals >> (P852_SDHCI_SHIFT * i));
158 cd = i * 3;
159 wp = cd + 1;
160 pw = wp + 1;
161 if (sdhci_config & P852_SDHCI_ENABLE) {
162 if (sdhci_config & P852_SDHCI_CD_EN) {
163 snprintf(gpio_name[cd], count,
164 "sdhci%d_cd", i);
165 gpio_request(p852_sdhci_platform_data
166 [i].cd_gpio,
167 gpio_name[cd]);
168 tegra_gpio_enable
169 (p852_sdhci_platform_data[i].
170 cd_gpio);
171 }
172
173 if (sdhci_config & P852_SDHCI_WP_EN) {
174 snprintf(gpio_name[wp], count,
175 "sdhci%d_wp", i);
176 gpio_request(p852_sdhci_platform_data
177 [i].wp_gpio,
178 gpio_name[wp]);
179 tegra_gpio_enable
180 (p852_sdhci_platform_data[i].
181 wp_gpio);
182 }
183
184 if (sdhci_config & P852_SDHCI_PW_EN) {
185 snprintf(gpio_name[pw], count,
186 "sdhci%d_pw", i);
187 gpio_request(p852_sdhci_platform_data
188 [i].power_gpio,
189 gpio_name[pw]);
190 tegra_gpio_enable
191 (p852_sdhci_platform_data[i].
192 power_gpio);
193 }
194
195 platform_device_register(&tegra_sdhci_device
196 [i]);
197 }
198 }
199}