omap4: add i2c1 peripherals data
[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/regulator/machine.h>
24
25 #include <mach/hardware.h>
26 #include <mach/omap4-common.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30
31 #include <plat/board.h>
32 #include <plat/common.h>
33 #include <plat/control.h>
34 #include <plat/timer-gp.h>
35 #include <plat/usb.h>
36
37 #define ETH_KS8851_IRQ                  34
38 #define ETH_KS8851_POWER_ON             48
39 #define ETH_KS8851_QUART                138
40
41 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
42         {
43                 .modalias               = "ks8851",
44                 .bus_num                = 1,
45                 .chip_select            = 0,
46                 .max_speed_hz           = 24000000,
47                 .irq                    = ETH_KS8851_IRQ,
48         },
49 };
50
51 static int omap_ethernet_init(void)
52 {
53         int status;
54
55         /* Request of GPIO lines */
56
57         status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
58         if (status) {
59                 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
60                 return status;
61         }
62
63         status = gpio_request(ETH_KS8851_QUART, "quart");
64         if (status) {
65                 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
66                 goto error1;
67         }
68
69         status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
70         if (status) {
71                 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
72                 goto error2;
73         }
74
75         /* Configuration of requested GPIO lines */
76
77         status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
78         if (status) {
79                 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
80                 goto error3;
81         }
82
83         status = gpio_direction_output(ETH_KS8851_QUART, 1);
84         if (status) {
85                 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
86                 goto error3;
87         }
88
89         status = gpio_direction_input(ETH_KS8851_IRQ);
90         if (status) {
91                 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
92                 goto error3;
93         }
94
95         return 0;
96
97 error3:
98         gpio_free(ETH_KS8851_IRQ);
99 error2:
100         gpio_free(ETH_KS8851_QUART);
101 error1:
102         gpio_free(ETH_KS8851_POWER_ON);
103         return status;
104 }
105
106 static struct platform_device sdp4430_lcd_device = {
107         .name           = "sdp4430_lcd",
108         .id             = -1,
109 };
110
111 static struct platform_device *sdp4430_devices[] __initdata = {
112         &sdp4430_lcd_device,
113 };
114
115 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
116         .ctrl_name      = "internal",
117 };
118
119 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
120         { OMAP_TAG_LCD,         &sdp4430_lcd_config },
121 };
122
123 static void __init omap_4430sdp_init_irq(void)
124 {
125         omap_board_config = sdp4430_config;
126         omap_board_config_size = ARRAY_SIZE(sdp4430_config);
127         omap2_init_common_hw(NULL, NULL);
128 #ifdef CONFIG_OMAP_32K_TIMER
129         omap2_gp_clockevent_set_gptimer(1);
130 #endif
131         gic_init_irq();
132         omap_gpio_init();
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 static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
141         {
142                 .supply = "vmmc",
143         },
144         {
145                 .supply = "vmmc",
146         },
147         {
148                 .supply = "vmmc",
149         },
150         {
151                 .supply = "vmmc",
152         },
153         {
154                 .supply = "vmmc",
155         },
156 };
157
158 static struct regulator_init_data sdp4430_vaux1 = {
159         .constraints = {
160                 .min_uV                 = 1000000,
161                 .max_uV                 = 3000000,
162                 .apply_uV               = true,
163                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
164                                         | REGULATOR_MODE_STANDBY,
165                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
166                                         | REGULATOR_CHANGE_MODE
167                                         | REGULATOR_CHANGE_STATUS,
168         },
169 };
170
171 static struct regulator_init_data sdp4430_vaux2 = {
172         .constraints = {
173                 .min_uV                 = 1200000,
174                 .max_uV                 = 2800000,
175                 .apply_uV               = true,
176                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
177                                         | REGULATOR_MODE_STANDBY,
178                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
179                                         | REGULATOR_CHANGE_MODE
180                                         | REGULATOR_CHANGE_STATUS,
181         },
182 };
183
184 static struct regulator_init_data sdp4430_vaux3 = {
185         .constraints = {
186                 .min_uV                 = 1000000,
187                 .max_uV                 = 3000000,
188                 .apply_uV               = true,
189                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
190                                         | REGULATOR_MODE_STANDBY,
191                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
192                                         | REGULATOR_CHANGE_MODE
193                                         | REGULATOR_CHANGE_STATUS,
194         },
195 };
196
197 /* VMMC1 for MMC1 card */
198 static struct regulator_init_data sdp4430_vmmc = {
199         .constraints = {
200                 .min_uV                 = 1200000,
201                 .max_uV                 = 3000000,
202                 .apply_uV               = true,
203                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
204                                         | REGULATOR_MODE_STANDBY,
205                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
206                                         | REGULATOR_CHANGE_MODE
207                                         | REGULATOR_CHANGE_STATUS,
208         },
209         .num_consumer_supplies  = 5,
210         .consumer_supplies      = sdp4430_vmmc_supply,
211 };
212
213 static struct regulator_init_data sdp4430_vpp = {
214         .constraints = {
215                 .min_uV                 = 1800000,
216                 .max_uV                 = 2500000,
217                 .apply_uV               = true,
218                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
219                                         | REGULATOR_MODE_STANDBY,
220                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
221                                         | REGULATOR_CHANGE_MODE
222                                         | REGULATOR_CHANGE_STATUS,
223         },
224 };
225
226 static struct regulator_init_data sdp4430_vusim = {
227         .constraints = {
228                 .min_uV                 = 1200000,
229                 .max_uV                 = 2900000,
230                 .apply_uV               = true,
231                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
232                                         | REGULATOR_MODE_STANDBY,
233                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
234                                         | REGULATOR_CHANGE_MODE
235                                         | REGULATOR_CHANGE_STATUS,
236         },
237 };
238
239 static struct regulator_init_data sdp4430_vana = {
240         .constraints = {
241                 .min_uV                 = 2100000,
242                 .max_uV                 = 2100000,
243                 .apply_uV               = true,
244                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
245                                         | REGULATOR_MODE_STANDBY,
246                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
247                                         | REGULATOR_CHANGE_STATUS,
248         },
249 };
250
251 static struct regulator_init_data sdp4430_vcxio = {
252         .constraints = {
253                 .min_uV                 = 1800000,
254                 .max_uV                 = 1800000,
255                 .apply_uV               = true,
256                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
257                                         | REGULATOR_MODE_STANDBY,
258                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
259                                         | REGULATOR_CHANGE_STATUS,
260         },
261 };
262
263 static struct regulator_init_data sdp4430_vdac = {
264         .constraints = {
265                 .min_uV                 = 1800000,
266                 .max_uV                 = 1800000,
267                 .apply_uV               = true,
268                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
269                                         | REGULATOR_MODE_STANDBY,
270                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
271                                         | REGULATOR_CHANGE_STATUS,
272         },
273 };
274
275 static struct regulator_init_data sdp4430_vusb = {
276         .constraints = {
277                 .min_uV                 = 3300000,
278                 .max_uV                 = 3300000,
279                 .apply_uV               = true,
280                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
281                                         | REGULATOR_MODE_STANDBY,
282                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
283                                         | REGULATOR_CHANGE_STATUS,
284         },
285 };
286
287 static struct twl4030_platform_data sdp4430_twldata = {
288         .irq_base       = TWL6030_IRQ_BASE,
289         .irq_end        = TWL6030_IRQ_END,
290
291         /* Regulators */
292         .vmmc           = &sdp4430_vmmc,
293         .vpp            = &sdp4430_vpp,
294         .vusim          = &sdp4430_vusim,
295         .vana           = &sdp4430_vana,
296         .vcxio          = &sdp4430_vcxio,
297         .vdac           = &sdp4430_vdac,
298         .vusb           = &sdp4430_vusb,
299         .vaux1          = &sdp4430_vaux1,
300         .vaux2          = &sdp4430_vaux2,
301         .vaux3          = &sdp4430_vaux3,
302 };
303
304 static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
305         {
306                 I2C_BOARD_INFO("twl6030", 0x48),
307                 .flags = I2C_CLIENT_WAKE,
308                 .irq = OMAP44XX_IRQ_SYS_1N,
309                 .platform_data = &sdp4430_twldata,
310         },
311 };
312 static int __init omap4_i2c_init(void)
313 {
314         /*
315          * Phoenix Audio IC needs I2C1 to
316          * start with 400 KHz or less
317          */
318         omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
319                         ARRAY_SIZE(sdp4430_i2c_boardinfo));
320         omap_register_i2c_bus(2, 400, NULL, 0);
321         omap_register_i2c_bus(3, 400, NULL, 0);
322         omap_register_i2c_bus(4, 400, NULL, 0);
323         return 0;
324 }
325 static void __init omap_4430sdp_init(void)
326 {
327         int status;
328
329         omap4_i2c_init();
330         platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
331         omap_serial_init();
332         /* OMAP4 SDP uses internal transceiver so register nop transceiver */
333         usb_nop_xceiv_register();
334         /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
335         if (!cpu_is_omap44xx())
336                 usb_musb_init(&musb_board_data);
337
338         status = omap_ethernet_init();
339         if (status) {
340                 pr_err("Ethernet initialization failed: %d\n", status);
341         } else {
342                 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
343                 spi_register_board_info(sdp4430_spi_board_info,
344                                 ARRAY_SIZE(sdp4430_spi_board_info));
345         }
346 }
347
348 static void __init omap_4430sdp_map_io(void)
349 {
350         omap2_set_globals_443x();
351         omap44xx_map_common_io();
352 }
353
354 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
355         /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
356         .phys_io        = 0x48000000,
357         .io_pg_offst    = ((0xfa000000) >> 18) & 0xfffc,
358         .boot_params    = 0x80000100,
359         .map_io         = omap_4430sdp_map_io,
360         .init_irq       = omap_4430sdp_init_irq,
361         .init_machine   = omap_4430sdp_init,
362         .timer          = &omap_timer,
363 MACHINE_END