OMAP: hsmmc: Rename the device and driver
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap4panda.c
1 /*
2  * Board support file for OMAP4430 based PandaBoard.
3  *
4  * Copyright (C) 2010 Texas Instruments
5  *
6  * Author: David Anders <x0132446@ti.com>
7  *
8  * Based on mach-omap2/board-4430sdp.c
9  *
10  * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
11  *
12  * Based on mach-omap2/board-3430sdp.c
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2 as
16  * published by the Free Software Foundation.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/clk.h>
23 #include <linux/io.h>
24 #include <linux/leds.h>
25 #include <linux/gpio.h>
26 #include <linux/usb/otg.h>
27 #include <linux/i2c/twl.h>
28 #include <linux/regulator/machine.h>
29 #include <linux/regulator/fixed.h>
30 #include <linux/wl12xx.h>
31
32 #include <mach/hardware.h>
33 #include <mach/omap4-common.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37
38 #include <plat/board.h>
39 #include <plat/common.h>
40 #include <plat/usb.h>
41 #include <plat/mmc.h>
42 #include "timer-gp.h"
43
44 #include "hsmmc.h"
45 #include "control.h"
46 #include "mux.h"
47
48 #define GPIO_HUB_POWER          1
49 #define GPIO_HUB_NRESET         62
50 #define GPIO_WIFI_PMENA         43
51 #define GPIO_WIFI_IRQ           53
52
53 static struct gpio_led gpio_leds[] = {
54         {
55                 .name                   = "pandaboard::status1",
56                 .default_trigger        = "heartbeat",
57                 .gpio                   = 7,
58         },
59         {
60                 .name                   = "pandaboard::status2",
61                 .default_trigger        = "mmc0",
62                 .gpio                   = 8,
63         },
64 };
65
66 static struct gpio_led_platform_data gpio_led_info = {
67         .leds           = gpio_leds,
68         .num_leds       = ARRAY_SIZE(gpio_leds),
69 };
70
71 static struct platform_device leds_gpio = {
72         .name   = "leds-gpio",
73         .id     = -1,
74         .dev    = {
75                 .platform_data  = &gpio_led_info,
76         },
77 };
78
79 static struct platform_device *panda_devices[] __initdata = {
80         &leds_gpio,
81 };
82
83 static void __init omap4_panda_init_early(void)
84 {
85         omap2_init_common_infrastructure();
86         omap2_init_common_devices(NULL, NULL);
87 }
88
89 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
90         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
91         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
92         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
93         .phy_reset  = false,
94         .reset_gpio_port[0]  = -EINVAL,
95         .reset_gpio_port[1]  = -EINVAL,
96         .reset_gpio_port[2]  = -EINVAL
97 };
98
99 static void __init omap4_ehci_init(void)
100 {
101         int ret;
102         struct clk *phy_ref_clk;
103
104         /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
105         phy_ref_clk = clk_get(NULL, "auxclk3_ck");
106         if (IS_ERR(phy_ref_clk)) {
107                 pr_err("Cannot request auxclk3\n");
108                 goto error1;
109         }
110         clk_set_rate(phy_ref_clk, 19200000);
111         clk_enable(phy_ref_clk);
112
113         /* disable the power to the usb hub prior to init */
114         ret = gpio_request(GPIO_HUB_POWER, "hub_power");
115         if (ret) {
116                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
117                 goto error1;
118         }
119         gpio_export(GPIO_HUB_POWER, 0);
120         gpio_direction_output(GPIO_HUB_POWER, 0);
121         gpio_set_value(GPIO_HUB_POWER, 0);
122
123         /* reset phy+hub */
124         ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
125         if (ret) {
126                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
127                 goto error2;
128         }
129         gpio_export(GPIO_HUB_NRESET, 0);
130         gpio_direction_output(GPIO_HUB_NRESET, 0);
131         gpio_set_value(GPIO_HUB_NRESET, 0);
132         gpio_set_value(GPIO_HUB_NRESET, 1);
133
134         usb_ehci_init(&ehci_pdata);
135
136         /* enable power to hub */
137         gpio_set_value(GPIO_HUB_POWER, 1);
138         return;
139
140 error2:
141         gpio_free(GPIO_HUB_POWER);
142 error1:
143         pr_err("Unable to initialize EHCI power/reset\n");
144         return;
145
146 }
147
148 static struct omap_musb_board_data musb_board_data = {
149         .interface_type         = MUSB_INTERFACE_UTMI,
150         .mode                   = MUSB_OTG,
151         .power                  = 100,
152 };
153
154 static struct twl4030_usb_data omap4_usbphy_data = {
155         .phy_init       = omap4430_phy_init,
156         .phy_exit       = omap4430_phy_exit,
157         .phy_power      = omap4430_phy_power,
158         .phy_set_clock  = omap4430_phy_set_clk,
159 };
160
161 static struct omap2_hsmmc_info mmc[] = {
162         {
163                 .mmc            = 1,
164                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
165                 .gpio_wp        = -EINVAL,
166                 .gpio_cd        = -EINVAL,
167         },
168         {
169                 .name           = "wl1271",
170                 .mmc            = 5,
171                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
172                 .gpio_wp        = -EINVAL,
173                 .gpio_cd        = -EINVAL,
174                 .ocr_mask       = MMC_VDD_165_195,
175                 .nonremovable   = true,
176         },
177         {}      /* Terminator */
178 };
179
180 static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
181         {
182                 .supply = "vmmc",
183                 .dev_name = "omap_hsmmc.0",
184         },
185 };
186
187 static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
188         .supply = "vmmc",
189         .dev_name = "omap_hsmmc.4",
190 };
191
192 static struct regulator_init_data panda_vmmc5 = {
193         .constraints = {
194                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
195         },
196         .num_consumer_supplies = 1,
197         .consumer_supplies = &omap4_panda_vmmc5_supply,
198 };
199
200 static struct fixed_voltage_config panda_vwlan = {
201         .supply_name = "vwl1271",
202         .microvolts = 1800000, /* 1.8V */
203         .gpio = GPIO_WIFI_PMENA,
204         .startup_delay = 70000, /* 70msec */
205         .enable_high = 1,
206         .enabled_at_boot = 0,
207         .init_data = &panda_vmmc5,
208 };
209
210 static struct platform_device omap_vwlan_device = {
211         .name           = "reg-fixed-voltage",
212         .id             = 1,
213         .dev = {
214                 .platform_data = &panda_vwlan,
215         },
216 };
217
218 struct wl12xx_platform_data omap_panda_wlan_data  __initdata = {
219         .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
220         /* PANDA ref clock is 38.4 MHz */
221         .board_ref_clock = 2,
222 };
223
224 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
225 {
226         int ret = 0;
227         struct platform_device *pdev = container_of(dev,
228                                 struct platform_device, dev);
229         struct omap_mmc_platform_data *pdata = dev->platform_data;
230
231         if (!pdata) {
232                 dev_err(dev, "%s: NULL platform data\n", __func__);
233                 return -EINVAL;
234         }
235         /* Setting MMC1 Card detect Irq */
236         if (pdev->id == 0) {
237                 ret = twl6030_mmc_card_detect_config();
238                  if (ret)
239                         dev_err(dev, "%s: Error card detect config(%d)\n",
240                                 __func__, ret);
241                  else
242                         pdata->slots[0].card_detect = twl6030_mmc_card_detect;
243         }
244         return ret;
245 }
246
247 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
248 {
249         struct omap_mmc_platform_data *pdata;
250
251         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
252         if (!dev) {
253                 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
254                 return;
255         }
256         pdata = dev->platform_data;
257
258         pdata->init =   omap4_twl6030_hsmmc_late_init;
259 }
260
261 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
262 {
263         struct omap2_hsmmc_info *c;
264
265         omap2_hsmmc_init(controllers);
266         for (c = controllers; c->mmc; c++)
267                 omap4_twl6030_hsmmc_set_late_init(c->dev);
268
269         return 0;
270 }
271
272 static struct regulator_init_data omap4_panda_vaux1 = {
273         .constraints = {
274                 .min_uV                 = 1000000,
275                 .max_uV                 = 3000000,
276                 .apply_uV               = true,
277                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
278                                         | REGULATOR_MODE_STANDBY,
279                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
280                                         | REGULATOR_CHANGE_MODE
281                                         | REGULATOR_CHANGE_STATUS,
282         },
283 };
284
285 static struct regulator_init_data omap4_panda_vaux2 = {
286         .constraints = {
287                 .min_uV                 = 1200000,
288                 .max_uV                 = 2800000,
289                 .apply_uV               = true,
290                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
291                                         | REGULATOR_MODE_STANDBY,
292                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
293                                         | REGULATOR_CHANGE_MODE
294                                         | REGULATOR_CHANGE_STATUS,
295         },
296 };
297
298 static struct regulator_init_data omap4_panda_vaux3 = {
299         .constraints = {
300                 .min_uV                 = 1000000,
301                 .max_uV                 = 3000000,
302                 .apply_uV               = true,
303                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
304                                         | REGULATOR_MODE_STANDBY,
305                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
306                                         | REGULATOR_CHANGE_MODE
307                                         | REGULATOR_CHANGE_STATUS,
308         },
309 };
310
311 /* VMMC1 for MMC1 card */
312 static struct regulator_init_data omap4_panda_vmmc = {
313         .constraints = {
314                 .min_uV                 = 1200000,
315                 .max_uV                 = 3000000,
316                 .apply_uV               = true,
317                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
318                                         | REGULATOR_MODE_STANDBY,
319                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
320                                         | REGULATOR_CHANGE_MODE
321                                         | REGULATOR_CHANGE_STATUS,
322         },
323         .num_consumer_supplies  = 1,
324         .consumer_supplies      = omap4_panda_vmmc_supply,
325 };
326
327 static struct regulator_init_data omap4_panda_vpp = {
328         .constraints = {
329                 .min_uV                 = 1800000,
330                 .max_uV                 = 2500000,
331                 .apply_uV               = true,
332                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
333                                         | REGULATOR_MODE_STANDBY,
334                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
335                                         | REGULATOR_CHANGE_MODE
336                                         | REGULATOR_CHANGE_STATUS,
337         },
338 };
339
340 static struct regulator_init_data omap4_panda_vusim = {
341         .constraints = {
342                 .min_uV                 = 1200000,
343                 .max_uV                 = 2900000,
344                 .apply_uV               = true,
345                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
346                                         | REGULATOR_MODE_STANDBY,
347                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
348                                         | REGULATOR_CHANGE_MODE
349                                         | REGULATOR_CHANGE_STATUS,
350         },
351 };
352
353 static struct regulator_init_data omap4_panda_vana = {
354         .constraints = {
355                 .min_uV                 = 2100000,
356                 .max_uV                 = 2100000,
357                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
358                                         | REGULATOR_MODE_STANDBY,
359                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
360                                         | REGULATOR_CHANGE_STATUS,
361         },
362 };
363
364 static struct regulator_init_data omap4_panda_vcxio = {
365         .constraints = {
366                 .min_uV                 = 1800000,
367                 .max_uV                 = 1800000,
368                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
369                                         | REGULATOR_MODE_STANDBY,
370                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
371                                         | REGULATOR_CHANGE_STATUS,
372         },
373 };
374
375 static struct regulator_init_data omap4_panda_vdac = {
376         .constraints = {
377                 .min_uV                 = 1800000,
378                 .max_uV                 = 1800000,
379                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
380                                         | REGULATOR_MODE_STANDBY,
381                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
382                                         | REGULATOR_CHANGE_STATUS,
383         },
384 };
385
386 static struct regulator_init_data omap4_panda_vusb = {
387         .constraints = {
388                 .min_uV                 = 3300000,
389                 .max_uV                 = 3300000,
390                 .apply_uV               = true,
391                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
392                                         | REGULATOR_MODE_STANDBY,
393                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
394                                         | REGULATOR_CHANGE_STATUS,
395         },
396 };
397
398 static struct twl4030_platform_data omap4_panda_twldata = {
399         .irq_base       = TWL6030_IRQ_BASE,
400         .irq_end        = TWL6030_IRQ_END,
401
402         /* Regulators */
403         .vmmc           = &omap4_panda_vmmc,
404         .vpp            = &omap4_panda_vpp,
405         .vusim          = &omap4_panda_vusim,
406         .vana           = &omap4_panda_vana,
407         .vcxio          = &omap4_panda_vcxio,
408         .vdac           = &omap4_panda_vdac,
409         .vusb           = &omap4_panda_vusb,
410         .vaux1          = &omap4_panda_vaux1,
411         .vaux2          = &omap4_panda_vaux2,
412         .vaux3          = &omap4_panda_vaux3,
413         .usb            = &omap4_usbphy_data,
414 };
415
416 static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
417         {
418                 I2C_BOARD_INFO("twl6030", 0x48),
419                 .flags = I2C_CLIENT_WAKE,
420                 .irq = OMAP44XX_IRQ_SYS_1N,
421                 .platform_data = &omap4_panda_twldata,
422         },
423 };
424 static int __init omap4_panda_i2c_init(void)
425 {
426         /*
427          * Phoenix Audio IC needs I2C1 to
428          * start with 400 KHz or less
429          */
430         omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
431                         ARRAY_SIZE(omap4_panda_i2c_boardinfo));
432         omap_register_i2c_bus(2, 400, NULL, 0);
433         omap_register_i2c_bus(3, 400, NULL, 0);
434         omap_register_i2c_bus(4, 400, NULL, 0);
435         return 0;
436 }
437
438 #ifdef CONFIG_OMAP_MUX
439 static struct omap_board_mux board_mux[] __initdata = {
440         /* WLAN IRQ - GPIO 53 */
441         OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
442         /* WLAN POWER ENABLE - GPIO 43 */
443         OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
444         /* WLAN SDIO: MMC5 CMD */
445         OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
446         /* WLAN SDIO: MMC5 CLK */
447         OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
448         /* WLAN SDIO: MMC5 DAT[0-3] */
449         OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
450         OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
451         OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
452         OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
453         { .reg_offset = OMAP_MUX_TERMINATOR },
454 };
455 #else
456 #define board_mux       NULL
457 #endif
458
459 static void __init omap4_panda_init(void)
460 {
461         int package = OMAP_PACKAGE_CBS;
462
463         if (omap_rev() == OMAP4430_REV_ES1_0)
464                 package = OMAP_PACKAGE_CBL;
465         omap4_mux_init(board_mux, package);
466
467         if (wl12xx_set_platform_data(&omap_panda_wlan_data))
468                 pr_err("error setting wl12xx data\n");
469
470         omap4_panda_i2c_init();
471         platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
472         platform_device_register(&omap_vwlan_device);
473         omap_serial_init();
474         omap4_twl6030_hsmmc_init(mmc);
475         omap4_ehci_init();
476         usb_musb_init(&musb_board_data);
477 }
478
479 static void __init omap4_panda_map_io(void)
480 {
481         omap2_set_globals_443x();
482         omap44xx_map_common_io();
483 }
484
485 MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
486         /* Maintainer: David Anders - Texas Instruments Inc */
487         .boot_params    = 0x80000100,
488         .reserve        = omap_reserve,
489         .map_io         = omap4_panda_map_io,
490         .init_early     = omap4_panda_init_early,
491         .init_irq       = gic_init_irq,
492         .init_machine   = omap4_panda_init,
493         .timer          = &omap_timer,
494 MACHINE_END