omap: omap3evm: add support for the WL12xx WLAN module to the omap3evm
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / board-omap3evm.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3evm.c
3  *
4  * Copyright (C) 2008 Texas Instruments
5  *
6  * Modified from mach-omap2/board-3430sdp.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/gpio.h>
22 #include <linux/input.h>
23 #include <linux/input/matrix_keypad.h>
24 #include <linux/leds.h>
25 #include <linux/interrupt.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
29 #include <linux/i2c/twl.h>
30 #include <linux/usb/otg.h>
31 #include <linux/smsc911x.h>
33 #include <linux/wl12xx.h>
34 #include <linux/regulator/fixed.h>
35 #include <linux/regulator/machine.h>
36 #include <linux/mmc/host.h>
38 #include <mach/hardware.h>
39 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
43 #include <plat/board.h>
44 #include <plat/usb.h>
45 #include <plat/common.h>
46 #include <plat/mcspi.h>
47 #include <plat/display.h>
48 #include <plat/panel-generic-dpi.h>
50 #include "mux.h"
51 #include "sdram-micron-mt46h32m32lf-6.h"
52 #include "hsmmc.h"
54 #define OMAP3_EVM_TS_GPIO       175
55 #define OMAP3_EVM_EHCI_VBUS     22
56 #define OMAP3_EVM_EHCI_SELECT   61
58 #define OMAP3EVM_ETHR_START     0x2c000000
59 #define OMAP3EVM_ETHR_SIZE      1024
60 #define OMAP3EVM_ETHR_ID_REV    0x50
61 #define OMAP3EVM_ETHR_GPIO_IRQ  176
62 #define OMAP3EVM_SMSC911X_CS    5
63 /*
64  * Eth Reset signal
65  *      64 = Generation 1 (<=RevD)
66  *      7 = Generation 2 (>=RevE)
67  */
68 #define OMAP3EVM_GEN1_ETHR_GPIO_RST     64
69 #define OMAP3EVM_GEN2_ETHR_GPIO_RST     7
71 static u8 omap3_evm_version;
73 u8 get_omap3_evm_rev(void)
74 {
75         return omap3_evm_version;
76 }
77 EXPORT_SYMBOL(get_omap3_evm_rev);
79 static void __init omap3_evm_get_revision(void)
80 {
81         void __iomem *ioaddr;
82         unsigned int smsc_id;
84         /* Ethernet PHY ID is stored at ID_REV register */
85         ioaddr = ioremap_nocache(OMAP3EVM_ETHR_START, SZ_1K);
86         if (!ioaddr)
87                 return;
88         smsc_id = readl(ioaddr + OMAP3EVM_ETHR_ID_REV) & 0xFFFF0000;
89         iounmap(ioaddr);
91         switch (smsc_id) {
92         /*SMSC9115 chipset*/
93         case 0x01150000:
94                 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
95                 break;
96         /*SMSC 9220 chipset*/
97         case 0x92200000:
98         default:
99                 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
100         }
103 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
104 static struct resource omap3evm_smsc911x_resources[] = {
105         [0] =   {
106                 .start  = OMAP3EVM_ETHR_START,
107                 .end    = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
108                 .flags  = IORESOURCE_MEM,
109         },
110         [1] =   {
111                 .start  = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
112                 .end    = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
113                 .flags  = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW),
114         },
115 };
117 static struct smsc911x_platform_config smsc911x_config = {
118         .phy_interface  = PHY_INTERFACE_MODE_MII,
119         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
120         .irq_type       = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
121         .flags          = (SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS),
122 };
124 static struct platform_device omap3evm_smsc911x_device = {
125         .name           = "smsc911x",
126         .id             = -1,
127         .num_resources  = ARRAY_SIZE(omap3evm_smsc911x_resources),
128         .resource       = &omap3evm_smsc911x_resources[0],
129         .dev            = {
130                 .platform_data = &smsc911x_config,
131         },
132 };
134 static inline void __init omap3evm_init_smsc911x(void)
136         int eth_cs, eth_rst;
137         struct clk *l3ck;
138         unsigned int rate;
140         if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1)
141                 eth_rst = OMAP3EVM_GEN1_ETHR_GPIO_RST;
142         else
143                 eth_rst = OMAP3EVM_GEN2_ETHR_GPIO_RST;
145         eth_cs = OMAP3EVM_SMSC911X_CS;
147         l3ck = clk_get(NULL, "l3_ck");
148         if (IS_ERR(l3ck))
149                 rate = 100000000;
150         else
151                 rate = clk_get_rate(l3ck);
153         /* Configure ethernet controller reset gpio */
154         if (cpu_is_omap3430()) {
155                 if (gpio_request(eth_rst, "SMSC911x gpio") < 0) {
156                         pr_err(KERN_ERR "Failed to request %d for smsc911x\n",
157                                         eth_rst);
158                         return;
159                 }
161                 if (gpio_direction_output(eth_rst, 1) < 0) {
162                         pr_err(KERN_ERR "Failed to set direction of %d for" \
163                                         " smsc911x\n", eth_rst);
164                         return;
165                 }
166                 /* reset pulse to ethernet controller*/
167                 usleep_range(150, 220);
168                 gpio_set_value(eth_rst, 0);
169                 usleep_range(150, 220);
170                 gpio_set_value(eth_rst, 1);
171                 usleep_range(1, 2);
172         }
174         if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMSC911x irq") < 0) {
175                 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
176                         OMAP3EVM_ETHR_GPIO_IRQ);
177                 return;
178         }
180         gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
181         platform_device_register(&omap3evm_smsc911x_device);
184 #else
185 static inline void __init omap3evm_init_smsc911x(void) { return; }
186 #endif
188 /*
189  * OMAP3EVM LCD Panel control signals
190  */
191 #define OMAP3EVM_LCD_PANEL_LR           2
192 #define OMAP3EVM_LCD_PANEL_UD           3
193 #define OMAP3EVM_LCD_PANEL_INI          152
194 #define OMAP3EVM_LCD_PANEL_ENVDD        153
195 #define OMAP3EVM_LCD_PANEL_QVGA         154
196 #define OMAP3EVM_LCD_PANEL_RESB         155
197 #define OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO 210
198 #define OMAP3EVM_DVI_PANEL_EN_GPIO      199
200 static int lcd_enabled;
201 static int dvi_enabled;
203 static void __init omap3_evm_display_init(void)
205         int r;
207         r = gpio_request(OMAP3EVM_LCD_PANEL_RESB, "lcd_panel_resb");
208         if (r) {
209                 printk(KERN_ERR "failed to get lcd_panel_resb\n");
210                 return;
211         }
212         gpio_direction_output(OMAP3EVM_LCD_PANEL_RESB, 1);
214         r = gpio_request(OMAP3EVM_LCD_PANEL_INI, "lcd_panel_ini");
215         if (r) {
216                 printk(KERN_ERR "failed to get lcd_panel_ini\n");
217                 goto err_1;
218         }
219         gpio_direction_output(OMAP3EVM_LCD_PANEL_INI, 1);
221         r = gpio_request(OMAP3EVM_LCD_PANEL_QVGA, "lcd_panel_qvga");
222         if (r) {
223                 printk(KERN_ERR "failed to get lcd_panel_qvga\n");
224                 goto err_2;
225         }
226         gpio_direction_output(OMAP3EVM_LCD_PANEL_QVGA, 0);
228         r = gpio_request(OMAP3EVM_LCD_PANEL_LR, "lcd_panel_lr");
229         if (r) {
230                 printk(KERN_ERR "failed to get lcd_panel_lr\n");
231                 goto err_3;
232         }
233         gpio_direction_output(OMAP3EVM_LCD_PANEL_LR, 1);
235         r = gpio_request(OMAP3EVM_LCD_PANEL_UD, "lcd_panel_ud");
236         if (r) {
237                 printk(KERN_ERR "failed to get lcd_panel_ud\n");
238                 goto err_4;
239         }
240         gpio_direction_output(OMAP3EVM_LCD_PANEL_UD, 1);
242         r = gpio_request(OMAP3EVM_LCD_PANEL_ENVDD, "lcd_panel_envdd");
243         if (r) {
244                 printk(KERN_ERR "failed to get lcd_panel_envdd\n");
245                 goto err_5;
246         }
247         gpio_direction_output(OMAP3EVM_LCD_PANEL_ENVDD, 0);
249         return;
251 err_5:
252         gpio_free(OMAP3EVM_LCD_PANEL_UD);
253 err_4:
254         gpio_free(OMAP3EVM_LCD_PANEL_LR);
255 err_3:
256         gpio_free(OMAP3EVM_LCD_PANEL_QVGA);
257 err_2:
258         gpio_free(OMAP3EVM_LCD_PANEL_INI);
259 err_1:
260         gpio_free(OMAP3EVM_LCD_PANEL_RESB);
264 static int omap3_evm_enable_lcd(struct omap_dss_device *dssdev)
266         if (dvi_enabled) {
267                 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
268                 return -EINVAL;
269         }
270         gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 0);
272         if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
273                 gpio_set_value_cansleep(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
274         else
275                 gpio_set_value_cansleep(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
277         lcd_enabled = 1;
278         return 0;
281 static void omap3_evm_disable_lcd(struct omap_dss_device *dssdev)
283         gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 1);
285         if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
286                 gpio_set_value_cansleep(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
287         else
288                 gpio_set_value_cansleep(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
290         lcd_enabled = 0;
293 static struct omap_dss_device omap3_evm_lcd_device = {
294         .name                   = "lcd",
295         .driver_name            = "sharp_ls_panel",
296         .type                   = OMAP_DISPLAY_TYPE_DPI,
297         .phy.dpi.data_lines     = 18,
298         .platform_enable        = omap3_evm_enable_lcd,
299         .platform_disable       = omap3_evm_disable_lcd,
300 };
302 static int omap3_evm_enable_tv(struct omap_dss_device *dssdev)
304         return 0;
307 static void omap3_evm_disable_tv(struct omap_dss_device *dssdev)
311 static struct omap_dss_device omap3_evm_tv_device = {
312         .name                   = "tv",
313         .driver_name            = "venc",
314         .type                   = OMAP_DISPLAY_TYPE_VENC,
315         .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
316         .platform_enable        = omap3_evm_enable_tv,
317         .platform_disable       = omap3_evm_disable_tv,
318 };
320 static int omap3_evm_enable_dvi(struct omap_dss_device *dssdev)
322         if (lcd_enabled) {
323                 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
324                 return -EINVAL;
325         }
327         gpio_set_value_cansleep(OMAP3EVM_DVI_PANEL_EN_GPIO, 1);
329         dvi_enabled = 1;
330         return 0;
333 static void omap3_evm_disable_dvi(struct omap_dss_device *dssdev)
335         gpio_set_value_cansleep(OMAP3EVM_DVI_PANEL_EN_GPIO, 0);
337         dvi_enabled = 0;
340 static struct panel_generic_dpi_data dvi_panel = {
341         .name                   = "generic",
342         .platform_enable        = omap3_evm_enable_dvi,
343         .platform_disable       = omap3_evm_disable_dvi,
344 };
346 static struct omap_dss_device omap3_evm_dvi_device = {
347         .name                   = "dvi",
348         .type                   = OMAP_DISPLAY_TYPE_DPI,
349         .driver_name            = "generic_dpi_panel",
350         .data                   = &dvi_panel,
351         .phy.dpi.data_lines     = 24,
352 };
354 static struct omap_dss_device *omap3_evm_dss_devices[] = {
355         &omap3_evm_lcd_device,
356         &omap3_evm_tv_device,
357         &omap3_evm_dvi_device,
358 };
360 static struct omap_dss_board_info omap3_evm_dss_data = {
361         .num_devices    = ARRAY_SIZE(omap3_evm_dss_devices),
362         .devices        = omap3_evm_dss_devices,
363         .default_device = &omap3_evm_lcd_device,
364 };
366 static struct regulator_consumer_supply omap3evm_vmmc1_supply = {
367         .supply                 = "vmmc",
368 };
370 static struct regulator_consumer_supply omap3evm_vsim_supply = {
371         .supply                 = "vmmc_aux",
372 };
374 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
375 static struct regulator_init_data omap3evm_vmmc1 = {
376         .constraints = {
377                 .min_uV                 = 1850000,
378                 .max_uV                 = 3150000,
379                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
380                                         | REGULATOR_MODE_STANDBY,
381                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
382                                         | REGULATOR_CHANGE_MODE
383                                         | REGULATOR_CHANGE_STATUS,
384         },
385         .num_consumer_supplies  = 1,
386         .consumer_supplies      = &omap3evm_vmmc1_supply,
387 };
389 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
390 static struct regulator_init_data omap3evm_vsim = {
391         .constraints = {
392                 .min_uV                 = 1800000,
393                 .max_uV                 = 3000000,
394                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
395                                         | REGULATOR_MODE_STANDBY,
396                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
397                                         | REGULATOR_CHANGE_MODE
398                                         | REGULATOR_CHANGE_STATUS,
399         },
400         .num_consumer_supplies  = 1,
401         .consumer_supplies      = &omap3evm_vsim_supply,
402 };
404 static struct omap2_hsmmc_info mmc[] = {
405         {
406                 .mmc            = 1,
407                 .caps           = MMC_CAP_4_BIT_DATA,
408                 .gpio_cd        = -EINVAL,
409                 .gpio_wp        = 63,
410         },
411 #ifdef CONFIG_WL12XX_PLATFORM_DATA
412         {
413                 .name           = "wl1271",
414                 .mmc            = 2,
415                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
416                 .gpio_wp        = -EINVAL,
417                 .gpio_cd        = -EINVAL,
418                 .nonremovable   = true,
419         },
420 #endif
421         {}      /* Terminator */
422 };
424 static struct gpio_led gpio_leds[] = {
425         {
426                 .name                   = "omap3evm::ledb",
427                 /* normally not visible (board underside) */
428                 .default_trigger        = "default-on",
429                 .gpio                   = -EINVAL,      /* gets replaced */
430                 .active_low             = true,
431         },
432 };
434 static struct gpio_led_platform_data gpio_led_info = {
435         .leds           = gpio_leds,
436         .num_leds       = ARRAY_SIZE(gpio_leds),
437 };
439 static struct platform_device leds_gpio = {
440         .name   = "leds-gpio",
441         .id     = -1,
442         .dev    = {
443                 .platform_data  = &gpio_led_info,
444         },
445 };
448 static int omap3evm_twl_gpio_setup(struct device *dev,
449                 unsigned gpio, unsigned ngpio)
451         int r;
453         /* gpio + 0 is "mmc0_cd" (input/IRQ) */
454         omap_mux_init_gpio(63, OMAP_PIN_INPUT);
455         mmc[0].gpio_cd = gpio + 0;
456         omap2_hsmmc_init(mmc);
458         /* link regulators to MMC adapters */
459         omap3evm_vmmc1_supply.dev = mmc[0].dev;
460         omap3evm_vsim_supply.dev = mmc[0].dev;
462         /*
463          * Most GPIOs are for USB OTG.  Some are mostly sent to
464          * the P2 connector; notably LEDA for the LCD backlight.
465          */
467         /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
468         r = gpio_request(gpio + TWL4030_GPIO_MAX, "EN_LCD_BKL");
469         if (!r)
470                 r = gpio_direction_output(gpio + TWL4030_GPIO_MAX,
471                         (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) ? 1 : 0);
472         if (r)
473                 printk(KERN_ERR "failed to get/set lcd_bkl gpio\n");
475         /* gpio + 7 == DVI Enable */
476         gpio_request(gpio + 7, "EN_DVI");
477         gpio_direction_output(gpio + 7, 0);
479         /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
480         gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
482         platform_device_register(&leds_gpio);
484         return 0;
487 static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
488         .gpio_base      = OMAP_MAX_GPIO_LINES,
489         .irq_base       = TWL4030_GPIO_IRQ_BASE,
490         .irq_end        = TWL4030_GPIO_IRQ_END,
491         .use_leds       = true,
492         .setup          = omap3evm_twl_gpio_setup,
493 };
495 static struct twl4030_usb_data omap3evm_usb_data = {
496         .usb_mode       = T2_USB_MODE_ULPI,
497 };
499 static uint32_t board_keymap[] = {
500         KEY(0, 0, KEY_LEFT),
501         KEY(0, 1, KEY_DOWN),
502         KEY(0, 2, KEY_ENTER),
503         KEY(0, 3, KEY_M),
505         KEY(1, 0, KEY_RIGHT),
506         KEY(1, 1, KEY_UP),
507         KEY(1, 2, KEY_I),
508         KEY(1, 3, KEY_N),
510         KEY(2, 0, KEY_A),
511         KEY(2, 1, KEY_E),
512         KEY(2, 2, KEY_J),
513         KEY(2, 3, KEY_O),
515         KEY(3, 0, KEY_B),
516         KEY(3, 1, KEY_F),
517         KEY(3, 2, KEY_K),
518         KEY(3, 3, KEY_P)
519 };
521 static struct matrix_keymap_data board_map_data = {
522         .keymap                 = board_keymap,
523         .keymap_size            = ARRAY_SIZE(board_keymap),
524 };
526 static struct twl4030_keypad_data omap3evm_kp_data = {
527         .keymap_data    = &board_map_data,
528         .rows           = 4,
529         .cols           = 4,
530         .rep            = 1,
531 };
533 static struct twl4030_madc_platform_data omap3evm_madc_data = {
534         .irq_line       = 1,
535 };
537 static struct twl4030_codec_audio_data omap3evm_audio_data = {
538         .audio_mclk = 26000000,
539 };
541 static struct twl4030_codec_data omap3evm_codec_data = {
542         .audio_mclk = 26000000,
543         .audio = &omap3evm_audio_data,
544 };
546 static struct regulator_consumer_supply omap3_evm_vdda_dac_supply =
547         REGULATOR_SUPPLY("vdda_dac", "omapdss");
549 /* VDAC for DSS driving S-Video */
550 static struct regulator_init_data omap3_evm_vdac = {
551         .constraints = {
552                 .min_uV                 = 1800000,
553                 .max_uV                 = 1800000,
554                 .apply_uV               = true,
555                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
556                                         | REGULATOR_MODE_STANDBY,
557                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
558                                         | REGULATOR_CHANGE_STATUS,
559         },
560         .num_consumer_supplies  = 1,
561         .consumer_supplies      = &omap3_evm_vdda_dac_supply,
562 };
564 /* VPLL2 for digital video outputs */
565 static struct regulator_consumer_supply omap3_evm_vpll2_supply =
566         REGULATOR_SUPPLY("vdds_dsi", "omapdss");
568 static struct regulator_init_data omap3_evm_vpll2 = {
569         .constraints = {
570                 .min_uV                 = 1800000,
571                 .max_uV                 = 1800000,
572                 .apply_uV               = true,
573                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
574                                         | REGULATOR_MODE_STANDBY,
575                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
576                                         | REGULATOR_CHANGE_STATUS,
577         },
578         .num_consumer_supplies  = 1,
579         .consumer_supplies      = &omap3_evm_vpll2_supply,
580 };
582 /* ads7846 on SPI */
583 static struct regulator_consumer_supply omap3evm_vio_supply =
584         REGULATOR_SUPPLY("vcc", "spi1.0");
586 /* VIO for ads7846 */
587 static struct regulator_init_data omap3evm_vio = {
588         .constraints = {
589                 .min_uV                 = 1800000,
590                 .max_uV                 = 1800000,
591                 .apply_uV               = true,
592                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
593                                         | REGULATOR_MODE_STANDBY,
594                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
595                                         | REGULATOR_CHANGE_STATUS,
596         },
597         .num_consumer_supplies  = 1,
598         .consumer_supplies      = &omap3evm_vio_supply,
599 };
601 #ifdef CONFIG_WL12XX_PLATFORM_DATA
603 #define OMAP3EVM_WLAN_PMENA_GPIO        (150)
604 #define OMAP3EVM_WLAN_IRQ_GPIO          (149)
606 static struct regulator_consumer_supply omap3evm_vmmc2_supply =
607         REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
609 /* VMMC2 for driving the WL12xx module */
610 static struct regulator_init_data omap3evm_vmmc2 = {
611         .constraints = {
612                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
613         },
614         .num_consumer_supplies  = 1,
615         .consumer_supplies = &omap3evm_vmmc2_supply,
616 };
618 static struct fixed_voltage_config omap3evm_vwlan = {
619         .supply_name            = "vwl1271",
620         .microvolts             = 1800000, /* 1.80V */
621         .gpio                   = OMAP3EVM_WLAN_PMENA_GPIO,
622         .startup_delay          = 70000, /* 70ms */
623         .enable_high            = 1,
624         .enabled_at_boot        = 0,
625         .init_data              = &omap3evm_vmmc2,
626 };
628 static struct platform_device omap3evm_wlan_regulator = {
629         .name           = "reg-fixed-voltage",
630         .id             = 1,
631         .dev = {
632                 .platform_data  = &omap3evm_vwlan,
633         },
634 };
636 struct wl12xx_platform_data omap3evm_wlan_data __initdata = {
637         .irq = OMAP_GPIO_IRQ(OMAP3EVM_WLAN_IRQ_GPIO),
638         .board_ref_clock = WL12XX_REFCLOCK_38, /* 38.4 MHz */
639 };
640 #endif
642 static struct twl4030_platform_data omap3evm_twldata = {
643         .irq_base       = TWL4030_IRQ_BASE,
644         .irq_end        = TWL4030_IRQ_END,
646         /* platform_data for children goes here */
647         .keypad         = &omap3evm_kp_data,
648         .madc           = &omap3evm_madc_data,
649         .usb            = &omap3evm_usb_data,
650         .gpio           = &omap3evm_gpio_data,
651         .codec          = &omap3evm_codec_data,
652         .vdac           = &omap3_evm_vdac,
653         .vpll2          = &omap3_evm_vpll2,
654         .vio            = &omap3evm_vio,
655 };
657 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
658         {
659                 I2C_BOARD_INFO("twl4030", 0x48),
660                 .flags = I2C_CLIENT_WAKE,
661                 .irq = INT_34XX_SYS_NIRQ,
662                 .platform_data = &omap3evm_twldata,
663         },
664 };
666 static int __init omap3_evm_i2c_init(void)
668         /*
669          * REVISIT: These entries can be set in omap3evm_twl_data
670          * after a merge with MFD tree
671          */
672         omap3evm_twldata.vmmc1 = &omap3evm_vmmc1;
673         omap3evm_twldata.vsim = &omap3evm_vsim;
675         omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
676                         ARRAY_SIZE(omap3evm_i2c_boardinfo));
677         omap_register_i2c_bus(2, 400, NULL, 0);
678         omap_register_i2c_bus(3, 400, NULL, 0);
679         return 0;
682 static void ads7846_dev_init(void)
684         if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
685                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
687         gpio_direction_input(OMAP3_EVM_TS_GPIO);
688         gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
691 static int ads7846_get_pendown_state(void)
693         return !gpio_get_value(OMAP3_EVM_TS_GPIO);
696 static struct ads7846_platform_data ads7846_config = {
697         .x_max                  = 0x0fff,
698         .y_max                  = 0x0fff,
699         .x_plate_ohms           = 180,
700         .pressure_max           = 255,
701         .debounce_max           = 10,
702         .debounce_tol           = 3,
703         .debounce_rep           = 1,
704         .get_pendown_state      = ads7846_get_pendown_state,
705         .keep_vref_on           = 1,
706         .settle_delay_usecs     = 150,
707         .wakeup                         = true,
708 };
710 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
711         .turbo_mode     = 0,
712         .single_channel = 1,    /* 0: slave, 1: master */
713 };
715 static struct spi_board_info omap3evm_spi_board_info[] = {
716         [0] = {
717                 .modalias               = "ads7846",
718                 .bus_num                = 1,
719                 .chip_select            = 0,
720                 .max_speed_hz           = 1500000,
721                 .controller_data        = &ads7846_mcspi_config,
722                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
723                 .platform_data          = &ads7846_config,
724         },
725 };
727 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
728 };
730 static void __init omap3_evm_init_early(void)
732         omap_board_config = omap3_evm_config;
733         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
734         omap2_init_common_infrastructure();
735         omap2_init_common_devices(mt46h32m32lf6_sdrc_params, NULL);
738 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
740         .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
741         .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
742         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
744         .phy_reset  = true,
745         /* PHY reset GPIO will be runtime programmed based on EVM version */
746         .reset_gpio_port[0]  = -EINVAL,
747         .reset_gpio_port[1]  = -EINVAL,
748         .reset_gpio_port[2]  = -EINVAL
749 };
751 #ifdef CONFIG_OMAP_MUX
752 static struct omap_board_mux omap35x_board_mux[] __initdata = {
753         OMAP3_MUX(SYS_NIRQ, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP |
754                                 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
755                                 OMAP_PIN_OFF_WAKEUPENABLE),
756         OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
757                                 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
758                                 OMAP_PIN_OFF_WAKEUPENABLE),
759         OMAP3_MUX(SYS_BOOT5, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
760                                 OMAP_PIN_OFF_NONE),
761         OMAP3_MUX(GPMC_WAIT2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
762                                 OMAP_PIN_OFF_NONE),
763 #ifdef CONFIG_WL12XX_PLATFORM_DATA
764         /* WLAN IRQ - GPIO 149 */
765         OMAP3_MUX(UART1_RTS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
767         /* WLAN POWER ENABLE - GPIO 150 */
768         OMAP3_MUX(UART1_CTS, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
770         /* MMC2 SDIO pin muxes for WL12xx */
771         OMAP3_MUX(SDMMC2_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
772         OMAP3_MUX(SDMMC2_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
773         OMAP3_MUX(SDMMC2_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
774         OMAP3_MUX(SDMMC2_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
775         OMAP3_MUX(SDMMC2_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
776         OMAP3_MUX(SDMMC2_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
777 #endif
778         { .reg_offset = OMAP_MUX_TERMINATOR },
779 };
781 static struct omap_board_mux omap36x_board_mux[] __initdata = {
782         OMAP3_MUX(SYS_NIRQ, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP |
783                                 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
784                                 OMAP_PIN_OFF_WAKEUPENABLE),
785         OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
786                                 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
787                                 OMAP_PIN_OFF_WAKEUPENABLE),
788         /* AM/DM37x EVM: DSS data bus muxed with sys_boot */
789         OMAP3_MUX(DSS_DATA18, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
790         OMAP3_MUX(DSS_DATA19, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
791         OMAP3_MUX(DSS_DATA22, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
792         OMAP3_MUX(DSS_DATA21, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
793         OMAP3_MUX(DSS_DATA22, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
794         OMAP3_MUX(DSS_DATA23, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
795         OMAP3_MUX(SYS_BOOT0, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
796         OMAP3_MUX(SYS_BOOT1, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
797         OMAP3_MUX(SYS_BOOT3, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
798         OMAP3_MUX(SYS_BOOT4, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
799         OMAP3_MUX(SYS_BOOT5, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
800         OMAP3_MUX(SYS_BOOT6, OMAP_MUX_MODE3 | OMAP_PIN_OFF_NONE),
801 #ifdef CONFIG_WL12XX_PLATFORM_DATA
802         /* WLAN IRQ - GPIO 149 */
803         OMAP3_MUX(UART1_RTS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
805         /* WLAN POWER ENABLE - GPIO 150 */
806         OMAP3_MUX(UART1_CTS, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
808         /* MMC2 SDIO pin muxes for WL12xx */
809         OMAP3_MUX(SDMMC2_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
810         OMAP3_MUX(SDMMC2_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
811         OMAP3_MUX(SDMMC2_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
812         OMAP3_MUX(SDMMC2_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
813         OMAP3_MUX(SDMMC2_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
814         OMAP3_MUX(SDMMC2_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
815 #endif
817         { .reg_offset = OMAP_MUX_TERMINATOR },
818 };
819 #else
820 #define omap35x_board_mux       NULL
821 #define omap36x_board_mux       NULL
822 #endif
824 static struct omap_musb_board_data musb_board_data = {
825         .interface_type         = MUSB_INTERFACE_ULPI,
826         .mode                   = MUSB_OTG,
827         .power                  = 100,
828 };
830 static void __init omap3_evm_init(void)
832         omap3_evm_get_revision();
834         if (cpu_is_omap3630())
835                 omap3_mux_init(omap36x_board_mux, OMAP_PACKAGE_CBB);
836         else
837                 omap3_mux_init(omap35x_board_mux, OMAP_PACKAGE_CBB);
839         omap3_evm_i2c_init();
841         omap_display_init(&omap3_evm_dss_data);
843         spi_register_board_info(omap3evm_spi_board_info,
844                                 ARRAY_SIZE(omap3evm_spi_board_info));
846         omap_serial_init();
848         /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
849         usb_nop_xceiv_register();
851         if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) {
852                 /* enable EHCI VBUS using GPIO22 */
853                 omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP);
854                 gpio_request(OMAP3_EVM_EHCI_VBUS, "enable EHCI VBUS");
855                 gpio_direction_output(OMAP3_EVM_EHCI_VBUS, 0);
856                 gpio_set_value(OMAP3_EVM_EHCI_VBUS, 1);
858                 /* Select EHCI port on main board */
859                 omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP);
860                 gpio_request(OMAP3_EVM_EHCI_SELECT, "select EHCI port");
861                 gpio_direction_output(OMAP3_EVM_EHCI_SELECT, 0);
862                 gpio_set_value(OMAP3_EVM_EHCI_SELECT, 0);
864                 /* setup EHCI phy reset config */
865                 omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP);
866                 ehci_pdata.reset_gpio_port[1] = 21;
868                 /* EVM REV >= E can supply 500mA with EXTVBUS programming */
869                 musb_board_data.power = 500;
870                 musb_board_data.extvbus = 1;
871         } else {
872                 /* setup EHCI phy reset on MDC */
873                 omap_mux_init_gpio(135, OMAP_PIN_OUTPUT);
874                 ehci_pdata.reset_gpio_port[1] = 135;
875         }
876         usb_musb_init(&musb_board_data);
877         usb_ehci_init(&ehci_pdata);
878         ads7846_dev_init();
879         omap3evm_init_smsc911x();
880         omap3_evm_display_init();
882 #ifdef CONFIG_WL12XX_PLATFORM_DATA
883         /* WL12xx WLAN Init */
884         if (wl12xx_set_platform_data(&omap3evm_wlan_data))
885                 pr_err("error setting wl12xx data\n");
886         platform_device_register(&omap3evm_wlan_regulator);
887 #endif
890 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
891         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
892         .boot_params    = 0x80000100,
893         .reserve        = omap_reserve,
894         .map_io         = omap3_map_io,
895         .init_early     = omap3_evm_init_early,
896         .init_irq       = omap_init_irq,
897         .init_machine   = omap3_evm_init,
898         .timer          = &omap_timer,
899 MACHINE_END