blob: 482d4584eaa00f29c5879805e9a0de4b0631fbf6 [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 */
Sekhar Noridb549d22010-06-28 17:16:38 +0530113static struct mtd_partition da850_evm_nandflash_partition[] = {
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400114 {
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
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400199static const short da850_evm_nand_pins[] = {
200 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
201 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
202 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
203 DA850_NEMA_WE, DA850_NEMA_OE,
204 -1
205};
206
207static const short da850_evm_nor_pins[] = {
208 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
209 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
210 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
211 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
212 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
213 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
214 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
215 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
216 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
217 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
218 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
219 DA850_EMA_A_22, DA850_EMA_A_23,
220 -1
221};
222
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400223static u32 ui_card_detected;
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530224
225#if defined(CONFIG_MMC_DAVINCI) || \
226 defined(CONFIG_MMC_DAVINCI_MODULE)
227#define HAS_MMC 1
228#else
229#define HAS_MMC 0
230#endif
231
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400232static inline void da850_evm_setup_nor_nand(void)
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530233{
234 int ret = 0;
235
236 if (ui_card_detected & !HAS_MMC) {
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400237 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530238 if (ret)
239 pr_warning("da850_evm_init: nand mux setup failed: "
240 "%d\n", ret);
241
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400242 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530243 if (ret)
244 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
245 ret);
246
247 da850_evm_init_nor();
248
249 platform_add_devices(da850_evm_devices,
250 ARRAY_SIZE(da850_evm_devices));
251 }
252}
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400253
Sekhar Noribae10582009-10-21 21:18:22 +0530254#ifdef CONFIG_DA850_UI_RMII
255static inline void da850_evm_setup_emac_rmii(int rmii_sel)
256{
257 struct davinci_soc_info *soc_info = &davinci_soc_info;
258
259 soc_info->emac_pdata->rmii_en = 1;
260 gpio_set_value(rmii_sel, 0);
261}
262#else
263static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
264#endif
265
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400266static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
267 unsigned ngpio, void *c)
268{
269 int sel_a, sel_b, sel_c, ret;
270
271 sel_a = gpio + 7;
272 sel_b = gpio + 6;
273 sel_c = gpio + 5;
274
275 ret = gpio_request(sel_a, "sel_a");
276 if (ret) {
277 pr_warning("Cannot open UI expander pin %d\n", sel_a);
278 goto exp_setup_sela_fail;
279 }
280
281 ret = gpio_request(sel_b, "sel_b");
282 if (ret) {
283 pr_warning("Cannot open UI expander pin %d\n", sel_b);
284 goto exp_setup_selb_fail;
285 }
286
287 ret = gpio_request(sel_c, "sel_c");
288 if (ret) {
289 pr_warning("Cannot open UI expander pin %d\n", sel_c);
290 goto exp_setup_selc_fail;
291 }
292
293 /* deselect all functionalities */
294 gpio_direction_output(sel_a, 1);
295 gpio_direction_output(sel_b, 1);
296 gpio_direction_output(sel_c, 1);
297
298 ui_card_detected = 1;
299 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
300
301 da850_evm_setup_nor_nand();
302
Sekhar Noribae10582009-10-21 21:18:22 +0530303 da850_evm_setup_emac_rmii(sel_a);
Chaithrika U S22067712009-09-30 17:00:53 -0400304
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400305 return 0;
306
307exp_setup_selc_fail:
308 gpio_free(sel_b);
309exp_setup_selb_fail:
310 gpio_free(sel_a);
311exp_setup_sela_fail:
312 return ret;
313}
314
315static int da850_evm_ui_expander_teardown(struct i2c_client *client,
316 unsigned gpio, unsigned ngpio, void *c)
317{
318 /* deselect all functionalities */
319 gpio_set_value(gpio + 5, 1);
320 gpio_set_value(gpio + 6, 1);
321 gpio_set_value(gpio + 7, 1);
322
323 gpio_free(gpio + 5);
324 gpio_free(gpio + 6);
325 gpio_free(gpio + 7);
326
327 return 0;
328}
329
330static struct pca953x_platform_data da850_evm_ui_expander_info = {
331 .gpio_base = DAVINCI_N_GPIO,
332 .setup = da850_evm_ui_expander_setup,
333 .teardown = da850_evm_ui_expander_teardown,
334};
335
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300336static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
337 {
338 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400339 },
340 {
341 I2C_BOARD_INFO("tca6416", 0x20),
342 .platform_data = &da850_evm_ui_expander_info,
343 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300344};
345
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400346static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
347 .bus_freq = 100, /* kHz */
348 .bus_delay = 0, /* usec */
349};
350
351static struct davinci_uart_config da850_evm_uart_config __initdata = {
352 .enabled_uarts = 0x7,
353};
354
Chaithrika U S491214e2009-08-11 17:03:25 -0400355/* davinci da850 evm audio machine driver */
356static u8 da850_iis_serializer_direction[] = {
357 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
358 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
359 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
360 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
361};
362
363static struct snd_platform_data da850_evm_snd_data = {
364 .tx_dma_offset = 0x2000,
365 .rx_dma_offset = 0x2000,
366 .op_mode = DAVINCI_MCASP_IIS_MODE,
367 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
368 .tdm_slots = 2,
369 .serial_dir = da850_iis_serializer_direction,
Sekhar Nori48519f02010-07-19 12:31:16 +0530370 .asp_chan_q = EVENTQ_1,
Chaithrika U S491214e2009-08-11 17:03:25 -0400371 .version = MCASP_VERSION_2,
372 .txnumevt = 1,
373 .rxnumevt = 1,
374};
375
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400376static int da850_evm_mmc_get_ro(int index)
377{
378 return gpio_get_value(DA850_MMCSD_WP_PIN);
379}
380
381static int da850_evm_mmc_get_cd(int index)
382{
383 return !gpio_get_value(DA850_MMCSD_CD_PIN);
384}
385
386static struct davinci_mmc_config da850_mmc_config = {
387 .get_ro = da850_evm_mmc_get_ro,
388 .get_cd = da850_evm_mmc_get_cd,
389 .wires = 4,
Chaithrika U S0046d0b2009-11-03 15:46:14 +0530390 .max_freq = 50000000,
391 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400392 .version = MMC_CTLR_VERSION_2,
393};
394
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800395static void da850_panel_power_ctrl(int val)
396{
397 /* lcd backlight */
398 gpio_set_value(DA850_LCD_BL_PIN, val);
399
400 /* lcd power */
401 gpio_set_value(DA850_LCD_PWR_PIN, val);
402}
403
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400404static int da850_lcd_hw_init(void)
405{
406 int status;
407
408 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
409 if (status < 0)
410 return status;
411
412 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
413 if (status < 0) {
414 gpio_free(DA850_LCD_BL_PIN);
415 return status;
416 }
417
418 gpio_direction_output(DA850_LCD_BL_PIN, 0);
419 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
420
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800421 /* Switch off panel power and backlight */
422 da850_panel_power_ctrl(0);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400423
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800424 /* Switch on panel power and backlight */
425 da850_panel_power_ctrl(1);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400426
427 return 0;
428}
Chaithrika U S491214e2009-08-11 17:03:25 -0400429
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530430/* TPS65070 voltage regulator support */
431
432/* 3.3V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530433static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530434 {
435 .supply = "usb0_vdda33",
436 },
437 {
438 .supply = "usb1_vdda33",
439 },
440};
441
442/* 3.3V or 1.8V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530443static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530444 {
445 .supply = "dvdd3318_a",
446 },
447 {
448 .supply = "dvdd3318_b",
449 },
450 {
451 .supply = "dvdd3318_c",
452 },
453};
454
455/* 1.2V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530456static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530457 {
458 .supply = "cvdd",
459 },
460};
461
462/* 1.8V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530463static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530464 {
465 .supply = "sata_vddr",
466 },
467 {
468 .supply = "usb0_vdda18",
469 },
470 {
471 .supply = "usb1_vdda18",
472 },
473 {
474 .supply = "ddr_dvdd18",
475 },
476};
477
478/* 1.2V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530479static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530480 {
481 .supply = "sata_vdd",
482 },
483 {
484 .supply = "pll0_vdda",
485 },
486 {
487 .supply = "pll1_vdda",
488 },
489 {
490 .supply = "usbs_cvdd",
491 },
492 {
493 .supply = "vddarnwa1",
494 },
495};
496
Sekhar Nori8b245992010-07-12 17:56:21 +0530497/* We take advantage of the fact that both defdcdc{2,3} are tied high */
498static struct tps6507x_reg_platform_data tps6507x_platform_data = {
499 .defdcdc_default = true,
500};
501
Sekhar Noridb549d22010-06-28 17:16:38 +0530502static struct regulator_init_data tps65070_regulator_data[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530503 /* dcdc1 */
504 {
505 .constraints = {
506 .min_uV = 3150000,
507 .max_uV = 3450000,
508 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
509 REGULATOR_CHANGE_STATUS),
510 .boot_on = 1,
511 },
512 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
513 .consumer_supplies = tps65070_dcdc1_consumers,
514 },
515
516 /* dcdc2 */
517 {
518 .constraints = {
519 .min_uV = 1710000,
520 .max_uV = 3450000,
521 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
522 REGULATOR_CHANGE_STATUS),
523 .boot_on = 1,
524 },
525 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
526 .consumer_supplies = tps65070_dcdc2_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530527 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530528 },
529
530 /* dcdc3 */
531 {
532 .constraints = {
533 .min_uV = 950000,
534 .max_uV = 1320000,
535 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
536 REGULATOR_CHANGE_STATUS),
537 .boot_on = 1,
538 },
539 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
540 .consumer_supplies = tps65070_dcdc3_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530541 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530542 },
543
544 /* ldo1 */
545 {
546 .constraints = {
547 .min_uV = 1710000,
548 .max_uV = 1890000,
549 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
550 REGULATOR_CHANGE_STATUS),
551 .boot_on = 1,
552 },
553 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
554 .consumer_supplies = tps65070_ldo1_consumers,
555 },
556
557 /* ldo2 */
558 {
559 .constraints = {
560 .min_uV = 1140000,
561 .max_uV = 1320000,
562 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
563 REGULATOR_CHANGE_STATUS),
564 .boot_on = 1,
565 },
566 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
567 .consumer_supplies = tps65070_ldo2_consumers,
568 },
569};
570
Todd Fischerda1e3682010-04-05 17:53:13 -0600571static struct touchscreen_init_data tps6507x_touchscreen_data = {
572 .poll_period = 30, /* ms between touch samples */
573 .min_pressure = 0x30, /* minimum pressure to trigger touch */
574 .vref = 0, /* turn off vref when not using A/D */
575 .vendor = 0, /* /sys/class/input/input?/id/vendor */
576 .product = 65070, /* /sys/class/input/input?/id/product */
577 .version = 0x100, /* /sys/class/input/input?/id/version */
578};
579
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600580static struct tps6507x_board tps_board = {
581 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
Todd Fischerda1e3682010-04-05 17:53:13 -0600582 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600583};
584
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530585static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
586 {
587 I2C_BOARD_INFO("tps6507x", 0x48),
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600588 .platform_data = &tps_board,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530589 },
590};
591
592static int __init pmic_tps65070_init(void)
593{
594 return i2c_register_board_info(1, da850evm_tps65070_info,
595 ARRAY_SIZE(da850evm_tps65070_info));
596}
597
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400598static const short da850_evm_lcdc_pins[] = {
599 DA850_GPIO2_8, DA850_GPIO2_15,
600 -1
601};
602
Sekhar Noribae10582009-10-21 21:18:22 +0530603static int __init da850_evm_config_emac(void)
Chaithrika U S22067712009-09-30 17:00:53 -0400604{
605 void __iomem *cfg_chip3_base;
606 int ret;
607 u32 val;
Sekhar Noribae10582009-10-21 21:18:22 +0530608 struct davinci_soc_info *soc_info = &davinci_soc_info;
609 u8 rmii_en = soc_info->emac_pdata->rmii_en;
610
611 if (!machine_is_davinci_da850_evm())
612 return 0;
Chaithrika U S22067712009-09-30 17:00:53 -0400613
Sekhar Norid2de0582009-11-16 17:21:32 +0530614 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
Chaithrika U S22067712009-09-30 17:00:53 -0400615
Chaithrika U S22067712009-09-30 17:00:53 -0400616 val = __raw_readl(cfg_chip3_base);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530617
618 if (rmii_en) {
Chaithrika U S22067712009-09-30 17:00:53 -0400619 val |= BIT(8);
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400620 ret = davinci_cfg_reg_list(da850_rmii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530621 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
622 " functional\n");
623 } else {
624 val &= ~BIT(8);
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400625 ret = davinci_cfg_reg_list(da850_cpgmac_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530626 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
627 " functional\n");
628 }
629
Chaithrika U S22067712009-09-30 17:00:53 -0400630 if (ret)
631 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
632 ret);
633
Sekhar Nori17fadd92009-10-21 21:18:24 +0530634 /* configure the CFGCHIP3 register for RMII or MII */
635 __raw_writel(val, cfg_chip3_base);
636
Chaithrika U S22067712009-09-30 17:00:53 -0400637 ret = davinci_cfg_reg(DA850_GPIO2_6);
638 if (ret)
639 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
640 "failed\n");
641
642 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
643 if (ret) {
644 pr_warning("Cannot open GPIO %d\n",
645 DA850_MII_MDIO_CLKEN_PIN);
646 return ret;
647 }
648
Sekhar Nori17fadd92009-10-21 21:18:24 +0530649 /* Enable/Disable MII MDIO clock */
650 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
Chaithrika U S22067712009-09-30 17:00:53 -0400651
Sekhar Noribae10582009-10-21 21:18:22 +0530652 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
653 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
654
655 ret = da8xx_register_emac();
656 if (ret)
657 pr_warning("da850_evm_init: emac registration failed: %d\n",
658 ret);
659
Chaithrika U S22067712009-09-30 17:00:53 -0400660 return 0;
661}
Sekhar Noribae10582009-10-21 21:18:22 +0530662device_initcall(da850_evm_config_emac);
Chaithrika U S22067712009-09-30 17:00:53 -0400663
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530664/*
665 * The following EDMA channels/slots are not being used by drivers (for
666 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
667 * they are being reserved for codecs on the DSP side.
668 */
669static const s16 da850_dma0_rsv_chans[][2] = {
670 /* (offset, number) */
671 { 8, 6},
672 {24, 4},
673 {30, 2},
674 {-1, -1}
675};
676
677static const s16 da850_dma0_rsv_slots[][2] = {
678 /* (offset, number) */
679 { 8, 6},
680 {24, 4},
681 {30, 50},
682 {-1, -1}
683};
684
685static const s16 da850_dma1_rsv_chans[][2] = {
686 /* (offset, number) */
687 { 0, 28},
688 {30, 2},
689 {-1, -1}
690};
691
692static const s16 da850_dma1_rsv_slots[][2] = {
693 /* (offset, number) */
694 { 0, 28},
695 {30, 90},
696 {-1, -1}
697};
698
699static struct edma_rsv_info da850_edma_cc0_rsv = {
700 .rsv_chans = da850_dma0_rsv_chans,
701 .rsv_slots = da850_dma0_rsv_slots,
702};
703
704static struct edma_rsv_info da850_edma_cc1_rsv = {
705 .rsv_chans = da850_dma1_rsv_chans,
706 .rsv_slots = da850_dma1_rsv_slots,
707};
708
709static struct edma_rsv_info *da850_edma_rsv[2] = {
710 &da850_edma_cc0_rsv,
711 &da850_edma_cc1_rsv,
712};
713
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400714static __init void da850_evm_init(void)
715{
716 int ret;
717
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530718 ret = pmic_tps65070_init();
719 if (ret)
720 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
721 ret);
722
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530723 ret = da850_register_edma(da850_edma_rsv);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400724 if (ret)
725 pr_warning("da850_evm_init: edma registration failed: %d\n",
726 ret);
727
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400728 ret = davinci_cfg_reg_list(da850_i2c0_pins);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400729 if (ret)
730 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
731 ret);
732
733 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
734 if (ret)
735 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
736 ret);
737
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400738
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400739 ret = da8xx_register_watchdog();
740 if (ret)
741 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
742 ret);
743
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400744 if (HAS_MMC) {
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400745 ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400746 if (ret)
747 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
748 " %d\n", ret);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400749
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400750 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
751 if (ret)
752 pr_warning("da850_evm_init: can not open GPIO %d\n",
753 DA850_MMCSD_CD_PIN);
754 gpio_direction_input(DA850_MMCSD_CD_PIN);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400755
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400756 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
757 if (ret)
758 pr_warning("da850_evm_init: can not open GPIO %d\n",
759 DA850_MMCSD_WP_PIN);
760 gpio_direction_input(DA850_MMCSD_WP_PIN);
761
762 ret = da8xx_register_mmcsd0(&da850_mmc_config);
763 if (ret)
764 pr_warning("da850_evm_init: mmcsd0 registration failed:"
765 " %d\n", ret);
766 }
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400767
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400768 davinci_serial_init(&da850_evm_uart_config);
769
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300770 i2c_register_board_info(1, da850_evm_i2c_devices,
771 ARRAY_SIZE(da850_evm_i2c_devices));
772
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400773 /*
774 * shut down uart 0 and 1; they are not used on the board and
775 * accessing them causes endless "too much work in irq53" messages
776 * with arago fs
777 */
778 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
779 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -0400780
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400781 ret = davinci_cfg_reg_list(da850_mcasp_pins);
Chaithrika U S491214e2009-08-11 17:03:25 -0400782 if (ret)
783 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
784 ret);
785
Mark A. Greerb8864aa2009-08-28 15:05:02 -0700786 da8xx_register_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400787
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400788 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400789 if (ret)
790 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
791 ret);
792
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400793 /* Handle board specific muxing for LCD here */
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400794 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400795 if (ret)
796 pr_warning("da850_evm_init: evm specific lcd mux setup "
797 "failed: %d\n", ret);
798
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400799 ret = da850_lcd_hw_init();
800 if (ret)
801 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
802 ret);
803
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800804 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
Mark A. Greerb9e63422009-09-15 18:14:19 -0700805 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400806 if (ret)
807 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
808 ret);
Mark A. Greerc51df702009-09-15 18:15:54 -0700809
810 ret = da8xx_register_rtc();
811 if (ret)
812 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
Sekhar Nori09dc2d42009-09-22 21:14:03 +0530813
Sekhar Norib987c4b2010-07-20 16:46:51 +0530814 ret = da850_register_cpufreq("pll0_sysclk3");
Sekhar Nori09dc2d42009-09-22 21:14:03 +0530815 if (ret)
816 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
817 ret);
Sekhar Nori5aeb15a2009-10-22 15:12:15 +0530818
819 ret = da8xx_register_cpuidle();
820 if (ret)
821 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
822 ret);
Sekhar Nori63534442009-12-17 18:29:33 +0530823
824 ret = da850_register_pm(&da850_pm_device);
825 if (ret)
826 pr_warning("da850_evm_init: suspend registration failed: %d\n",
827 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400828}
829
830#ifdef CONFIG_SERIAL_8250_CONSOLE
831static int __init da850_evm_console_init(void)
832{
833 return add_preferred_console("ttyS", 2, "115200");
834}
835console_initcall(da850_evm_console_init);
836#endif
837
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400838static void __init da850_evm_map_io(void)
839{
840 da850_init();
841}
842
Sekhar Nori48ea89e2010-07-01 19:00:50 +0530843MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400844 .phys_io = IO_PHYS,
845 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
846 .boot_params = (DA8XX_DDR_BASE + 0x100),
847 .map_io = da850_evm_map_io,
Cyril Chemparathybd808942010-05-07 17:06:37 -0400848 .init_irq = cp_intc_init,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400849 .timer = &davinci_timer,
850 .init_machine = da850_evm_init,
851MACHINE_END