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