blob: 0f24cb84ba5a524ff0256462d84be6cc2d6d9b0e [file] [log] [blame]
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -08001/*
2 * Copyright (C) 2009 Integration Software and Electronic Engineering.
3 *
4 * Modified from mach-omap2/board-generic.c
5 *
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.
9 */
10
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>
17#include <linux/io.h>
18#include <linux/gpio.h>
19#include <linux/interrupt.h>
Enric Balletbo i Serra18cbc7d2011-01-10 13:26:14 +000020#include <linux/input.h>
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080021
22#include <linux/regulator/machine.h>
Marc Zyngierda07c0c2010-12-20 18:48:16 -080023#include <linux/regulator/fixed.h>
Balaji T Kebeb53e2009-12-15 20:09:02 +053024#include <linux/i2c/twl.h>
Sukumar Ghorai3a638332010-09-15 14:49:23 +000025#include <linux/mmc/host.h>
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080026
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -070027#include <linux/mtd/nand.h>
28
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080029#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030032#include <video/omapdss.h>
Tomi Valkeinendac8eb52011-12-22 11:12:13 +020033#include <video/omap-panel-tfp410.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020034#include <linux/platform_data/mtd-onenand-omap2.h>
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080035
Tony Lindgren6d026432012-10-24 15:05:45 -070036#include "common.h"
37#include "gpmc.h"
Tony Lindgrenca5742b2009-12-11 16:16:32 -080038#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080039#include "hsmmc.h"
Enric Balletbo i Serra22f1baa2010-02-17 14:09:27 -080040#include "sdram-numonyx-m65kxxxxam.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030041#include "common-board-devices.h"
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -070042#include "board-flash.h"
43#include "control.h"
Afzal Mohammedb6ab13e2012-09-29 10:32:42 +053044#include "gpmc-onenand.h"
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080045
46#define IGEP2_SMSC911X_CS 5
47#define IGEP2_SMSC911X_GPIO 176
48#define IGEP2_GPIO_USBH_NRESET 24
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -070049#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
53
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
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080060
Mike Rapoport2a609972011-05-12 21:31:03 +000061#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
65
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -070066#define IGEP_SYSBOOT_MASK 0x1f
67#define IGEP_SYSBOOT_NAND 0x0f
68#define IGEP_SYSBOOT_ONENAND 0x10
69
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -070070/*
71 * IGEP2 Hardware Revision Table
72 *
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -070073 * --------------------------------------------------------------------------
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 * --------------------------------------------------------------------------
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -070080 */
81
82#define IGEP2_BOARD_HWREV_B 0
83#define IGEP2_BOARD_HWREV_C 1
Mike Rapoport2a609972011-05-12 21:31:03 +000084#define IGEP3_BOARD_HWREV 2
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -070085
86static u8 hwrev;
87
88static void __init igep2_get_revision(void)
89{
90 u8 ret;
91
Mike Rapoport2a609972011-05-12 21:31:03 +000092 if (machine_is_igep0030()) {
93 hwrev = IGEP3_BOARD_HWREV;
94 return;
95 }
96
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -070097 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT);
98
Igor Grinbergbc593f52011-05-03 18:22:09 +030099 if (gpio_request_one(IGEP2_GPIO_LED1_RED, GPIOF_IN, "GPIO_HW0_REV")) {
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -0700100 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
101 pr_err("IGEP2: Unknown Hardware Revision\n");
Igor Grinbergbc593f52011-05-03 18:22:09 +0300102 return;
103 }
104
105 ret = gpio_get_value(IGEP2_GPIO_LED1_RED);
106 if (ret == 0) {
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;
112 } else {
113 pr_err("IGEP2: Unknown Hardware Revision\n");
114 hwrev = -1;
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -0700115 }
116
117 gpio_free(IGEP2_GPIO_LED1_RED);
118}
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800119
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700120#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)
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800124
125#define ONENAND_MAP 0x20000000
126
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)
133 */
134
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700135static struct mtd_partition igep_flash_partitions[] = {
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800136 {
137 .name = "X-Loader",
138 .offset = 0,
139 .size = 2 * (64*(2*2048))
140 },
141 {
142 .name = "U-Boot",
143 .offset = MTDPART_OFS_APPEND,
144 .size = 6 * (64*(2*2048)),
145 },
146 {
147 .name = "Environment",
148 .offset = MTDPART_OFS_APPEND,
149 .size = 2 * (64*(2*2048)),
150 },
151 {
152 .name = "Kernel",
153 .offset = MTDPART_OFS_APPEND,
154 .size = 12 * (64*(2*2048)),
155 },
156 {
157 .name = "File System",
158 .offset = MTDPART_OFS_APPEND,
159 .size = MTDPART_SIZ_FULL,
160 },
161};
162
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700163static inline u32 igep_get_sysboot_value(void)
164{
165 return omap_ctrl_readl(OMAP343X_CONTROL_STATUS) & IGEP_SYSBOOT_MASK;
166}
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800167
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000168static void __init igep_flash_init(void)
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800169{
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700170 u32 mux;
171 mux = igep_get_sysboot_value();
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800172
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700173 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),
Afzal Mohammed2e618262012-02-29 18:11:56 +0530177 0, NAND_BUSWIDTH_16, nand_default_timings);
Javier Martinez Canillasa42cf2c2012-05-09 14:19:14 -0700178 } 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);
182 } else {
183 pr_err("IGEP: Flash: unsupported sysboot sequence found\n");
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800184 }
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800185}
186
187#else
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000188static void __init igep_flash_init(void) {}
Enric Balletbo i Serracddb4832010-02-17 14:09:26 -0800189#endif
190
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800191#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
192
193#include <linux/smsc911x.h>
Tony Lindgrenac839b32012-09-20 11:41:46 -0700194#include "gpmc-smsc911x.h"
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800195
Mike Rapoport21b42732011-04-16 22:29:30 +0000196static 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,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800201};
202
203static inline void __init igep2_init_smsc911x(void)
204{
Mike Rapoport21b42732011-04-16 22:29:30 +0000205 gpmc_smsc911x_init(&smsc911x_cfg);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800206}
207
208#else
209static inline void __init igep2_init_smsc911x(void) { }
210#endif
211
Oleg Drokin786b01a2011-06-06 18:57:07 +0000212static struct regulator_consumer_supply igep_vmmc1_supply[] = {
213 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
214};
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800215
216/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000217static struct regulator_init_data igep_vmmc1 = {
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800218 .constraints = {
219 .min_uV = 1850000,
220 .max_uV = 3150000,
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,
226 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000227 .num_consumer_supplies = ARRAY_SIZE(igep_vmmc1_supply),
228 .consumer_supplies = igep_vmmc1_supply,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800229};
230
Oleg Drokin786b01a2011-06-06 18:57:07 +0000231static struct regulator_consumer_supply igep_vio_supply[] = {
232 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
233};
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800234
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000235static struct regulator_init_data igep_vio = {
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800236 .constraints = {
237 .min_uV = 1800000,
238 .max_uV = 1800000,
239 .apply_uV = 1,
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,
245 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000246 .num_consumer_supplies = ARRAY_SIZE(igep_vio_supply),
247 .consumer_supplies = igep_vio_supply,
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800248};
249
Oleg Drokin786b01a2011-06-06 18:57:07 +0000250static struct regulator_consumer_supply igep_vmmc2_supply[] = {
251 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
252};
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800253
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000254static struct regulator_init_data igep_vmmc2 = {
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800255 .constraints = {
256 .valid_modes_mask = REGULATOR_MODE_NORMAL,
257 .always_on = 1,
258 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000259 .num_consumer_supplies = ARRAY_SIZE(igep_vmmc2_supply),
260 .consumer_supplies = igep_vmmc2_supply,
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800261};
262
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000263static struct fixed_voltage_config igep_vwlan = {
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800264 .supply_name = "vwlan",
265 .microvolts = 3300000,
266 .gpio = -EINVAL,
267 .enabled_at_boot = 1,
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000268 .init_data = &igep_vmmc2,
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800269};
270
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000271static struct platform_device igep_vwlan_device = {
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800272 .name = "reg-fixed-voltage",
273 .id = 0,
274 .dev = {
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000275 .platform_data = &igep_vwlan,
Marc Zyngierda07c0c2010-12-20 18:48:16 -0800276 },
277};
278
Adrian Hunter68ff0422010-02-15 10:03:34 -0800279static struct omap2_hsmmc_info mmc[] = {
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800280 {
281 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000282 .caps = MMC_CAP_4_BIT_DATA,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800283 .gpio_cd = -EINVAL,
284 .gpio_wp = -EINVAL,
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800285 .deferred = true,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800286 },
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700287#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800288 {
289 .mmc = 2,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000290 .caps = MMC_CAP_4_BIT_DATA,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800291 .gpio_cd = -EINVAL,
292 .gpio_wp = -EINVAL,
293 },
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700294#endif
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800295 {} /* Terminator */
296};
297
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700298#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
299#include <linux/leds.h>
300
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000301static struct gpio_led igep_gpio_leds[] = {
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700302 [0] = {
303 .name = "gpio-led:red:d0",
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700304 .default_trigger = "default-off"
305 },
306 [1] = {
307 .name = "gpio-led:green:d0",
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700308 .default_trigger = "default-off",
309 },
310 [2] = {
311 .name = "gpio-led:red:d1",
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700312 .default_trigger = "default-off",
313 },
314 [3] = {
315 .name = "gpio-led:green:d1",
316 .default_trigger = "heartbeat",
317 .gpio = -EINVAL, /* gets replaced */
Laurent Pinchart70e77762010-12-17 18:15:08 -0800318 .active_low = 1,
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700319 },
320};
321
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000322static struct gpio_led_platform_data igep_led_pdata = {
323 .leds = igep_gpio_leds,
324 .num_leds = ARRAY_SIZE(igep_gpio_leds),
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700325};
326
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000327static struct platform_device igep_led_device = {
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700328 .name = "leds-gpio",
329 .id = -1,
330 .dev = {
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000331 .platform_data = &igep_led_pdata,
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700332 },
333};
334
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000335static void __init igep_leds_init(void)
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700336{
Mike Rapoport2a609972011-05-12 21:31:03 +0000337 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;
341 } else {
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;
345 }
Mike Rapoport0d4ab9a2011-05-12 21:31:02 +0000346
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000347 platform_device_register(&igep_led_device);
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700348}
349
350#else
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000351static struct gpio igep_gpio_leds[] __initdata = {
Mike Rapoport2a609972011-05-12 21:31:03 +0000352 { -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" },
Igor Grinbergbc593f52011-05-03 18:22:09 +0300355};
356
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000357static inline void igep_leds_init(void)
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700358{
Mike Rapoport0d4ab9a2011-05-12 21:31:02 +0000359 int i;
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700360
Mike Rapoport2a609972011-05-12 21:31:03 +0000361 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;
365 } else {
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;
369 }
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700370
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000371 if (gpio_request_array(igep_gpio_leds, ARRAY_SIZE(igep_gpio_leds))) {
Igor Grinbergbc593f52011-05-03 18:22:09 +0300372 pr_warning("IGEP v2: Could not obtain leds gpios\n");
373 return;
374 }
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700375
Mike Rapoport0d4ab9a2011-05-12 21:31:02 +0000376 for (i = 0; i < ARRAY_SIZE(igep_gpio_leds); i++)
377 gpio_export(igep_gpio_leds[i].gpio, 0);
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700378}
379#endif
380
Igor Grinbergbc593f52011-05-03 18:22:09 +0300381static struct gpio igep2_twl_gpios[] = {
382 { -EINVAL, GPIOF_IN, "GPIO_EHCI_NOC" },
383 { -EINVAL, GPIOF_OUT_INIT_LOW, "GPIO_USBH_CPEN" },
384};
385
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000386static int igep_twl_gpio_setup(struct device *dev,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800387 unsigned gpio, unsigned ngpio)
388{
Igor Grinbergbc593f52011-05-03 18:22:09 +0300389 int ret;
390
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800391 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
392 mmc[0].gpio_cd = gpio + 0;
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800393 omap_hsmmc_late_init(mmc);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800394
Mike Rapoport0d4ab9a2011-05-12 21:31:02 +0000395 /* 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");
399 if (ret == 0)
400 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
401 else
402 pr_warning("IGEP: Could not obtain gpio GPIO_LED1_GREEN\n");
403#else
404 igep_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
405#endif
406
Mike Rapoport2a609972011-05-12 21:31:03 +0000407 if (machine_is_igep0030())
408 return 0;
409
Enric Balletbo i Serra72f381b2010-10-08 10:22:57 -0700410 /*
Enric Balletbo i Serra61e118d2010-10-08 10:22:19 -0700411 * REVISIT: need ehci-omap hooks for external VBUS
412 * power switch and overcurrent detect
413 */
Igor Grinbergbc593f52011-05-03 18:22:09 +0300414 igep2_twl_gpios[0].gpio = gpio + 1;
Enric Balletbo i Serra61e118d2010-10-08 10:22:19 -0700415
Igor Grinbergbc593f52011-05-03 18:22:09 +0300416 /* TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN (out, active low) */
417 igep2_twl_gpios[1].gpio = gpio + TWL4030_GPIO_MAX;
418
419 ret = gpio_request_array(igep2_twl_gpios, ARRAY_SIZE(igep2_twl_gpios));
420 if (ret < 0)
Enric Balletbo i Serra61e118d2010-10-08 10:22:19 -0700421 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
422
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800423 return 0;
424};
425
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000426static struct twl4030_gpio_platform_data igep_twl4030_gpio_pdata = {
Enric Balletbo i Serrabee15392010-10-08 10:22:28 -0700427 .use_leds = true,
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000428 .setup = igep_twl_gpio_setup,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800429};
430
Tomi Valkeinen2e6f2ee2012-03-05 14:29:28 +0200431static struct tfp410_platform_data dvi_panel = {
Tomi Valkeinene813a552012-02-17 13:30:27 +0200432 .i2c_bus_num = 3,
433 .power_down_gpio = IGEP2_GPIO_DVI_PUP,
Bryan Wu89747c92010-11-17 13:34:34 +0000434};
435
Enric Balletbo i Serra691de272010-02-17 14:09:26 -0800436static struct omap_dss_device igep2_dvi_device = {
437 .type = OMAP_DISPLAY_TYPE_DPI,
438 .name = "dvi",
Tomi Valkeinen2e6f2ee2012-03-05 14:29:28 +0200439 .driver_name = "tfp410",
Bryan Wu89747c92010-11-17 13:34:34 +0000440 .data = &dvi_panel,
Enric Balletbo i Serra691de272010-02-17 14:09:26 -0800441 .phy.dpi.data_lines = 24,
Enric Balletbo i Serra691de272010-02-17 14:09:26 -0800442};
443
444static struct omap_dss_device *igep2_dss_devices[] = {
445 &igep2_dvi_device
446};
447
448static 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,
452};
453
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000454static struct platform_device *igep_devices[] __initdata = {
455 &igep_vwlan_device,
Enric Balletbo i Serra691de272010-02-17 14:09:26 -0800456};
457
Enric Balletbo i Serra18cbc7d2011-01-10 13:26:14 +0000458static int igep2_keymap[] = {
459 KEY(0, 0, KEY_LEFT),
460 KEY(0, 1, KEY_RIGHT),
461 KEY(0, 2, KEY_A),
462 KEY(0, 3, KEY_B),
463 KEY(1, 0, KEY_DOWN),
464 KEY(1, 1, KEY_UP),
465 KEY(1, 2, KEY_E),
466 KEY(1, 3, KEY_F),
467 KEY(2, 0, KEY_ENTER),
468 KEY(2, 1, KEY_I),
469 KEY(2, 2, KEY_J),
470 KEY(2, 3, KEY_K),
471 KEY(3, 0, KEY_M),
472 KEY(3, 1, KEY_N),
473 KEY(3, 2, KEY_O),
474 KEY(3, 3, KEY_P)
475};
476
477static struct matrix_keymap_data igep2_keymap_data = {
478 .keymap = igep2_keymap,
479 .keymap_size = ARRAY_SIZE(igep2_keymap),
480};
481
482static struct twl4030_keypad_data igep2_keypad_pdata = {
483 .keymap_data = &igep2_keymap_data,
484 .rows = 4,
485 .cols = 4,
486 .rep = 1,
487};
488
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000489static struct twl4030_platform_data igep_twldata = {
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800490 /* platform_data for children goes here */
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000491 .gpio = &igep_twl4030_gpio_pdata,
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000492 .vmmc1 = &igep_vmmc1,
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000493 .vio = &igep_vio,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800494};
495
Enric Balletbo i Serra91d139c2010-10-08 10:22:51 -0700496static struct i2c_board_info __initdata igep2_i2c3_boardinfo[] = {
497 {
498 I2C_BOARD_INFO("eeprom", 0x50),
499 },
500};
501
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000502static void __init igep_i2c_init(void)
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800503{
Enric Balletbo i Serra91d139c2010-10-08 10:22:51 -0700504 int ret;
505
Laurent Pinchartb2f44dc2012-05-09 08:10:42 -0700506 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";
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300510
Mike Rapoport2a609972011-05-12 21:31:03 +0000511 if (machine_is_igep0020()) {
512 /*
513 * Bus 3 is attached to the DVI port where devices like the
514 * pico DLP projector don't work reliably with 400kHz
515 */
516 ret = omap_register_i2c_bus(3, 100, igep2_i2c3_boardinfo,
517 ARRAY_SIZE(igep2_i2c3_boardinfo));
518 if (ret)
519 pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret);
Enric Balletbo i Serra91d139c2010-10-08 10:22:51 -0700520
Mike Rapoport2a609972011-05-12 21:31:03 +0000521 igep_twldata.keypad = &igep2_keypad_pdata;
Peter Ujfalusib252b0e2011-06-07 11:38:24 +0300522 /* Get common pmic data */
Laurent Pinchartb2f44dc2012-05-09 08:10:42 -0700523 omap3_pmic_get_config(&igep_twldata, TWL_COMMON_PDATA_AUDIO, 0);
Mike Rapoport2a609972011-05-12 21:31:03 +0000524 }
Mike Rapoport0d4ab9a2011-05-12 21:31:02 +0000525
526 omap3_pmic_init("twl4030", &igep_twldata);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800527}
528
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000529static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst = {
Keshava Munegowda181b2502011-03-01 20:08:16 +0530530 .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,
Enric Balletbo i Serrad08854862010-02-17 14:09:26 -0800533
534 .phy_reset = true,
Enric Balletbo i Serraf6b74532010-03-01 15:02:36 +0000535 .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
536 .reset_gpio_port[1] = -EINVAL,
Enric Balletbo i Serrad08854862010-02-17 14:09:26 -0800537 .reset_gpio_port[2] = -EINVAL,
538};
539
Mike Rapoport2a609972011-05-12 21:31:03 +0000540static 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,
544
545 .phy_reset = true,
546 .reset_gpio_port[0] = -EINVAL,
547 .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
548 .reset_gpio_port[2] = -EINVAL,
549};
550
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800551#ifdef CONFIG_OMAP_MUX
552static struct omap_board_mux board_mux[] __initdata = {
Javier Martinez Canillasa71eb612012-07-10 03:57:32 +0200553 /* SMSC9221 LAN Controller ETH IRQ (GPIO_176) */
554 OMAP3_MUX(MCSPI1_CS2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800555 { .reg_offset = OMAP_MUX_TERMINATOR },
556};
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800557#endif
558
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700559#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000560static struct gpio igep_wlan_bt_gpios[] __initdata = {
Igor Grinbergbc593f52011-05-03 18:22:09 +0300561 { -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" },
564};
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700565
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000566static void __init igep_wlan_bt_init(void)
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700567{
Igor Grinbergbc593f52011-05-03 18:22:09 +0300568 int err;
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700569
570 /* GPIO's for WLAN-BT combo depends on hardware revision */
571 if (hwrev == IGEP2_BOARD_HWREV_B) {
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000572 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;
Mike Rapoport2a609972011-05-12 21:31:03 +0000575 } else if (hwrev == IGEP2_BOARD_HWREV_C || machine_is_igep0030()) {
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000576 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;
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700579 } else
580 return;
581
Anders Hedlundcbf6bae2012-10-29 20:25:42 +0100582 /* 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);
586
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000587 err = gpio_request_array(igep_wlan_bt_gpios,
588 ARRAY_SIZE(igep_wlan_bt_gpios));
Igor Grinbergbc593f52011-05-03 18:22:09 +0300589 if (err) {
590 pr_warning("IGEP2: Could not obtain WIFI/BT gpios\n");
591 return;
592 }
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700593
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000594 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);
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700597
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000598 gpio_set_value(igep_wlan_bt_gpios[1].gpio, 0);
Igor Grinbergbc593f52011-05-03 18:22:09 +0300599 udelay(10);
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000600 gpio_set_value(igep_wlan_bt_gpios[1].gpio, 1);
Igor Grinbergbc593f52011-05-03 18:22:09 +0300601
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700602}
603#else
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000604static inline void __init igep_wlan_bt_init(void) { }
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700605#endif
606
Russ Dill5b3689f2012-03-23 02:21:37 -0700607static struct regulator_consumer_supply dummy_supplies[] = {
608 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
609 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
610};
611
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000612static void __init igep_init(void)
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800613{
Enrico Butera1a219322012-05-09 11:27:59 +0200614 regulator_register_fixed(1, dummy_supplies, ARRAY_SIZE(dummy_supplies));
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800615 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Enric Balletbo i Serra3f8c48d2010-10-08 10:22:35 -0700616
617 /* Get IGEP2 hardware revision */
618 igep2_get_revision();
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800619
620 omap_hsmmc_init(mmc);
621
Enric Balletbo i Serra91d139c2010-10-08 10:22:51 -0700622 /* Register I2C busses and drivers */
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000623 igep_i2c_init();
624 platform_add_devices(igep_devices, ARRAY_SIZE(igep_devices));
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800625 omap_serial_init();
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700626 omap_sdrc_init(m65kxxxxam_sdrc_params,
627 m65kxxxxam_sdrc_params);
Mike Rapoport9e186302011-04-27 11:56:12 +0300628 usb_musb_init(NULL);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800629
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000630 igep_flash_init();
631 igep_leds_init();
Peter Ujfalusiac51c902012-08-14 12:07:58 +0300632 omap_twl4030_audio_init("igep2");
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800633
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700634 /*
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300635 * WLAN-BT combo module from MuRata which has a Marvell WLAN
Enric Balletbo i Serra5a9fcc92010-10-08 10:22:43 -0700636 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
637 */
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000638 igep_wlan_bt_init();
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800639
Mike Rapoport2a609972011-05-12 21:31:03 +0000640 if (machine_is_igep0020()) {
641 omap_display_init(&igep2_dss_data);
Mike Rapoport2a609972011-05-12 21:31:03 +0000642 igep2_init_smsc911x();
643 usbhs_init(&igep2_usbhs_bdata);
644 } else {
645 usbhs_init(&igep3_usbhs_bdata);
646 }
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800647}
648
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800649MACHINE_START(IGEP0020, "IGEP v2 board")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400650 .atag_offset = 0x100,
Russell King71ee7da2010-05-23 10:18:16 +0100651 .reserve = omap_reserve,
Russell King - ARM Linux3dc3bad2011-02-14 15:40:20 -0800652 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700653 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700654 .init_irq = omap3_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100655 .handle_irq = omap3_intc_handle_irq,
Mike Rapoportfdfb03b2011-05-12 21:31:01 +0000656 .init_machine = igep_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800657 .init_late = omap35xx_init_late,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700658 .timer = &omap3_timer,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600659 .restart = omap3xxx_restart,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800660MACHINE_END
Mike Rapoport2a609972011-05-12 21:31:03 +0000661
662MACHINE_START(IGEP0030, "IGEP OMAP3 module")
Nicolas Pitre5e52b432011-07-05 22:38:15 -0400663 .atag_offset = 0x100,
Mike Rapoport2a609972011-05-12 21:31:03 +0000664 .reserve = omap_reserve,
665 .map_io = omap3_map_io,
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700666 .init_early = omap35xx_init_early,
Tony Lindgren741e3a82011-05-17 03:51:26 -0700667 .init_irq = omap3_init_irq,
Marc Zyngier6b2f55d2011-09-06 10:23:45 +0100668 .handle_irq = omap3_intc_handle_irq,
Mike Rapoport2a609972011-05-12 21:31:03 +0000669 .init_machine = igep_init,
Shawn Guobbd707a2012-04-26 16:06:50 +0800670 .init_late = omap35xx_init_late,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700671 .timer = &omap3_timer,
Paul Walmsley187e3e02012-10-29 20:56:12 -0600672 .restart = omap3xxx_restart,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800673MACHINE_END