OMAP2+: io: split omap2_init_common_hw()
[linux-2.6/x86.git] / arch / arm / mach-omap2 / board-4430sdp.c
blob1cb208b6e62623168da8a181c45516e374f4a34c
1 /*
2 * Board support file for OMAP4430 SDP.
4 * Copyright (C) 2009 Texas Instruments
6 * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
8 * Based on mach-omap2/board-3430sdp.c
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.
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>
20 #include <linux/usb/otg.h>
21 #include <linux/spi/spi.h>
22 #include <linux/i2c/twl.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/leds.h>
26 #include <linux/leds_pwm.h>
28 #include <mach/hardware.h>
29 #include <mach/omap4-common.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <plat/board.h>
35 #include <plat/common.h>
36 #include <plat/usb.h>
37 #include <plat/mmc.h>
39 #include "mux.h"
40 #include "hsmmc.h"
41 #include "timer-gp.h"
42 #include "control.h"
44 #define ETH_KS8851_IRQ 34
45 #define ETH_KS8851_POWER_ON 48
46 #define ETH_KS8851_QUART 138
47 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
48 #define OMAP4_SFH7741_ENABLE_GPIO 188
50 static struct gpio_led sdp4430_gpio_leds[] = {
52 .name = "omap4:green:debug0",
53 .gpio = 61,
56 .name = "omap4:green:debug1",
57 .gpio = 30,
60 .name = "omap4:green:debug2",
61 .gpio = 7,
64 .name = "omap4:green:debug3",
65 .gpio = 8,
68 .name = "omap4:green:debug4",
69 .gpio = 50,
72 .name = "omap4:blue:user",
73 .gpio = 169,
76 .name = "omap4:red:user",
77 .gpio = 170,
80 .name = "omap4:green:user",
81 .gpio = 139,
86 static struct gpio_keys_button sdp4430_gpio_keys[] = {
88 .desc = "Proximity Sensor",
89 .type = EV_SW,
90 .code = SW_FRONT_PROXIMITY,
91 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
92 .active_low = 0,
96 static struct gpio_led_platform_data sdp4430_led_data = {
97 .leds = sdp4430_gpio_leds,
98 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
101 static struct led_pwm sdp4430_pwm_leds[] = {
103 .name = "omap4:green:chrg",
104 .pwm_id = 1,
105 .max_brightness = 255,
106 .pwm_period_ns = 7812500,
110 static struct led_pwm_platform_data sdp4430_pwm_data = {
111 .num_leds = ARRAY_SIZE(sdp4430_pwm_leds),
112 .leds = sdp4430_pwm_leds,
115 static struct platform_device sdp4430_leds_pwm = {
116 .name = "leds_pwm",
117 .id = -1,
118 .dev = {
119 .platform_data = &sdp4430_pwm_data,
123 static int omap_prox_activate(struct device *dev)
125 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
126 return 0;
129 static void omap_prox_deactivate(struct device *dev)
131 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
134 static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
135 .buttons = sdp4430_gpio_keys,
136 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
137 .enable = omap_prox_activate,
138 .disable = omap_prox_deactivate,
141 static struct platform_device sdp4430_gpio_keys_device = {
142 .name = "gpio-keys",
143 .id = -1,
144 .dev = {
145 .platform_data = &sdp4430_gpio_keys_data,
149 static struct platform_device sdp4430_leds_gpio = {
150 .name = "leds-gpio",
151 .id = -1,
152 .dev = {
153 .platform_data = &sdp4430_led_data,
156 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
158 .modalias = "ks8851",
159 .bus_num = 1,
160 .chip_select = 0,
161 .max_speed_hz = 24000000,
162 .irq = ETH_KS8851_IRQ,
166 static int omap_ethernet_init(void)
168 int status;
170 /* Request of GPIO lines */
172 status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
173 if (status) {
174 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
175 return status;
178 status = gpio_request(ETH_KS8851_QUART, "quart");
179 if (status) {
180 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
181 goto error1;
184 status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
185 if (status) {
186 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
187 goto error2;
190 /* Configuration of requested GPIO lines */
192 status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
193 if (status) {
194 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
195 goto error3;
198 status = gpio_direction_output(ETH_KS8851_QUART, 1);
199 if (status) {
200 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
201 goto error3;
204 status = gpio_direction_input(ETH_KS8851_IRQ);
205 if (status) {
206 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
207 goto error3;
210 return 0;
212 error3:
213 gpio_free(ETH_KS8851_IRQ);
214 error2:
215 gpio_free(ETH_KS8851_QUART);
216 error1:
217 gpio_free(ETH_KS8851_POWER_ON);
218 return status;
221 static struct platform_device sdp4430_lcd_device = {
222 .name = "sdp4430_lcd",
223 .id = -1,
226 static struct platform_device *sdp4430_devices[] __initdata = {
227 &sdp4430_lcd_device,
228 &sdp4430_gpio_keys_device,
229 &sdp4430_leds_gpio,
230 &sdp4430_leds_pwm,
233 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
234 .ctrl_name = "internal",
237 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
238 { OMAP_TAG_LCD, &sdp4430_lcd_config },
241 static void __init omap_4430sdp_init_irq(void)
243 omap_board_config = sdp4430_config;
244 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
245 omap2_init_common_infrastructure();
246 omap2_init_common_devices(NULL, NULL);
247 #ifdef CONFIG_OMAP_32K_TIMER
248 omap2_gp_clockevent_set_gptimer(1);
249 #endif
250 gic_init_irq();
253 static struct omap_musb_board_data musb_board_data = {
254 .interface_type = MUSB_INTERFACE_UTMI,
255 .mode = MUSB_PERIPHERAL,
256 .power = 100,
259 static struct omap2_hsmmc_info mmc[] = {
261 .mmc = 1,
262 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
263 .gpio_wp = -EINVAL,
266 .mmc = 2,
267 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
268 .gpio_cd = -EINVAL,
269 .gpio_wp = -EINVAL,
270 .nonremovable = true,
271 .ocr_mask = MMC_VDD_29_30,
273 {} /* Terminator */
276 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
278 .supply = "vmmc",
279 .dev_name = "mmci-omap-hs.1",
282 static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
284 .supply = "vmmc",
285 .dev_name = "mmci-omap-hs.0",
289 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
291 int ret = 0;
292 struct platform_device *pdev = container_of(dev,
293 struct platform_device, dev);
294 struct omap_mmc_platform_data *pdata = dev->platform_data;
296 /* Setting MMC1 Card detect Irq */
297 if (pdev->id == 0) {
298 ret = twl6030_mmc_card_detect_config();
299 if (ret)
300 pr_err("Failed configuring MMC1 card detect\n");
301 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
302 MMCDETECT_INTR_OFFSET;
303 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
305 return ret;
308 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
310 struct omap_mmc_platform_data *pdata;
312 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
313 if (!dev) {
314 pr_err("Failed %s\n", __func__);
315 return;
317 pdata = dev->platform_data;
318 pdata->init = omap4_twl6030_hsmmc_late_init;
321 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
323 struct omap2_hsmmc_info *c;
325 omap2_hsmmc_init(controllers);
326 for (c = controllers; c->mmc; c++)
327 omap4_twl6030_hsmmc_set_late_init(c->dev);
329 return 0;
332 static struct regulator_init_data sdp4430_vaux1 = {
333 .constraints = {
334 .min_uV = 1000000,
335 .max_uV = 3000000,
336 .apply_uV = true,
337 .valid_modes_mask = REGULATOR_MODE_NORMAL
338 | REGULATOR_MODE_STANDBY,
339 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
340 | REGULATOR_CHANGE_MODE
341 | REGULATOR_CHANGE_STATUS,
343 .num_consumer_supplies = 1,
344 .consumer_supplies = sdp4430_vaux_supply,
347 static struct regulator_init_data sdp4430_vaux2 = {
348 .constraints = {
349 .min_uV = 1200000,
350 .max_uV = 2800000,
351 .apply_uV = true,
352 .valid_modes_mask = REGULATOR_MODE_NORMAL
353 | REGULATOR_MODE_STANDBY,
354 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
355 | REGULATOR_CHANGE_MODE
356 | REGULATOR_CHANGE_STATUS,
360 static struct regulator_init_data sdp4430_vaux3 = {
361 .constraints = {
362 .min_uV = 1000000,
363 .max_uV = 3000000,
364 .apply_uV = true,
365 .valid_modes_mask = REGULATOR_MODE_NORMAL
366 | REGULATOR_MODE_STANDBY,
367 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
368 | REGULATOR_CHANGE_MODE
369 | REGULATOR_CHANGE_STATUS,
373 /* VMMC1 for MMC1 card */
374 static struct regulator_init_data sdp4430_vmmc = {
375 .constraints = {
376 .min_uV = 1200000,
377 .max_uV = 3000000,
378 .apply_uV = true,
379 .valid_modes_mask = REGULATOR_MODE_NORMAL
380 | REGULATOR_MODE_STANDBY,
381 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
382 | REGULATOR_CHANGE_MODE
383 | REGULATOR_CHANGE_STATUS,
385 .num_consumer_supplies = 1,
386 .consumer_supplies = sdp4430_vmmc_supply,
389 static struct regulator_init_data sdp4430_vpp = {
390 .constraints = {
391 .min_uV = 1800000,
392 .max_uV = 2500000,
393 .apply_uV = true,
394 .valid_modes_mask = REGULATOR_MODE_NORMAL
395 | REGULATOR_MODE_STANDBY,
396 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
397 | REGULATOR_CHANGE_MODE
398 | REGULATOR_CHANGE_STATUS,
402 static struct regulator_init_data sdp4430_vusim = {
403 .constraints = {
404 .min_uV = 1200000,
405 .max_uV = 2900000,
406 .apply_uV = true,
407 .valid_modes_mask = REGULATOR_MODE_NORMAL
408 | REGULATOR_MODE_STANDBY,
409 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
410 | REGULATOR_CHANGE_MODE
411 | REGULATOR_CHANGE_STATUS,
415 static struct regulator_init_data sdp4430_vana = {
416 .constraints = {
417 .min_uV = 2100000,
418 .max_uV = 2100000,
419 .apply_uV = true,
420 .valid_modes_mask = REGULATOR_MODE_NORMAL
421 | REGULATOR_MODE_STANDBY,
422 .valid_ops_mask = REGULATOR_CHANGE_MODE
423 | REGULATOR_CHANGE_STATUS,
427 static struct regulator_init_data sdp4430_vcxio = {
428 .constraints = {
429 .min_uV = 1800000,
430 .max_uV = 1800000,
431 .apply_uV = true,
432 .valid_modes_mask = REGULATOR_MODE_NORMAL
433 | REGULATOR_MODE_STANDBY,
434 .valid_ops_mask = REGULATOR_CHANGE_MODE
435 | REGULATOR_CHANGE_STATUS,
439 static struct regulator_init_data sdp4430_vdac = {
440 .constraints = {
441 .min_uV = 1800000,
442 .max_uV = 1800000,
443 .apply_uV = true,
444 .valid_modes_mask = REGULATOR_MODE_NORMAL
445 | REGULATOR_MODE_STANDBY,
446 .valid_ops_mask = REGULATOR_CHANGE_MODE
447 | REGULATOR_CHANGE_STATUS,
451 static struct regulator_init_data sdp4430_vusb = {
452 .constraints = {
453 .min_uV = 3300000,
454 .max_uV = 3300000,
455 .apply_uV = true,
456 .valid_modes_mask = REGULATOR_MODE_NORMAL
457 | REGULATOR_MODE_STANDBY,
458 .valid_ops_mask = REGULATOR_CHANGE_MODE
459 | REGULATOR_CHANGE_STATUS,
463 static struct twl4030_platform_data sdp4430_twldata = {
464 .irq_base = TWL6030_IRQ_BASE,
465 .irq_end = TWL6030_IRQ_END,
467 /* Regulators */
468 .vmmc = &sdp4430_vmmc,
469 .vpp = &sdp4430_vpp,
470 .vusim = &sdp4430_vusim,
471 .vana = &sdp4430_vana,
472 .vcxio = &sdp4430_vcxio,
473 .vdac = &sdp4430_vdac,
474 .vusb = &sdp4430_vusb,
475 .vaux1 = &sdp4430_vaux1,
476 .vaux2 = &sdp4430_vaux2,
477 .vaux3 = &sdp4430_vaux3,
480 static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
482 I2C_BOARD_INFO("twl6030", 0x48),
483 .flags = I2C_CLIENT_WAKE,
484 .irq = OMAP44XX_IRQ_SYS_1N,
485 .platform_data = &sdp4430_twldata,
488 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
490 I2C_BOARD_INFO("tmp105", 0x48),
493 I2C_BOARD_INFO("bh1780", 0x29),
496 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
498 I2C_BOARD_INFO("hmc5843", 0x1e),
501 static int __init omap4_i2c_init(void)
504 * Phoenix Audio IC needs I2C1 to
505 * start with 400 KHz or less
507 omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
508 ARRAY_SIZE(sdp4430_i2c_boardinfo));
509 omap_register_i2c_bus(2, 400, NULL, 0);
510 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
511 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
512 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
513 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
514 return 0;
517 static void __init omap_sfh7741prox_init(void)
519 int error;
521 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
522 if (error < 0) {
523 pr_err("%s:failed to request GPIO %d, error %d\n",
524 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
525 return;
528 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
529 if (error < 0) {
530 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
531 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
532 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
536 #ifdef CONFIG_OMAP_MUX
537 static struct omap_board_mux board_mux[] __initdata = {
538 { .reg_offset = OMAP_MUX_TERMINATOR },
540 #else
541 #define board_mux NULL
542 #endif
544 static void __init omap_4430sdp_init(void)
546 int status;
547 int package = OMAP_PACKAGE_CBS;
549 if (omap_rev() == OMAP4430_REV_ES1_0)
550 package = OMAP_PACKAGE_CBL;
551 omap4_mux_init(board_mux, package);
553 omap4_i2c_init();
554 omap_sfh7741prox_init();
555 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
556 omap_serial_init();
557 omap4_twl6030_hsmmc_init(mmc);
558 /* OMAP4 SDP uses internal transceiver so register nop transceiver */
559 usb_nop_xceiv_register();
560 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
561 if (!cpu_is_omap44xx())
562 usb_musb_init(&musb_board_data);
564 status = omap_ethernet_init();
565 if (status) {
566 pr_err("Ethernet initialization failed: %d\n", status);
567 } else {
568 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
569 spi_register_board_info(sdp4430_spi_board_info,
570 ARRAY_SIZE(sdp4430_spi_board_info));
574 static void __init omap_4430sdp_map_io(void)
576 omap2_set_globals_443x();
577 omap44xx_map_common_io();
580 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
581 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
582 .boot_params = 0x80000100,
583 .map_io = omap_4430sdp_map_io,
584 .reserve = omap_reserve,
585 .init_irq = omap_4430sdp_init_irq,
586 .init_machine = omap_4430sdp_init,
587 .timer = &omap_timer,
588 MACHINE_END