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>
21 #include <linux/regulator/machine.h>
22 #include <linux/i2c/twl.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
27 #include <plat/board.h>
28 #include <plat/common.h>
29 #include <plat/gpmc.h>
31 #include <plat/display.h>
32 #include <plat/onenand.h>
36 #include "sdram-numonyx-m65kxxxxam.h"
38 #define IGEP2_SMSC911X_CS 5
39 #define IGEP2_SMSC911X_GPIO 176
40 #define IGEP2_GPIO_USBH_NRESET 24
41 #define IGEP2_GPIO_LED0_GREEN 26
42 #define IGEP2_GPIO_LED0_RED 27
43 #define IGEP2_GPIO_LED1_RED 28
44 #define IGEP2_GPIO_DVI_PUP 170
45 #define IGEP2_GPIO_WIFI_NPD 94
46 #define IGEP2_GPIO_WIFI_NRESET 95
48 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
49 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
51 #define ONENAND_MAP 0x20000000
53 /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
54 * Since the device is equipped with two DataRAMs, and two-plane NAND
55 * Flash memory array, these two component enables simultaneous program
56 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
57 * while Plane2 has only odd blocks such as block1, block3, block5.
58 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
61 static struct mtd_partition igep2_onenand_partitions[] = {
65 .size = 2 * (64*(2*2048))
69 .offset = MTDPART_OFS_APPEND,
70 .size = 6 * (64*(2*2048)),
73 .name = "Environment",
74 .offset = MTDPART_OFS_APPEND,
75 .size = 2 * (64*(2*2048)),
79 .offset = MTDPART_OFS_APPEND,
80 .size = 12 * (64*(2*2048)),
83 .name = "File System",
84 .offset = MTDPART_OFS_APPEND,
85 .size = MTDPART_SIZ_FULL,
89 static int igep2_onenand_setup(void __iomem *onenand_base, int freq)
91 /* nothing is required to be setup for onenand as of now */
95 static struct omap_onenand_platform_data igep2_onenand_data = {
96 .parts = igep2_onenand_partitions,
97 .nr_parts = ARRAY_SIZE(igep2_onenand_partitions),
98 .onenand_setup = igep2_onenand_setup,
99 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
102 static struct platform_device igep2_onenand_device = {
103 .name = "omap2-onenand",
106 .platform_data = &igep2_onenand_data,
110 void __init igep2_flash_init(void)
113 u8 onenandcs = GPMC_CS_NUM + 1;
115 while (cs < GPMC_CS_NUM) {
117 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
119 /* Check if NAND/oneNAND is configured */
120 if ((ret & 0xC00) == 0x800)
122 pr_err("IGEP v2: Unsupported NAND found\n");
124 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
125 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
131 if (onenandcs > GPMC_CS_NUM) {
132 pr_err("IGEP v2: Unable to find configuration in GPMC\n");
136 if (onenandcs < GPMC_CS_NUM) {
137 igep2_onenand_data.cs = onenandcs;
138 if (platform_device_register(&igep2_onenand_device) < 0)
139 pr_err("IGEP v2: Unable to register OneNAND device\n");
144 void __init igep2_flash_init(void) {}
147 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
149 #include <linux/smsc911x.h>
151 static struct smsc911x_platform_config igep2_smsc911x_config = {
152 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
153 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
154 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
155 .phy_interface = PHY_INTERFACE_MODE_MII,
158 static struct resource igep2_smsc911x_resources[] = {
160 .flags = IORESOURCE_MEM,
163 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
164 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
165 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
169 static struct platform_device igep2_smsc911x_device = {
172 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
173 .resource = igep2_smsc911x_resources,
175 .platform_data = &igep2_smsc911x_config,
179 static inline void __init igep2_init_smsc911x(void)
181 unsigned long cs_mem_base;
183 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
184 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
185 gpmc_cs_free(IGEP2_SMSC911X_CS);
189 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
190 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
192 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
193 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
194 gpio_export(IGEP2_SMSC911X_GPIO, 0);
196 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
200 platform_device_register(&igep2_smsc911x_device);
204 static inline void __init igep2_init_smsc911x(void) { }
207 static struct omap_board_config_kernel igep2_config[] __initdata = {
210 static struct regulator_consumer_supply igep2_vmmc1_supply = {
214 static struct regulator_consumer_supply igep2_vmmc2_supply = {
218 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
219 static struct regulator_init_data igep2_vmmc1 = {
223 .valid_modes_mask = REGULATOR_MODE_NORMAL
224 | REGULATOR_MODE_STANDBY,
225 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
226 | REGULATOR_CHANGE_MODE
227 | REGULATOR_CHANGE_STATUS,
229 .num_consumer_supplies = 1,
230 .consumer_supplies = &igep2_vmmc1_supply,
233 /* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
234 static struct regulator_init_data igep2_vmmc2 = {
238 .valid_modes_mask = REGULATOR_MODE_NORMAL
239 | REGULATOR_MODE_STANDBY,
240 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
241 | REGULATOR_CHANGE_MODE
242 | REGULATOR_CHANGE_STATUS,
244 .num_consumer_supplies = 1,
245 .consumer_supplies = &igep2_vmmc2_supply,
248 static struct omap2_hsmmc_info mmc[] = {
264 static int igep2_twl_gpio_setup(struct device *dev,
265 unsigned gpio, unsigned ngpio)
267 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
268 mmc[0].gpio_cd = gpio + 0;
269 omap2_hsmmc_init(mmc);
271 /* link regulators to MMC adapters ... we "know" the
272 * regulators will be set up only *after* we return.
274 igep2_vmmc1_supply.dev = mmc[0].dev;
275 igep2_vmmc2_supply.dev = mmc[1].dev;
280 static struct twl4030_gpio_platform_data igep2_gpio_data = {
281 .gpio_base = OMAP_MAX_GPIO_LINES,
282 .irq_base = TWL4030_GPIO_IRQ_BASE,
283 .irq_end = TWL4030_GPIO_IRQ_END,
285 .setup = igep2_twl_gpio_setup,
288 static struct twl4030_usb_data igep2_usb_data = {
289 .usb_mode = T2_USB_MODE_ULPI,
292 static int igep2_enable_dvi(struct omap_dss_device *dssdev)
294 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
299 static void igep2_disable_dvi(struct omap_dss_device *dssdev)
301 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
304 static struct omap_dss_device igep2_dvi_device = {
305 .type = OMAP_DISPLAY_TYPE_DPI,
307 .driver_name = "generic_panel",
308 .phy.dpi.data_lines = 24,
309 .platform_enable = igep2_enable_dvi,
310 .platform_disable = igep2_disable_dvi,
313 static struct omap_dss_device *igep2_dss_devices[] = {
317 static struct omap_dss_board_info igep2_dss_data = {
318 .num_devices = ARRAY_SIZE(igep2_dss_devices),
319 .devices = igep2_dss_devices,
320 .default_device = &igep2_dvi_device,
323 static struct platform_device igep2_dss_device = {
327 .platform_data = &igep2_dss_data,
331 static struct regulator_consumer_supply igep2_vpll2_supply = {
332 .supply = "vdds_dsi",
333 .dev = &igep2_dss_device.dev,
336 static struct regulator_init_data igep2_vpll2 = {
342 .valid_modes_mask = REGULATOR_MODE_NORMAL
343 | REGULATOR_MODE_STANDBY,
344 .valid_ops_mask = REGULATOR_CHANGE_MODE
345 | REGULATOR_CHANGE_STATUS,
347 .num_consumer_supplies = 1,
348 .consumer_supplies = &igep2_vpll2_supply,
351 static void __init igep2_display_init(void)
353 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
354 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
355 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
358 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
359 #include <linux/leds.h>
361 static struct gpio_led igep2_gpio_leds[] = {
364 .gpio = IGEP2_GPIO_LED0_RED,
367 .name = "led0:green",
368 .default_trigger = "heartbeat",
369 .gpio = IGEP2_GPIO_LED0_GREEN,
373 .gpio = IGEP2_GPIO_LED1_RED,
377 static struct gpio_led_platform_data igep2_led_pdata = {
378 .leds = igep2_gpio_leds,
379 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
382 static struct platform_device igep2_led_device = {
386 .platform_data = &igep2_led_pdata,
390 static void __init igep2_init_led(void)
392 platform_device_register(&igep2_led_device);
396 static inline void igep2_init_led(void) {}
399 static struct platform_device *igep2_devices[] __initdata = {
403 static void __init igep2_init_irq(void)
405 omap_board_config = igep2_config;
406 omap_board_config_size = ARRAY_SIZE(igep2_config);
407 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
412 static struct twl4030_codec_audio_data igep2_audio_data = {
413 .audio_mclk = 26000000,
416 static struct twl4030_codec_data igep2_codec_data = {
417 .audio_mclk = 26000000,
418 .audio = &igep2_audio_data,
421 static struct twl4030_platform_data igep2_twldata = {
422 .irq_base = TWL4030_IRQ_BASE,
423 .irq_end = TWL4030_IRQ_END,
425 /* platform_data for children goes here */
426 .usb = &igep2_usb_data,
427 .codec = &igep2_codec_data,
428 .gpio = &igep2_gpio_data,
429 .vmmc1 = &igep2_vmmc1,
430 .vmmc2 = &igep2_vmmc2,
431 .vpll2 = &igep2_vpll2,
435 static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
437 I2C_BOARD_INFO("twl4030", 0x48),
438 .flags = I2C_CLIENT_WAKE,
439 .irq = INT_34XX_SYS_NIRQ,
440 .platform_data = &igep2_twldata,
444 static int __init igep2_i2c_init(void)
446 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
447 ARRAY_SIZE(igep2_i2c_boardinfo));
448 /* Bus 3 is attached to the DVI port where devices like the pico DLP
449 * projector don't work reliably with 400kHz */
450 omap_register_i2c_bus(3, 100, NULL, 0);
454 static struct omap_musb_board_data musb_board_data = {
455 .interface_type = MUSB_INTERFACE_ULPI,
460 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
461 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
462 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
463 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
466 .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
467 .reset_gpio_port[1] = -EINVAL,
468 .reset_gpio_port[2] = -EINVAL,
471 #ifdef CONFIG_OMAP_MUX
472 static struct omap_board_mux board_mux[] __initdata = {
473 { .reg_offset = OMAP_MUX_TERMINATOR },
476 #define board_mux NULL
479 static void __init igep2_init(void)
481 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
483 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
485 usb_musb_init(&musb_board_data);
486 usb_ehci_init(&ehci_pdata);
490 igep2_display_init();
491 igep2_init_smsc911x();
493 /* GPIO userspace leds */
494 #if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
495 if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) &&
496 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
497 gpio_export(IGEP2_GPIO_LED0_RED, 0);
498 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
500 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
502 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
503 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
504 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
505 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
507 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
509 if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
510 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
511 gpio_export(IGEP2_GPIO_LED1_RED, 0);
512 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
514 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
517 /* GPIO W-LAN + Bluetooth combo module */
518 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
519 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
520 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
521 /* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
523 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
525 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
526 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
527 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
528 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
530 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
532 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
535 MACHINE_START(IGEP0020, "IGEP v2 board")
536 .boot_params = 0x80000100,
537 .map_io = omap3_map_io,
538 .reserve = omap_reserve,
539 .init_irq = igep2_init_irq,
540 .init_machine = igep2_init,
541 .timer = &omap_timer,