blob: f6102c7372724dadf8a710855238f3b27043bc8a [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>
20
21#include <linux/regulator/machine.h>
Balaji T Kebeb53e2009-12-15 20:09:02 +053022#include <linux/i2c/twl.h>
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080023
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26
27#include <plat/board.h>
28#include <plat/common.h>
29#include <plat/gpmc.h>
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080030#include <plat/usb.h>
31
Tony Lindgrenca5742b2009-12-11 16:16:32 -080032#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080033#include "hsmmc.h"
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -080034
35#define IGEP2_SMSC911X_CS 5
36#define IGEP2_SMSC911X_GPIO 176
37#define IGEP2_GPIO_USBH_NRESET 24
38#define IGEP2_GPIO_LED0_RED 26
39#define IGEP2_GPIO_LED0_GREEN 27
40#define IGEP2_GPIO_LED1_RED 28
41
42#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
43
44#include <linux/smsc911x.h>
45
46static struct smsc911x_platform_config igep2_smsc911x_config = {
47 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
48 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
49 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
50 .phy_interface = PHY_INTERFACE_MODE_MII,
51};
52
53static struct resource igep2_smsc911x_resources[] = {
54 {
55 .flags = IORESOURCE_MEM,
56 },
57 {
58 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
59 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
60 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
61 },
62};
63
64static struct platform_device igep2_smsc911x_device = {
65 .name = "smsc911x",
66 .id = 0,
67 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
68 .resource = igep2_smsc911x_resources,
69 .dev = {
70 .platform_data = &igep2_smsc911x_config,
71 },
72};
73
74static inline void __init igep2_init_smsc911x(void)
75{
76 unsigned long cs_mem_base;
77
78 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
79 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
80 gpmc_cs_free(IGEP2_SMSC911X_CS);
81 return;
82 }
83
84 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
85 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
86
87 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
88 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
89 gpio_export(IGEP2_SMSC911X_GPIO, 0);
90 } else {
91 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
92 return;
93 }
94
95 platform_device_register(&igep2_smsc911x_device);
96}
97
98#else
99static inline void __init igep2_init_smsc911x(void) { }
100#endif
101
102static struct omap_board_config_kernel igep2_config[] __initdata = {
103};
104
105static struct regulator_consumer_supply igep2_vmmc1_supply = {
106 .supply = "vmmc",
107};
108
109/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
110static struct regulator_init_data igep2_vmmc1 = {
111 .constraints = {
112 .min_uV = 1850000,
113 .max_uV = 3150000,
114 .valid_modes_mask = REGULATOR_MODE_NORMAL
115 | REGULATOR_MODE_STANDBY,
116 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
117 | REGULATOR_CHANGE_MODE
118 | REGULATOR_CHANGE_STATUS,
119 },
120 .num_consumer_supplies = 1,
121 .consumer_supplies = &igep2_vmmc1_supply,
122};
123
Adrian Hunter68ff0422010-02-15 10:03:34 -0800124static struct omap2_hsmmc_info mmc[] = {
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800125 {
126 .mmc = 1,
127 .wires = 4,
128 .gpio_cd = -EINVAL,
129 .gpio_wp = -EINVAL,
130 },
131 {
132 .mmc = 2,
133 .wires = 4,
134 .gpio_cd = -EINVAL,
135 .gpio_wp = -EINVAL,
136 },
137 {} /* Terminator */
138};
139
140static int igep2_twl_gpio_setup(struct device *dev,
141 unsigned gpio, unsigned ngpio)
142{
143 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
144 mmc[0].gpio_cd = gpio + 0;
Adrian Hunter68ff0422010-02-15 10:03:34 -0800145 omap2_hsmmc_init(mmc);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800146
147 /* link regulators to MMC adapters ... we "know" the
148 * regulators will be set up only *after* we return.
149 */
150 igep2_vmmc1_supply.dev = mmc[0].dev;
151
152 return 0;
153};
154
155static struct twl4030_gpio_platform_data igep2_gpio_data = {
156 .gpio_base = OMAP_MAX_GPIO_LINES,
157 .irq_base = TWL4030_GPIO_IRQ_BASE,
158 .irq_end = TWL4030_GPIO_IRQ_END,
159 .use_leds = false,
160 .setup = igep2_twl_gpio_setup,
161};
162
163static struct twl4030_usb_data igep2_usb_data = {
164 .usb_mode = T2_USB_MODE_ULPI,
165};
166
167static void __init igep2_init_irq(void)
168{
169 omap_board_config = igep2_config;
170 omap_board_config_size = ARRAY_SIZE(igep2_config);
171 omap2_init_common_hw(NULL, NULL);
172 omap_init_irq();
173 omap_gpio_init();
174}
175
Enric Balletbo i Serra7f5f23d2010-02-17 14:09:25 -0800176static struct twl4030_codec_audio_data igep2_audio_data = {
177 .audio_mclk = 26000000,
178};
179
180static struct twl4030_codec_data igep2_codec_data = {
181 .audio_mclk = 26000000,
182 .audio = &igep2_audio_data,
183};
184
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800185static struct twl4030_platform_data igep2_twldata = {
186 .irq_base = TWL4030_IRQ_BASE,
187 .irq_end = TWL4030_IRQ_END,
188
189 /* platform_data for children goes here */
190 .usb = &igep2_usb_data,
Enric Balletbo i Serra7f5f23d2010-02-17 14:09:25 -0800191 .codec = &igep2_codec_data,
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800192 .gpio = &igep2_gpio_data,
193 .vmmc1 = &igep2_vmmc1,
194
195};
196
197static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
198 {
199 I2C_BOARD_INFO("twl4030", 0x48),
200 .flags = I2C_CLIENT_WAKE,
201 .irq = INT_34XX_SYS_NIRQ,
202 .platform_data = &igep2_twldata,
203 },
204};
205
206static int __init igep2_i2c_init(void)
207{
208 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
209 ARRAY_SIZE(igep2_i2c_boardinfo));
210 /* Bus 3 is attached to the DVI port where devices like the pico DLP
211 * projector don't work reliably with 400kHz */
212 omap_register_i2c_bus(3, 100, NULL, 0);
213 return 0;
214}
215
Enric Balletbo i Serrad08854862010-02-17 14:09:26 -0800216static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
217 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
218 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
219 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
220
221 .phy_reset = true,
222 .reset_gpio_port[0] = -EINVAL,
223 .reset_gpio_port[1] = IGEP2_GPIO_USBH_NRESET,
224 .reset_gpio_port[2] = -EINVAL,
225};
226
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800227#ifdef CONFIG_OMAP_MUX
228static struct omap_board_mux board_mux[] __initdata = {
229 { .reg_offset = OMAP_MUX_TERMINATOR },
230};
231#else
232#define board_mux NULL
233#endif
234
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800235static void __init igep2_init(void)
236{
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800237 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800238 igep2_i2c_init();
239 omap_serial_init();
240 usb_musb_init();
Enric Balletbo i Serrad08854862010-02-17 14:09:26 -0800241 usb_ehci_init(&ehci_pdata);
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800242
243 igep2_init_smsc911x();
244
245 /* GPIO userspace leds */
246 if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
247 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
248 gpio_export(IGEP2_GPIO_LED0_RED, 0);
249 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
250 } else
251 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
252
253 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
254 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
255 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
256 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
257 } else
258 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
259
260 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
261 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
262 gpio_export(IGEP2_GPIO_LED1_RED, 0);
263 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
264 } else
265 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
266}
267
268static void __init igep2_map_io(void)
269{
270 omap2_set_globals_343x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800271 omap34xx_map_common_io();
Enric Balletbo i Serra58e11162009-11-18 18:41:07 -0800272}
273
274MACHINE_START(IGEP0020, "IGEP v2 board")
275 .phys_io = 0x48000000,
276 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
277 .boot_params = 0x80000100,
278 .map_io = igep2_map_io,
279 .init_irq = igep2_init_irq,
280 .init_machine = igep2_init,
281 .timer = &omap_timer,
282MACHINE_END