omap3: Use timing data for omap2_init_common_hw on IGEP v2
[safe/jmp/linux-2.6] / arch / arm / mach-omap2 / board-igep0020.c
1 /*
2  * Copyright (C) 2009 Integration Software and Electronic Engineering.
3  *
4  * Modified from mach-omap2/board-generic.c
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/err.h>
16 #include <linux/clk.h>
17 #include <linux/io.h>
18 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
20
21 #include <linux/regulator/machine.h>
22 #include <linux/i2c/twl.h>
23
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26
27 #include <plat/board.h>
28 #include <plat/common.h>
29 #include <plat/gpmc.h>
30 #include <plat/usb.h>
31 #include <plat/display.h>
32 #include <plat/onenand.h>
33
34 #include "mux.h"
35 #include "hsmmc.h"
36 #include "sdram-numonyx-m65kxxxxam.h"
37
38 #define IGEP2_SMSC911X_CS       5
39 #define IGEP2_SMSC911X_GPIO     176
40 #define IGEP2_GPIO_USBH_NRESET  24
41 #define IGEP2_GPIO_LED0_RED     26
42 #define IGEP2_GPIO_LED0_GREEN   27
43 #define IGEP2_GPIO_LED1_RED     28
44 #define IGEP2_GPIO_DVI_PUP      170
45
46 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
47         defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
48
49 #define ONENAND_MAP             0x20000000
50
51 /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
52  * Since the device is equipped with two DataRAMs, and two-plane NAND
53  * Flash memory array, these two component enables simultaneous program
54  * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
55  * while Plane2 has only odd blocks such as block1, block3, block5.
56  * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
57  */
58
59 static struct mtd_partition igep2_onenand_partitions[] = {
60         {
61                 .name           = "X-Loader",
62                 .offset         = 0,
63                 .size           = 2 * (64*(2*2048))
64         },
65         {
66                 .name           = "U-Boot",
67                 .offset         = MTDPART_OFS_APPEND,
68                 .size           = 6 * (64*(2*2048)),
69         },
70         {
71                 .name           = "Environment",
72                 .offset         = MTDPART_OFS_APPEND,
73                 .size           = 2 * (64*(2*2048)),
74         },
75         {
76                 .name           = "Kernel",
77                 .offset         = MTDPART_OFS_APPEND,
78                 .size           = 12 * (64*(2*2048)),
79         },
80         {
81                 .name           = "File System",
82                 .offset         = MTDPART_OFS_APPEND,
83                 .size           = MTDPART_SIZ_FULL,
84         },
85 };
86
87 static int igep2_onenand_setup(void __iomem *onenand_base, int freq)
88 {
89        /* nothing is required to be setup for onenand as of now */
90        return 0;
91 }
92
93 static struct omap_onenand_platform_data igep2_onenand_data = {
94         .parts = igep2_onenand_partitions,
95         .nr_parts = ARRAY_SIZE(igep2_onenand_partitions),
96         .onenand_setup = igep2_onenand_setup,
97         .dma_channel    = -1,   /* disable DMA in OMAP OneNAND driver */
98 };
99
100 static struct platform_device igep2_onenand_device = {
101         .name           = "omap2-onenand",
102         .id             = -1,
103         .dev = {
104                 .platform_data = &igep2_onenand_data,
105         },
106 };
107
108 void __init igep2_flash_init(void)
109 {
110         u8              cs = 0;
111         u8              onenandcs = GPMC_CS_NUM + 1;
112
113         while (cs < GPMC_CS_NUM) {
114                 u32 ret = 0;
115                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
116
117                 /* Check if NAND/oneNAND is configured */
118                 if ((ret & 0xC00) == 0x800)
119                         /* NAND found */
120                         pr_err("IGEP v2: Unsupported NAND found\n");
121                 else {
122                         ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
123                         if ((ret & 0x3F) == (ONENAND_MAP >> 24))
124                                 /* ONENAND found */
125                                 onenandcs = cs;
126                 }
127                 cs++;
128         }
129         if (onenandcs > GPMC_CS_NUM) {
130                 pr_err("IGEP v2: Unable to find configuration in GPMC\n");
131                 return;
132         }
133
134         if (onenandcs < GPMC_CS_NUM) {
135                 igep2_onenand_data.cs = onenandcs;
136                 if (platform_device_register(&igep2_onenand_device) < 0)
137                         pr_err("IGEP v2: Unable to register OneNAND device\n");
138         }
139 }
140
141 #else
142 void __init igep2_flash_init(void) {}
143 #endif
144
145 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
146
147 #include <linux/smsc911x.h>
148
149 static struct smsc911x_platform_config igep2_smsc911x_config = {
150         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
151         .irq_type       = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
152         .flags          = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS  ,
153         .phy_interface  = PHY_INTERFACE_MODE_MII,
154 };
155
156 static struct resource igep2_smsc911x_resources[] = {
157         {
158                 .flags  = IORESOURCE_MEM,
159         },
160         {
161                 .start  = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
162                 .end    = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
163                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
164         },
165 };
166
167 static struct platform_device igep2_smsc911x_device = {
168         .name           = "smsc911x",
169         .id             = 0,
170         .num_resources  = ARRAY_SIZE(igep2_smsc911x_resources),
171         .resource       = igep2_smsc911x_resources,
172         .dev            = {
173                 .platform_data = &igep2_smsc911x_config,
174         },
175 };
176
177 static inline void __init igep2_init_smsc911x(void)
178 {
179         unsigned long cs_mem_base;
180
181         if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
182                 pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
183                 gpmc_cs_free(IGEP2_SMSC911X_CS);
184                 return;
185         }
186
187         igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
188         igep2_smsc911x_resources[0].end   = cs_mem_base + 0xff;
189
190         if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
191             (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
192                 gpio_export(IGEP2_SMSC911X_GPIO, 0);
193         } else {
194                 pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
195                 return;
196         }
197
198         platform_device_register(&igep2_smsc911x_device);
199 }
200
201 #else
202 static inline void __init igep2_init_smsc911x(void) { }
203 #endif
204
205 static struct omap_board_config_kernel igep2_config[] __initdata = {
206 };
207
208 static struct regulator_consumer_supply igep2_vmmc1_supply = {
209         .supply         = "vmmc",
210 };
211
212 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
213 static struct regulator_init_data igep2_vmmc1 = {
214         .constraints = {
215                 .min_uV                 = 1850000,
216                 .max_uV                 = 3150000,
217                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
218                                         | REGULATOR_MODE_STANDBY,
219                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
220                                         | REGULATOR_CHANGE_MODE
221                                         | REGULATOR_CHANGE_STATUS,
222         },
223         .num_consumer_supplies  = 1,
224         .consumer_supplies      = &igep2_vmmc1_supply,
225 };
226
227 static struct omap2_hsmmc_info mmc[] = {
228         {
229                 .mmc            = 1,
230                 .wires          = 4,
231                 .gpio_cd        = -EINVAL,
232                 .gpio_wp        = -EINVAL,
233         },
234         {
235                 .mmc            = 2,
236                 .wires          = 4,
237                 .gpio_cd        = -EINVAL,
238                 .gpio_wp        = -EINVAL,
239         },
240         {}      /* Terminator */
241 };
242
243 static int igep2_twl_gpio_setup(struct device *dev,
244                 unsigned gpio, unsigned ngpio)
245 {
246         /* gpio + 0 is "mmc0_cd" (input/IRQ) */
247         mmc[0].gpio_cd = gpio + 0;
248         omap2_hsmmc_init(mmc);
249
250         /* link regulators to MMC adapters ... we "know" the
251          * regulators will be set up only *after* we return.
252         */
253         igep2_vmmc1_supply.dev = mmc[0].dev;
254
255         return 0;
256 };
257
258 static struct twl4030_gpio_platform_data igep2_gpio_data = {
259         .gpio_base      = OMAP_MAX_GPIO_LINES,
260         .irq_base       = TWL4030_GPIO_IRQ_BASE,
261         .irq_end        = TWL4030_GPIO_IRQ_END,
262         .use_leds       = false,
263         .setup          = igep2_twl_gpio_setup,
264 };
265
266 static struct twl4030_usb_data igep2_usb_data = {
267         .usb_mode       = T2_USB_MODE_ULPI,
268 };
269
270 static int igep2_enable_dvi(struct omap_dss_device *dssdev)
271 {
272         gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
273
274         return 0;
275 }
276
277 static void igep2_disable_dvi(struct omap_dss_device *dssdev)
278 {
279         gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
280 }
281
282 static struct omap_dss_device igep2_dvi_device = {
283         .type                   = OMAP_DISPLAY_TYPE_DPI,
284         .name                   = "dvi",
285         .driver_name            = "generic_panel",
286         .phy.dpi.data_lines     = 24,
287         .platform_enable        = igep2_enable_dvi,
288         .platform_disable       = igep2_disable_dvi,
289 };
290
291 static struct omap_dss_device *igep2_dss_devices[] = {
292         &igep2_dvi_device
293 };
294
295 static struct omap_dss_board_info igep2_dss_data = {
296         .num_devices    = ARRAY_SIZE(igep2_dss_devices),
297         .devices        = igep2_dss_devices,
298         .default_device = &igep2_dvi_device,
299 };
300
301 static struct platform_device igep2_dss_device = {
302         .name   = "omapdss",
303         .id     = -1,
304         .dev    = {
305                 .platform_data = &igep2_dss_data,
306         },
307 };
308
309 static struct regulator_consumer_supply igep2_vpll2_supply = {
310         .supply = "vdds_dsi",
311         .dev    = &igep2_dss_device.dev,
312 };
313
314 static struct regulator_init_data igep2_vpll2 = {
315         .constraints = {
316                 .name                   = "VDVI",
317                 .min_uV                 = 1800000,
318                 .max_uV                 = 1800000,
319                 .apply_uV               = true,
320                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
321                                         | REGULATOR_MODE_STANDBY,
322                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
323                                         | REGULATOR_CHANGE_STATUS,
324         },
325         .num_consumer_supplies  = 1,
326         .consumer_supplies      = &igep2_vpll2_supply,
327 };
328
329 static void __init igep2_display_init(void)
330 {
331         if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
332             gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
333                 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
334 }
335
336 static struct platform_device *igep2_devices[] __initdata = {
337         &igep2_dss_device,
338 };
339
340 static void __init igep2_init_irq(void)
341 {
342         omap_board_config = igep2_config;
343         omap_board_config_size = ARRAY_SIZE(igep2_config);
344         omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
345         omap_init_irq();
346         omap_gpio_init();
347 }
348
349 static struct twl4030_codec_audio_data igep2_audio_data = {
350         .audio_mclk = 26000000,
351 };
352
353 static struct twl4030_codec_data igep2_codec_data = {
354         .audio_mclk = 26000000,
355         .audio = &igep2_audio_data,
356 };
357
358 static struct twl4030_platform_data igep2_twldata = {
359         .irq_base       = TWL4030_IRQ_BASE,
360         .irq_end        = TWL4030_IRQ_END,
361
362         /* platform_data for children goes here */
363         .usb            = &igep2_usb_data,
364         .codec          = &igep2_codec_data,
365         .gpio           = &igep2_gpio_data,
366         .vmmc1          = &igep2_vmmc1,
367         .vpll2          = &igep2_vpll2,
368
369 };
370
371 static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
372         {
373                 I2C_BOARD_INFO("twl4030", 0x48),
374                 .flags          = I2C_CLIENT_WAKE,
375                 .irq            = INT_34XX_SYS_NIRQ,
376                 .platform_data  = &igep2_twldata,
377         },
378 };
379
380 static int __init igep2_i2c_init(void)
381 {
382         omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
383                         ARRAY_SIZE(igep2_i2c_boardinfo));
384         /* Bus 3 is attached to the DVI port where devices like the pico DLP
385          * projector don't work reliably with 400kHz */
386         omap_register_i2c_bus(3, 100, NULL, 0);
387         return 0;
388 }
389
390 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
391         .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
392         .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
393         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
394
395         .phy_reset = true,
396         .reset_gpio_port[0] = -EINVAL,
397         .reset_gpio_port[1] = IGEP2_GPIO_USBH_NRESET,
398         .reset_gpio_port[2] = -EINVAL,
399 };
400
401 #ifdef CONFIG_OMAP_MUX
402 static struct omap_board_mux board_mux[] __initdata = {
403         { .reg_offset = OMAP_MUX_TERMINATOR },
404 };
405 #else
406 #define board_mux       NULL
407 #endif
408
409 static void __init igep2_init(void)
410 {
411         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
412         igep2_i2c_init();
413         platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
414         omap_serial_init();
415         usb_musb_init();
416         usb_ehci_init(&ehci_pdata);
417
418         igep2_flash_init();
419         igep2_display_init();
420         igep2_init_smsc911x();
421
422         /* GPIO userspace leds */
423         if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
424             (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
425                 gpio_export(IGEP2_GPIO_LED0_RED, 0);
426                 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
427         } else
428                 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
429
430         if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
431             (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
432                 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
433                 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
434         } else
435                 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
436
437         if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
438             (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
439                 gpio_export(IGEP2_GPIO_LED1_RED, 0);
440                 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
441         } else
442                 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
443 }
444
445 static void __init igep2_map_io(void)
446 {
447         omap2_set_globals_343x();
448         omap34xx_map_common_io();
449 }
450
451 MACHINE_START(IGEP0020, "IGEP v2 board")
452         .phys_io        = 0x48000000,
453         .io_pg_offst    = ((0xfa000000) >> 18) & 0xfffc,
454         .boot_params    = 0x80000100,
455         .map_io         = igep2_map_io,
456         .init_irq       = igep2_init_irq,
457         .init_machine   = igep2_init,
458         .timer          = &omap_timer,
459 MACHINE_END