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