2 * Copyright (C) 2009 Integration Software and Electronic Engineering.
4 * Modified from mach-omap2/board-generic.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/err.h>
16 #include <linux/clk.h>
18 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
20 #include <linux/input.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/regulator/fixed.h>
24 #include <linux/i2c/twl.h>
25 #include <linux/mmc/host.h>
27 #include <linux/mtd/nand.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
32 #include <video/omapdss.h>
33 #include <video/omap-panel-tfp410.h>
34 #include <linux/platform_data/mtd-onenand-omap2.h>
40 #include "sdram-numonyx-m65kxxxxam.h"
41 #include "common-board-devices.h"
42 #include "board-flash.h"
44 #include "gpmc-onenand.h"
46 #define IGEP2_SMSC911X_CS 5
47 #define IGEP2_SMSC911X_GPIO 176
48 #define IGEP2_GPIO_USBH_NRESET 24
49 #define IGEP2_GPIO_LED0_GREEN 26
50 #define IGEP2_GPIO_LED0_RED 27
51 #define IGEP2_GPIO_LED1_RED 28
52 #define IGEP2_GPIO_DVI_PUP 170
54 #define IGEP2_RB_GPIO_WIFI_NPD 94
55 #define IGEP2_RB_GPIO_WIFI_NRESET 95
56 #define IGEP2_RB_GPIO_BT_NRESET 137
57 #define IGEP2_RC_GPIO_WIFI_NPD 138
58 #define IGEP2_RC_GPIO_WIFI_NRESET 139
59 #define IGEP2_RC_GPIO_BT_NRESET 137
61 #define IGEP3_GPIO_LED0_GREEN 54
62 #define IGEP3_GPIO_LED0_RED 53
63 #define IGEP3_GPIO_LED1_RED 16
64 #define IGEP3_GPIO_USBH_NRESET 183
66 #define IGEP_SYSBOOT_MASK 0x1f
67 #define IGEP_SYSBOOT_NAND 0x0f
68 #define IGEP_SYSBOOT_ONENAND 0x10
71 * IGEP2 Hardware Revision Table
73 * --------------------------------------------------------------------------
74 * | Id. | Hw Rev. | HW0 (28) | WIFI_NPD | WIFI_NRESET | BT_NRESET |
75 * --------------------------------------------------------------------------
76 * | 0 | B | high | gpio94 | gpio95 | - |
77 * | 0 | B/C (B-compatible) | high | gpio94 | gpio95 | gpio137 |
78 * | 1 | C | low | gpio138 | gpio139 | gpio137 |
79 * --------------------------------------------------------------------------
82 #define IGEP2_BOARD_HWREV_B 0
83 #define IGEP2_BOARD_HWREV_C 1
84 #define IGEP3_BOARD_HWREV 2
88 static void __init
igep2_get_revision(void)
92 if (machine_is_igep0030()) {
93 hwrev
= IGEP3_BOARD_HWREV
;
97 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED
, OMAP_PIN_INPUT
);
99 if (gpio_request_one(IGEP2_GPIO_LED1_RED
, GPIOF_IN
, "GPIO_HW0_REV")) {
100 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
101 pr_err("IGEP2: Unknown Hardware Revision\n");
105 ret
= gpio_get_value(IGEP2_GPIO_LED1_RED
);
107 pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
108 hwrev
= IGEP2_BOARD_HWREV_C
;
109 } else if (ret
== 1) {
110 pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
111 hwrev
= IGEP2_BOARD_HWREV_B
;
113 pr_err("IGEP2: Unknown Hardware Revision\n");
117 gpio_free(IGEP2_GPIO_LED1_RED
);
120 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
121 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) || \
122 defined(CONFIG_MTD_NAND_OMAP2) || \
123 defined(CONFIG_MTD_NAND_OMAP2_MODULE)
125 #define ONENAND_MAP 0x20000000
127 /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
128 * Since the device is equipped with two DataRAMs, and two-plane NAND
129 * Flash memory array, these two component enables simultaneous program
130 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
131 * while Plane2 has only odd blocks such as block1, block3, block5.
132 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
135 static struct mtd_partition igep_flash_partitions
[] = {
139 .size
= 2 * (64*(2*2048))
143 .offset
= MTDPART_OFS_APPEND
,
144 .size
= 6 * (64*(2*2048)),
147 .name
= "Environment",
148 .offset
= MTDPART_OFS_APPEND
,
149 .size
= 2 * (64*(2*2048)),
153 .offset
= MTDPART_OFS_APPEND
,
154 .size
= 12 * (64*(2*2048)),
157 .name
= "File System",
158 .offset
= MTDPART_OFS_APPEND
,
159 .size
= MTDPART_SIZ_FULL
,
163 static inline u32
igep_get_sysboot_value(void)
165 return omap_ctrl_readl(OMAP343X_CONTROL_STATUS
) & IGEP_SYSBOOT_MASK
;
168 static void __init
igep_flash_init(void)
171 mux
= igep_get_sysboot_value();
173 if (mux
== IGEP_SYSBOOT_NAND
) {
174 pr_info("IGEP: initializing NAND memory device\n");
175 board_nand_init(igep_flash_partitions
,
176 ARRAY_SIZE(igep_flash_partitions
),
177 0, NAND_BUSWIDTH_16
, nand_default_timings
);
178 } else if (mux
== IGEP_SYSBOOT_ONENAND
) {
179 pr_info("IGEP: initializing OneNAND memory device\n");
180 board_onenand_init(igep_flash_partitions
,
181 ARRAY_SIZE(igep_flash_partitions
), 0);
183 pr_err("IGEP: Flash: unsupported sysboot sequence found\n");
188 static void __init
igep_flash_init(void) {}
191 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
193 #include <linux/smsc911x.h>
194 #include "gpmc-smsc911x.h"
196 static struct omap_smsc911x_platform_data smsc911x_cfg
= {
197 .cs
= IGEP2_SMSC911X_CS
,
198 .gpio_irq
= IGEP2_SMSC911X_GPIO
,
199 .gpio_reset
= -EINVAL
,
200 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
203 static inline void __init
igep2_init_smsc911x(void)
205 gpmc_smsc911x_init(&smsc911x_cfg
);
209 static inline void __init
igep2_init_smsc911x(void) { }
212 static struct regulator_consumer_supply igep_vmmc1_supply
[] = {
213 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
216 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
217 static struct regulator_init_data igep_vmmc1
= {
221 .valid_modes_mask
= REGULATOR_MODE_NORMAL
222 | REGULATOR_MODE_STANDBY
,
223 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
224 | REGULATOR_CHANGE_MODE
225 | REGULATOR_CHANGE_STATUS
,
227 .num_consumer_supplies
= ARRAY_SIZE(igep_vmmc1_supply
),
228 .consumer_supplies
= igep_vmmc1_supply
,
231 static struct regulator_consumer_supply igep_vio_supply
[] = {
232 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
235 static struct regulator_init_data igep_vio
= {
240 .valid_modes_mask
= REGULATOR_MODE_NORMAL
241 | REGULATOR_MODE_STANDBY
,
242 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
243 | REGULATOR_CHANGE_MODE
244 | REGULATOR_CHANGE_STATUS
,
246 .num_consumer_supplies
= ARRAY_SIZE(igep_vio_supply
),
247 .consumer_supplies
= igep_vio_supply
,
250 static struct regulator_consumer_supply igep_vmmc2_supply
[] = {
251 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
254 static struct regulator_init_data igep_vmmc2
= {
256 .valid_modes_mask
= REGULATOR_MODE_NORMAL
,
259 .num_consumer_supplies
= ARRAY_SIZE(igep_vmmc2_supply
),
260 .consumer_supplies
= igep_vmmc2_supply
,
263 static struct fixed_voltage_config igep_vwlan
= {
264 .supply_name
= "vwlan",
265 .microvolts
= 3300000,
267 .enabled_at_boot
= 1,
268 .init_data
= &igep_vmmc2
,
271 static struct platform_device igep_vwlan_device
= {
272 .name
= "reg-fixed-voltage",
275 .platform_data
= &igep_vwlan
,
279 static struct omap2_hsmmc_info mmc
[] = {
282 .caps
= MMC_CAP_4_BIT_DATA
,
287 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
290 .caps
= MMC_CAP_4_BIT_DATA
,
298 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
299 #include <linux/leds.h>
301 static struct gpio_led igep_gpio_leds
[] = {
303 .name
= "gpio-led:red:d0",
304 .default_trigger
= "default-off"
307 .name
= "gpio-led:green:d0",
308 .default_trigger
= "default-off",
311 .name
= "gpio-led:red:d1",
312 .default_trigger
= "default-off",
315 .name
= "gpio-led:green:d1",
316 .default_trigger
= "heartbeat",
317 .gpio
= -EINVAL
, /* gets replaced */
322 static struct gpio_led_platform_data igep_led_pdata
= {
323 .leds
= igep_gpio_leds
,
324 .num_leds
= ARRAY_SIZE(igep_gpio_leds
),
327 static struct platform_device igep_led_device
= {
331 .platform_data
= &igep_led_pdata
,
335 static void __init
igep_leds_init(void)
337 if (machine_is_igep0020()) {
338 igep_gpio_leds
[0].gpio
= IGEP2_GPIO_LED0_RED
;
339 igep_gpio_leds
[1].gpio
= IGEP2_GPIO_LED0_GREEN
;
340 igep_gpio_leds
[2].gpio
= IGEP2_GPIO_LED1_RED
;
342 igep_gpio_leds
[0].gpio
= IGEP3_GPIO_LED0_RED
;
343 igep_gpio_leds
[1].gpio
= IGEP3_GPIO_LED0_GREEN
;
344 igep_gpio_leds
[2].gpio
= IGEP3_GPIO_LED1_RED
;
347 platform_device_register(&igep_led_device
);
351 static struct gpio igep_gpio_leds
[] __initdata
= {
352 { -EINVAL
, GPIOF_OUT_INIT_LOW
, "gpio-led:red:d0" },
353 { -EINVAL
, GPIOF_OUT_INIT_LOW
, "gpio-led:green:d0" },
354 { -EINVAL
, GPIOF_OUT_INIT_LOW
, "gpio-led:red:d1" },
357 static inline void igep_leds_init(void)
361 if (machine_is_igep0020()) {
362 igep_gpio_leds
[0].gpio
= IGEP2_GPIO_LED0_RED
;
363 igep_gpio_leds
[1].gpio
= IGEP2_GPIO_LED0_GREEN
;
364 igep_gpio_leds
[2].gpio
= IGEP2_GPIO_LED1_RED
;
366 igep_gpio_leds
[0].gpio
= IGEP3_GPIO_LED0_RED
;
367 igep_gpio_leds
[1].gpio
= IGEP3_GPIO_LED0_GREEN
;
368 igep_gpio_leds
[2].gpio
= IGEP3_GPIO_LED1_RED
;
371 if (gpio_request_array(igep_gpio_leds
, ARRAY_SIZE(igep_gpio_leds
))) {
372 pr_warning("IGEP v2: Could not obtain leds gpios\n");
376 for (i
= 0; i
< ARRAY_SIZE(igep_gpio_leds
); i
++)
377 gpio_export(igep_gpio_leds
[i
].gpio
, 0);
381 static struct gpio igep2_twl_gpios
[] = {
382 { -EINVAL
, GPIOF_IN
, "GPIO_EHCI_NOC" },
383 { -EINVAL
, GPIOF_OUT_INIT_LOW
, "GPIO_USBH_CPEN" },
386 static int igep_twl_gpio_setup(struct device
*dev
,
387 unsigned gpio
, unsigned ngpio
)
391 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
392 mmc
[0].gpio_cd
= gpio
+ 0;
393 omap_hsmmc_late_init(mmc
);
395 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
396 #if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
397 ret
= gpio_request_one(gpio
+ TWL4030_GPIO_MAX
+ 1, GPIOF_OUT_INIT_HIGH
,
398 "gpio-led:green:d1");
400 gpio_export(gpio
+ TWL4030_GPIO_MAX
+ 1, 0);
402 pr_warning("IGEP: Could not obtain gpio GPIO_LED1_GREEN\n");
404 igep_gpio_leds
[3].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
407 if (machine_is_igep0030())
411 * REVISIT: need ehci-omap hooks for external VBUS
412 * power switch and overcurrent detect
414 igep2_twl_gpios
[0].gpio
= gpio
+ 1;
416 /* TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN (out, active low) */
417 igep2_twl_gpios
[1].gpio
= gpio
+ TWL4030_GPIO_MAX
;
419 ret
= gpio_request_array(igep2_twl_gpios
, ARRAY_SIZE(igep2_twl_gpios
));
421 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
426 static struct twl4030_gpio_platform_data igep_twl4030_gpio_pdata
= {
428 .setup
= igep_twl_gpio_setup
,
431 static struct tfp410_platform_data dvi_panel
= {
433 .power_down_gpio
= IGEP2_GPIO_DVI_PUP
,
436 static struct omap_dss_device igep2_dvi_device
= {
437 .type
= OMAP_DISPLAY_TYPE_DPI
,
439 .driver_name
= "tfp410",
441 .phy
.dpi
.data_lines
= 24,
444 static struct omap_dss_device
*igep2_dss_devices
[] = {
448 static struct omap_dss_board_info igep2_dss_data
= {
449 .num_devices
= ARRAY_SIZE(igep2_dss_devices
),
450 .devices
= igep2_dss_devices
,
451 .default_device
= &igep2_dvi_device
,
454 static struct platform_device
*igep_devices
[] __initdata
= {
458 static int igep2_keymap
[] = {
460 KEY(0, 1, KEY_RIGHT
),
467 KEY(2, 0, KEY_ENTER
),
477 static struct matrix_keymap_data igep2_keymap_data
= {
478 .keymap
= igep2_keymap
,
479 .keymap_size
= ARRAY_SIZE(igep2_keymap
),
482 static struct twl4030_keypad_data igep2_keypad_pdata
= {
483 .keymap_data
= &igep2_keymap_data
,
489 static struct twl4030_platform_data igep_twldata
= {
490 /* platform_data for children goes here */
491 .gpio
= &igep_twl4030_gpio_pdata
,
492 .vmmc1
= &igep_vmmc1
,
496 static struct i2c_board_info __initdata igep2_i2c3_boardinfo
[] = {
498 I2C_BOARD_INFO("eeprom", 0x50),
502 static void __init
igep_i2c_init(void)
506 omap3_pmic_get_config(&igep_twldata
, TWL_COMMON_PDATA_USB
,
507 TWL_COMMON_REGULATOR_VPLL2
);
508 igep_twldata
.vpll2
->constraints
.apply_uV
= true;
509 igep_twldata
.vpll2
->constraints
.name
= "VDVI";
511 if (machine_is_igep0020()) {
513 * Bus 3 is attached to the DVI port where devices like the
514 * pico DLP projector don't work reliably with 400kHz
516 ret
= omap_register_i2c_bus(3, 100, igep2_i2c3_boardinfo
,
517 ARRAY_SIZE(igep2_i2c3_boardinfo
));
519 pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret
);
521 igep_twldata
.keypad
= &igep2_keypad_pdata
;
522 /* Get common pmic data */
523 omap3_pmic_get_config(&igep_twldata
, TWL_COMMON_PDATA_AUDIO
, 0);
526 omap3_pmic_init("twl4030", &igep_twldata
);
529 static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst
= {
530 .port_mode
[0] = OMAP_EHCI_PORT_MODE_PHY
,
531 .port_mode
[1] = OMAP_USBHS_PORT_MODE_UNUSED
,
532 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
,
535 .reset_gpio_port
[0] = IGEP2_GPIO_USBH_NRESET
,
536 .reset_gpio_port
[1] = -EINVAL
,
537 .reset_gpio_port
[2] = -EINVAL
,
540 static const struct usbhs_omap_board_data igep3_usbhs_bdata __initconst
= {
541 .port_mode
[0] = OMAP_USBHS_PORT_MODE_UNUSED
,
542 .port_mode
[1] = OMAP_EHCI_PORT_MODE_PHY
,
543 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
,
546 .reset_gpio_port
[0] = -EINVAL
,
547 .reset_gpio_port
[1] = IGEP3_GPIO_USBH_NRESET
,
548 .reset_gpio_port
[2] = -EINVAL
,
551 #ifdef CONFIG_OMAP_MUX
552 static struct omap_board_mux board_mux
[] __initdata
= {
553 /* SMSC9221 LAN Controller ETH IRQ (GPIO_176) */
554 OMAP3_MUX(MCSPI1_CS2
, OMAP_MUX_MODE4
| OMAP_PIN_INPUT
),
555 { .reg_offset
= OMAP_MUX_TERMINATOR
},
559 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
560 static struct gpio igep_wlan_bt_gpios
[] __initdata
= {
561 { -EINVAL
, GPIOF_OUT_INIT_HIGH
, "GPIO_WIFI_NPD" },
562 { -EINVAL
, GPIOF_OUT_INIT_HIGH
, "GPIO_WIFI_NRESET" },
563 { -EINVAL
, GPIOF_OUT_INIT_HIGH
, "GPIO_BT_NRESET" },
566 static void __init
igep_wlan_bt_init(void)
570 /* GPIO's for WLAN-BT combo depends on hardware revision */
571 if (hwrev
== IGEP2_BOARD_HWREV_B
) {
572 igep_wlan_bt_gpios
[0].gpio
= IGEP2_RB_GPIO_WIFI_NPD
;
573 igep_wlan_bt_gpios
[1].gpio
= IGEP2_RB_GPIO_WIFI_NRESET
;
574 igep_wlan_bt_gpios
[2].gpio
= IGEP2_RB_GPIO_BT_NRESET
;
575 } else if (hwrev
== IGEP2_BOARD_HWREV_C
|| machine_is_igep0030()) {
576 igep_wlan_bt_gpios
[0].gpio
= IGEP2_RC_GPIO_WIFI_NPD
;
577 igep_wlan_bt_gpios
[1].gpio
= IGEP2_RC_GPIO_WIFI_NRESET
;
578 igep_wlan_bt_gpios
[2].gpio
= IGEP2_RC_GPIO_BT_NRESET
;
582 /* Make sure that the GPIO pins are muxed correctly */
583 omap_mux_init_gpio(igep_wlan_bt_gpios
[0].gpio
, OMAP_PIN_OUTPUT
);
584 omap_mux_init_gpio(igep_wlan_bt_gpios
[1].gpio
, OMAP_PIN_OUTPUT
);
585 omap_mux_init_gpio(igep_wlan_bt_gpios
[2].gpio
, OMAP_PIN_OUTPUT
);
587 err
= gpio_request_array(igep_wlan_bt_gpios
,
588 ARRAY_SIZE(igep_wlan_bt_gpios
));
590 pr_warning("IGEP2: Could not obtain WIFI/BT gpios\n");
594 gpio_export(igep_wlan_bt_gpios
[0].gpio
, 0);
595 gpio_export(igep_wlan_bt_gpios
[1].gpio
, 0);
596 gpio_export(igep_wlan_bt_gpios
[2].gpio
, 0);
598 gpio_set_value(igep_wlan_bt_gpios
[1].gpio
, 0);
600 gpio_set_value(igep_wlan_bt_gpios
[1].gpio
, 1);
604 static inline void __init
igep_wlan_bt_init(void) { }
607 static struct regulator_consumer_supply dummy_supplies
[] = {
608 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
609 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
612 static void __init
igep_init(void)
614 regulator_register_fixed(1, dummy_supplies
, ARRAY_SIZE(dummy_supplies
));
615 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
617 /* Get IGEP2 hardware revision */
618 igep2_get_revision();
620 omap_hsmmc_init(mmc
);
622 /* Register I2C busses and drivers */
624 platform_add_devices(igep_devices
, ARRAY_SIZE(igep_devices
));
626 omap_sdrc_init(m65kxxxxam_sdrc_params
,
627 m65kxxxxam_sdrc_params
);
632 omap_twl4030_audio_init("igep2");
635 * WLAN-BT combo module from MuRata which has a Marvell WLAN
636 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
640 if (machine_is_igep0020()) {
641 omap_display_init(&igep2_dss_data
);
642 igep2_init_smsc911x();
643 usbhs_init(&igep2_usbhs_bdata
);
645 usbhs_init(&igep3_usbhs_bdata
);
649 MACHINE_START(IGEP0020
, "IGEP v2 board")
650 .atag_offset
= 0x100,
651 .reserve
= omap_reserve
,
652 .map_io
= omap3_map_io
,
653 .init_early
= omap35xx_init_early
,
654 .init_irq
= omap3_init_irq
,
655 .handle_irq
= omap3_intc_handle_irq
,
656 .init_machine
= igep_init
,
657 .init_late
= omap35xx_init_late
,
658 .timer
= &omap3_timer
,
659 .restart
= omap3xxx_restart
,
662 MACHINE_START(IGEP0030
, "IGEP OMAP3 module")
663 .atag_offset
= 0x100,
664 .reserve
= omap_reserve
,
665 .map_io
= omap3_map_io
,
666 .init_early
= omap35xx_init_early
,
667 .init_irq
= omap3_init_irq
,
668 .handle_irq
= omap3_intc_handle_irq
,
669 .init_machine
= igep_init
,
670 .init_late
= omap35xx_init_late
,
671 .timer
= &omap3_timer
,
672 .restart
= omap3xxx_restart
,