blob: d70b58002d2bc4b394473c2f468d4ac80d65576d [file] [log] [blame]
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -07001/*
2 * Board support file for OMAP4430 SDP.
3 *
4 * Copyright (C) 2009 Texas Instruments
5 *
6 * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
7 *
8 * Based on mach-omap2/board-3430sdp.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/gpio.h>
Maulik Mankadbce06682010-02-17 14:09:32 -080020#include <linux/usb/otg.h>
Abraham Arceb2aa5e52010-05-14 12:05:26 -070021#include <linux/spi/spi.h>
Balaji T K6e30a7d2010-05-12 08:27:30 +000022#include <linux/i2c/twl.h>
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -070023#include <linux/gpio_keys.h>
Balaji T K6e30a7d2010-05-12 08:27:30 +000024#include <linux/regulator/machine.h>
Hemanth V509b6d92010-08-02 13:18:04 +030025#include <linux/leds.h>
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -070026
27#include <mach/hardware.h>
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070028#include <mach/omap4-common.h>
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -070029#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
Tony Lindgrence491cf2009-10-20 09:40:47 -070033#include <plat/board.h>
34#include <plat/common.h>
35#include <plat/control.h>
Maulik Mankadbce06682010-02-17 14:09:32 -080036#include <plat/usb.h>
kishore kadiyala717c1fb2010-05-15 18:21:06 +000037#include <plat/mmc.h>
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070038
kishore kadiyala717c1fb2010-05-15 18:21:06 +000039#include "hsmmc.h"
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070040#include "timer-gp.h"
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -070041
Abraham Arceb2aa5e52010-05-14 12:05:26 -070042#define ETH_KS8851_IRQ 34
43#define ETH_KS8851_POWER_ON 48
44#define ETH_KS8851_QUART 138
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -070045#define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
46#define OMAP4_SFH7741_ENABLE_GPIO 188
Abraham Arceb2aa5e52010-05-14 12:05:26 -070047
Hemanth V509b6d92010-08-02 13:18:04 +030048static struct gpio_led sdp4430_gpio_leds[] = {
49 {
50 .name = "omap4:green:debug0",
51 .gpio = 61,
52 },
53 {
54 .name = "omap4:green:debug1",
55 .gpio = 30,
56 },
57 {
58 .name = "omap4:green:debug2",
59 .gpio = 7,
60 },
61 {
62 .name = "omap4:green:debug3",
63 .gpio = 8,
64 },
65 {
66 .name = "omap4:green:debug4",
67 .gpio = 50,
68 },
69 {
70 .name = "omap4:blue:user",
71 .gpio = 169,
72 },
73 {
74 .name = "omap4:red:user",
75 .gpio = 170,
76 },
77 {
78 .name = "omap4:green:user",
79 .gpio = 139,
80 },
81
82};
83
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -070084static struct gpio_keys_button sdp4430_gpio_keys[] = {
85 {
86 .desc = "Proximity Sensor",
87 .type = EV_SW,
88 .code = SW_FRONT_PROXIMITY,
89 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
90 .active_low = 0,
91 }
92};
93
Hemanth V509b6d92010-08-02 13:18:04 +030094static struct gpio_led_platform_data sdp4430_led_data = {
95 .leds = sdp4430_gpio_leds,
96 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
97};
98
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -070099static int omap_prox_activate(struct device *dev)
100{
101 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
102 return 0;
103}
104
105static void omap_prox_deactivate(struct device *dev)
106{
107 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
108}
109
110static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
111 .buttons = sdp4430_gpio_keys,
112 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
113 .enable = omap_prox_activate,
114 .disable = omap_prox_deactivate,
115};
116
117static struct platform_device sdp4430_gpio_keys_device = {
118 .name = "gpio-keys",
119 .id = -1,
120 .dev = {
121 .platform_data = &sdp4430_gpio_keys_data,
122 },
123};
124
Hemanth V509b6d92010-08-02 13:18:04 +0300125static struct platform_device sdp4430_leds_gpio = {
126 .name = "leds-gpio",
127 .id = -1,
128 .dev = {
129 .platform_data = &sdp4430_led_data,
130 },
131};
Abraham Arceb2aa5e52010-05-14 12:05:26 -0700132static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
133 {
134 .modalias = "ks8851",
135 .bus_num = 1,
136 .chip_select = 0,
137 .max_speed_hz = 24000000,
138 .irq = ETH_KS8851_IRQ,
139 },
140};
141
142static int omap_ethernet_init(void)
143{
144 int status;
145
146 /* Request of GPIO lines */
147
148 status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
149 if (status) {
150 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
151 return status;
152 }
153
154 status = gpio_request(ETH_KS8851_QUART, "quart");
155 if (status) {
156 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
157 goto error1;
158 }
159
160 status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
161 if (status) {
162 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
163 goto error2;
164 }
165
166 /* Configuration of requested GPIO lines */
167
168 status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
169 if (status) {
170 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
171 goto error3;
172 }
173
174 status = gpio_direction_output(ETH_KS8851_QUART, 1);
175 if (status) {
176 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
177 goto error3;
178 }
179
180 status = gpio_direction_input(ETH_KS8851_IRQ);
181 if (status) {
182 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
183 goto error3;
184 }
185
186 return 0;
187
188error3:
189 gpio_free(ETH_KS8851_IRQ);
190error2:
191 gpio_free(ETH_KS8851_QUART);
192error1:
193 gpio_free(ETH_KS8851_POWER_ON);
194 return status;
195}
196
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700197static struct platform_device sdp4430_lcd_device = {
198 .name = "sdp4430_lcd",
199 .id = -1,
200};
201
202static struct platform_device *sdp4430_devices[] __initdata = {
203 &sdp4430_lcd_device,
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -0700204 &sdp4430_gpio_keys_device,
Hemanth V509b6d92010-08-02 13:18:04 +0300205 &sdp4430_leds_gpio,
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700206};
207
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700208static struct omap_lcd_config sdp4430_lcd_config __initdata = {
209 .ctrl_name = "internal",
210};
211
212static struct omap_board_config_kernel sdp4430_config[] __initdata = {
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700213 { OMAP_TAG_LCD, &sdp4430_lcd_config },
214};
215
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700216static void __init omap_4430sdp_init_irq(void)
217{
Santosh Shilimkar5b7815b2009-10-22 14:48:14 -0700218 omap_board_config = sdp4430_config;
219 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
Jean Pihet58cda882009-07-24 19:43:25 -0600220 omap2_init_common_hw(NULL, NULL);
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700221#ifdef CONFIG_OMAP_32K_TIMER
222 omap2_gp_clockevent_set_gptimer(1);
223#endif
224 gic_init_irq();
225 omap_gpio_init();
226}
227
Maulik Mankadbce06682010-02-17 14:09:32 -0800228static struct omap_musb_board_data musb_board_data = {
229 .interface_type = MUSB_INTERFACE_UTMI,
230 .mode = MUSB_PERIPHERAL,
231 .power = 100,
232};
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000233
234static struct omap2_hsmmc_info mmc[] = {
235 {
236 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000237 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000238 .gpio_wp = -EINVAL,
239 },
240 {
241 .mmc = 2,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000242 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000243 .gpio_cd = -EINVAL,
244 .gpio_wp = -EINVAL,
245 .nonremovable = true,
246 },
247 {} /* Terminator */
248};
249
Santosh Shilimkar50263912010-08-02 13:18:03 +0300250static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
251 {
252 .supply = "vmmc",
253 .dev_name = "mmci-omap-hs.1",
254 },
255};
Balaji T K6e30a7d2010-05-12 08:27:30 +0000256static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
257 {
258 .supply = "vmmc",
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000259 .dev_name = "mmci-omap-hs.0",
Balaji T K6e30a7d2010-05-12 08:27:30 +0000260 },
Balaji T K6e30a7d2010-05-12 08:27:30 +0000261};
262
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000263static int omap4_twl6030_hsmmc_late_init(struct device *dev)
264{
265 int ret = 0;
266 struct platform_device *pdev = container_of(dev,
267 struct platform_device, dev);
268 struct omap_mmc_platform_data *pdata = dev->platform_data;
269
270 /* Setting MMC1 Card detect Irq */
271 if (pdev->id == 0)
272 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
273 MMCDETECT_INTR_OFFSET;
274 return ret;
275}
276
277static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
278{
279 struct omap_mmc_platform_data *pdata = dev->platform_data;
280
281 pdata->init = omap4_twl6030_hsmmc_late_init;
282}
283
284static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
285{
286 struct omap2_hsmmc_info *c;
287
288 omap2_hsmmc_init(controllers);
289 for (c = controllers; c->mmc; c++)
290 omap4_twl6030_hsmmc_set_late_init(c->dev);
291
292 return 0;
293}
294
Balaji T K6e30a7d2010-05-12 08:27:30 +0000295static struct regulator_init_data sdp4430_vaux1 = {
296 .constraints = {
297 .min_uV = 1000000,
298 .max_uV = 3000000,
299 .apply_uV = true,
300 .valid_modes_mask = REGULATOR_MODE_NORMAL
301 | REGULATOR_MODE_STANDBY,
302 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
303 | REGULATOR_CHANGE_MODE
304 | REGULATOR_CHANGE_STATUS,
305 },
Santosh Shilimkar50263912010-08-02 13:18:03 +0300306 .num_consumer_supplies = 1,
307 .consumer_supplies = sdp4430_vaux_supply,
Balaji T K6e30a7d2010-05-12 08:27:30 +0000308};
309
310static struct regulator_init_data sdp4430_vaux2 = {
311 .constraints = {
312 .min_uV = 1200000,
313 .max_uV = 2800000,
314 .apply_uV = true,
315 .valid_modes_mask = REGULATOR_MODE_NORMAL
316 | REGULATOR_MODE_STANDBY,
317 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
318 | REGULATOR_CHANGE_MODE
319 | REGULATOR_CHANGE_STATUS,
320 },
321};
322
323static struct regulator_init_data sdp4430_vaux3 = {
324 .constraints = {
325 .min_uV = 1000000,
326 .max_uV = 3000000,
327 .apply_uV = true,
328 .valid_modes_mask = REGULATOR_MODE_NORMAL
329 | REGULATOR_MODE_STANDBY,
330 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
331 | REGULATOR_CHANGE_MODE
332 | REGULATOR_CHANGE_STATUS,
333 },
334};
335
336/* VMMC1 for MMC1 card */
337static struct regulator_init_data sdp4430_vmmc = {
338 .constraints = {
339 .min_uV = 1200000,
340 .max_uV = 3000000,
341 .apply_uV = true,
342 .valid_modes_mask = REGULATOR_MODE_NORMAL
343 | REGULATOR_MODE_STANDBY,
344 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
345 | REGULATOR_CHANGE_MODE
346 | REGULATOR_CHANGE_STATUS,
347 },
Santosh Shilimkar50263912010-08-02 13:18:03 +0300348 .num_consumer_supplies = 1,
Balaji T K6e30a7d2010-05-12 08:27:30 +0000349 .consumer_supplies = sdp4430_vmmc_supply,
350};
351
352static struct regulator_init_data sdp4430_vpp = {
353 .constraints = {
354 .min_uV = 1800000,
355 .max_uV = 2500000,
356 .apply_uV = true,
357 .valid_modes_mask = REGULATOR_MODE_NORMAL
358 | REGULATOR_MODE_STANDBY,
359 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
360 | REGULATOR_CHANGE_MODE
361 | REGULATOR_CHANGE_STATUS,
362 },
363};
364
365static struct regulator_init_data sdp4430_vusim = {
366 .constraints = {
367 .min_uV = 1200000,
368 .max_uV = 2900000,
369 .apply_uV = true,
370 .valid_modes_mask = REGULATOR_MODE_NORMAL
371 | REGULATOR_MODE_STANDBY,
372 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
373 | REGULATOR_CHANGE_MODE
374 | REGULATOR_CHANGE_STATUS,
375 },
376};
377
378static struct regulator_init_data sdp4430_vana = {
379 .constraints = {
380 .min_uV = 2100000,
381 .max_uV = 2100000,
382 .apply_uV = true,
383 .valid_modes_mask = REGULATOR_MODE_NORMAL
384 | REGULATOR_MODE_STANDBY,
385 .valid_ops_mask = REGULATOR_CHANGE_MODE
386 | REGULATOR_CHANGE_STATUS,
387 },
388};
389
390static struct regulator_init_data sdp4430_vcxio = {
391 .constraints = {
392 .min_uV = 1800000,
393 .max_uV = 1800000,
394 .apply_uV = true,
395 .valid_modes_mask = REGULATOR_MODE_NORMAL
396 | REGULATOR_MODE_STANDBY,
397 .valid_ops_mask = REGULATOR_CHANGE_MODE
398 | REGULATOR_CHANGE_STATUS,
399 },
400};
401
402static struct regulator_init_data sdp4430_vdac = {
403 .constraints = {
404 .min_uV = 1800000,
405 .max_uV = 1800000,
406 .apply_uV = true,
407 .valid_modes_mask = REGULATOR_MODE_NORMAL
408 | REGULATOR_MODE_STANDBY,
409 .valid_ops_mask = REGULATOR_CHANGE_MODE
410 | REGULATOR_CHANGE_STATUS,
411 },
412};
413
414static struct regulator_init_data sdp4430_vusb = {
415 .constraints = {
416 .min_uV = 3300000,
417 .max_uV = 3300000,
418 .apply_uV = true,
419 .valid_modes_mask = REGULATOR_MODE_NORMAL
420 | REGULATOR_MODE_STANDBY,
421 .valid_ops_mask = REGULATOR_CHANGE_MODE
422 | REGULATOR_CHANGE_STATUS,
423 },
424};
425
426static struct twl4030_platform_data sdp4430_twldata = {
427 .irq_base = TWL6030_IRQ_BASE,
428 .irq_end = TWL6030_IRQ_END,
429
430 /* Regulators */
431 .vmmc = &sdp4430_vmmc,
432 .vpp = &sdp4430_vpp,
433 .vusim = &sdp4430_vusim,
434 .vana = &sdp4430_vana,
435 .vcxio = &sdp4430_vcxio,
436 .vdac = &sdp4430_vdac,
437 .vusb = &sdp4430_vusb,
438 .vaux1 = &sdp4430_vaux1,
439 .vaux2 = &sdp4430_vaux2,
440 .vaux3 = &sdp4430_vaux3,
441};
442
443static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
444 {
445 I2C_BOARD_INFO("twl6030", 0x48),
446 .flags = I2C_CLIENT_WAKE,
447 .irq = OMAP44XX_IRQ_SYS_1N,
448 .platform_data = &sdp4430_twldata,
449 },
450};
Shubhrajyoti Datta83078f92010-08-02 13:18:04 +0300451static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
452 {
453 I2C_BOARD_INFO("tmp105", 0x48),
454 },
455};
Shubhrajyoti Datta0df891b2010-09-23 18:22:47 -0700456static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
457 {
458 I2C_BOARD_INFO("hmc5843", 0x1e),
459 },
460};
Santosh Shilimkarbaeb73e2010-05-12 08:27:29 +0000461static int __init omap4_i2c_init(void)
462{
463 /*
464 * Phoenix Audio IC needs I2C1 to
465 * start with 400 KHz or less
466 */
Balaji T K6e30a7d2010-05-12 08:27:30 +0000467 omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
468 ARRAY_SIZE(sdp4430_i2c_boardinfo));
Santosh Shilimkarbaeb73e2010-05-12 08:27:29 +0000469 omap_register_i2c_bus(2, 400, NULL, 0);
Shubhrajyoti Datta83078f92010-08-02 13:18:04 +0300470 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
471 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
Shubhrajyoti Datta0df891b2010-09-23 18:22:47 -0700472 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
473 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
Santosh Shilimkarbaeb73e2010-05-12 08:27:29 +0000474 return 0;
475}
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -0700476
477static void __init omap_sfh7741prox_init(void)
478{
479 int error;
480
481 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
482 if (error < 0) {
483 pr_err("%s:failed to request GPIO %d, error %d\n",
484 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
485 return;
486 }
487
488 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
489 if (error < 0) {
490 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
491 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
492 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
493 }
494}
495
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700496static void __init omap_4430sdp_init(void)
497{
Abraham Arceb2aa5e52010-05-14 12:05:26 -0700498 int status;
499
Santosh Shilimkarbaeb73e2010-05-12 08:27:29 +0000500 omap4_i2c_init();
Shubhrajyoti Datta94ce7a62010-09-23 18:22:49 -0700501 omap_sfh7741prox_init();
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700502 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700503 omap_serial_init();
kishore kadiyala717c1fb2010-05-15 18:21:06 +0000504 omap4_twl6030_hsmmc_init(mmc);
Maulik Mankadbce06682010-02-17 14:09:32 -0800505 /* OMAP4 SDP uses internal transceiver so register nop transceiver */
506 usb_nop_xceiv_register();
Santosh Shilimkarae46ec72010-02-16 19:29:20 +0530507 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
508 if (!cpu_is_omap44xx())
509 usb_musb_init(&musb_board_data);
Abraham Arceb2aa5e52010-05-14 12:05:26 -0700510
511 status = omap_ethernet_init();
512 if (status) {
513 pr_err("Ethernet initialization failed: %d\n", status);
514 } else {
515 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
516 spi_register_board_info(sdp4430_spi_board_info,
517 ARRAY_SIZE(sdp4430_spi_board_info));
518 }
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700519}
520
521static void __init omap_4430sdp_map_io(void)
522{
523 omap2_set_globals_443x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800524 omap44xx_map_common_io();
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700525}
526
527MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
528 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
529 .phys_io = 0x48000000,
Santosh Shilimkarb4224b22009-10-19 17:25:55 -0700530 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700531 .boot_params = 0x80000100,
532 .map_io = omap_4430sdp_map_io,
Russell King71ee7da2010-05-23 10:18:16 +0100533 .reserve = omap_reserve,
Santosh Shilimkar46ba0ab2009-05-28 14:16:05 -0700534 .init_irq = omap_4430sdp_init_irq,
535 .init_machine = omap_4430sdp_init,
536 .timer = &omap_timer,
537MACHINE_END