blob: b26f5cbfce3e2f5f1d8b4e8ee47a5e138e1a2999 [file] [log] [blame]
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001/*
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>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040015#include <linux/init.h>
16#include <linux/console.h>
17#include <linux/i2c.h>
18#include <linux/i2c/at24.h>
Chaithrika U S75e2ea62009-09-30 17:00:28 -040019#include <linux/i2c/pca953x.h>
Todd Fischer0bc20bb2010-04-05 20:23:57 -060020#include <linux/mfd/tps6507x.h>
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040021#include <linux/gpio.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040022#include <linux/platform_device.h>
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/nand.h>
25#include <linux/mtd/partitions.h>
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -040026#include <linux/mtd/physmap.h>
Sekhar Noria9eb1f62009-09-22 21:14:04 +053027#include <linux/regulator/machine.h>
Sekhar Nori8b245992010-07-12 17:56:21 +053028#include <linux/regulator/tps6507x.h>
Todd Fischerda1e3682010-04-05 17:53:13 -060029#include <linux/mfd/tps6507x.h>
30#include <linux/input/tps6507x-ts.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040031
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040035#include <mach/cp_intc.h>
36#include <mach/da8xx.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040037#include <mach/nand.h>
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -040038#include <mach/mux.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040039
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -040040#define DA850_EVM_PHY_MASK 0x1
41#define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
42
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -040043#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040044#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040045
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -040046#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
47#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
48
Chaithrika U S22067712009-09-30 17:00:53 -040049#define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
50
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -040051static struct mtd_partition da850_evm_norflash_partition[] = {
52 {
Sudhakar Rajashekharae2abd5a2009-11-18 11:48:37 +053053 .name = "bootloaders + env",
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -040054 .offset = 0,
Sudhakar Rajashekharae2abd5a2009-11-18 11:48:37 +053055 .size = SZ_512K,
56 .mask_flags = MTD_WRITEABLE,
57 },
58 {
59 .name = "kernel",
60 .offset = MTDPART_OFS_APPEND,
61 .size = SZ_2M,
62 .mask_flags = 0,
63 },
64 {
65 .name = "filesystem",
66 .offset = MTDPART_OFS_APPEND,
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -040067 .size = MTDPART_SIZ_FULL,
68 .mask_flags = 0,
69 },
70};
71
72static struct physmap_flash_data da850_evm_norflash_data = {
73 .width = 2,
74 .parts = da850_evm_norflash_partition,
75 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
76};
77
78static struct resource da850_evm_norflash_resource[] = {
79 {
80 .start = DA8XX_AEMIF_CS2_BASE,
81 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
82 .flags = IORESOURCE_MEM,
83 },
84};
85
86static struct platform_device da850_evm_norflash_device = {
87 .name = "physmap-flash",
88 .id = 0,
89 .dev = {
90 .platform_data = &da850_evm_norflash_data,
91 },
92 .num_resources = 1,
93 .resource = da850_evm_norflash_resource,
94};
95
Sekhar Nori63534442009-12-17 18:29:33 +053096static struct davinci_pm_config da850_pm_pdata = {
97 .sleepcount = 128,
98};
99
100static struct platform_device da850_pm_device = {
101 .name = "pm-davinci",
102 .dev = {
103 .platform_data = &da850_pm_pdata,
104 },
105 .id = -1,
106};
107
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400108/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
109 * (128K blocks). It may be used instead of the (default) SPI flash
110 * to boot, using TI's tools to install the secondary boot loader
111 * (UBL) and U-Boot.
112 */
113struct mtd_partition da850_evm_nandflash_partition[] = {
114 {
115 .name = "u-boot env",
116 .offset = 0,
117 .size = SZ_128K,
118 .mask_flags = MTD_WRITEABLE,
119 },
120 {
121 .name = "UBL",
122 .offset = MTDPART_OFS_APPEND,
123 .size = SZ_128K,
124 .mask_flags = MTD_WRITEABLE,
125 },
126 {
127 .name = "u-boot",
128 .offset = MTDPART_OFS_APPEND,
129 .size = 4 * SZ_128K,
130 .mask_flags = MTD_WRITEABLE,
131 },
132 {
133 .name = "kernel",
134 .offset = 0x200000,
135 .size = SZ_2M,
136 .mask_flags = 0,
137 },
138 {
139 .name = "filesystem",
140 .offset = MTDPART_OFS_APPEND,
141 .size = MTDPART_SIZ_FULL,
142 .mask_flags = 0,
143 },
144};
145
146static struct davinci_nand_pdata da850_evm_nandflash_data = {
147 .parts = da850_evm_nandflash_partition,
148 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
149 .ecc_mode = NAND_ECC_HW,
Sudhakar Rajashekharafc42e332009-11-18 12:11:41 +0530150 .ecc_bits = 4,
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400151 .options = NAND_USE_FLASH_BBT,
152};
153
154static struct resource da850_evm_nandflash_resource[] = {
155 {
156 .start = DA8XX_AEMIF_CS3_BASE,
157 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
158 .flags = IORESOURCE_MEM,
159 },
160 {
161 .start = DA8XX_AEMIF_CTL_BASE,
162 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
163 .flags = IORESOURCE_MEM,
164 },
165};
166
167static struct platform_device da850_evm_nandflash_device = {
168 .name = "davinci_nand",
169 .id = 1,
170 .dev = {
171 .platform_data = &da850_evm_nandflash_data,
172 },
173 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
174 .resource = da850_evm_nandflash_resource,
175};
176
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530177static struct platform_device *da850_evm_devices[] __initdata = {
178 &da850_evm_nandflash_device,
179 &da850_evm_norflash_device,
180};
181
182#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
183#define DA8XX_AEMIF_ASIZE_16BIT 0x1
184
185static void __init da850_evm_init_nor(void)
186{
187 void __iomem *aemif_addr;
188
189 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
190
191 /* Configure data bus width of CS2 to 16 bit */
192 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
193 DA8XX_AEMIF_ASIZE_16BIT,
194 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
195
196 iounmap(aemif_addr);
197}
198
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400199static u32 ui_card_detected;
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530200
201#if defined(CONFIG_MMC_DAVINCI) || \
202 defined(CONFIG_MMC_DAVINCI_MODULE)
203#define HAS_MMC 1
204#else
205#define HAS_MMC 0
206#endif
207
Sudhakar Rajashekhara1ef203c2009-11-03 11:51:19 +0530208static __init void da850_evm_setup_nor_nand(void)
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530209{
210 int ret = 0;
211
212 if (ui_card_detected & !HAS_MMC) {
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400213 ret = davinci_cfg_reg_list(da850_nand_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530214 if (ret)
215 pr_warning("da850_evm_init: nand mux setup failed: "
216 "%d\n", ret);
217
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400218 ret = davinci_cfg_reg_list(da850_nor_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530219 if (ret)
220 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
221 ret);
222
223 da850_evm_init_nor();
224
225 platform_add_devices(da850_evm_devices,
226 ARRAY_SIZE(da850_evm_devices));
227 }
228}
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400229
Sekhar Noribae10582009-10-21 21:18:22 +0530230#ifdef CONFIG_DA850_UI_RMII
231static inline void da850_evm_setup_emac_rmii(int rmii_sel)
232{
233 struct davinci_soc_info *soc_info = &davinci_soc_info;
234
235 soc_info->emac_pdata->rmii_en = 1;
236 gpio_set_value(rmii_sel, 0);
237}
238#else
239static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
240#endif
241
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400242static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
243 unsigned ngpio, void *c)
244{
245 int sel_a, sel_b, sel_c, ret;
246
247 sel_a = gpio + 7;
248 sel_b = gpio + 6;
249 sel_c = gpio + 5;
250
251 ret = gpio_request(sel_a, "sel_a");
252 if (ret) {
253 pr_warning("Cannot open UI expander pin %d\n", sel_a);
254 goto exp_setup_sela_fail;
255 }
256
257 ret = gpio_request(sel_b, "sel_b");
258 if (ret) {
259 pr_warning("Cannot open UI expander pin %d\n", sel_b);
260 goto exp_setup_selb_fail;
261 }
262
263 ret = gpio_request(sel_c, "sel_c");
264 if (ret) {
265 pr_warning("Cannot open UI expander pin %d\n", sel_c);
266 goto exp_setup_selc_fail;
267 }
268
269 /* deselect all functionalities */
270 gpio_direction_output(sel_a, 1);
271 gpio_direction_output(sel_b, 1);
272 gpio_direction_output(sel_c, 1);
273
274 ui_card_detected = 1;
275 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
276
277 da850_evm_setup_nor_nand();
278
Sekhar Noribae10582009-10-21 21:18:22 +0530279 da850_evm_setup_emac_rmii(sel_a);
Chaithrika U S22067712009-09-30 17:00:53 -0400280
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400281 return 0;
282
283exp_setup_selc_fail:
284 gpio_free(sel_b);
285exp_setup_selb_fail:
286 gpio_free(sel_a);
287exp_setup_sela_fail:
288 return ret;
289}
290
291static int da850_evm_ui_expander_teardown(struct i2c_client *client,
292 unsigned gpio, unsigned ngpio, void *c)
293{
294 /* deselect all functionalities */
295 gpio_set_value(gpio + 5, 1);
296 gpio_set_value(gpio + 6, 1);
297 gpio_set_value(gpio + 7, 1);
298
299 gpio_free(gpio + 5);
300 gpio_free(gpio + 6);
301 gpio_free(gpio + 7);
302
303 return 0;
304}
305
306static struct pca953x_platform_data da850_evm_ui_expander_info = {
307 .gpio_base = DAVINCI_N_GPIO,
308 .setup = da850_evm_ui_expander_setup,
309 .teardown = da850_evm_ui_expander_teardown,
310};
311
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300312static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
313 {
314 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400315 },
316 {
317 I2C_BOARD_INFO("tca6416", 0x20),
318 .platform_data = &da850_evm_ui_expander_info,
319 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300320};
321
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400322static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
323 .bus_freq = 100, /* kHz */
324 .bus_delay = 0, /* usec */
325};
326
327static struct davinci_uart_config da850_evm_uart_config __initdata = {
328 .enabled_uarts = 0x7,
329};
330
Chaithrika U S491214e2009-08-11 17:03:25 -0400331/* davinci da850 evm audio machine driver */
332static u8 da850_iis_serializer_direction[] = {
333 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
334 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
335 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
336 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
337};
338
339static struct snd_platform_data da850_evm_snd_data = {
340 .tx_dma_offset = 0x2000,
341 .rx_dma_offset = 0x2000,
342 .op_mode = DAVINCI_MCASP_IIS_MODE,
343 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
344 .tdm_slots = 2,
345 .serial_dir = da850_iis_serializer_direction,
Sekhar Nori48519f02010-07-19 12:31:16 +0530346 .asp_chan_q = EVENTQ_1,
Chaithrika U S491214e2009-08-11 17:03:25 -0400347 .version = MCASP_VERSION_2,
348 .txnumevt = 1,
349 .rxnumevt = 1,
350};
351
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400352static int da850_evm_mmc_get_ro(int index)
353{
354 return gpio_get_value(DA850_MMCSD_WP_PIN);
355}
356
357static int da850_evm_mmc_get_cd(int index)
358{
359 return !gpio_get_value(DA850_MMCSD_CD_PIN);
360}
361
362static struct davinci_mmc_config da850_mmc_config = {
363 .get_ro = da850_evm_mmc_get_ro,
364 .get_cd = da850_evm_mmc_get_cd,
365 .wires = 4,
Chaithrika U S0046d0b2009-11-03 15:46:14 +0530366 .max_freq = 50000000,
367 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400368 .version = MMC_CTLR_VERSION_2,
369};
370
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800371static void da850_panel_power_ctrl(int val)
372{
373 /* lcd backlight */
374 gpio_set_value(DA850_LCD_BL_PIN, val);
375
376 /* lcd power */
377 gpio_set_value(DA850_LCD_PWR_PIN, val);
378}
379
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400380static int da850_lcd_hw_init(void)
381{
382 int status;
383
384 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
385 if (status < 0)
386 return status;
387
388 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
389 if (status < 0) {
390 gpio_free(DA850_LCD_BL_PIN);
391 return status;
392 }
393
394 gpio_direction_output(DA850_LCD_BL_PIN, 0);
395 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
396
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800397 /* Switch off panel power and backlight */
398 da850_panel_power_ctrl(0);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400399
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800400 /* Switch on panel power and backlight */
401 da850_panel_power_ctrl(1);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400402
403 return 0;
404}
Chaithrika U S491214e2009-08-11 17:03:25 -0400405
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530406/* TPS65070 voltage regulator support */
407
408/* 3.3V */
409struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
410 {
411 .supply = "usb0_vdda33",
412 },
413 {
414 .supply = "usb1_vdda33",
415 },
416};
417
418/* 3.3V or 1.8V */
419struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
420 {
421 .supply = "dvdd3318_a",
422 },
423 {
424 .supply = "dvdd3318_b",
425 },
426 {
427 .supply = "dvdd3318_c",
428 },
429};
430
431/* 1.2V */
432struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
433 {
434 .supply = "cvdd",
435 },
436};
437
438/* 1.8V LDO */
439struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
440 {
441 .supply = "sata_vddr",
442 },
443 {
444 .supply = "usb0_vdda18",
445 },
446 {
447 .supply = "usb1_vdda18",
448 },
449 {
450 .supply = "ddr_dvdd18",
451 },
452};
453
454/* 1.2V LDO */
455struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
456 {
457 .supply = "sata_vdd",
458 },
459 {
460 .supply = "pll0_vdda",
461 },
462 {
463 .supply = "pll1_vdda",
464 },
465 {
466 .supply = "usbs_cvdd",
467 },
468 {
469 .supply = "vddarnwa1",
470 },
471};
472
Sekhar Nori8b245992010-07-12 17:56:21 +0530473/* We take advantage of the fact that both defdcdc{2,3} are tied high */
474static struct tps6507x_reg_platform_data tps6507x_platform_data = {
475 .defdcdc_default = true,
476};
477
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530478struct regulator_init_data tps65070_regulator_data[] = {
479 /* dcdc1 */
480 {
481 .constraints = {
482 .min_uV = 3150000,
483 .max_uV = 3450000,
484 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
485 REGULATOR_CHANGE_STATUS),
486 .boot_on = 1,
487 },
488 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
489 .consumer_supplies = tps65070_dcdc1_consumers,
490 },
491
492 /* dcdc2 */
493 {
494 .constraints = {
495 .min_uV = 1710000,
496 .max_uV = 3450000,
497 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
498 REGULATOR_CHANGE_STATUS),
499 .boot_on = 1,
500 },
501 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
502 .consumer_supplies = tps65070_dcdc2_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530503 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530504 },
505
506 /* dcdc3 */
507 {
508 .constraints = {
509 .min_uV = 950000,
510 .max_uV = 1320000,
511 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
512 REGULATOR_CHANGE_STATUS),
513 .boot_on = 1,
514 },
515 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
516 .consumer_supplies = tps65070_dcdc3_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530517 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530518 },
519
520 /* ldo1 */
521 {
522 .constraints = {
523 .min_uV = 1710000,
524 .max_uV = 1890000,
525 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
526 REGULATOR_CHANGE_STATUS),
527 .boot_on = 1,
528 },
529 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
530 .consumer_supplies = tps65070_ldo1_consumers,
531 },
532
533 /* ldo2 */
534 {
535 .constraints = {
536 .min_uV = 1140000,
537 .max_uV = 1320000,
538 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
539 REGULATOR_CHANGE_STATUS),
540 .boot_on = 1,
541 },
542 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
543 .consumer_supplies = tps65070_ldo2_consumers,
544 },
545};
546
Todd Fischerda1e3682010-04-05 17:53:13 -0600547static struct touchscreen_init_data tps6507x_touchscreen_data = {
548 .poll_period = 30, /* ms between touch samples */
549 .min_pressure = 0x30, /* minimum pressure to trigger touch */
550 .vref = 0, /* turn off vref when not using A/D */
551 .vendor = 0, /* /sys/class/input/input?/id/vendor */
552 .product = 65070, /* /sys/class/input/input?/id/product */
553 .version = 0x100, /* /sys/class/input/input?/id/version */
554};
555
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600556static struct tps6507x_board tps_board = {
557 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
Todd Fischerda1e3682010-04-05 17:53:13 -0600558 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600559};
560
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530561static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
562 {
563 I2C_BOARD_INFO("tps6507x", 0x48),
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600564 .platform_data = &tps_board,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530565 },
566};
567
568static int __init pmic_tps65070_init(void)
569{
570 return i2c_register_board_info(1, da850evm_tps65070_info,
571 ARRAY_SIZE(da850evm_tps65070_info));
572}
573
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400574static const short da850_evm_lcdc_pins[] = {
575 DA850_GPIO2_8, DA850_GPIO2_15,
576 -1
577};
578
Sekhar Noribae10582009-10-21 21:18:22 +0530579static int __init da850_evm_config_emac(void)
Chaithrika U S22067712009-09-30 17:00:53 -0400580{
581 void __iomem *cfg_chip3_base;
582 int ret;
583 u32 val;
Sekhar Noribae10582009-10-21 21:18:22 +0530584 struct davinci_soc_info *soc_info = &davinci_soc_info;
585 u8 rmii_en = soc_info->emac_pdata->rmii_en;
586
587 if (!machine_is_davinci_da850_evm())
588 return 0;
Chaithrika U S22067712009-09-30 17:00:53 -0400589
Sekhar Norid2de0582009-11-16 17:21:32 +0530590 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
Chaithrika U S22067712009-09-30 17:00:53 -0400591
Chaithrika U S22067712009-09-30 17:00:53 -0400592 val = __raw_readl(cfg_chip3_base);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530593
594 if (rmii_en) {
Chaithrika U S22067712009-09-30 17:00:53 -0400595 val |= BIT(8);
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400596 ret = davinci_cfg_reg_list(da850_rmii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530597 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
598 " functional\n");
599 } else {
600 val &= ~BIT(8);
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400601 ret = davinci_cfg_reg_list(da850_cpgmac_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530602 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
603 " functional\n");
604 }
605
Chaithrika U S22067712009-09-30 17:00:53 -0400606 if (ret)
607 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
608 ret);
609
Sekhar Nori17fadd92009-10-21 21:18:24 +0530610 /* configure the CFGCHIP3 register for RMII or MII */
611 __raw_writel(val, cfg_chip3_base);
612
Chaithrika U S22067712009-09-30 17:00:53 -0400613 ret = davinci_cfg_reg(DA850_GPIO2_6);
614 if (ret)
615 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
616 "failed\n");
617
618 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
619 if (ret) {
620 pr_warning("Cannot open GPIO %d\n",
621 DA850_MII_MDIO_CLKEN_PIN);
622 return ret;
623 }
624
Sekhar Nori17fadd92009-10-21 21:18:24 +0530625 /* Enable/Disable MII MDIO clock */
626 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
Chaithrika U S22067712009-09-30 17:00:53 -0400627
Sekhar Noribae10582009-10-21 21:18:22 +0530628 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
629 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
630
631 ret = da8xx_register_emac();
632 if (ret)
633 pr_warning("da850_evm_init: emac registration failed: %d\n",
634 ret);
635
Chaithrika U S22067712009-09-30 17:00:53 -0400636 return 0;
637}
Sekhar Noribae10582009-10-21 21:18:22 +0530638device_initcall(da850_evm_config_emac);
Chaithrika U S22067712009-09-30 17:00:53 -0400639
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530640/*
641 * The following EDMA channels/slots are not being used by drivers (for
642 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
643 * they are being reserved for codecs on the DSP side.
644 */
645static const s16 da850_dma0_rsv_chans[][2] = {
646 /* (offset, number) */
647 { 8, 6},
648 {24, 4},
649 {30, 2},
650 {-1, -1}
651};
652
653static const s16 da850_dma0_rsv_slots[][2] = {
654 /* (offset, number) */
655 { 8, 6},
656 {24, 4},
657 {30, 50},
658 {-1, -1}
659};
660
661static const s16 da850_dma1_rsv_chans[][2] = {
662 /* (offset, number) */
663 { 0, 28},
664 {30, 2},
665 {-1, -1}
666};
667
668static const s16 da850_dma1_rsv_slots[][2] = {
669 /* (offset, number) */
670 { 0, 28},
671 {30, 90},
672 {-1, -1}
673};
674
675static struct edma_rsv_info da850_edma_cc0_rsv = {
676 .rsv_chans = da850_dma0_rsv_chans,
677 .rsv_slots = da850_dma0_rsv_slots,
678};
679
680static struct edma_rsv_info da850_edma_cc1_rsv = {
681 .rsv_chans = da850_dma1_rsv_chans,
682 .rsv_slots = da850_dma1_rsv_slots,
683};
684
685static struct edma_rsv_info *da850_edma_rsv[2] = {
686 &da850_edma_cc0_rsv,
687 &da850_edma_cc1_rsv,
688};
689
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400690static __init void da850_evm_init(void)
691{
692 int ret;
693
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530694 ret = pmic_tps65070_init();
695 if (ret)
696 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
697 ret);
698
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530699 ret = da850_register_edma(da850_edma_rsv);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400700 if (ret)
701 pr_warning("da850_evm_init: edma registration failed: %d\n",
702 ret);
703
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400704 ret = davinci_cfg_reg_list(da850_i2c0_pins);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400705 if (ret)
706 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
707 ret);
708
709 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
710 if (ret)
711 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
712 ret);
713
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400714
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400715 ret = da8xx_register_watchdog();
716 if (ret)
717 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
718 ret);
719
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400720 if (HAS_MMC) {
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400721 ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400722 if (ret)
723 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
724 " %d\n", ret);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400725
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400726 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
727 if (ret)
728 pr_warning("da850_evm_init: can not open GPIO %d\n",
729 DA850_MMCSD_CD_PIN);
730 gpio_direction_input(DA850_MMCSD_CD_PIN);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400731
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400732 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
733 if (ret)
734 pr_warning("da850_evm_init: can not open GPIO %d\n",
735 DA850_MMCSD_WP_PIN);
736 gpio_direction_input(DA850_MMCSD_WP_PIN);
737
738 ret = da8xx_register_mmcsd0(&da850_mmc_config);
739 if (ret)
740 pr_warning("da850_evm_init: mmcsd0 registration failed:"
741 " %d\n", ret);
742 }
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400743
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400744 davinci_serial_init(&da850_evm_uart_config);
745
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300746 i2c_register_board_info(1, da850_evm_i2c_devices,
747 ARRAY_SIZE(da850_evm_i2c_devices));
748
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400749 /*
750 * shut down uart 0 and 1; they are not used on the board and
751 * accessing them causes endless "too much work in irq53" messages
752 * with arago fs
753 */
754 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
755 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -0400756
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400757 ret = davinci_cfg_reg_list(da850_mcasp_pins);
Chaithrika U S491214e2009-08-11 17:03:25 -0400758 if (ret)
759 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
760 ret);
761
Mark A. Greerb8864aa2009-08-28 15:05:02 -0700762 da8xx_register_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400763
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400764 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400765 if (ret)
766 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
767 ret);
768
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400769 /* Handle board specific muxing for LCD here */
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400770 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400771 if (ret)
772 pr_warning("da850_evm_init: evm specific lcd mux setup "
773 "failed: %d\n", ret);
774
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400775 ret = da850_lcd_hw_init();
776 if (ret)
777 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
778 ret);
779
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800780 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
Mark A. Greerb9e63422009-09-15 18:14:19 -0700781 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400782 if (ret)
783 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
784 ret);
Mark A. Greerc51df702009-09-15 18:15:54 -0700785
786 ret = da8xx_register_rtc();
787 if (ret)
788 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
Sekhar Nori09dc2d42009-09-22 21:14:03 +0530789
790 ret = da850_register_cpufreq();
791 if (ret)
792 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
793 ret);
Sekhar Nori5aeb15a2009-10-22 15:12:15 +0530794
795 ret = da8xx_register_cpuidle();
796 if (ret)
797 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
798 ret);
Sekhar Nori63534442009-12-17 18:29:33 +0530799
800 ret = da850_register_pm(&da850_pm_device);
801 if (ret)
802 pr_warning("da850_evm_init: suspend registration failed: %d\n",
803 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400804}
805
806#ifdef CONFIG_SERIAL_8250_CONSOLE
807static int __init da850_evm_console_init(void)
808{
809 return add_preferred_console("ttyS", 2, "115200");
810}
811console_initcall(da850_evm_console_init);
812#endif
813
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400814static void __init da850_evm_map_io(void)
815{
816 da850_init();
817}
818
819MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400820 .boot_params = (DA8XX_DDR_BASE + 0x100),
821 .map_io = da850_evm_map_io,
Cyril Chemparathybd808942010-05-07 17:06:37 -0400822 .init_irq = cp_intc_init,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400823 .timer = &davinci_timer,
824 .init_machine = da850_evm_init,
825MACHINE_END