omap3: Enable DSS2 for IGEP v2 board
[deliverable/linux.git] / arch / arm / mach-omap2 / board-igep0020.c
CommitLineData
58e11162
EBS
1/*
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>
ebeb53e1 22#include <linux/i2c/twl.h>
58e11162
EBS
23
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>
58e11162 30#include <plat/usb.h>
691de27f 31#include <plat/display.h>
58e11162 32
ca5742bd 33#include "mux.h"
d02a900b 34#include "hsmmc.h"
58e11162
EBS
35
36#define IGEP2_SMSC911X_CS 5
37#define IGEP2_SMSC911X_GPIO 176
38#define IGEP2_GPIO_USBH_NRESET 24
39#define IGEP2_GPIO_LED0_RED 26
40#define IGEP2_GPIO_LED0_GREEN 27
41#define IGEP2_GPIO_LED1_RED 28
691de27f 42#define IGEP2_GPIO_DVI_PUP 170
58e11162
EBS
43
44#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
45
46#include <linux/smsc911x.h>
47
48static struct smsc911x_platform_config igep2_smsc911x_config = {
49 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
50 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
51 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
52 .phy_interface = PHY_INTERFACE_MODE_MII,
53};
54
55static struct resource igep2_smsc911x_resources[] = {
56 {
57 .flags = IORESOURCE_MEM,
58 },
59 {
60 .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
61 .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
62 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
63 },
64};
65
66static struct platform_device igep2_smsc911x_device = {
67 .name = "smsc911x",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
70 .resource = igep2_smsc911x_resources,
71 .dev = {
72 .platform_data = &igep2_smsc911x_config,
73 },
74};
75
76static inline void __init igep2_init_smsc911x(void)
77{
78 unsigned long cs_mem_base;
79
80 if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
81 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
82 gpmc_cs_free(IGEP2_SMSC911X_CS);
83 return;
84 }
85
86 igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
87 igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
88
89 if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
90 (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
91 gpio_export(IGEP2_SMSC911X_GPIO, 0);
92 } else {
93 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
94 return;
95 }
96
97 platform_device_register(&igep2_smsc911x_device);
98}
99
100#else
101static inline void __init igep2_init_smsc911x(void) { }
102#endif
103
104static struct omap_board_config_kernel igep2_config[] __initdata = {
105};
106
107static struct regulator_consumer_supply igep2_vmmc1_supply = {
108 .supply = "vmmc",
109};
110
111/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
112static struct regulator_init_data igep2_vmmc1 = {
113 .constraints = {
114 .min_uV = 1850000,
115 .max_uV = 3150000,
116 .valid_modes_mask = REGULATOR_MODE_NORMAL
117 | REGULATOR_MODE_STANDBY,
118 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
119 | REGULATOR_CHANGE_MODE
120 | REGULATOR_CHANGE_STATUS,
121 },
122 .num_consumer_supplies = 1,
123 .consumer_supplies = &igep2_vmmc1_supply,
124};
125
68ff0423 126static struct omap2_hsmmc_info mmc[] = {
58e11162
EBS
127 {
128 .mmc = 1,
129 .wires = 4,
130 .gpio_cd = -EINVAL,
131 .gpio_wp = -EINVAL,
132 },
133 {
134 .mmc = 2,
135 .wires = 4,
136 .gpio_cd = -EINVAL,
137 .gpio_wp = -EINVAL,
138 },
139 {} /* Terminator */
140};
141
142static int igep2_twl_gpio_setup(struct device *dev,
143 unsigned gpio, unsigned ngpio)
144{
145 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
146 mmc[0].gpio_cd = gpio + 0;
68ff0423 147 omap2_hsmmc_init(mmc);
58e11162
EBS
148
149 /* link regulators to MMC adapters ... we "know" the
150 * regulators will be set up only *after* we return.
151 */
152 igep2_vmmc1_supply.dev = mmc[0].dev;
153
154 return 0;
155};
156
157static struct twl4030_gpio_platform_data igep2_gpio_data = {
158 .gpio_base = OMAP_MAX_GPIO_LINES,
159 .irq_base = TWL4030_GPIO_IRQ_BASE,
160 .irq_end = TWL4030_GPIO_IRQ_END,
161 .use_leds = false,
162 .setup = igep2_twl_gpio_setup,
163};
164
165static struct twl4030_usb_data igep2_usb_data = {
166 .usb_mode = T2_USB_MODE_ULPI,
167};
168
691de27f
EBS
169static int igep2_enable_dvi(struct omap_dss_device *dssdev)
170{
171 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
172
173 return 0;
174}
175
176static void igep2_disable_dvi(struct omap_dss_device *dssdev)
177{
178 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
179}
180
181static struct omap_dss_device igep2_dvi_device = {
182 .type = OMAP_DISPLAY_TYPE_DPI,
183 .name = "dvi",
184 .driver_name = "generic_panel",
185 .phy.dpi.data_lines = 24,
186 .platform_enable = igep2_enable_dvi,
187 .platform_disable = igep2_disable_dvi,
188};
189
190static struct omap_dss_device *igep2_dss_devices[] = {
191 &igep2_dvi_device
192};
193
194static struct omap_dss_board_info igep2_dss_data = {
195 .num_devices = ARRAY_SIZE(igep2_dss_devices),
196 .devices = igep2_dss_devices,
197 .default_device = &igep2_dvi_device,
198};
199
200static struct platform_device igep2_dss_device = {
201 .name = "omapdss",
202 .id = -1,
203 .dev = {
204 .platform_data = &igep2_dss_data,
205 },
206};
207
208static struct regulator_consumer_supply igep2_vpll2_supply = {
209 .supply = "vdds_dsi",
210 .dev = &igep2_dss_device.dev,
211};
212
213static struct regulator_init_data igep2_vpll2 = {
214 .constraints = {
215 .name = "VDVI",
216 .min_uV = 1800000,
217 .max_uV = 1800000,
218 .apply_uV = true,
219 .valid_modes_mask = REGULATOR_MODE_NORMAL
220 | REGULATOR_MODE_STANDBY,
221 .valid_ops_mask = REGULATOR_CHANGE_MODE
222 | REGULATOR_CHANGE_STATUS,
223 },
224 .num_consumer_supplies = 1,
225 .consumer_supplies = &igep2_vpll2_supply,
226};
227
228static void __init igep2_display_init(void)
229{
230 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
231 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
232 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
233}
234
235static struct platform_device *igep2_devices[] __initdata = {
236 &igep2_dss_device,
237};
238
58e11162
EBS
239static void __init igep2_init_irq(void)
240{
241 omap_board_config = igep2_config;
242 omap_board_config_size = ARRAY_SIZE(igep2_config);
243 omap2_init_common_hw(NULL, NULL);
244 omap_init_irq();
245 omap_gpio_init();
246}
247
7f5f23da
EBS
248static struct twl4030_codec_audio_data igep2_audio_data = {
249 .audio_mclk = 26000000,
250};
251
252static struct twl4030_codec_data igep2_codec_data = {
253 .audio_mclk = 26000000,
254 .audio = &igep2_audio_data,
255};
256
58e11162
EBS
257static struct twl4030_platform_data igep2_twldata = {
258 .irq_base = TWL4030_IRQ_BASE,
259 .irq_end = TWL4030_IRQ_END,
260
261 /* platform_data for children goes here */
262 .usb = &igep2_usb_data,
7f5f23da 263 .codec = &igep2_codec_data,
58e11162
EBS
264 .gpio = &igep2_gpio_data,
265 .vmmc1 = &igep2_vmmc1,
691de27f 266 .vpll2 = &igep2_vpll2,
58e11162
EBS
267
268};
269
270static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
271 {
272 I2C_BOARD_INFO("twl4030", 0x48),
273 .flags = I2C_CLIENT_WAKE,
274 .irq = INT_34XX_SYS_NIRQ,
275 .platform_data = &igep2_twldata,
276 },
277};
278
279static int __init igep2_i2c_init(void)
280{
281 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
282 ARRAY_SIZE(igep2_i2c_boardinfo));
283 /* Bus 3 is attached to the DVI port where devices like the pico DLP
284 * projector don't work reliably with 400kHz */
285 omap_register_i2c_bus(3, 100, NULL, 0);
286 return 0;
287}
288
d0885486
EBS
289static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
290 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
291 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
292 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
293
294 .phy_reset = true,
295 .reset_gpio_port[0] = -EINVAL,
296 .reset_gpio_port[1] = IGEP2_GPIO_USBH_NRESET,
297 .reset_gpio_port[2] = -EINVAL,
298};
299
ca5742bd
TL
300#ifdef CONFIG_OMAP_MUX
301static struct omap_board_mux board_mux[] __initdata = {
302 { .reg_offset = OMAP_MUX_TERMINATOR },
303};
304#else
305#define board_mux NULL
306#endif
307
58e11162
EBS
308static void __init igep2_init(void)
309{
ca5742bd 310 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
58e11162 311 igep2_i2c_init();
691de27f 312 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
58e11162
EBS
313 omap_serial_init();
314 usb_musb_init();
d0885486 315 usb_ehci_init(&ehci_pdata);
58e11162 316
691de27f 317 igep2_display_init();
58e11162
EBS
318 igep2_init_smsc911x();
319
320 /* GPIO userspace leds */
321 if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
322 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
323 gpio_export(IGEP2_GPIO_LED0_RED, 0);
324 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
325 } else
326 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
327
328 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
329 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
330 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
331 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
332 } else
333 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
334
335 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
336 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
337 gpio_export(IGEP2_GPIO_LED1_RED, 0);
338 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
339 } else
340 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
341}
342
343static void __init igep2_map_io(void)
344{
345 omap2_set_globals_343x();
6fbd55d0 346 omap34xx_map_common_io();
58e11162
EBS
347}
348
349MACHINE_START(IGEP0020, "IGEP v2 board")
350 .phys_io = 0x48000000,
351 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
352 .boot_params = 0x80000100,
353 .map_io = igep2_map_io,
354 .init_irq = igep2_init_irq,
355 .init_machine = igep2_init,
356 .timer = &omap_timer,
357MACHINE_END
This page took 0.051831 seconds and 5 git commands to generate.