davinci: am18x/da850/omap-l138 evm: setup NAND flash timing
[pandora-kernel.git] / arch / arm / mach-davinci / board-da850-evm.c
1 /*
2  * TI DA850/OMAP-L138 EVM board
3  *
4  * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5  *
6  * Derived from: arch/arm/mach-davinci/board-da830-evm.c
7  * Original Copyrights follow:
8  *
9  * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
10  * the terms of the GNU General Public License version 2. This program
11  * is licensed "as is" without any warranty of any kind, whether express
12  * or implied.
13  */
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/console.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/at24.h>
19 #include <linux/i2c/pca953x.h>
20 #include <linux/mfd/tps6507x.h>
21 #include <linux/gpio.h>
22 #include <linux/platform_device.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/nand.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/mtd/physmap.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/regulator/tps6507x.h>
29 #include <linux/mfd/tps6507x.h>
30 #include <linux/input/tps6507x-ts.h>
31
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34
35 #include <mach/cp_intc.h>
36 #include <mach/da8xx.h>
37 #include <mach/nand.h>
38 #include <mach/mux.h>
39 #include <mach/aemif.h>
40
41 #define DA850_EVM_PHY_MASK              0x1
42 #define DA850_EVM_MDIO_FREQUENCY        2200000 /* PHY bus frequency */
43
44 #define DA850_LCD_PWR_PIN               GPIO_TO_PIN(2, 8)
45 #define DA850_LCD_BL_PIN                GPIO_TO_PIN(2, 15)
46
47 #define DA850_MMCSD_CD_PIN              GPIO_TO_PIN(4, 0)
48 #define DA850_MMCSD_WP_PIN              GPIO_TO_PIN(4, 1)
49
50 #define DA850_MII_MDIO_CLKEN_PIN        GPIO_TO_PIN(2, 6)
51
52 static struct mtd_partition da850_evm_norflash_partition[] = {
53         {
54                 .name           = "bootloaders + env",
55                 .offset         = 0,
56                 .size           = SZ_512K,
57                 .mask_flags     = MTD_WRITEABLE,
58         },
59         {
60                 .name           = "kernel",
61                 .offset         = MTDPART_OFS_APPEND,
62                 .size           = SZ_2M,
63                 .mask_flags     = 0,
64         },
65         {
66                 .name           = "filesystem",
67                 .offset         = MTDPART_OFS_APPEND,
68                 .size           = MTDPART_SIZ_FULL,
69                 .mask_flags     = 0,
70         },
71 };
72
73 static struct physmap_flash_data da850_evm_norflash_data = {
74         .width          = 2,
75         .parts          = da850_evm_norflash_partition,
76         .nr_parts       = ARRAY_SIZE(da850_evm_norflash_partition),
77 };
78
79 static struct resource da850_evm_norflash_resource[] = {
80         {
81                 .start  = DA8XX_AEMIF_CS2_BASE,
82                 .end    = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
83                 .flags  = IORESOURCE_MEM,
84         },
85 };
86
87 static struct platform_device da850_evm_norflash_device = {
88         .name           = "physmap-flash",
89         .id             = 0,
90         .dev            = {
91                 .platform_data  = &da850_evm_norflash_data,
92         },
93         .num_resources  = 1,
94         .resource       = da850_evm_norflash_resource,
95 };
96
97 static struct davinci_pm_config da850_pm_pdata = {
98         .sleepcount = 128,
99 };
100
101 static struct platform_device da850_pm_device = {
102         .name           = "pm-davinci",
103         .dev = {
104                 .platform_data  = &da850_pm_pdata,
105         },
106         .id             = -1,
107 };
108
109 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
110  * (128K blocks). It may be used instead of the (default) SPI flash
111  * to boot, using TI's tools to install the secondary boot loader
112  * (UBL) and U-Boot.
113  */
114 static struct mtd_partition da850_evm_nandflash_partition[] = {
115         {
116                 .name           = "u-boot env",
117                 .offset         = 0,
118                 .size           = SZ_128K,
119                 .mask_flags     = MTD_WRITEABLE,
120          },
121         {
122                 .name           = "UBL",
123                 .offset         = MTDPART_OFS_APPEND,
124                 .size           = SZ_128K,
125                 .mask_flags     = MTD_WRITEABLE,
126         },
127         {
128                 .name           = "u-boot",
129                 .offset         = MTDPART_OFS_APPEND,
130                 .size           = 4 * SZ_128K,
131                 .mask_flags     = MTD_WRITEABLE,
132         },
133         {
134                 .name           = "kernel",
135                 .offset         = 0x200000,
136                 .size           = SZ_2M,
137                 .mask_flags     = 0,
138         },
139         {
140                 .name           = "filesystem",
141                 .offset         = MTDPART_OFS_APPEND,
142                 .size           = MTDPART_SIZ_FULL,
143                 .mask_flags     = 0,
144         },
145 };
146
147 static struct davinci_aemif_timing da850_evm_nandflash_timing = {
148         .wsetup         = 24,
149         .wstrobe        = 21,
150         .whold          = 14,
151         .rsetup         = 19,
152         .rstrobe        = 50,
153         .rhold          = 0,
154         .ta             = 20,
155 };
156
157 static struct davinci_nand_pdata da850_evm_nandflash_data = {
158         .parts          = da850_evm_nandflash_partition,
159         .nr_parts       = ARRAY_SIZE(da850_evm_nandflash_partition),
160         .ecc_mode       = NAND_ECC_HW,
161         .ecc_bits       = 4,
162         .options        = NAND_USE_FLASH_BBT,
163         .timing         = &da850_evm_nandflash_timing,
164 };
165
166 static struct resource da850_evm_nandflash_resource[] = {
167         {
168                 .start  = DA8XX_AEMIF_CS3_BASE,
169                 .end    = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
170                 .flags  = IORESOURCE_MEM,
171         },
172         {
173                 .start  = DA8XX_AEMIF_CTL_BASE,
174                 .end    = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
175                 .flags  = IORESOURCE_MEM,
176         },
177 };
178
179 static struct platform_device da850_evm_nandflash_device = {
180         .name           = "davinci_nand",
181         .id             = 1,
182         .dev            = {
183                 .platform_data  = &da850_evm_nandflash_data,
184         },
185         .num_resources  = ARRAY_SIZE(da850_evm_nandflash_resource),
186         .resource       = da850_evm_nandflash_resource,
187 };
188
189 static struct platform_device *da850_evm_devices[] __initdata = {
190         &da850_evm_nandflash_device,
191         &da850_evm_norflash_device,
192 };
193
194 #define DA8XX_AEMIF_CE2CFG_OFFSET       0x10
195 #define DA8XX_AEMIF_ASIZE_16BIT         0x1
196
197 static void __init da850_evm_init_nor(void)
198 {
199         void __iomem *aemif_addr;
200
201         aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
202
203         /* Configure data bus width of CS2 to 16 bit */
204         writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
205                 DA8XX_AEMIF_ASIZE_16BIT,
206                 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
207
208         iounmap(aemif_addr);
209 }
210
211 static const short da850_evm_nand_pins[] = {
212         DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
213         DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
214         DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
215         DA850_NEMA_WE, DA850_NEMA_OE,
216         -1
217 };
218
219 static const short da850_evm_nor_pins[] = {
220         DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
221         DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
222         DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
223         DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
224         DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
225         DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
226         DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
227         DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
228         DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
229         DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
230         DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
231         DA850_EMA_A_22, DA850_EMA_A_23,
232         -1
233 };
234
235 static u32 ui_card_detected;
236
237 #if defined(CONFIG_MMC_DAVINCI) || \
238     defined(CONFIG_MMC_DAVINCI_MODULE)
239 #define HAS_MMC 1
240 #else
241 #define HAS_MMC 0
242 #endif
243
244 static inline void da850_evm_setup_nor_nand(void)
245 {
246         int ret = 0;
247
248         if (ui_card_detected & !HAS_MMC) {
249                 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
250                 if (ret)
251                         pr_warning("da850_evm_init: nand mux setup failed: "
252                                         "%d\n", ret);
253
254                 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
255                 if (ret)
256                         pr_warning("da850_evm_init: nor mux setup failed: %d\n",
257                                 ret);
258
259                 da850_evm_init_nor();
260
261                 platform_add_devices(da850_evm_devices,
262                                         ARRAY_SIZE(da850_evm_devices));
263         }
264 }
265
266 #ifdef CONFIG_DA850_UI_RMII
267 static inline void da850_evm_setup_emac_rmii(int rmii_sel)
268 {
269         struct davinci_soc_info *soc_info = &davinci_soc_info;
270
271         soc_info->emac_pdata->rmii_en = 1;
272         gpio_set_value(rmii_sel, 0);
273 }
274 #else
275 static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
276 #endif
277
278 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
279                                                 unsigned ngpio, void *c)
280 {
281         int sel_a, sel_b, sel_c, ret;
282
283         sel_a = gpio + 7;
284         sel_b = gpio + 6;
285         sel_c = gpio + 5;
286
287         ret = gpio_request(sel_a, "sel_a");
288         if (ret) {
289                 pr_warning("Cannot open UI expander pin %d\n", sel_a);
290                 goto exp_setup_sela_fail;
291         }
292
293         ret = gpio_request(sel_b, "sel_b");
294         if (ret) {
295                 pr_warning("Cannot open UI expander pin %d\n", sel_b);
296                 goto exp_setup_selb_fail;
297         }
298
299         ret = gpio_request(sel_c, "sel_c");
300         if (ret) {
301                 pr_warning("Cannot open UI expander pin %d\n", sel_c);
302                 goto exp_setup_selc_fail;
303         }
304
305         /* deselect all functionalities */
306         gpio_direction_output(sel_a, 1);
307         gpio_direction_output(sel_b, 1);
308         gpio_direction_output(sel_c, 1);
309
310         ui_card_detected = 1;
311         pr_info("DA850/OMAP-L138 EVM UI card detected\n");
312
313         da850_evm_setup_nor_nand();
314
315         da850_evm_setup_emac_rmii(sel_a);
316
317         return 0;
318
319 exp_setup_selc_fail:
320         gpio_free(sel_b);
321 exp_setup_selb_fail:
322         gpio_free(sel_a);
323 exp_setup_sela_fail:
324         return ret;
325 }
326
327 static int da850_evm_ui_expander_teardown(struct i2c_client *client,
328                                         unsigned gpio, unsigned ngpio, void *c)
329 {
330         /* deselect all functionalities */
331         gpio_set_value(gpio + 5, 1);
332         gpio_set_value(gpio + 6, 1);
333         gpio_set_value(gpio + 7, 1);
334
335         gpio_free(gpio + 5);
336         gpio_free(gpio + 6);
337         gpio_free(gpio + 7);
338
339         return 0;
340 }
341
342 static struct pca953x_platform_data da850_evm_ui_expander_info = {
343         .gpio_base      = DAVINCI_N_GPIO,
344         .setup          = da850_evm_ui_expander_setup,
345         .teardown       = da850_evm_ui_expander_teardown,
346 };
347
348 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
349         {
350                 I2C_BOARD_INFO("tlv320aic3x", 0x18),
351         },
352         {
353                 I2C_BOARD_INFO("tca6416", 0x20),
354                 .platform_data = &da850_evm_ui_expander_info,
355         },
356 };
357
358 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
359         .bus_freq       = 100,  /* kHz */
360         .bus_delay      = 0,    /* usec */
361 };
362
363 static struct davinci_uart_config da850_evm_uart_config __initdata = {
364         .enabled_uarts = 0x7,
365 };
366
367 /* davinci da850 evm audio machine driver */
368 static u8 da850_iis_serializer_direction[] = {
369         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
370         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
371         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  TX_MODE,
372         RX_MODE,        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
373 };
374
375 static struct snd_platform_data da850_evm_snd_data = {
376         .tx_dma_offset  = 0x2000,
377         .rx_dma_offset  = 0x2000,
378         .op_mode        = DAVINCI_MCASP_IIS_MODE,
379         .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
380         .tdm_slots      = 2,
381         .serial_dir     = da850_iis_serializer_direction,
382         .asp_chan_q     = EVENTQ_1,
383         .version        = MCASP_VERSION_2,
384         .txnumevt       = 1,
385         .rxnumevt       = 1,
386 };
387
388 static int da850_evm_mmc_get_ro(int index)
389 {
390         return gpio_get_value(DA850_MMCSD_WP_PIN);
391 }
392
393 static int da850_evm_mmc_get_cd(int index)
394 {
395         return !gpio_get_value(DA850_MMCSD_CD_PIN);
396 }
397
398 static struct davinci_mmc_config da850_mmc_config = {
399         .get_ro         = da850_evm_mmc_get_ro,
400         .get_cd         = da850_evm_mmc_get_cd,
401         .wires          = 4,
402         .max_freq       = 50000000,
403         .caps           = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
404         .version        = MMC_CTLR_VERSION_2,
405 };
406
407 static void da850_panel_power_ctrl(int val)
408 {
409         /* lcd backlight */
410         gpio_set_value(DA850_LCD_BL_PIN, val);
411
412         /* lcd power */
413         gpio_set_value(DA850_LCD_PWR_PIN, val);
414 }
415
416 static int da850_lcd_hw_init(void)
417 {
418         int status;
419
420         status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
421         if (status < 0)
422                 return status;
423
424         status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
425         if (status < 0) {
426                 gpio_free(DA850_LCD_BL_PIN);
427                 return status;
428         }
429
430         gpio_direction_output(DA850_LCD_BL_PIN, 0);
431         gpio_direction_output(DA850_LCD_PWR_PIN, 0);
432
433         /* Switch off panel power and backlight */
434         da850_panel_power_ctrl(0);
435
436         /* Switch on panel power and backlight */
437         da850_panel_power_ctrl(1);
438
439         return 0;
440 }
441
442 /* TPS65070 voltage regulator support */
443
444 /* 3.3V */
445 static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
446         {
447                 .supply = "usb0_vdda33",
448         },
449         {
450                 .supply = "usb1_vdda33",
451         },
452 };
453
454 /* 3.3V or 1.8V */
455 static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
456         {
457                 .supply = "dvdd3318_a",
458         },
459         {
460                 .supply = "dvdd3318_b",
461         },
462         {
463                 .supply = "dvdd3318_c",
464         },
465 };
466
467 /* 1.2V */
468 static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
469         {
470                 .supply = "cvdd",
471         },
472 };
473
474 /* 1.8V LDO */
475 static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
476         {
477                 .supply = "sata_vddr",
478         },
479         {
480                 .supply = "usb0_vdda18",
481         },
482         {
483                 .supply = "usb1_vdda18",
484         },
485         {
486                 .supply = "ddr_dvdd18",
487         },
488 };
489
490 /* 1.2V LDO */
491 static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
492         {
493                 .supply = "sata_vdd",
494         },
495         {
496                 .supply = "pll0_vdda",
497         },
498         {
499                 .supply = "pll1_vdda",
500         },
501         {
502                 .supply = "usbs_cvdd",
503         },
504         {
505                 .supply = "vddarnwa1",
506         },
507 };
508
509 /* We take advantage of the fact that both defdcdc{2,3} are tied high */
510 static struct tps6507x_reg_platform_data tps6507x_platform_data = {
511         .defdcdc_default = true,
512 };
513
514 static struct regulator_init_data tps65070_regulator_data[] = {
515         /* dcdc1 */
516         {
517                 .constraints = {
518                         .min_uV = 3150000,
519                         .max_uV = 3450000,
520                         .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
521                                 REGULATOR_CHANGE_STATUS),
522                         .boot_on = 1,
523                 },
524                 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
525                 .consumer_supplies = tps65070_dcdc1_consumers,
526         },
527
528         /* dcdc2 */
529         {
530                 .constraints = {
531                         .min_uV = 1710000,
532                         .max_uV = 3450000,
533                         .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
534                                 REGULATOR_CHANGE_STATUS),
535                         .boot_on = 1,
536                 },
537                 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
538                 .consumer_supplies = tps65070_dcdc2_consumers,
539                 .driver_data = &tps6507x_platform_data,
540         },
541
542         /* dcdc3 */
543         {
544                 .constraints = {
545                         .min_uV = 950000,
546                         .max_uV = 1320000,
547                         .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
548                                 REGULATOR_CHANGE_STATUS),
549                         .boot_on = 1,
550                 },
551                 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
552                 .consumer_supplies = tps65070_dcdc3_consumers,
553                 .driver_data = &tps6507x_platform_data,
554         },
555
556         /* ldo1 */
557         {
558                 .constraints = {
559                         .min_uV = 1710000,
560                         .max_uV = 1890000,
561                         .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
562                                 REGULATOR_CHANGE_STATUS),
563                         .boot_on = 1,
564                 },
565                 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
566                 .consumer_supplies = tps65070_ldo1_consumers,
567         },
568
569         /* ldo2 */
570         {
571                 .constraints = {
572                         .min_uV = 1140000,
573                         .max_uV = 1320000,
574                         .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
575                                 REGULATOR_CHANGE_STATUS),
576                         .boot_on = 1,
577                 },
578                 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
579                 .consumer_supplies = tps65070_ldo2_consumers,
580         },
581 };
582
583 static struct touchscreen_init_data tps6507x_touchscreen_data = {
584         .poll_period =  30,     /* ms between touch samples */
585         .min_pressure = 0x30,   /* minimum pressure to trigger touch */
586         .vref = 0,              /* turn off vref when not using A/D */
587         .vendor = 0,            /* /sys/class/input/input?/id/vendor */
588         .product = 65070,       /* /sys/class/input/input?/id/product */
589         .version = 0x100,       /* /sys/class/input/input?/id/version */
590 };
591
592 static struct tps6507x_board tps_board = {
593         .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
594         .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
595 };
596
597 static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
598         {
599                 I2C_BOARD_INFO("tps6507x", 0x48),
600                 .platform_data = &tps_board,
601         },
602 };
603
604 static int __init pmic_tps65070_init(void)
605 {
606         return i2c_register_board_info(1, da850evm_tps65070_info,
607                                         ARRAY_SIZE(da850evm_tps65070_info));
608 }
609
610 static const short da850_evm_lcdc_pins[] = {
611         DA850_GPIO2_8, DA850_GPIO2_15,
612         -1
613 };
614
615 static const short da850_evm_mii_pins[] = {
616         DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
617         DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
618         DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
619         DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
620         DA850_MDIO_D,
621         -1
622 };
623
624 static const short da850_evm_rmii_pins[] = {
625         DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
626         DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
627         DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
628         DA850_MDIO_D,
629         -1
630 };
631
632 static int __init da850_evm_config_emac(void)
633 {
634         void __iomem *cfg_chip3_base;
635         int ret;
636         u32 val;
637         struct davinci_soc_info *soc_info = &davinci_soc_info;
638         u8 rmii_en = soc_info->emac_pdata->rmii_en;
639
640         if (!machine_is_davinci_da850_evm())
641                 return 0;
642
643         cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
644
645         val = __raw_readl(cfg_chip3_base);
646
647         if (rmii_en) {
648                 val |= BIT(8);
649                 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
650                 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
651                                                         " functional\n");
652         } else {
653                 val &= ~BIT(8);
654                 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
655                 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
656                                                         " functional\n");
657         }
658
659         if (ret)
660                 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
661                                 ret);
662
663         /* configure the CFGCHIP3 register for RMII or MII */
664         __raw_writel(val, cfg_chip3_base);
665
666         ret = davinci_cfg_reg(DA850_GPIO2_6);
667         if (ret)
668                 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
669                                                         "failed\n");
670
671         ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
672         if (ret) {
673                 pr_warning("Cannot open GPIO %d\n",
674                                         DA850_MII_MDIO_CLKEN_PIN);
675                 return ret;
676         }
677
678         /* Enable/Disable MII MDIO clock */
679         gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
680
681         soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
682         soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
683
684         ret = da8xx_register_emac();
685         if (ret)
686                 pr_warning("da850_evm_init: emac registration failed: %d\n",
687                                 ret);
688
689         return 0;
690 }
691 device_initcall(da850_evm_config_emac);
692
693 /*
694  * The following EDMA channels/slots are not being used by drivers (for
695  * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
696  * they are being reserved for codecs on the DSP side.
697  */
698 static const s16 da850_dma0_rsv_chans[][2] = {
699         /* (offset, number) */
700         { 8,  6},
701         {24,  4},
702         {30,  2},
703         {-1, -1}
704 };
705
706 static const s16 da850_dma0_rsv_slots[][2] = {
707         /* (offset, number) */
708         { 8,  6},
709         {24,  4},
710         {30, 50},
711         {-1, -1}
712 };
713
714 static const s16 da850_dma1_rsv_chans[][2] = {
715         /* (offset, number) */
716         { 0, 28},
717         {30,  2},
718         {-1, -1}
719 };
720
721 static const s16 da850_dma1_rsv_slots[][2] = {
722         /* (offset, number) */
723         { 0, 28},
724         {30, 90},
725         {-1, -1}
726 };
727
728 static struct edma_rsv_info da850_edma_cc0_rsv = {
729         .rsv_chans      = da850_dma0_rsv_chans,
730         .rsv_slots      = da850_dma0_rsv_slots,
731 };
732
733 static struct edma_rsv_info da850_edma_cc1_rsv = {
734         .rsv_chans      = da850_dma1_rsv_chans,
735         .rsv_slots      = da850_dma1_rsv_slots,
736 };
737
738 static struct edma_rsv_info *da850_edma_rsv[2] = {
739         &da850_edma_cc0_rsv,
740         &da850_edma_cc1_rsv,
741 };
742
743 static __init void da850_evm_init(void)
744 {
745         int ret;
746
747         ret = pmic_tps65070_init();
748         if (ret)
749                 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
750                                 ret);
751
752         ret = da850_register_edma(da850_edma_rsv);
753         if (ret)
754                 pr_warning("da850_evm_init: edma registration failed: %d\n",
755                                 ret);
756
757         ret = davinci_cfg_reg_list(da850_i2c0_pins);
758         if (ret)
759                 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
760                                 ret);
761
762         ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
763         if (ret)
764                 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
765                                 ret);
766
767
768         ret = da8xx_register_watchdog();
769         if (ret)
770                 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
771                                 ret);
772
773         if (HAS_MMC) {
774                 ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
775                 if (ret)
776                         pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
777                                         " %d\n", ret);
778
779                 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
780                 if (ret)
781                         pr_warning("da850_evm_init: can not open GPIO %d\n",
782                                         DA850_MMCSD_CD_PIN);
783                 gpio_direction_input(DA850_MMCSD_CD_PIN);
784
785                 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
786                 if (ret)
787                         pr_warning("da850_evm_init: can not open GPIO %d\n",
788                                         DA850_MMCSD_WP_PIN);
789                 gpio_direction_input(DA850_MMCSD_WP_PIN);
790
791                 ret = da8xx_register_mmcsd0(&da850_mmc_config);
792                 if (ret)
793                         pr_warning("da850_evm_init: mmcsd0 registration failed:"
794                                         " %d\n", ret);
795         }
796
797         davinci_serial_init(&da850_evm_uart_config);
798
799         i2c_register_board_info(1, da850_evm_i2c_devices,
800                         ARRAY_SIZE(da850_evm_i2c_devices));
801
802         /*
803          * shut down uart 0 and 1; they are not used on the board and
804          * accessing them causes endless "too much work in irq53" messages
805          * with arago fs
806          */
807         __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
808         __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
809
810         ret = davinci_cfg_reg_list(da850_mcasp_pins);
811         if (ret)
812                 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
813                                 ret);
814
815         da8xx_register_mcasp(0, &da850_evm_snd_data);
816
817         ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
818         if (ret)
819                 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
820                                 ret);
821
822         /* Handle board specific muxing for LCD here */
823         ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
824         if (ret)
825                 pr_warning("da850_evm_init: evm specific lcd mux setup "
826                                 "failed: %d\n", ret);
827
828         ret = da850_lcd_hw_init();
829         if (ret)
830                 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
831                                 ret);
832
833         sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
834         ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
835         if (ret)
836                 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
837                                 ret);
838
839         ret = da8xx_register_rtc();
840         if (ret)
841                 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
842
843         ret = da850_register_cpufreq("pll0_sysclk3");
844         if (ret)
845                 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
846                                 ret);
847
848         ret = da8xx_register_cpuidle();
849         if (ret)
850                 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
851                                 ret);
852
853         ret = da850_register_pm(&da850_pm_device);
854         if (ret)
855                 pr_warning("da850_evm_init: suspend registration failed: %d\n",
856                                 ret);
857 }
858
859 #ifdef CONFIG_SERIAL_8250_CONSOLE
860 static int __init da850_evm_console_init(void)
861 {
862         return add_preferred_console("ttyS", 2, "115200");
863 }
864 console_initcall(da850_evm_console_init);
865 #endif
866
867 static void __init da850_evm_map_io(void)
868 {
869         da850_init();
870 }
871
872 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
873         .phys_io        = IO_PHYS,
874         .io_pg_offst    = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
875         .boot_params    = (DA8XX_DDR_BASE + 0x100),
876         .map_io         = da850_evm_map_io,
877         .init_irq       = cp_intc_init,
878         .timer          = &davinci_timer,
879         .init_machine   = da850_evm_init,
880 MACHINE_END