aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/board-aruba-sdhci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/board-aruba-sdhci.c')
-rw-r--r--arch/arm/mach-tegra/board-aruba-sdhci.c248
1 files changed, 248 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-aruba-sdhci.c b/arch/arm/mach-tegra/board-aruba-sdhci.c
new file mode 100644
index 00000000000..26b04a9021e
--- /dev/null
+++ b/arch/arm/mach-tegra/board-aruba-sdhci.c
@@ -0,0 +1,248 @@
1/*
2 * arch/arm/mach-tegra/board-harmony-sdhci.c
3 *
4 * Copyright (C) 2010 Google, Inc.
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/wlan_plat.h>
20#include <linux/delay.h>
21#include <linux/gpio.h>
22#include <linux/clk.h>
23#include <linux/err.h>
24#include <linux/mmc/host.h>
25
26#include <asm/mach-types.h>
27#include <mach/irqs.h>
28#include <mach/iomap.h>
29#include <mach/sdhci.h>
30
31#include "gpio-names.h"
32#include "board.h"
33
34#define ARUBA_WIFI 0 /* !!!FIXME!!! NOT SUPPORTED YET */
35
36#if ARUBA_WIFI
37
38#define ARUBA_WLAN_PWR TEGRA_GPIO_PK5
39#define ARUBA_WLAN_RST TEGRA_GPIO_PK6
40
41static void (*wifi_status_cb)(int card_present, void *dev_id);
42static void *wifi_status_cb_devid;
43static int aruba_wifi_status_register(void (*callback)(int , void *), void *);
44static struct clk *wifi_32k_clk;
45
46static int aruba_wifi_reset(int on);
47static int aruba_wifi_power(int on);
48static int aruba_wifi_set_carddetect(int val);
49
50static struct wifi_platform_data aruba_wifi_control = {
51 .set_power = aruba_wifi_power,
52 .set_reset = aruba_wifi_reset,
53 .set_carddetect = aruba_wifi_set_carddetect,
54};
55
56static struct platform_device aruba_wifi_device = {
57 .name = "bcm4329_wlan",
58 .id = 1,
59 .dev = {
60 .platform_data = &aruba_wifi_control,
61 },
62};
63#endif
64
65static struct resource sdhci_resource0[] = {
66 [0] = {
67 .start = INT_SDMMC1,
68 .end = INT_SDMMC1,
69 .flags = IORESOURCE_IRQ,
70 },
71 [1] = {
72 .start = TEGRA_SDMMC1_BASE,
73 .end = TEGRA_SDMMC1_BASE + TEGRA_SDMMC1_SIZE-1,
74 .flags = IORESOURCE_MEM,
75 },
76};
77
78static struct resource sdhci_resource2[] = {
79 [0] = {
80 .start = INT_SDMMC3,
81 .end = INT_SDMMC3,
82 .flags = IORESOURCE_IRQ,
83 },
84 [1] = {
85 .start = TEGRA_SDMMC3_BASE,
86 .end = TEGRA_SDMMC3_BASE + TEGRA_SDMMC3_SIZE-1,
87 .flags = IORESOURCE_MEM,
88 },
89};
90
91static struct resource sdhci_resource3[] = {
92 [0] = {
93 .start = INT_SDMMC4,
94 .end = INT_SDMMC4,
95 .flags = IORESOURCE_IRQ,
96 },
97 [1] = {
98 .start = TEGRA_SDMMC4_BASE,
99 .end = TEGRA_SDMMC4_BASE + TEGRA_SDMMC4_SIZE-1,
100 .flags = IORESOURCE_MEM,
101 },
102};
103
104
105static struct tegra_sdhci_platform_data tegra_sdhci_platform_data0 = {
106#if ARUBA_WIFI /* !!!FIXME!!! NOT SUPPORTED YET */
107 .register_status_notify = aruba_wifi_status_register,
108 .cccr = {
109 .sdio_vsn = 2,
110 .multi_block = 1,
111 .low_speed = 0,
112 .wide_bus = 0,
113 .high_power = 1,
114 .high_speed = 1,
115 },
116 .cis = {
117 .vendor = 0x02d0,
118 .device = 0x4329,
119 },
120#endif
121 .cd_gpio = -1,
122 .wp_gpio = -1,
123 .power_gpio = -1,
124/* .max_clk = 12000000, */
125};
126
127static struct tegra_sdhci_platform_data tegra_sdhci_platform_data2 = {
128 .cd_gpio = -1,
129 .wp_gpio = -1,
130 .power_gpio = -1,
131/* .max_clk = 12000000, */
132};
133
134static struct tegra_sdhci_platform_data tegra_sdhci_platform_data3 = {
135 .cd_gpio = -1,
136 .wp_gpio = -1,
137 .power_gpio = -1,
138/* .max_clk = 12000000, */
139};
140
141static struct platform_device tegra_sdhci_device0 = {
142 .name = "sdhci-tegra",
143 .id = 0,
144 .resource = sdhci_resource0,
145 .num_resources = ARRAY_SIZE(sdhci_resource0),
146 .dev = {
147 .platform_data = &tegra_sdhci_platform_data0,
148 },
149};
150
151static struct platform_device tegra_sdhci_device2 = {
152 .name = "sdhci-tegra",
153 .id = 2,
154 .resource = sdhci_resource2,
155 .num_resources = ARRAY_SIZE(sdhci_resource2),
156 .dev = {
157 .platform_data = &tegra_sdhci_platform_data2,
158 },
159};
160
161static struct platform_device tegra_sdhci_device3 = {
162 .name = "sdhci-tegra",
163 .id = 3,
164 .resource = sdhci_resource3,
165 .num_resources = ARRAY_SIZE(sdhci_resource3),
166 .dev = {
167 .platform_data = &tegra_sdhci_platform_data3,
168 },
169};
170
171#if ARUBA_WIFI /* !!!FIXME!!! NOT SUPPORTED YET */
172static int aruba_wifi_status_register(
173 void (*callback)(int card_present, void *dev_id),
174 void *dev_id)
175{
176 if (wifi_status_cb)
177 return -EAGAIN;
178 wifi_status_cb = callback;
179 wifi_status_cb_devid = dev_id;
180 return 0;
181}
182
183static int aruba_wifi_set_carddetect(int val)
184{
185 pr_debug("%s: %d\n", __func__, val);
186 if (wifi_status_cb)
187 wifi_status_cb(val, wifi_status_cb_devid);
188 else
189 pr_warning("%s: Nobody to notify\n", __func__);
190 return 0;
191}
192
193static int aruba_wifi_power(int on)
194{
195 pr_debug("%s: %d\n", __func__, on);
196
197 gpio_set_value(ARUBA_WLAN_PWR, on);
198 mdelay(100);
199 gpio_set_value(ARUBA_WLAN_RST, on);
200 mdelay(200);
201
202 if (on)
203 clk_enable(wifi_32k_clk);
204 else
205 clk_disable(wifi_32k_clk);
206
207 return 0;
208}
209
210static int aruba_wifi_reset(int on)
211{
212 pr_debug("%s: do nothing\n", __func__);
213 return 0;
214}
215
216static int __init aruba_wifi_init(void)
217{
218 wifi_32k_clk = clk_get_sys(NULL, "blink");
219 if (IS_ERR(wifi_32k_clk)) {
220 pr_err("%s: unable to get blink clock\n", __func__);
221 return PTR_ERR(wifi_32k_clk);
222 }
223
224 gpio_request(ARUBA_WLAN_PWR, "wlan_power");
225 gpio_request(ARUBA_WLAN_RST, "wlan_rst");
226
227 tegra_gpio_enable(ARUBA_WLAN_PWR);
228 tegra_gpio_enable(ARUBA_WLAN_RST);
229
230 gpio_direction_output(ARUBA_WLAN_PWR, 0);
231 gpio_direction_output(ARUBA_WLAN_RST, 0);
232
233 platform_device_register(&aruba_wifi_device);
234 return 0;
235}
236#else
237#define aruba_wifi_init() do {} while (0)
238#endif
239
240int __init aruba_sdhci_init(void)
241{
242 platform_device_register(&tegra_sdhci_device3);
243 platform_device_register(&tegra_sdhci_device2);
244 platform_device_register(&tegra_sdhci_device0);
245
246 aruba_wifi_init();
247 return 0;
248}