]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm/mach-omap2/board-4430sdp.c
omap4: Add platform changes for Ambient Light sensor
[mirror_ubuntu-artful-kernel.git] / arch / arm / mach-omap2 / board-4430sdp.c
CommitLineData
46ba0abf
SS
1/*
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>
bce06683 20#include <linux/usb/otg.h>
b2aa5e57 21#include <linux/spi/spi.h>
6e30a7db 22#include <linux/i2c/twl.h>
94ce7a66 23#include <linux/gpio_keys.h>
6e30a7db 24#include <linux/regulator/machine.h>
509b6d93 25#include <linux/leds.h>
46ba0abf
SS
26
27#include <mach/hardware.h>
fbc9be10 28#include <mach/omap4-common.h>
46ba0abf
SS
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
ce491cf8
TL
33#include <plat/board.h>
34#include <plat/common.h>
bce06683 35#include <plat/usb.h>
717c1fbf 36#include <plat/mmc.h>
04aeae77 37
fb6bf632 38#include "mux.h"
717c1fbf 39#include "hsmmc.h"
04aeae77 40#include "timer-gp.h"
4814ced5 41#include "control.h"
46ba0abf 42
b2aa5e57
AA
43#define ETH_KS8851_IRQ 34
44#define ETH_KS8851_POWER_ON 48
45#define ETH_KS8851_QUART 138
94ce7a66
SD
46#define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
47#define OMAP4_SFH7741_ENABLE_GPIO 188
b2aa5e57 48
509b6d93
H
49static struct gpio_led sdp4430_gpio_leds[] = {
50 {
51 .name = "omap4:green:debug0",
52 .gpio = 61,
53 },
54 {
55 .name = "omap4:green:debug1",
56 .gpio = 30,
57 },
58 {
59 .name = "omap4:green:debug2",
60 .gpio = 7,
61 },
62 {
63 .name = "omap4:green:debug3",
64 .gpio = 8,
65 },
66 {
67 .name = "omap4:green:debug4",
68 .gpio = 50,
69 },
70 {
71 .name = "omap4:blue:user",
72 .gpio = 169,
73 },
74 {
75 .name = "omap4:red:user",
76 .gpio = 170,
77 },
78 {
79 .name = "omap4:green:user",
80 .gpio = 139,
81 },
82
83};
84
94ce7a66
SD
85static struct gpio_keys_button sdp4430_gpio_keys[] = {
86 {
87 .desc = "Proximity Sensor",
88 .type = EV_SW,
89 .code = SW_FRONT_PROXIMITY,
90 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
91 .active_low = 0,
92 }
93};
94
509b6d93
H
95static struct gpio_led_platform_data sdp4430_led_data = {
96 .leds = sdp4430_gpio_leds,
97 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
98};
99
94ce7a66
SD
100static int omap_prox_activate(struct device *dev)
101{
102 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
103 return 0;
104}
105
106static void omap_prox_deactivate(struct device *dev)
107{
108 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
109}
110
111static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
112 .buttons = sdp4430_gpio_keys,
113 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
114 .enable = omap_prox_activate,
115 .disable = omap_prox_deactivate,
116};
117
118static struct platform_device sdp4430_gpio_keys_device = {
119 .name = "gpio-keys",
120 .id = -1,
121 .dev = {
122 .platform_data = &sdp4430_gpio_keys_data,
123 },
124};
125
509b6d93
H
126static struct platform_device sdp4430_leds_gpio = {
127 .name = "leds-gpio",
128 .id = -1,
129 .dev = {
130 .platform_data = &sdp4430_led_data,
131 },
132};
b2aa5e57
AA
133static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
134 {
135 .modalias = "ks8851",
136 .bus_num = 1,
137 .chip_select = 0,
138 .max_speed_hz = 24000000,
139 .irq = ETH_KS8851_IRQ,
140 },
141};
142
143static int omap_ethernet_init(void)
144{
145 int status;
146
147 /* Request of GPIO lines */
148
149 status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
150 if (status) {
151 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
152 return status;
153 }
154
155 status = gpio_request(ETH_KS8851_QUART, "quart");
156 if (status) {
157 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
158 goto error1;
159 }
160
161 status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
162 if (status) {
163 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
164 goto error2;
165 }
166
167 /* Configuration of requested GPIO lines */
168
169 status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
170 if (status) {
171 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
172 goto error3;
173 }
174
175 status = gpio_direction_output(ETH_KS8851_QUART, 1);
176 if (status) {
177 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
178 goto error3;
179 }
180
181 status = gpio_direction_input(ETH_KS8851_IRQ);
182 if (status) {
183 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
184 goto error3;
185 }
186
187 return 0;
188
189error3:
190 gpio_free(ETH_KS8851_IRQ);
191error2:
192 gpio_free(ETH_KS8851_QUART);
193error1:
194 gpio_free(ETH_KS8851_POWER_ON);
195 return status;
196}
197
46ba0abf
SS
198static struct platform_device sdp4430_lcd_device = {
199 .name = "sdp4430_lcd",
200 .id = -1,
201};
202
203static struct platform_device *sdp4430_devices[] __initdata = {
204 &sdp4430_lcd_device,
94ce7a66 205 &sdp4430_gpio_keys_device,
509b6d93 206 &sdp4430_leds_gpio,
46ba0abf
SS
207};
208
46ba0abf
SS
209static struct omap_lcd_config sdp4430_lcd_config __initdata = {
210 .ctrl_name = "internal",
211};
212
213static struct omap_board_config_kernel sdp4430_config[] __initdata = {
46ba0abf
SS
214 { OMAP_TAG_LCD, &sdp4430_lcd_config },
215};
216
46ba0abf
SS
217static void __init omap_4430sdp_init_irq(void)
218{
5b7815b5
SS
219 omap_board_config = sdp4430_config;
220 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
58cda884 221 omap2_init_common_hw(NULL, NULL);
46ba0abf
SS
222#ifdef CONFIG_OMAP_32K_TIMER
223 omap2_gp_clockevent_set_gptimer(1);
224#endif
225 gic_init_irq();
46ba0abf
SS
226}
227
bce06683
MM
228static struct omap_musb_board_data musb_board_data = {
229 .interface_type = MUSB_INTERFACE_UTMI,
230 .mode = MUSB_PERIPHERAL,
231 .power = 100,
232};
717c1fbf 233
234static struct omap2_hsmmc_info mmc[] = {
6e30a7db 235 {
717c1fbf 236 .mmc = 1,
3a63833e 237 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
717c1fbf 238 .gpio_wp = -EINVAL,
6e30a7db
B
239 },
240 {
717c1fbf 241 .mmc = 2,
3a63833e 242 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
717c1fbf 243 .gpio_cd = -EINVAL,
244 .gpio_wp = -EINVAL,
245 .nonremovable = true,
64be9782 246 .ocr_mask = MMC_VDD_29_30,
6e30a7db 247 },
717c1fbf 248 {} /* Terminator */
249};
250
5026391c 251static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
6e30a7db
B
252 {
253 .supply = "vmmc",
5026391c 254 .dev_name = "mmci-omap-hs.1",
6e30a7db 255 },
5026391c
SS
256};
257static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
6e30a7db
B
258 {
259 .supply = "vmmc",
5026391c 260 .dev_name = "mmci-omap-hs.0",
6e30a7db
B
261 },
262};
263
717c1fbf 264static int omap4_twl6030_hsmmc_late_init(struct device *dev)
265{
266 int ret = 0;
267 struct platform_device *pdev = container_of(dev,
268 struct platform_device, dev);
269 struct omap_mmc_platform_data *pdata = dev->platform_data;
270
271 /* Setting MMC1 Card detect Irq */
72f2e2c7 272 if (pdev->id == 0) {
273 ret = twl6030_mmc_card_detect_config();
274 if (ret)
275 pr_err("Failed configuring MMC1 card detect\n");
717c1fbf 276 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
277 MMCDETECT_INTR_OFFSET;
72f2e2c7 278 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
279 }
717c1fbf 280 return ret;
281}
282
283static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
284{
531c21ba 285 struct omap_mmc_platform_data *pdata;
717c1fbf 286
531c21ba
BC
287 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
288 if (!dev) {
289 pr_err("Failed %s\n", __func__);
290 return;
291 }
292 pdata = dev->platform_data;
717c1fbf 293 pdata->init = omap4_twl6030_hsmmc_late_init;
294}
295
296static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
297{
298 struct omap2_hsmmc_info *c;
299
300 omap2_hsmmc_init(controllers);
301 for (c = controllers; c->mmc; c++)
302 omap4_twl6030_hsmmc_set_late_init(c->dev);
303
304 return 0;
305}
306
6e30a7db
B
307static struct regulator_init_data sdp4430_vaux1 = {
308 .constraints = {
309 .min_uV = 1000000,
310 .max_uV = 3000000,
311 .apply_uV = true,
312 .valid_modes_mask = REGULATOR_MODE_NORMAL
313 | REGULATOR_MODE_STANDBY,
314 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
315 | REGULATOR_CHANGE_MODE
316 | REGULATOR_CHANGE_STATUS,
317 },
5026391c
SS
318 .num_consumer_supplies = 1,
319 .consumer_supplies = sdp4430_vaux_supply,
6e30a7db
B
320};
321
322static struct regulator_init_data sdp4430_vaux2 = {
323 .constraints = {
324 .min_uV = 1200000,
325 .max_uV = 2800000,
326 .apply_uV = true,
327 .valid_modes_mask = REGULATOR_MODE_NORMAL
328 | REGULATOR_MODE_STANDBY,
329 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
330 | REGULATOR_CHANGE_MODE
331 | REGULATOR_CHANGE_STATUS,
332 },
333};
334
335static struct regulator_init_data sdp4430_vaux3 = {
336 .constraints = {
337 .min_uV = 1000000,
338 .max_uV = 3000000,
339 .apply_uV = true,
340 .valid_modes_mask = REGULATOR_MODE_NORMAL
341 | REGULATOR_MODE_STANDBY,
342 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
343 | REGULATOR_CHANGE_MODE
344 | REGULATOR_CHANGE_STATUS,
345 },
346};
347
348/* VMMC1 for MMC1 card */
349static struct regulator_init_data sdp4430_vmmc = {
350 .constraints = {
351 .min_uV = 1200000,
352 .max_uV = 3000000,
353 .apply_uV = true,
354 .valid_modes_mask = REGULATOR_MODE_NORMAL
355 | REGULATOR_MODE_STANDBY,
356 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
357 | REGULATOR_CHANGE_MODE
358 | REGULATOR_CHANGE_STATUS,
359 },
5026391c 360 .num_consumer_supplies = 1,
6e30a7db
B
361 .consumer_supplies = sdp4430_vmmc_supply,
362};
363
364static struct regulator_init_data sdp4430_vpp = {
365 .constraints = {
366 .min_uV = 1800000,
367 .max_uV = 2500000,
368 .apply_uV = true,
369 .valid_modes_mask = REGULATOR_MODE_NORMAL
370 | REGULATOR_MODE_STANDBY,
371 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
372 | REGULATOR_CHANGE_MODE
373 | REGULATOR_CHANGE_STATUS,
374 },
375};
376
377static struct regulator_init_data sdp4430_vusim = {
378 .constraints = {
379 .min_uV = 1200000,
380 .max_uV = 2900000,
381 .apply_uV = true,
382 .valid_modes_mask = REGULATOR_MODE_NORMAL
383 | REGULATOR_MODE_STANDBY,
384 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
385 | REGULATOR_CHANGE_MODE
386 | REGULATOR_CHANGE_STATUS,
387 },
388};
389
390static struct regulator_init_data sdp4430_vana = {
391 .constraints = {
392 .min_uV = 2100000,
393 .max_uV = 2100000,
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_vcxio = {
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_vdac = {
415 .constraints = {
416 .min_uV = 1800000,
417 .max_uV = 1800000,
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 regulator_init_data sdp4430_vusb = {
427 .constraints = {
428 .min_uV = 3300000,
429 .max_uV = 3300000,
430 .apply_uV = true,
431 .valid_modes_mask = REGULATOR_MODE_NORMAL
432 | REGULATOR_MODE_STANDBY,
433 .valid_ops_mask = REGULATOR_CHANGE_MODE
434 | REGULATOR_CHANGE_STATUS,
435 },
436};
437
438static struct twl4030_platform_data sdp4430_twldata = {
439 .irq_base = TWL6030_IRQ_BASE,
440 .irq_end = TWL6030_IRQ_END,
441
442 /* Regulators */
443 .vmmc = &sdp4430_vmmc,
444 .vpp = &sdp4430_vpp,
445 .vusim = &sdp4430_vusim,
446 .vana = &sdp4430_vana,
447 .vcxio = &sdp4430_vcxio,
448 .vdac = &sdp4430_vdac,
449 .vusb = &sdp4430_vusb,
450 .vaux1 = &sdp4430_vaux1,
451 .vaux2 = &sdp4430_vaux2,
452 .vaux3 = &sdp4430_vaux3,
453};
454
455static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
456 {
457 I2C_BOARD_INFO("twl6030", 0x48),
458 .flags = I2C_CLIENT_WAKE,
459 .irq = OMAP44XX_IRQ_SYS_1N,
460 .platform_data = &sdp4430_twldata,
461 },
462};
83078f9b
SD
463static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
464 {
465 I2C_BOARD_INFO("tmp105", 0x48),
466 },
d048aca2
H
467 {
468 I2C_BOARD_INFO("bh1780", 0x29),
469 },
83078f9b 470};
0df891bb
SD
471static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
472 {
473 I2C_BOARD_INFO("hmc5843", 0x1e),
474 },
475};
baeb73e8
SS
476static int __init omap4_i2c_init(void)
477{
478 /*
479 * Phoenix Audio IC needs I2C1 to
480 * start with 400 KHz or less
481 */
6e30a7db
B
482 omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
483 ARRAY_SIZE(sdp4430_i2c_boardinfo));
baeb73e8 484 omap_register_i2c_bus(2, 400, NULL, 0);
83078f9b
SD
485 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
486 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
0df891bb
SD
487 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
488 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
baeb73e8
SS
489 return 0;
490}
94ce7a66
SD
491
492static void __init omap_sfh7741prox_init(void)
493{
494 int error;
495
496 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
497 if (error < 0) {
498 pr_err("%s:failed to request GPIO %d, error %d\n",
499 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
500 return;
501 }
502
503 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
504 if (error < 0) {
505 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
506 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
507 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
508 }
509}
510
fb6bf632
BC
511#ifdef CONFIG_OMAP_MUX
512static struct omap_board_mux board_mux[] __initdata = {
513 { .reg_offset = OMAP_MUX_TERMINATOR },
514};
515#else
516#define board_mux NULL
517#endif
518
46ba0abf
SS
519static void __init omap_4430sdp_init(void)
520{
b2aa5e57 521 int status;
6fea7b0a
BC
522 int package = OMAP_PACKAGE_CBS;
523
524 if (omap_rev() == OMAP4430_REV_ES1_0)
525 package = OMAP_PACKAGE_CBL;
526 omap4_mux_init(board_mux, package);
b2aa5e57 527
baeb73e8 528 omap4_i2c_init();
94ce7a66 529 omap_sfh7741prox_init();
46ba0abf 530 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
46ba0abf 531 omap_serial_init();
717c1fbf 532 omap4_twl6030_hsmmc_init(mmc);
bce06683
MM
533 /* OMAP4 SDP uses internal transceiver so register nop transceiver */
534 usb_nop_xceiv_register();
ae46ec77
SS
535 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
536 if (!cpu_is_omap44xx())
537 usb_musb_init(&musb_board_data);
b2aa5e57
AA
538
539 status = omap_ethernet_init();
540 if (status) {
541 pr_err("Ethernet initialization failed: %d\n", status);
542 } else {
543 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
544 spi_register_board_info(sdp4430_spi_board_info,
545 ARRAY_SIZE(sdp4430_spi_board_info));
546 }
46ba0abf
SS
547}
548
549static void __init omap_4430sdp_map_io(void)
550{
551 omap2_set_globals_443x();
6fbd55d0 552 omap44xx_map_common_io();
46ba0abf
SS
553}
554
555MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
556 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
46ba0abf
SS
557 .boot_params = 0x80000100,
558 .map_io = omap_4430sdp_map_io,
71ee7dad 559 .reserve = omap_reserve,
46ba0abf
SS
560 .init_irq = omap_4430sdp_init_irq,
561 .init_machine = omap_4430sdp_init,
562 .timer = &omap_timer,
563MACHINE_END