omap2plus: clockdomain: Trivial fix for build break because of clktrctrl_mask
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap4panda.c
1 /*
2  * Board support file for OMAP4430 based PandaBoard.
3  *
4  * Copyright (C) 2010 Texas Instruments
5  *
6  * Author: David Anders <x0132446@ti.com>
7  *
8  * Based on mach-omap2/board-4430sdp.c
9  *
10  * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
11  *
12  * Based on mach-omap2/board-3430sdp.c
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2 as
16  * published by the Free Software Foundation.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/io.h>
23 #include <linux/leds.h>
24 #include <linux/gpio.h>
25 #include <linux/usb/otg.h>
26 #include <linux/i2c/twl.h>
27 #include <linux/regulator/machine.h>
28
29 #include <mach/hardware.h>
30 #include <mach/omap4-common.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34
35 #include <plat/board.h>
36 #include <plat/common.h>
37 #include <plat/usb.h>
38 #include <plat/mmc.h>
39 #include "timer-gp.h"
40
41 #include "hsmmc.h"
42 #include "control.h"
43 #include "mux.h"
44
45 #define GPIO_HUB_POWER          1
46 #define GPIO_HUB_NRESET         62
47
48 static struct gpio_led gpio_leds[] = {
49         {
50                 .name                   = "pandaboard::status1",
51                 .default_trigger        = "heartbeat",
52                 .gpio                   = 7,
53         },
54         {
55                 .name                   = "pandaboard::status2",
56                 .default_trigger        = "mmc0",
57                 .gpio                   = 8,
58         },
59 };
60
61 static struct gpio_led_platform_data gpio_led_info = {
62         .leds           = gpio_leds,
63         .num_leds       = ARRAY_SIZE(gpio_leds),
64 };
65
66 static struct platform_device leds_gpio = {
67         .name   = "leds-gpio",
68         .id     = -1,
69         .dev    = {
70                 .platform_data  = &gpio_led_info,
71         },
72 };
73
74 static struct platform_device *panda_devices[] __initdata = {
75         &leds_gpio,
76 };
77
78 static void __init omap4_panda_init_irq(void)
79 {
80         omap2_init_common_infrastructure();
81         omap2_init_common_devices(NULL, NULL);
82         gic_init_irq();
83 }
84
85 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
86         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
87         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
88         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
89         .phy_reset  = false,
90         .reset_gpio_port[0]  = -EINVAL,
91         .reset_gpio_port[1]  = -EINVAL,
92         .reset_gpio_port[2]  = -EINVAL
93 };
94
95 static void __init omap4_ehci_init(void)
96 {
97         int ret;
98
99
100         /* disable the power to the usb hub prior to init */
101         ret = gpio_request(GPIO_HUB_POWER, "hub_power");
102         if (ret) {
103                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
104                 goto error1;
105         }
106         gpio_export(GPIO_HUB_POWER, 0);
107         gpio_direction_output(GPIO_HUB_POWER, 0);
108         gpio_set_value(GPIO_HUB_POWER, 0);
109
110         /* reset phy+hub */
111         ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
112         if (ret) {
113                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
114                 goto error2;
115         }
116         gpio_export(GPIO_HUB_NRESET, 0);
117         gpio_direction_output(GPIO_HUB_NRESET, 0);
118         gpio_set_value(GPIO_HUB_NRESET, 0);
119         gpio_set_value(GPIO_HUB_NRESET, 1);
120
121         usb_ehci_init(&ehci_pdata);
122
123         /* enable power to hub */
124         gpio_set_value(GPIO_HUB_POWER, 1);
125         return;
126
127 error2:
128         gpio_free(GPIO_HUB_POWER);
129 error1:
130         pr_err("Unable to initialize EHCI power/reset\n");
131         return;
132
133 }
134
135 static struct omap_musb_board_data musb_board_data = {
136         .interface_type         = MUSB_INTERFACE_UTMI,
137         .mode                   = MUSB_PERIPHERAL,
138         .power                  = 100,
139 };
140
141 static struct omap2_hsmmc_info mmc[] = {
142         {
143                 .mmc            = 1,
144                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
145                 .gpio_wp        = -EINVAL,
146                 .gpio_cd        = -EINVAL,
147         },
148         {}      /* Terminator */
149 };
150
151 static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
152         {
153                 .supply = "vmmc",
154                 .dev_name = "mmci-omap-hs.0",
155         },
156 };
157
158 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
159 {
160         int ret = 0;
161         struct platform_device *pdev = container_of(dev,
162                                 struct platform_device, dev);
163         struct omap_mmc_platform_data *pdata = dev->platform_data;
164
165         if (!pdata) {
166                 dev_err(dev, "%s: NULL platform data\n", __func__);
167                 return -EINVAL;
168         }
169         /* Setting MMC1 Card detect Irq */
170         if (pdev->id == 0) {
171                 ret = twl6030_mmc_card_detect_config();
172                  if (ret)
173                         dev_err(dev, "%s: Error card detect config(%d)\n",
174                                 __func__, ret);
175                  else
176                         pdata->slots[0].card_detect = twl6030_mmc_card_detect;
177         }
178         return ret;
179 }
180
181 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
182 {
183         struct omap_mmc_platform_data *pdata;
184
185         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
186         if (!dev) {
187                 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
188                 return;
189         }
190         pdata = dev->platform_data;
191
192         pdata->init =   omap4_twl6030_hsmmc_late_init;
193 }
194
195 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
196 {
197         struct omap2_hsmmc_info *c;
198
199         omap2_hsmmc_init(controllers);
200         for (c = controllers; c->mmc; c++)
201                 omap4_twl6030_hsmmc_set_late_init(c->dev);
202
203         return 0;
204 }
205
206 static struct regulator_init_data omap4_panda_vaux1 = {
207         .constraints = {
208                 .min_uV                 = 1000000,
209                 .max_uV                 = 3000000,
210                 .apply_uV               = true,
211                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
212                                         | REGULATOR_MODE_STANDBY,
213                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
214                                         | REGULATOR_CHANGE_MODE
215                                         | REGULATOR_CHANGE_STATUS,
216         },
217 };
218
219 static struct regulator_init_data omap4_panda_vaux2 = {
220         .constraints = {
221                 .min_uV                 = 1200000,
222                 .max_uV                 = 2800000,
223                 .apply_uV               = true,
224                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
225                                         | REGULATOR_MODE_STANDBY,
226                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
227                                         | REGULATOR_CHANGE_MODE
228                                         | REGULATOR_CHANGE_STATUS,
229         },
230 };
231
232 static struct regulator_init_data omap4_panda_vaux3 = {
233         .constraints = {
234                 .min_uV                 = 1000000,
235                 .max_uV                 = 3000000,
236                 .apply_uV               = true,
237                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
238                                         | REGULATOR_MODE_STANDBY,
239                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
240                                         | REGULATOR_CHANGE_MODE
241                                         | REGULATOR_CHANGE_STATUS,
242         },
243 };
244
245 /* VMMC1 for MMC1 card */
246 static struct regulator_init_data omap4_panda_vmmc = {
247         .constraints = {
248                 .min_uV                 = 1200000,
249                 .max_uV                 = 3000000,
250                 .apply_uV               = true,
251                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
252                                         | REGULATOR_MODE_STANDBY,
253                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
254                                         | REGULATOR_CHANGE_MODE
255                                         | REGULATOR_CHANGE_STATUS,
256         },
257         .num_consumer_supplies  = 1,
258         .consumer_supplies      = omap4_panda_vmmc_supply,
259 };
260
261 static struct regulator_init_data omap4_panda_vpp = {
262         .constraints = {
263                 .min_uV                 = 1800000,
264                 .max_uV                 = 2500000,
265                 .apply_uV               = true,
266                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
267                                         | REGULATOR_MODE_STANDBY,
268                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
269                                         | REGULATOR_CHANGE_MODE
270                                         | REGULATOR_CHANGE_STATUS,
271         },
272 };
273
274 static struct regulator_init_data omap4_panda_vusim = {
275         .constraints = {
276                 .min_uV                 = 1200000,
277                 .max_uV                 = 2900000,
278                 .apply_uV               = true,
279                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
280                                         | REGULATOR_MODE_STANDBY,
281                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
282                                         | REGULATOR_CHANGE_MODE
283                                         | REGULATOR_CHANGE_STATUS,
284         },
285 };
286
287 static struct regulator_init_data omap4_panda_vana = {
288         .constraints = {
289                 .min_uV                 = 2100000,
290                 .max_uV                 = 2100000,
291                 .apply_uV               = true,
292                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
293                                         | REGULATOR_MODE_STANDBY,
294                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
295                                         | REGULATOR_CHANGE_STATUS,
296         },
297 };
298
299 static struct regulator_init_data omap4_panda_vcxio = {
300         .constraints = {
301                 .min_uV                 = 1800000,
302                 .max_uV                 = 1800000,
303                 .apply_uV               = true,
304                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
305                                         | REGULATOR_MODE_STANDBY,
306                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
307                                         | REGULATOR_CHANGE_STATUS,
308         },
309 };
310
311 static struct regulator_init_data omap4_panda_vdac = {
312         .constraints = {
313                 .min_uV                 = 1800000,
314                 .max_uV                 = 1800000,
315                 .apply_uV               = true,
316                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
317                                         | REGULATOR_MODE_STANDBY,
318                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
319                                         | REGULATOR_CHANGE_STATUS,
320         },
321 };
322
323 static struct regulator_init_data omap4_panda_vusb = {
324         .constraints = {
325                 .min_uV                 = 3300000,
326                 .max_uV                 = 3300000,
327                 .apply_uV               = true,
328                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
329                                         | REGULATOR_MODE_STANDBY,
330                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
331                                         | REGULATOR_CHANGE_STATUS,
332         },
333 };
334
335 static struct twl4030_platform_data omap4_panda_twldata = {
336         .irq_base       = TWL6030_IRQ_BASE,
337         .irq_end        = TWL6030_IRQ_END,
338
339         /* Regulators */
340         .vmmc           = &omap4_panda_vmmc,
341         .vpp            = &omap4_panda_vpp,
342         .vusim          = &omap4_panda_vusim,
343         .vana           = &omap4_panda_vana,
344         .vcxio          = &omap4_panda_vcxio,
345         .vdac           = &omap4_panda_vdac,
346         .vusb           = &omap4_panda_vusb,
347         .vaux1          = &omap4_panda_vaux1,
348         .vaux2          = &omap4_panda_vaux2,
349         .vaux3          = &omap4_panda_vaux3,
350 };
351
352 static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
353         {
354                 I2C_BOARD_INFO("twl6030", 0x48),
355                 .flags = I2C_CLIENT_WAKE,
356                 .irq = OMAP44XX_IRQ_SYS_1N,
357                 .platform_data = &omap4_panda_twldata,
358         },
359 };
360 static int __init omap4_panda_i2c_init(void)
361 {
362         /*
363          * Phoenix Audio IC needs I2C1 to
364          * start with 400 KHz or less
365          */
366         omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
367                         ARRAY_SIZE(omap4_panda_i2c_boardinfo));
368         omap_register_i2c_bus(2, 400, NULL, 0);
369         omap_register_i2c_bus(3, 400, NULL, 0);
370         omap_register_i2c_bus(4, 400, NULL, 0);
371         return 0;
372 }
373
374 #ifdef CONFIG_OMAP_MUX
375 static struct omap_board_mux board_mux[] __initdata = {
376         { .reg_offset = OMAP_MUX_TERMINATOR },
377 };
378 #else
379 #define board_mux       NULL
380 #endif
381
382 static void __init omap4_panda_init(void)
383 {
384         int package = OMAP_PACKAGE_CBS;
385
386         if (omap_rev() == OMAP4430_REV_ES1_0)
387                 package = OMAP_PACKAGE_CBL;
388         omap4_mux_init(board_mux, package);
389
390         omap4_panda_i2c_init();
391         platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
392         omap_serial_init();
393         omap4_twl6030_hsmmc_init(mmc);
394         /* OMAP4 Panda uses internal transceiver so register nop transceiver */
395         usb_nop_xceiv_register();
396         omap4_ehci_init();
397         /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
398         if (!cpu_is_omap44xx())
399                 usb_musb_init(&musb_board_data);
400 }
401
402 static void __init omap4_panda_map_io(void)
403 {
404         omap2_set_globals_443x();
405         omap44xx_map_common_io();
406 }
407
408 MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
409         /* Maintainer: David Anders - Texas Instruments Inc */
410         .boot_params    = 0x80000100,
411         .reserve        = omap_reserve,
412         .map_io         = omap4_panda_map_io,
413         .init_irq       = omap4_panda_init_irq,
414         .init_machine   = omap4_panda_init,
415         .timer          = &omap_timer,
416 MACHINE_END