hwspinlock: depend on OMAP4
[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 /* wl127x BT, FM, GPS connectivity chip */
54 static int wl1271_gpios[] = {46, -1, -1};
55 static struct platform_device wl1271_device = {
56         .name   = "kim",
57         .id     = -1,
58         .dev    = {
59                 .platform_data  = &wl1271_gpios,
60         },
61 };
62
63 static struct gpio_led gpio_leds[] = {
64         {
65                 .name                   = "pandaboard::status1",
66                 .default_trigger        = "heartbeat",
67                 .gpio                   = 7,
68         },
69         {
70                 .name                   = "pandaboard::status2",
71                 .default_trigger        = "mmc0",
72                 .gpio                   = 8,
73         },
74 };
75
76 static struct gpio_led_platform_data gpio_led_info = {
77         .leds           = gpio_leds,
78         .num_leds       = ARRAY_SIZE(gpio_leds),
79 };
80
81 static struct platform_device leds_gpio = {
82         .name   = "leds-gpio",
83         .id     = -1,
84         .dev    = {
85                 .platform_data  = &gpio_led_info,
86         },
87 };
88
89 static struct platform_device *panda_devices[] __initdata = {
90         &leds_gpio,
91         &wl1271_device,
92 };
93
94 static void __init omap4_panda_init_early(void)
95 {
96         omap2_init_common_infrastructure();
97         omap2_init_common_devices(NULL, NULL);
98 }
99
100 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
101         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
102         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
103         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
104         .phy_reset  = false,
105         .reset_gpio_port[0]  = -EINVAL,
106         .reset_gpio_port[1]  = -EINVAL,
107         .reset_gpio_port[2]  = -EINVAL
108 };
109
110 static void __init omap4_ehci_init(void)
111 {
112         int ret;
113         struct clk *phy_ref_clk;
114
115         /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
116         phy_ref_clk = clk_get(NULL, "auxclk3_ck");
117         if (IS_ERR(phy_ref_clk)) {
118                 pr_err("Cannot request auxclk3\n");
119                 goto error1;
120         }
121         clk_set_rate(phy_ref_clk, 19200000);
122         clk_enable(phy_ref_clk);
123
124         /* disable the power to the usb hub prior to init */
125         ret = gpio_request(GPIO_HUB_POWER, "hub_power");
126         if (ret) {
127                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
128                 goto error1;
129         }
130         gpio_export(GPIO_HUB_POWER, 0);
131         gpio_direction_output(GPIO_HUB_POWER, 0);
132         gpio_set_value(GPIO_HUB_POWER, 0);
133
134         /* reset phy+hub */
135         ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
136         if (ret) {
137                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
138                 goto error2;
139         }
140         gpio_export(GPIO_HUB_NRESET, 0);
141         gpio_direction_output(GPIO_HUB_NRESET, 0);
142         gpio_set_value(GPIO_HUB_NRESET, 0);
143         gpio_set_value(GPIO_HUB_NRESET, 1);
144
145         usb_ehci_init(&ehci_pdata);
146
147         /* enable power to hub */
148         gpio_set_value(GPIO_HUB_POWER, 1);
149         return;
150
151 error2:
152         gpio_free(GPIO_HUB_POWER);
153 error1:
154         pr_err("Unable to initialize EHCI power/reset\n");
155         return;
156
157 }
158
159 static struct omap_musb_board_data musb_board_data = {
160         .interface_type         = MUSB_INTERFACE_UTMI,
161         .mode                   = MUSB_OTG,
162         .power                  = 100,
163 };
164
165 static struct twl4030_usb_data omap4_usbphy_data = {
166         .phy_init       = omap4430_phy_init,
167         .phy_exit       = omap4430_phy_exit,
168         .phy_power      = omap4430_phy_power,
169         .phy_set_clock  = omap4430_phy_set_clk,
170 };
171
172 static struct omap2_hsmmc_info mmc[] = {
173         {
174                 .mmc            = 1,
175                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
176                 .gpio_wp        = -EINVAL,
177                 .gpio_cd        = -EINVAL,
178         },
179         {
180                 .name           = "wl1271",
181                 .mmc            = 5,
182                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
183                 .gpio_wp        = -EINVAL,
184                 .gpio_cd        = -EINVAL,
185                 .ocr_mask       = MMC_VDD_165_195,
186                 .nonremovable   = true,
187         },
188         {}      /* Terminator */
189 };
190
191 static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
192         {
193                 .supply = "vmmc",
194                 .dev_name = "omap_hsmmc.0",
195         },
196 };
197
198 static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
199         .supply = "vmmc",
200         .dev_name = "omap_hsmmc.4",
201 };
202
203 static struct regulator_init_data panda_vmmc5 = {
204         .constraints = {
205                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
206         },
207         .num_consumer_supplies = 1,
208         .consumer_supplies = &omap4_panda_vmmc5_supply,
209 };
210
211 static struct fixed_voltage_config panda_vwlan = {
212         .supply_name = "vwl1271",
213         .microvolts = 1800000, /* 1.8V */
214         .gpio = GPIO_WIFI_PMENA,
215         .startup_delay = 70000, /* 70msec */
216         .enable_high = 1,
217         .enabled_at_boot = 0,
218         .init_data = &panda_vmmc5,
219 };
220
221 static struct platform_device omap_vwlan_device = {
222         .name           = "reg-fixed-voltage",
223         .id             = 1,
224         .dev = {
225                 .platform_data = &panda_vwlan,
226         },
227 };
228
229 struct wl12xx_platform_data omap_panda_wlan_data  __initdata = {
230         .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
231         /* PANDA ref clock is 38.4 MHz */
232         .board_ref_clock = 2,
233 };
234
235 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
236 {
237         int ret = 0;
238         struct platform_device *pdev = container_of(dev,
239                                 struct platform_device, dev);
240         struct omap_mmc_platform_data *pdata = dev->platform_data;
241
242         if (!pdata) {
243                 dev_err(dev, "%s: NULL platform data\n", __func__);
244                 return -EINVAL;
245         }
246         /* Setting MMC1 Card detect Irq */
247         if (pdev->id == 0) {
248                 ret = twl6030_mmc_card_detect_config();
249                  if (ret)
250                         dev_err(dev, "%s: Error card detect config(%d)\n",
251                                 __func__, ret);
252                  else
253                         pdata->slots[0].card_detect = twl6030_mmc_card_detect;
254         }
255         return ret;
256 }
257
258 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
259 {
260         struct omap_mmc_platform_data *pdata;
261
262         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
263         if (!dev) {
264                 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
265                 return;
266         }
267         pdata = dev->platform_data;
268
269         pdata->init =   omap4_twl6030_hsmmc_late_init;
270 }
271
272 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
273 {
274         struct omap2_hsmmc_info *c;
275
276         omap2_hsmmc_init(controllers);
277         for (c = controllers; c->mmc; c++)
278                 omap4_twl6030_hsmmc_set_late_init(c->dev);
279
280         return 0;
281 }
282
283 static struct regulator_init_data omap4_panda_vaux2 = {
284         .constraints = {
285                 .min_uV                 = 1200000,
286                 .max_uV                 = 2800000,
287                 .apply_uV               = true,
288                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
289                                         | REGULATOR_MODE_STANDBY,
290                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
291                                         | REGULATOR_CHANGE_MODE
292                                         | REGULATOR_CHANGE_STATUS,
293         },
294 };
295
296 static struct regulator_init_data omap4_panda_vaux3 = {
297         .constraints = {
298                 .min_uV                 = 1000000,
299                 .max_uV                 = 3000000,
300                 .apply_uV               = true,
301                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
302                                         | REGULATOR_MODE_STANDBY,
303                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
304                                         | REGULATOR_CHANGE_MODE
305                                         | REGULATOR_CHANGE_STATUS,
306         },
307 };
308
309 /* VMMC1 for MMC1 card */
310 static struct regulator_init_data omap4_panda_vmmc = {
311         .constraints = {
312                 .min_uV                 = 1200000,
313                 .max_uV                 = 3000000,
314                 .apply_uV               = true,
315                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
316                                         | REGULATOR_MODE_STANDBY,
317                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
318                                         | REGULATOR_CHANGE_MODE
319                                         | REGULATOR_CHANGE_STATUS,
320         },
321         .num_consumer_supplies  = 1,
322         .consumer_supplies      = omap4_panda_vmmc_supply,
323 };
324
325 static struct regulator_init_data omap4_panda_vpp = {
326         .constraints = {
327                 .min_uV                 = 1800000,
328                 .max_uV                 = 2500000,
329                 .apply_uV               = true,
330                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
331                                         | REGULATOR_MODE_STANDBY,
332                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
333                                         | REGULATOR_CHANGE_MODE
334                                         | REGULATOR_CHANGE_STATUS,
335         },
336 };
337
338 static struct regulator_init_data omap4_panda_vana = {
339         .constraints = {
340                 .min_uV                 = 2100000,
341                 .max_uV                 = 2100000,
342                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
343                                         | REGULATOR_MODE_STANDBY,
344                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
345                                         | REGULATOR_CHANGE_STATUS,
346         },
347 };
348
349 static struct regulator_init_data omap4_panda_vcxio = {
350         .constraints = {
351                 .min_uV                 = 1800000,
352                 .max_uV                 = 1800000,
353                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
354                                         | REGULATOR_MODE_STANDBY,
355                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
356                                         | REGULATOR_CHANGE_STATUS,
357         },
358 };
359
360 static struct regulator_init_data omap4_panda_vdac = {
361         .constraints = {
362                 .min_uV                 = 1800000,
363                 .max_uV                 = 1800000,
364                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
365                                         | REGULATOR_MODE_STANDBY,
366                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
367                                         | REGULATOR_CHANGE_STATUS,
368         },
369 };
370
371 static struct regulator_init_data omap4_panda_vusb = {
372         .constraints = {
373                 .min_uV                 = 3300000,
374                 .max_uV                 = 3300000,
375                 .apply_uV               = true,
376                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
377                                         | REGULATOR_MODE_STANDBY,
378                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
379                                         | REGULATOR_CHANGE_STATUS,
380         },
381 };
382
383 static struct twl4030_platform_data omap4_panda_twldata = {
384         .irq_base       = TWL6030_IRQ_BASE,
385         .irq_end        = TWL6030_IRQ_END,
386
387         /* Regulators */
388         .vmmc           = &omap4_panda_vmmc,
389         .vpp            = &omap4_panda_vpp,
390         .vana           = &omap4_panda_vana,
391         .vcxio          = &omap4_panda_vcxio,
392         .vdac           = &omap4_panda_vdac,
393         .vusb           = &omap4_panda_vusb,
394         .vaux2          = &omap4_panda_vaux2,
395         .vaux3          = &omap4_panda_vaux3,
396         .usb            = &omap4_usbphy_data,
397 };
398
399 static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
400         {
401                 I2C_BOARD_INFO("twl6030", 0x48),
402                 .flags = I2C_CLIENT_WAKE,
403                 .irq = OMAP44XX_IRQ_SYS_1N,
404                 .platform_data = &omap4_panda_twldata,
405         },
406 };
407 static int __init omap4_panda_i2c_init(void)
408 {
409         /*
410          * Phoenix Audio IC needs I2C1 to
411          * start with 400 KHz or less
412          */
413         omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
414                         ARRAY_SIZE(omap4_panda_i2c_boardinfo));
415         omap_register_i2c_bus(2, 400, NULL, 0);
416         omap_register_i2c_bus(3, 400, NULL, 0);
417         omap_register_i2c_bus(4, 400, NULL, 0);
418         return 0;
419 }
420
421 #ifdef CONFIG_OMAP_MUX
422 static struct omap_board_mux board_mux[] __initdata = {
423         /* WLAN IRQ - GPIO 53 */
424         OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
425         /* WLAN POWER ENABLE - GPIO 43 */
426         OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
427         /* WLAN SDIO: MMC5 CMD */
428         OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
429         /* WLAN SDIO: MMC5 CLK */
430         OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
431         /* WLAN SDIO: MMC5 DAT[0-3] */
432         OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
433         OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
434         OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
435         OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
436         { .reg_offset = OMAP_MUX_TERMINATOR },
437 };
438
439 static struct omap_device_pad serial2_pads[] __initdata = {
440         OMAP_MUX_STATIC("uart2_cts.uart2_cts",
441                          OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
442         OMAP_MUX_STATIC("uart2_rts.uart2_rts",
443                          OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
444         OMAP_MUX_STATIC("uart2_rx.uart2_rx",
445                          OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
446         OMAP_MUX_STATIC("uart2_tx.uart2_tx",
447                          OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
448 };
449
450 static struct omap_device_pad serial3_pads[] __initdata = {
451         OMAP_MUX_STATIC("uart3_cts_rctx.uart3_cts_rctx",
452                          OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
453         OMAP_MUX_STATIC("uart3_rts_sd.uart3_rts_sd",
454                          OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
455         OMAP_MUX_STATIC("uart3_rx_irrx.uart3_rx_irrx",
456                          OMAP_PIN_INPUT | OMAP_MUX_MODE0),
457         OMAP_MUX_STATIC("uart3_tx_irtx.uart3_tx_irtx",
458                          OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
459 };
460
461 static struct omap_device_pad serial4_pads[] __initdata = {
462         OMAP_MUX_STATIC("uart4_rx.uart4_rx",
463                          OMAP_PIN_INPUT | OMAP_MUX_MODE0),
464         OMAP_MUX_STATIC("uart4_tx.uart4_tx",
465                          OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
466 };
467
468 static struct omap_board_data serial2_data = {
469         .id             = 1,
470         .pads           = serial2_pads,
471         .pads_cnt       = ARRAY_SIZE(serial2_pads),
472 };
473
474 static struct omap_board_data serial3_data = {
475         .id             = 2,
476         .pads           = serial3_pads,
477         .pads_cnt       = ARRAY_SIZE(serial3_pads),
478 };
479
480 static struct omap_board_data serial4_data = {
481         .id             = 3,
482         .pads           = serial4_pads,
483         .pads_cnt       = ARRAY_SIZE(serial4_pads),
484 };
485
486 static inline void board_serial_init(void)
487 {
488         struct omap_board_data bdata;
489         bdata.flags     = 0;
490         bdata.pads      = NULL;
491         bdata.pads_cnt  = 0;
492         bdata.id        = 0;
493         /* pass dummy data for UART1 */
494         omap_serial_init_port(&bdata);
495
496         omap_serial_init_port(&serial2_data);
497         omap_serial_init_port(&serial3_data);
498         omap_serial_init_port(&serial4_data);
499 }
500 #else
501 #define board_mux       NULL
502
503 static inline void board_serial_init(void)
504 {
505         omap_serial_init();
506 }
507 #endif
508
509 static void __init omap4_panda_init(void)
510 {
511         int package = OMAP_PACKAGE_CBS;
512
513         if (omap_rev() == OMAP4430_REV_ES1_0)
514                 package = OMAP_PACKAGE_CBL;
515         omap4_mux_init(board_mux, package);
516
517         if (wl12xx_set_platform_data(&omap_panda_wlan_data))
518                 pr_err("error setting wl12xx data\n");
519
520         omap4_panda_i2c_init();
521         platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
522         platform_device_register(&omap_vwlan_device);
523         board_serial_init();
524         omap4_twl6030_hsmmc_init(mmc);
525         omap4_ehci_init();
526         usb_musb_init(&musb_board_data);
527 }
528
529 static void __init omap4_panda_map_io(void)
530 {
531         omap2_set_globals_443x();
532         omap44xx_map_common_io();
533 }
534
535 MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
536         /* Maintainer: David Anders - Texas Instruments Inc */
537         .boot_params    = 0x80000100,
538         .reserve        = omap_reserve,
539         .map_io         = omap4_panda_map_io,
540         .init_early     = omap4_panda_init_early,
541         .init_irq       = gic_init_irq,
542         .init_machine   = omap4_panda_init,
543         .timer          = &omap_timer,
544 MACHINE_END