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 <asm/mach-types.h>
28 #include <asm/mach/arch.h>
30 #include <plat/board.h>
31 #include <plat/common.h>
32 #include <plat/gpmc.h>
34 #include <plat/display.h>
35 #include <plat/panel-generic-dpi.h>
36 #include <plat/onenand.h>
40 #include "sdram-numonyx-m65kxxxxam.h"
42 #define IGEP2_SMSC911X_CS 5
43 #define IGEP2_SMSC911X_GPIO 176
44 #define IGEP2_GPIO_USBH_NRESET 24
45 #define IGEP2_GPIO_LED0_GREEN 26
46 #define IGEP2_GPIO_LED0_RED 27
47 #define IGEP2_GPIO_LED1_RED 28
48 #define IGEP2_GPIO_DVI_PUP 170
50 #define IGEP2_RB_GPIO_WIFI_NPD 94
51 #define IGEP2_RB_GPIO_WIFI_NRESET 95
52 #define IGEP2_RB_GPIO_BT_NRESET 137
53 #define IGEP2_RC_GPIO_WIFI_NPD 138
54 #define IGEP2_RC_GPIO_WIFI_NRESET 139
55 #define IGEP2_RC_GPIO_BT_NRESET 137
58 * IGEP2 Hardware Revision Table
60 * --------------------------------------------------------------------------
61 * | Id. | Hw Rev. | HW0 (28) | WIFI_NPD | WIFI_NRESET | BT_NRESET |
62 * --------------------------------------------------------------------------
63 * | 0 | B | high | gpio94 | gpio95 | - |
64 * | 0 | B/C (B-compatible) | high | gpio94 | gpio95 | gpio137 |
65 * | 1 | C | low | gpio138 | gpio139 | gpio137 |
66 * --------------------------------------------------------------------------
69 #define IGEP2_BOARD_HWREV_B 0
70 #define IGEP2_BOARD_HWREV_C 1
74 static void __init
igep2_get_revision(void)
78 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED
, OMAP_PIN_INPUT
);
80 if ((gpio_request(IGEP2_GPIO_LED1_RED
, "GPIO_HW0_REV") == 0) &&
81 (gpio_direction_input(IGEP2_GPIO_LED1_RED
) == 0)) {
82 ret
= gpio_get_value(IGEP2_GPIO_LED1_RED
);
84 pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
85 hwrev
= IGEP2_BOARD_HWREV_C
;
86 } else if (ret
== 1) {
87 pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
88 hwrev
= IGEP2_BOARD_HWREV_B
;
90 pr_err("IGEP2: Unknown Hardware Revision\n");
94 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
95 pr_err("IGEP2: Unknown Hardware Revision\n");
98 gpio_free(IGEP2_GPIO_LED1_RED
);
101 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
102 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
104 #define ONENAND_MAP 0x20000000
106 /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
107 * Since the device is equipped with two DataRAMs, and two-plane NAND
108 * Flash memory array, these two component enables simultaneous program
109 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
110 * while Plane2 has only odd blocks such as block1, block3, block5.
111 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
114 static struct mtd_partition igep2_onenand_partitions
[] = {
118 .size
= 2 * (64*(2*2048))
122 .offset
= MTDPART_OFS_APPEND
,
123 .size
= 6 * (64*(2*2048)),
126 .name
= "Environment",
127 .offset
= MTDPART_OFS_APPEND
,
128 .size
= 2 * (64*(2*2048)),
132 .offset
= MTDPART_OFS_APPEND
,
133 .size
= 12 * (64*(2*2048)),
136 .name
= "File System",
137 .offset
= MTDPART_OFS_APPEND
,
138 .size
= MTDPART_SIZ_FULL
,
142 static struct omap_onenand_platform_data igep2_onenand_data
= {
143 .parts
= igep2_onenand_partitions
,
144 .nr_parts
= ARRAY_SIZE(igep2_onenand_partitions
),
145 .dma_channel
= -1, /* disable DMA in OMAP OneNAND driver */
148 static struct platform_device igep2_onenand_device
= {
149 .name
= "omap2-onenand",
152 .platform_data
= &igep2_onenand_data
,
156 static void __init
igep2_flash_init(void)
159 u8 onenandcs
= GPMC_CS_NUM
+ 1;
161 for (cs
= 0; cs
< GPMC_CS_NUM
; cs
++) {
163 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
165 /* Check if NAND/oneNAND is configured */
166 if ((ret
& 0xC00) == 0x800)
168 pr_err("IGEP2: Unsupported NAND found\n");
170 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG7
);
171 if ((ret
& 0x3F) == (ONENAND_MAP
>> 24))
177 if (onenandcs
> GPMC_CS_NUM
) {
178 pr_err("IGEP2: Unable to find configuration in GPMC\n");
182 igep2_onenand_data
.cs
= onenandcs
;
184 if (platform_device_register(&igep2_onenand_device
) < 0)
185 pr_err("IGEP2: Unable to register OneNAND device\n");
189 static void __init
igep2_flash_init(void) {}
192 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
194 #include <linux/smsc911x.h>
196 static struct smsc911x_platform_config igep2_smsc911x_config
= {
197 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
198 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
199 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
200 .phy_interface
= PHY_INTERFACE_MODE_MII
,
203 static struct resource igep2_smsc911x_resources
[] = {
205 .flags
= IORESOURCE_MEM
,
208 .start
= OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO
),
209 .end
= OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO
),
210 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
214 static struct platform_device igep2_smsc911x_device
= {
217 .num_resources
= ARRAY_SIZE(igep2_smsc911x_resources
),
218 .resource
= igep2_smsc911x_resources
,
220 .platform_data
= &igep2_smsc911x_config
,
224 static inline void __init
igep2_init_smsc911x(void)
226 unsigned long cs_mem_base
;
228 if (gpmc_cs_request(IGEP2_SMSC911X_CS
, SZ_16M
, &cs_mem_base
) < 0) {
229 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
230 gpmc_cs_free(IGEP2_SMSC911X_CS
);
234 igep2_smsc911x_resources
[0].start
= cs_mem_base
+ 0x0;
235 igep2_smsc911x_resources
[0].end
= cs_mem_base
+ 0xff;
237 if ((gpio_request(IGEP2_SMSC911X_GPIO
, "SMSC911X IRQ") == 0) &&
238 (gpio_direction_input(IGEP2_SMSC911X_GPIO
) == 0)) {
239 gpio_export(IGEP2_SMSC911X_GPIO
, 0);
241 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
245 platform_device_register(&igep2_smsc911x_device
);
249 static inline void __init
igep2_init_smsc911x(void) { }
252 static struct regulator_consumer_supply igep2_vmmc1_supply
=
253 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0");
255 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
256 static struct regulator_init_data igep2_vmmc1
= {
260 .valid_modes_mask
= REGULATOR_MODE_NORMAL
261 | REGULATOR_MODE_STANDBY
,
262 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
263 | REGULATOR_CHANGE_MODE
264 | REGULATOR_CHANGE_STATUS
,
266 .num_consumer_supplies
= 1,
267 .consumer_supplies
= &igep2_vmmc1_supply
,
270 static struct regulator_consumer_supply igep2_vio_supply
=
271 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1");
273 static struct regulator_init_data igep2_vio
= {
278 .valid_modes_mask
= REGULATOR_MODE_NORMAL
279 | REGULATOR_MODE_STANDBY
,
280 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
281 | REGULATOR_CHANGE_MODE
282 | REGULATOR_CHANGE_STATUS
,
284 .num_consumer_supplies
= 1,
285 .consumer_supplies
= &igep2_vio_supply
,
288 static struct regulator_consumer_supply igep2_vmmc2_supply
=
289 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1");
291 static struct regulator_init_data igep2_vmmc2
= {
293 .valid_modes_mask
= REGULATOR_MODE_NORMAL
,
296 .num_consumer_supplies
= 1,
297 .consumer_supplies
= &igep2_vmmc2_supply
,
300 static struct fixed_voltage_config igep2_vwlan
= {
301 .supply_name
= "vwlan",
302 .microvolts
= 3300000,
304 .enabled_at_boot
= 1,
305 .init_data
= &igep2_vmmc2
,
308 static struct platform_device igep2_vwlan_device
= {
309 .name
= "reg-fixed-voltage",
312 .platform_data
= &igep2_vwlan
,
316 static struct omap2_hsmmc_info mmc
[] = {
319 .caps
= MMC_CAP_4_BIT_DATA
,
323 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
326 .caps
= MMC_CAP_4_BIT_DATA
,
334 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
335 #include <linux/leds.h>
337 static struct gpio_led igep2_gpio_leds
[] = {
339 .name
= "gpio-led:red:d0",
340 .gpio
= IGEP2_GPIO_LED0_RED
,
341 .default_trigger
= "default-off"
344 .name
= "gpio-led:green:d0",
345 .gpio
= IGEP2_GPIO_LED0_GREEN
,
346 .default_trigger
= "default-off",
349 .name
= "gpio-led:red:d1",
350 .gpio
= IGEP2_GPIO_LED1_RED
,
351 .default_trigger
= "default-off",
354 .name
= "gpio-led:green:d1",
355 .default_trigger
= "heartbeat",
356 .gpio
= -EINVAL
, /* gets replaced */
361 static struct gpio_led_platform_data igep2_led_pdata
= {
362 .leds
= igep2_gpio_leds
,
363 .num_leds
= ARRAY_SIZE(igep2_gpio_leds
),
366 static struct platform_device igep2_led_device
= {
370 .platform_data
= &igep2_led_pdata
,
374 static void __init
igep2_leds_init(void)
376 platform_device_register(&igep2_led_device
);
380 static inline void igep2_leds_init(void)
382 if ((gpio_request(IGEP2_GPIO_LED0_RED
, "gpio-led:red:d0") == 0) &&
383 (gpio_direction_output(IGEP2_GPIO_LED0_RED
, 0) == 0))
384 gpio_export(IGEP2_GPIO_LED0_RED
, 0);
386 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
388 if ((gpio_request(IGEP2_GPIO_LED0_GREEN
, "gpio-led:green:d0") == 0) &&
389 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN
, 0) == 0))
390 gpio_export(IGEP2_GPIO_LED0_GREEN
, 0);
392 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
394 if ((gpio_request(IGEP2_GPIO_LED1_RED
, "gpio-led:red:d1") == 0) &&
395 (gpio_direction_output(IGEP2_GPIO_LED1_RED
, 0) == 0))
396 gpio_export(IGEP2_GPIO_LED1_RED
, 0);
398 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
403 static int igep2_twl_gpio_setup(struct device
*dev
,
404 unsigned gpio
, unsigned ngpio
)
406 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
407 mmc
[0].gpio_cd
= gpio
+ 0;
408 omap2_hsmmc_init(mmc
);
411 * REVISIT: need ehci-omap hooks for external VBUS
412 * power switch and overcurrent detect
414 if ((gpio_request(gpio
+ 1, "GPIO_EHCI_NOC") < 0) ||
415 (gpio_direction_input(gpio
+ 1) < 0))
416 pr_err("IGEP2: Could not obtain gpio for EHCI NOC");
419 * TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN
422 if ((gpio_request(gpio
+ TWL4030_GPIO_MAX
, "GPIO_USBH_CPEN") < 0) ||
423 (gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 0) < 0))
424 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
426 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
427 #if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
428 if ((gpio_request(gpio
+TWL4030_GPIO_MAX
+1, "gpio-led:green:d1") == 0)
429 && (gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
+ 1, 1) == 0))
430 gpio_export(gpio
+ TWL4030_GPIO_MAX
+ 1, 0);
432 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_GREEN\n");
434 igep2_gpio_leds
[3].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
440 static struct twl4030_gpio_platform_data igep2_twl4030_gpio_pdata
= {
441 .gpio_base
= OMAP_MAX_GPIO_LINES
,
442 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
443 .irq_end
= TWL4030_GPIO_IRQ_END
,
445 .setup
= igep2_twl_gpio_setup
,
448 static struct twl4030_usb_data igep2_usb_data
= {
449 .usb_mode
= T2_USB_MODE_ULPI
,
452 static int igep2_enable_dvi(struct omap_dss_device
*dssdev
)
454 gpio_direction_output(IGEP2_GPIO_DVI_PUP
, 1);
459 static void igep2_disable_dvi(struct omap_dss_device
*dssdev
)
461 gpio_direction_output(IGEP2_GPIO_DVI_PUP
, 0);
464 static struct panel_generic_dpi_data dvi_panel
= {
466 .platform_enable
= igep2_enable_dvi
,
467 .platform_disable
= igep2_disable_dvi
,
470 static struct omap_dss_device igep2_dvi_device
= {
471 .type
= OMAP_DISPLAY_TYPE_DPI
,
473 .driver_name
= "generic_dpi_panel",
475 .phy
.dpi
.data_lines
= 24,
478 static struct omap_dss_device
*igep2_dss_devices
[] = {
482 static struct omap_dss_board_info igep2_dss_data
= {
483 .num_devices
= ARRAY_SIZE(igep2_dss_devices
),
484 .devices
= igep2_dss_devices
,
485 .default_device
= &igep2_dvi_device
,
488 static struct regulator_consumer_supply igep2_vpll2_supplies
[] = {
489 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
490 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
493 static struct regulator_init_data igep2_vpll2
= {
499 .valid_modes_mask
= REGULATOR_MODE_NORMAL
500 | REGULATOR_MODE_STANDBY
,
501 .valid_ops_mask
= REGULATOR_CHANGE_MODE
502 | REGULATOR_CHANGE_STATUS
,
504 .num_consumer_supplies
= ARRAY_SIZE(igep2_vpll2_supplies
),
505 .consumer_supplies
= igep2_vpll2_supplies
,
508 static void __init
igep2_display_init(void)
510 if (gpio_request(IGEP2_GPIO_DVI_PUP
, "GPIO_DVI_PUP") &&
511 gpio_direction_output(IGEP2_GPIO_DVI_PUP
, 1))
512 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
515 static struct platform_device
*igep2_devices
[] __initdata
= {
519 static void __init
igep2_init_early(void)
521 omap2_init_common_infrastructure();
522 omap2_init_common_devices(m65kxxxxam_sdrc_params
,
523 m65kxxxxam_sdrc_params
);
526 static struct twl4030_codec_audio_data igep2_audio_data
;
528 static struct twl4030_codec_data igep2_codec_data
= {
529 .audio_mclk
= 26000000,
530 .audio
= &igep2_audio_data
,
533 static int igep2_keymap
[] = {
535 KEY(0, 1, KEY_RIGHT
),
542 KEY(2, 0, KEY_ENTER
),
552 static struct matrix_keymap_data igep2_keymap_data
= {
553 .keymap
= igep2_keymap
,
554 .keymap_size
= ARRAY_SIZE(igep2_keymap
),
557 static struct twl4030_keypad_data igep2_keypad_pdata
= {
558 .keymap_data
= &igep2_keymap_data
,
564 static struct twl4030_platform_data igep2_twldata
= {
565 .irq_base
= TWL4030_IRQ_BASE
,
566 .irq_end
= TWL4030_IRQ_END
,
568 /* platform_data for children goes here */
569 .usb
= &igep2_usb_data
,
570 .codec
= &igep2_codec_data
,
571 .gpio
= &igep2_twl4030_gpio_pdata
,
572 .keypad
= &igep2_keypad_pdata
,
573 .vmmc1
= &igep2_vmmc1
,
574 .vpll2
= &igep2_vpll2
,
578 static struct i2c_board_info __initdata igep2_i2c1_boardinfo
[] = {
580 I2C_BOARD_INFO("twl4030", 0x48),
581 .flags
= I2C_CLIENT_WAKE
,
582 .irq
= INT_34XX_SYS_NIRQ
,
583 .platform_data
= &igep2_twldata
,
587 static struct i2c_board_info __initdata igep2_i2c3_boardinfo
[] = {
589 I2C_BOARD_INFO("eeprom", 0x50),
593 static void __init
igep2_i2c_init(void)
597 ret
= omap_register_i2c_bus(1, 2600, igep2_i2c1_boardinfo
,
598 ARRAY_SIZE(igep2_i2c1_boardinfo
));
600 pr_warning("IGEP2: Could not register I2C1 bus (%d)\n", ret
);
603 * Bus 3 is attached to the DVI port where devices like the pico DLP
604 * projector don't work reliably with 400kHz
606 ret
= omap_register_i2c_bus(3, 100, igep2_i2c3_boardinfo
,
607 ARRAY_SIZE(igep2_i2c3_boardinfo
));
609 pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret
);
612 static struct omap_musb_board_data musb_board_data
= {
613 .interface_type
= MUSB_INTERFACE_ULPI
,
618 static const struct usbhs_omap_board_data usbhs_bdata __initconst
= {
619 .port_mode
[0] = OMAP_EHCI_PORT_MODE_PHY
,
620 .port_mode
[1] = OMAP_USBHS_PORT_MODE_UNUSED
,
621 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
,
624 .reset_gpio_port
[0] = IGEP2_GPIO_USBH_NRESET
,
625 .reset_gpio_port
[1] = -EINVAL
,
626 .reset_gpio_port
[2] = -EINVAL
,
629 #ifdef CONFIG_OMAP_MUX
630 static struct omap_board_mux board_mux
[] __initdata
= {
631 { .reg_offset
= OMAP_MUX_TERMINATOR
},
635 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
637 static void __init
igep2_wlan_bt_init(void)
639 unsigned npd
, wreset
, btreset
;
641 /* GPIO's for WLAN-BT combo depends on hardware revision */
642 if (hwrev
== IGEP2_BOARD_HWREV_B
) {
643 npd
= IGEP2_RB_GPIO_WIFI_NPD
;
644 wreset
= IGEP2_RB_GPIO_WIFI_NRESET
;
645 btreset
= IGEP2_RB_GPIO_BT_NRESET
;
646 } else if (hwrev
== IGEP2_BOARD_HWREV_C
) {
647 npd
= IGEP2_RC_GPIO_WIFI_NPD
;
648 wreset
= IGEP2_RC_GPIO_WIFI_NRESET
;
649 btreset
= IGEP2_RC_GPIO_BT_NRESET
;
653 /* Set GPIO's for WLAN-BT combo module */
654 if ((gpio_request(npd
, "GPIO_WIFI_NPD") == 0) &&
655 (gpio_direction_output(npd
, 1) == 0)) {
658 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NPD\n");
660 if ((gpio_request(wreset
, "GPIO_WIFI_NRESET") == 0) &&
661 (gpio_direction_output(wreset
, 1) == 0)) {
662 gpio_export(wreset
, 0);
663 gpio_set_value(wreset
, 0);
665 gpio_set_value(wreset
, 1);
667 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NRESET\n");
669 if ((gpio_request(btreset
, "GPIO_BT_NRESET") == 0) &&
670 (gpio_direction_output(btreset
, 1) == 0)) {
671 gpio_export(btreset
, 0);
673 pr_warning("IGEP2: Could not obtain gpio GPIO_BT_NRESET\n");
676 static inline void __init
igep2_wlan_bt_init(void) { }
679 static void __init
igep2_init(void)
681 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
683 /* Get IGEP2 hardware revision */
684 igep2_get_revision();
685 /* Register I2C busses and drivers */
687 platform_add_devices(igep2_devices
, ARRAY_SIZE(igep2_devices
));
688 omap_display_init(&igep2_dss_data
);
690 usb_musb_init(&musb_board_data
);
691 usbhs_init(&usbhs_bdata
);
695 igep2_display_init();
696 igep2_init_smsc911x();
699 * WLAN-BT combo module from MuRata which has a Marvell WLAN
700 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
702 igep2_wlan_bt_init();
706 MACHINE_START(IGEP0020
, "IGEP v2 board")
707 .boot_params
= 0x80000100,
708 .reserve
= omap_reserve
,
709 .map_io
= omap3_map_io
,
710 .init_early
= igep2_init_early
,
711 .init_irq
= omap_init_irq
,
712 .init_machine
= igep2_init
,
713 .timer
= &omap_timer
,