USB: Merge 2.6.37-rc5 into usb-next
[firefly-linux-kernel-4.4.55.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/usb.h>
36 #include <plat/mmc.h>
37
38 #include "hsmmc.h"
39 #include "timer-gp.h"
40 #include "control.h"
41
42 #define ETH_KS8851_IRQ                  34
43 #define ETH_KS8851_POWER_ON             48
44 #define ETH_KS8851_QUART                138
45 #define OMAP4SDP_MDM_PWR_EN_GPIO        157
46 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO        184
47 #define OMAP4_SFH7741_ENABLE_GPIO               188
48
49 static 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
85 static 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
95 static struct gpio_led_platform_data sdp4430_led_data = {
96         .leds   = sdp4430_gpio_leds,
97         .num_leds       = ARRAY_SIZE(sdp4430_gpio_leds),
98 };
99
100 static int omap_prox_activate(struct device *dev)
101 {
102         gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
103         return 0;
104 }
105
106 static void omap_prox_deactivate(struct device *dev)
107 {
108         gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
109 }
110
111 static 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
118 static 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
126 static struct platform_device sdp4430_leds_gpio = {
127         .name   = "leds-gpio",
128         .id     = -1,
129         .dev    = {
130                 .platform_data = &sdp4430_led_data,
131         },
132 };
133 static 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
143 static 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
189 error3:
190         gpio_free(ETH_KS8851_IRQ);
191 error2:
192         gpio_free(ETH_KS8851_QUART);
193 error1:
194         gpio_free(ETH_KS8851_POWER_ON);
195         return status;
196 }
197
198 static struct platform_device sdp4430_lcd_device = {
199         .name           = "sdp4430_lcd",
200         .id             = -1,
201 };
202
203 static struct platform_device *sdp4430_devices[] __initdata = {
204         &sdp4430_lcd_device,
205         &sdp4430_gpio_keys_device,
206         &sdp4430_leds_gpio,
207 };
208
209 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
210         .ctrl_name      = "internal",
211 };
212
213 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
214         { OMAP_TAG_LCD,         &sdp4430_lcd_config },
215 };
216
217 static void __init omap_4430sdp_init_irq(void)
218 {
219         omap_board_config = sdp4430_config;
220         omap_board_config_size = ARRAY_SIZE(sdp4430_config);
221         omap2_init_common_hw(NULL, NULL);
222 #ifdef CONFIG_OMAP_32K_TIMER
223         omap2_gp_clockevent_set_gptimer(1);
224 #endif
225         gic_init_irq();
226         omap_gpio_init();
227 }
228
229 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
230         .port_mode[0]   = EHCI_HCD_OMAP_MODE_PHY,
231         .port_mode[1]   = EHCI_HCD_OMAP_MODE_UNKNOWN,
232         .port_mode[2]   = EHCI_HCD_OMAP_MODE_UNKNOWN,
233         .phy_reset      = false,
234         .reset_gpio_port[0]  = -EINVAL,
235         .reset_gpio_port[1]  = -EINVAL,
236         .reset_gpio_port[2]  = -EINVAL,
237 };
238
239 static struct omap_musb_board_data musb_board_data = {
240         .interface_type         = MUSB_INTERFACE_UTMI,
241         .mode                   = MUSB_OTG,
242         .power                  = 100,
243 };
244
245 static struct twl4030_usb_data omap4_usbphy_data = {
246         .phy_init       = omap4430_phy_init,
247         .phy_exit       = omap4430_phy_exit,
248         .phy_power      = omap4430_phy_power,
249         .phy_set_clock  = omap4430_phy_set_clk,
250 };
251
252 static struct omap2_hsmmc_info mmc[] = {
253         {
254                 .mmc            = 1,
255                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
256                 .gpio_wp        = -EINVAL,
257         },
258         {
259                 .mmc            = 2,
260                 .caps           =  MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
261                 .gpio_cd        = -EINVAL,
262                 .gpio_wp        = -EINVAL,
263                 .nonremovable   = true,
264                 .ocr_mask       = MMC_VDD_29_30,
265         },
266         {}      /* Terminator */
267 };
268
269 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
270         {
271                 .supply = "vmmc",
272                 .dev_name = "mmci-omap-hs.1",
273         },
274 };
275 static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
276         {
277                 .supply = "vmmc",
278                 .dev_name = "mmci-omap-hs.0",
279         },
280 };
281
282 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
283 {
284         int ret = 0;
285         struct platform_device *pdev = container_of(dev,
286                                 struct platform_device, dev);
287         struct omap_mmc_platform_data *pdata = dev->platform_data;
288
289         /* Setting MMC1 Card detect Irq */
290         if (pdev->id == 0) {
291                 ret = twl6030_mmc_card_detect_config();
292                 if (ret)
293                         pr_err("Failed configuring MMC1 card detect\n");
294                 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
295                                                 MMCDETECT_INTR_OFFSET;
296                 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
297         }
298         return ret;
299 }
300
301 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
302 {
303         struct omap_mmc_platform_data *pdata;
304
305         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
306         if (!dev) {
307                 pr_err("Failed %s\n", __func__);
308                 return;
309         }
310         pdata = dev->platform_data;
311         pdata->init =   omap4_twl6030_hsmmc_late_init;
312 }
313
314 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
315 {
316         struct omap2_hsmmc_info *c;
317
318         omap2_hsmmc_init(controllers);
319         for (c = controllers; c->mmc; c++)
320                 omap4_twl6030_hsmmc_set_late_init(c->dev);
321
322         return 0;
323 }
324
325 static struct regulator_init_data sdp4430_vaux1 = {
326         .constraints = {
327                 .min_uV                 = 1000000,
328                 .max_uV                 = 3000000,
329                 .apply_uV               = true,
330                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
331                                         | REGULATOR_MODE_STANDBY,
332                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
333                                         | REGULATOR_CHANGE_MODE
334                                         | REGULATOR_CHANGE_STATUS,
335         },
336         .num_consumer_supplies  = 1,
337         .consumer_supplies      = sdp4430_vaux_supply,
338 };
339
340 static struct regulator_init_data sdp4430_vaux2 = {
341         .constraints = {
342                 .min_uV                 = 1200000,
343                 .max_uV                 = 2800000,
344                 .apply_uV               = true,
345                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
346                                         | REGULATOR_MODE_STANDBY,
347                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
348                                         | REGULATOR_CHANGE_MODE
349                                         | REGULATOR_CHANGE_STATUS,
350         },
351 };
352
353 static struct regulator_init_data sdp4430_vaux3 = {
354         .constraints = {
355                 .min_uV                 = 1000000,
356                 .max_uV                 = 3000000,
357                 .apply_uV               = true,
358                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
359                                         | REGULATOR_MODE_STANDBY,
360                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
361                                         | REGULATOR_CHANGE_MODE
362                                         | REGULATOR_CHANGE_STATUS,
363         },
364 };
365
366 /* VMMC1 for MMC1 card */
367 static struct regulator_init_data sdp4430_vmmc = {
368         .constraints = {
369                 .min_uV                 = 1200000,
370                 .max_uV                 = 3000000,
371                 .apply_uV               = true,
372                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
373                                         | REGULATOR_MODE_STANDBY,
374                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
375                                         | REGULATOR_CHANGE_MODE
376                                         | REGULATOR_CHANGE_STATUS,
377         },
378         .num_consumer_supplies  = 1,
379         .consumer_supplies      = sdp4430_vmmc_supply,
380 };
381
382 static struct regulator_init_data sdp4430_vpp = {
383         .constraints = {
384                 .min_uV                 = 1800000,
385                 .max_uV                 = 2500000,
386                 .apply_uV               = true,
387                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
388                                         | REGULATOR_MODE_STANDBY,
389                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
390                                         | REGULATOR_CHANGE_MODE
391                                         | REGULATOR_CHANGE_STATUS,
392         },
393 };
394
395 static struct regulator_init_data sdp4430_vusim = {
396         .constraints = {
397                 .min_uV                 = 1200000,
398                 .max_uV                 = 2900000,
399                 .apply_uV               = true,
400                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
401                                         | REGULATOR_MODE_STANDBY,
402                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
403                                         | REGULATOR_CHANGE_MODE
404                                         | REGULATOR_CHANGE_STATUS,
405         },
406 };
407
408 static struct regulator_init_data sdp4430_vana = {
409         .constraints = {
410                 .min_uV                 = 2100000,
411                 .max_uV                 = 2100000,
412                 .apply_uV               = true,
413                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
414                                         | REGULATOR_MODE_STANDBY,
415                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
416                                         | REGULATOR_CHANGE_STATUS,
417         },
418 };
419
420 static struct regulator_init_data sdp4430_vcxio = {
421         .constraints = {
422                 .min_uV                 = 1800000,
423                 .max_uV                 = 1800000,
424                 .apply_uV               = true,
425                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
426                                         | REGULATOR_MODE_STANDBY,
427                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
428                                         | REGULATOR_CHANGE_STATUS,
429         },
430 };
431
432 static struct regulator_init_data sdp4430_vdac = {
433         .constraints = {
434                 .min_uV                 = 1800000,
435                 .max_uV                 = 1800000,
436                 .apply_uV               = true,
437                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
438                                         | REGULATOR_MODE_STANDBY,
439                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
440                                         | REGULATOR_CHANGE_STATUS,
441         },
442 };
443
444 static struct regulator_init_data sdp4430_vusb = {
445         .constraints = {
446                 .min_uV                 = 3300000,
447                 .max_uV                 = 3300000,
448                 .apply_uV               = true,
449                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
450                                         | REGULATOR_MODE_STANDBY,
451                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
452                                         | REGULATOR_CHANGE_STATUS,
453         },
454 };
455
456 static struct twl4030_platform_data sdp4430_twldata = {
457         .irq_base       = TWL6030_IRQ_BASE,
458         .irq_end        = TWL6030_IRQ_END,
459
460         /* Regulators */
461         .vmmc           = &sdp4430_vmmc,
462         .vpp            = &sdp4430_vpp,
463         .vusim          = &sdp4430_vusim,
464         .vana           = &sdp4430_vana,
465         .vcxio          = &sdp4430_vcxio,
466         .vdac           = &sdp4430_vdac,
467         .vusb           = &sdp4430_vusb,
468         .vaux1          = &sdp4430_vaux1,
469         .vaux2          = &sdp4430_vaux2,
470         .vaux3          = &sdp4430_vaux3,
471         .usb            = &omap4_usbphy_data
472 };
473
474 static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
475         {
476                 I2C_BOARD_INFO("twl6030", 0x48),
477                 .flags = I2C_CLIENT_WAKE,
478                 .irq = OMAP44XX_IRQ_SYS_1N,
479                 .platform_data = &sdp4430_twldata,
480         },
481 };
482 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
483         {
484                 I2C_BOARD_INFO("tmp105", 0x48),
485         },
486 };
487 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
488         {
489                 I2C_BOARD_INFO("hmc5843", 0x1e),
490         },
491 };
492 static int __init omap4_i2c_init(void)
493 {
494         /*
495          * Phoenix Audio IC needs I2C1 to
496          * start with 400 KHz or less
497          */
498         omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
499                         ARRAY_SIZE(sdp4430_i2c_boardinfo));
500         omap_register_i2c_bus(2, 400, NULL, 0);
501         omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
502                                 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
503         omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
504                                 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
505         return 0;
506 }
507
508 static void __init omap_sfh7741prox_init(void)
509 {
510         int  error;
511
512         error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
513         if (error < 0) {
514                 pr_err("%s:failed to request GPIO %d, error %d\n",
515                         __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
516                 return;
517         }
518
519         error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
520         if (error < 0) {
521                 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
522                          __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
523                 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
524         }
525 }
526
527 static void __init omap_4430sdp_init(void)
528 {
529         int status;
530
531         omap4_i2c_init();
532         omap_sfh7741prox_init();
533         platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
534         omap_serial_init();
535         omap4_twl6030_hsmmc_init(mmc);
536
537         /* Power on the ULPI PHY */
538         if (gpio_is_valid(OMAP4SDP_MDM_PWR_EN_GPIO)) {
539                 /* FIXME: Assumes pad is already muxed for GPIO mode */
540                 gpio_request(OMAP4SDP_MDM_PWR_EN_GPIO, "USBB1 PHY VMDM_3V3");
541                 gpio_direction_output(OMAP4SDP_MDM_PWR_EN_GPIO, 1);
542         }
543         usb_ehci_init(&ehci_pdata);
544         usb_musb_init(&musb_board_data);
545
546         status = omap_ethernet_init();
547         if (status) {
548                 pr_err("Ethernet initialization failed: %d\n", status);
549         } else {
550                 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
551                 spi_register_board_info(sdp4430_spi_board_info,
552                                 ARRAY_SIZE(sdp4430_spi_board_info));
553         }
554 }
555
556 static void __init omap_4430sdp_map_io(void)
557 {
558         omap2_set_globals_443x();
559         omap44xx_map_common_io();
560 }
561
562 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
563         /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
564         .boot_params    = 0x80000100,
565         .map_io         = omap_4430sdp_map_io,
566         .reserve        = omap_reserve,
567         .init_irq       = omap_4430sdp_init_irq,
568         .init_machine   = omap_4430sdp_init,
569         .timer          = &omap_timer,
570 MACHINE_END