blob: 93bd43e93c450ac1054040e0ad3d40df1721c5ba [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>
Ben Gardiner75929f52010-12-09 16:51:04 -050020#include <linux/input.h>
Todd Fischer0bc20bb2010-04-05 20:23:57 -060021#include <linux/mfd/tps6507x.h>
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040022#include <linux/gpio.h>
Ben Gardiner75929f52010-12-09 16:51:04 -050023#include <linux/gpio_keys.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040024#include <linux/platform_device.h>
25#include <linux/mtd/mtd.h>
26#include <linux/mtd/nand.h>
27#include <linux/mtd/partitions.h>
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -040028#include <linux/mtd/physmap.h>
Sekhar Noria9eb1f62009-09-22 21:14:04 +053029#include <linux/regulator/machine.h>
Sekhar Nori8b245992010-07-12 17:56:21 +053030#include <linux/regulator/tps6507x.h>
Todd Fischerda1e3682010-04-05 17:53:13 -060031#include <linux/input/tps6507x-ts.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040032
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040036#include <mach/cp_intc.h>
37#include <mach/da8xx.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040038#include <mach/nand.h>
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -040039#include <mach/mux.h>
Sekhar Nori18a85052010-08-09 15:46:39 +053040#include <mach/aemif.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040041
Cyril Chemparathy782f2d72010-09-15 10:11:25 -040042#define DA850_EVM_PHY_ID "0:00"
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
Sekhar Nori18a85052010-08-09 15:46:39 +0530146static struct davinci_aemif_timing da850_evm_nandflash_timing = {
147 .wsetup = 24,
148 .wstrobe = 21,
149 .whold = 14,
150 .rsetup = 19,
151 .rstrobe = 50,
152 .rhold = 0,
153 .ta = 20,
154};
155
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400156static struct davinci_nand_pdata da850_evm_nandflash_data = {
157 .parts = da850_evm_nandflash_partition,
158 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
159 .ecc_mode = NAND_ECC_HW,
Sudhakar Rajashekharafc42e332009-11-18 12:11:41 +0530160 .ecc_bits = 4,
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400161 .options = NAND_USE_FLASH_BBT,
Sekhar Nori18a85052010-08-09 15:46:39 +0530162 .timing = &da850_evm_nandflash_timing,
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400163};
164
165static struct resource da850_evm_nandflash_resource[] = {
166 {
167 .start = DA8XX_AEMIF_CS3_BASE,
168 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .start = DA8XX_AEMIF_CTL_BASE,
173 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
174 .flags = IORESOURCE_MEM,
175 },
176};
177
178static struct platform_device da850_evm_nandflash_device = {
179 .name = "davinci_nand",
180 .id = 1,
181 .dev = {
182 .platform_data = &da850_evm_nandflash_data,
183 },
184 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
185 .resource = da850_evm_nandflash_resource,
186};
187
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530188static struct platform_device *da850_evm_devices[] __initdata = {
189 &da850_evm_nandflash_device,
190 &da850_evm_norflash_device,
191};
192
193#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
194#define DA8XX_AEMIF_ASIZE_16BIT 0x1
195
196static void __init da850_evm_init_nor(void)
197{
198 void __iomem *aemif_addr;
199
200 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
201
202 /* Configure data bus width of CS2 to 16 bit */
203 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
204 DA8XX_AEMIF_ASIZE_16BIT,
205 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
206
207 iounmap(aemif_addr);
208}
209
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400210static const short da850_evm_nand_pins[] = {
211 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
212 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
213 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
214 DA850_NEMA_WE, DA850_NEMA_OE,
215 -1
216};
217
218static const short da850_evm_nor_pins[] = {
219 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
220 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
221 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
222 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
223 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
224 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
225 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
226 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
227 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
228 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
229 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
230 DA850_EMA_A_22, DA850_EMA_A_23,
231 -1
232};
233
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400234static u32 ui_card_detected;
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530235
236#if defined(CONFIG_MMC_DAVINCI) || \
237 defined(CONFIG_MMC_DAVINCI_MODULE)
238#define HAS_MMC 1
239#else
240#define HAS_MMC 0
241#endif
242
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400243static inline void da850_evm_setup_nor_nand(void)
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530244{
245 int ret = 0;
246
247 if (ui_card_detected & !HAS_MMC) {
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400248 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530249 if (ret)
250 pr_warning("da850_evm_init: nand mux setup failed: "
251 "%d\n", ret);
252
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400253 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530254 if (ret)
255 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
256 ret);
257
258 da850_evm_init_nor();
259
260 platform_add_devices(da850_evm_devices,
261 ARRAY_SIZE(da850_evm_devices));
262 }
263}
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400264
Sekhar Noribae10582009-10-21 21:18:22 +0530265#ifdef CONFIG_DA850_UI_RMII
266static inline void da850_evm_setup_emac_rmii(int rmii_sel)
267{
268 struct davinci_soc_info *soc_info = &davinci_soc_info;
269
270 soc_info->emac_pdata->rmii_en = 1;
Ben Gardiner47e7cb12010-11-15 09:42:52 -0500271 gpio_set_value_cansleep(rmii_sel, 0);
Sekhar Noribae10582009-10-21 21:18:22 +0530272}
273#else
274static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
275#endif
276
Ben Gardiner75929f52010-12-09 16:51:04 -0500277
278#define DA850_KEYS_DEBOUNCE_MS 10
279/*
280 * At 200ms polling interval it is possible to miss an
281 * event by tapping very lightly on the push button but most
282 * pushes do result in an event; longer intervals require the
283 * user to hold the button whereas shorter intervals require
284 * more CPU time for polling.
285 */
286#define DA850_GPIO_KEYS_POLL_MS 200
287
288enum da850_evm_ui_exp_pins {
289 DA850_EVM_UI_EXP_SEL_C = 5,
290 DA850_EVM_UI_EXP_SEL_B,
291 DA850_EVM_UI_EXP_SEL_A,
292 DA850_EVM_UI_EXP_PB8,
293 DA850_EVM_UI_EXP_PB7,
294 DA850_EVM_UI_EXP_PB6,
295 DA850_EVM_UI_EXP_PB5,
296 DA850_EVM_UI_EXP_PB4,
297 DA850_EVM_UI_EXP_PB3,
298 DA850_EVM_UI_EXP_PB2,
299 DA850_EVM_UI_EXP_PB1,
300};
301
302static const char const *da850_evm_ui_exp[] = {
303 [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
304 [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
305 [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
306 [DA850_EVM_UI_EXP_PB8] = "pb8",
307 [DA850_EVM_UI_EXP_PB7] = "pb7",
308 [DA850_EVM_UI_EXP_PB6] = "pb6",
309 [DA850_EVM_UI_EXP_PB5] = "pb5",
310 [DA850_EVM_UI_EXP_PB4] = "pb4",
311 [DA850_EVM_UI_EXP_PB3] = "pb3",
312 [DA850_EVM_UI_EXP_PB2] = "pb2",
313 [DA850_EVM_UI_EXP_PB1] = "pb1",
314};
315
316#define DA850_N_UI_PB 8
317
318static struct gpio_keys_button da850_evm_ui_keys[] = {
319 [0 ... DA850_N_UI_PB - 1] = {
320 .type = EV_KEY,
321 .active_low = 1,
322 .wakeup = 0,
323 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
324 .code = -1, /* assigned at runtime */
325 .gpio = -1, /* assigned at runtime */
326 .desc = NULL, /* assigned at runtime */
327 },
328};
329
330static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
331 .buttons = da850_evm_ui_keys,
332 .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
333 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
334};
335
336static struct platform_device da850_evm_ui_keys_device = {
337 .name = "gpio-keys-polled",
338 .id = 0,
339 .dev = {
340 .platform_data = &da850_evm_ui_keys_pdata
341 },
342};
343
344static void da850_evm_ui_keys_init(unsigned gpio)
345{
346 int i;
347 struct gpio_keys_button *button;
348
349 for (i = 0; i < DA850_N_UI_PB; i++) {
350 button = &da850_evm_ui_keys[i];
351 button->code = KEY_F8 - i;
352 button->desc = (char *)
353 da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
354 button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
355 }
356}
357
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400358static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
359 unsigned ngpio, void *c)
360{
361 int sel_a, sel_b, sel_c, ret;
362
363 sel_a = gpio + 7;
364 sel_b = gpio + 6;
365 sel_c = gpio + 5;
366
367 ret = gpio_request(sel_a, "sel_a");
368 if (ret) {
369 pr_warning("Cannot open UI expander pin %d\n", sel_a);
370 goto exp_setup_sela_fail;
371 }
372
373 ret = gpio_request(sel_b, "sel_b");
374 if (ret) {
375 pr_warning("Cannot open UI expander pin %d\n", sel_b);
376 goto exp_setup_selb_fail;
377 }
378
379 ret = gpio_request(sel_c, "sel_c");
380 if (ret) {
381 pr_warning("Cannot open UI expander pin %d\n", sel_c);
382 goto exp_setup_selc_fail;
383 }
384
385 /* deselect all functionalities */
386 gpio_direction_output(sel_a, 1);
387 gpio_direction_output(sel_b, 1);
388 gpio_direction_output(sel_c, 1);
389
Ben Gardiner75929f52010-12-09 16:51:04 -0500390 da850_evm_ui_keys_init(gpio);
391 ret = platform_device_register(&da850_evm_ui_keys_device);
392 if (ret) {
393 pr_warning("Could not register UI GPIO expander push-buttons");
394 goto exp_setup_keys_fail;
395 }
396
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400397 ui_card_detected = 1;
398 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
399
400 da850_evm_setup_nor_nand();
401
Sekhar Noribae10582009-10-21 21:18:22 +0530402 da850_evm_setup_emac_rmii(sel_a);
Chaithrika U S22067712009-09-30 17:00:53 -0400403
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400404 return 0;
405
Ben Gardiner75929f52010-12-09 16:51:04 -0500406exp_setup_keys_fail:
407 gpio_free(sel_c);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400408exp_setup_selc_fail:
409 gpio_free(sel_b);
410exp_setup_selb_fail:
411 gpio_free(sel_a);
412exp_setup_sela_fail:
413 return ret;
414}
415
416static int da850_evm_ui_expander_teardown(struct i2c_client *client,
417 unsigned gpio, unsigned ngpio, void *c)
418{
Ben Gardiner75929f52010-12-09 16:51:04 -0500419 platform_device_unregister(&da850_evm_ui_keys_device);
420
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400421 /* deselect all functionalities */
Ben Gardiner47e7cb12010-11-15 09:42:52 -0500422 gpio_set_value_cansleep(gpio + 5, 1);
423 gpio_set_value_cansleep(gpio + 6, 1);
424 gpio_set_value_cansleep(gpio + 7, 1);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400425
426 gpio_free(gpio + 5);
427 gpio_free(gpio + 6);
428 gpio_free(gpio + 7);
429
430 return 0;
431}
432
433static struct pca953x_platform_data da850_evm_ui_expander_info = {
434 .gpio_base = DAVINCI_N_GPIO,
435 .setup = da850_evm_ui_expander_setup,
436 .teardown = da850_evm_ui_expander_teardown,
Ben Gardiner75929f52010-12-09 16:51:04 -0500437 .names = da850_evm_ui_exp,
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400438};
439
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300440static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
441 {
442 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400443 },
444 {
445 I2C_BOARD_INFO("tca6416", 0x20),
446 .platform_data = &da850_evm_ui_expander_info,
447 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300448};
449
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400450static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
451 .bus_freq = 100, /* kHz */
452 .bus_delay = 0, /* usec */
453};
454
455static struct davinci_uart_config da850_evm_uart_config __initdata = {
456 .enabled_uarts = 0x7,
457};
458
Chaithrika U S491214e2009-08-11 17:03:25 -0400459/* davinci da850 evm audio machine driver */
460static u8 da850_iis_serializer_direction[] = {
461 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
462 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
463 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
464 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
465};
466
467static struct snd_platform_data da850_evm_snd_data = {
468 .tx_dma_offset = 0x2000,
469 .rx_dma_offset = 0x2000,
470 .op_mode = DAVINCI_MCASP_IIS_MODE,
471 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
472 .tdm_slots = 2,
473 .serial_dir = da850_iis_serializer_direction,
Sekhar Nori48519f02010-07-19 12:31:16 +0530474 .asp_chan_q = EVENTQ_1,
Chaithrika U S491214e2009-08-11 17:03:25 -0400475 .version = MCASP_VERSION_2,
476 .txnumevt = 1,
477 .rxnumevt = 1,
478};
479
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400480static int da850_evm_mmc_get_ro(int index)
481{
482 return gpio_get_value(DA850_MMCSD_WP_PIN);
483}
484
485static int da850_evm_mmc_get_cd(int index)
486{
487 return !gpio_get_value(DA850_MMCSD_CD_PIN);
488}
489
490static struct davinci_mmc_config da850_mmc_config = {
491 .get_ro = da850_evm_mmc_get_ro,
492 .get_cd = da850_evm_mmc_get_cd,
493 .wires = 4,
Chaithrika U S0046d0b2009-11-03 15:46:14 +0530494 .max_freq = 50000000,
495 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400496 .version = MMC_CTLR_VERSION_2,
497};
498
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800499static void da850_panel_power_ctrl(int val)
500{
501 /* lcd backlight */
502 gpio_set_value(DA850_LCD_BL_PIN, val);
503
504 /* lcd power */
505 gpio_set_value(DA850_LCD_PWR_PIN, val);
506}
507
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400508static int da850_lcd_hw_init(void)
509{
510 int status;
511
512 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
513 if (status < 0)
514 return status;
515
516 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
517 if (status < 0) {
518 gpio_free(DA850_LCD_BL_PIN);
519 return status;
520 }
521
522 gpio_direction_output(DA850_LCD_BL_PIN, 0);
523 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
524
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800525 /* Switch off panel power and backlight */
526 da850_panel_power_ctrl(0);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400527
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800528 /* Switch on panel power and backlight */
529 da850_panel_power_ctrl(1);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400530
531 return 0;
532}
Chaithrika U S491214e2009-08-11 17:03:25 -0400533
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530534/* TPS65070 voltage regulator support */
535
536/* 3.3V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530537static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530538 {
539 .supply = "usb0_vdda33",
540 },
541 {
542 .supply = "usb1_vdda33",
543 },
544};
545
546/* 3.3V or 1.8V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530547static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530548 {
549 .supply = "dvdd3318_a",
550 },
551 {
552 .supply = "dvdd3318_b",
553 },
554 {
555 .supply = "dvdd3318_c",
556 },
557};
558
559/* 1.2V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530560static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530561 {
562 .supply = "cvdd",
563 },
564};
565
566/* 1.8V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530567static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530568 {
569 .supply = "sata_vddr",
570 },
571 {
572 .supply = "usb0_vdda18",
573 },
574 {
575 .supply = "usb1_vdda18",
576 },
577 {
578 .supply = "ddr_dvdd18",
579 },
580};
581
582/* 1.2V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530583static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530584 {
585 .supply = "sata_vdd",
586 },
587 {
588 .supply = "pll0_vdda",
589 },
590 {
591 .supply = "pll1_vdda",
592 },
593 {
594 .supply = "usbs_cvdd",
595 },
596 {
597 .supply = "vddarnwa1",
598 },
599};
600
Sekhar Nori8b245992010-07-12 17:56:21 +0530601/* We take advantage of the fact that both defdcdc{2,3} are tied high */
602static struct tps6507x_reg_platform_data tps6507x_platform_data = {
603 .defdcdc_default = true,
604};
605
Sekhar Noridb549d22010-06-28 17:16:38 +0530606static struct regulator_init_data tps65070_regulator_data[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530607 /* dcdc1 */
608 {
609 .constraints = {
610 .min_uV = 3150000,
611 .max_uV = 3450000,
612 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
613 REGULATOR_CHANGE_STATUS),
614 .boot_on = 1,
615 },
616 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
617 .consumer_supplies = tps65070_dcdc1_consumers,
618 },
619
620 /* dcdc2 */
621 {
622 .constraints = {
623 .min_uV = 1710000,
624 .max_uV = 3450000,
625 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
626 REGULATOR_CHANGE_STATUS),
627 .boot_on = 1,
628 },
629 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
630 .consumer_supplies = tps65070_dcdc2_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530631 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530632 },
633
634 /* dcdc3 */
635 {
636 .constraints = {
637 .min_uV = 950000,
638 .max_uV = 1320000,
639 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
640 REGULATOR_CHANGE_STATUS),
641 .boot_on = 1,
642 },
643 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
644 .consumer_supplies = tps65070_dcdc3_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530645 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530646 },
647
648 /* ldo1 */
649 {
650 .constraints = {
651 .min_uV = 1710000,
652 .max_uV = 1890000,
653 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
654 REGULATOR_CHANGE_STATUS),
655 .boot_on = 1,
656 },
657 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
658 .consumer_supplies = tps65070_ldo1_consumers,
659 },
660
661 /* ldo2 */
662 {
663 .constraints = {
664 .min_uV = 1140000,
665 .max_uV = 1320000,
666 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
667 REGULATOR_CHANGE_STATUS),
668 .boot_on = 1,
669 },
670 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
671 .consumer_supplies = tps65070_ldo2_consumers,
672 },
673};
674
Todd Fischerda1e3682010-04-05 17:53:13 -0600675static struct touchscreen_init_data tps6507x_touchscreen_data = {
676 .poll_period = 30, /* ms between touch samples */
677 .min_pressure = 0x30, /* minimum pressure to trigger touch */
678 .vref = 0, /* turn off vref when not using A/D */
679 .vendor = 0, /* /sys/class/input/input?/id/vendor */
680 .product = 65070, /* /sys/class/input/input?/id/product */
681 .version = 0x100, /* /sys/class/input/input?/id/version */
682};
683
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600684static struct tps6507x_board tps_board = {
685 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
Todd Fischerda1e3682010-04-05 17:53:13 -0600686 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600687};
688
Ben Gardiner3506f272010-11-19 16:43:04 -0500689static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530690 {
691 I2C_BOARD_INFO("tps6507x", 0x48),
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600692 .platform_data = &tps_board,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530693 },
694};
695
696static int __init pmic_tps65070_init(void)
697{
Ben Gardiner3506f272010-11-19 16:43:04 -0500698 return i2c_register_board_info(1, da850_evm_tps65070_info,
699 ARRAY_SIZE(da850_evm_tps65070_info));
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530700}
701
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400702static const short da850_evm_lcdc_pins[] = {
703 DA850_GPIO2_8, DA850_GPIO2_15,
704 -1
705};
706
Sergei Shtylyov85b83072010-08-01 21:17:00 +0400707static const short da850_evm_mii_pins[] = {
708 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
709 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
710 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
711 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
712 DA850_MDIO_D,
713 -1
714};
715
716static const short da850_evm_rmii_pins[] = {
717 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
718 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
719 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
720 DA850_MDIO_D,
721 -1
722};
723
Sekhar Noribae10582009-10-21 21:18:22 +0530724static int __init da850_evm_config_emac(void)
Chaithrika U S22067712009-09-30 17:00:53 -0400725{
726 void __iomem *cfg_chip3_base;
727 int ret;
728 u32 val;
Sekhar Noribae10582009-10-21 21:18:22 +0530729 struct davinci_soc_info *soc_info = &davinci_soc_info;
730 u8 rmii_en = soc_info->emac_pdata->rmii_en;
731
732 if (!machine_is_davinci_da850_evm())
733 return 0;
Chaithrika U S22067712009-09-30 17:00:53 -0400734
Sekhar Norid2de0582009-11-16 17:21:32 +0530735 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
Chaithrika U S22067712009-09-30 17:00:53 -0400736
Chaithrika U S22067712009-09-30 17:00:53 -0400737 val = __raw_readl(cfg_chip3_base);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530738
739 if (rmii_en) {
Chaithrika U S22067712009-09-30 17:00:53 -0400740 val |= BIT(8);
Sergei Shtylyov85b83072010-08-01 21:17:00 +0400741 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530742 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
743 " functional\n");
744 } else {
745 val &= ~BIT(8);
Sergei Shtylyov85b83072010-08-01 21:17:00 +0400746 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +0530747 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
748 " functional\n");
749 }
750
Chaithrika U S22067712009-09-30 17:00:53 -0400751 if (ret)
752 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
753 ret);
754
Sekhar Nori17fadd92009-10-21 21:18:24 +0530755 /* configure the CFGCHIP3 register for RMII or MII */
756 __raw_writel(val, cfg_chip3_base);
757
Chaithrika U S22067712009-09-30 17:00:53 -0400758 ret = davinci_cfg_reg(DA850_GPIO2_6);
759 if (ret)
760 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
761 "failed\n");
762
763 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
764 if (ret) {
765 pr_warning("Cannot open GPIO %d\n",
766 DA850_MII_MDIO_CLKEN_PIN);
767 return ret;
768 }
769
Sekhar Nori17fadd92009-10-21 21:18:24 +0530770 /* Enable/Disable MII MDIO clock */
771 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
Chaithrika U S22067712009-09-30 17:00:53 -0400772
Cyril Chemparathy782f2d72010-09-15 10:11:25 -0400773 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
Sekhar Noribae10582009-10-21 21:18:22 +0530774
775 ret = da8xx_register_emac();
776 if (ret)
777 pr_warning("da850_evm_init: emac registration failed: %d\n",
778 ret);
779
Chaithrika U S22067712009-09-30 17:00:53 -0400780 return 0;
781}
Sekhar Noribae10582009-10-21 21:18:22 +0530782device_initcall(da850_evm_config_emac);
Chaithrika U S22067712009-09-30 17:00:53 -0400783
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530784/*
785 * The following EDMA channels/slots are not being used by drivers (for
786 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
787 * they are being reserved for codecs on the DSP side.
788 */
789static const s16 da850_dma0_rsv_chans[][2] = {
790 /* (offset, number) */
791 { 8, 6},
792 {24, 4},
793 {30, 2},
794 {-1, -1}
795};
796
797static const s16 da850_dma0_rsv_slots[][2] = {
798 /* (offset, number) */
799 { 8, 6},
800 {24, 4},
801 {30, 50},
802 {-1, -1}
803};
804
805static const s16 da850_dma1_rsv_chans[][2] = {
806 /* (offset, number) */
807 { 0, 28},
808 {30, 2},
809 {-1, -1}
810};
811
812static const s16 da850_dma1_rsv_slots[][2] = {
813 /* (offset, number) */
814 { 0, 28},
815 {30, 90},
816 {-1, -1}
817};
818
819static struct edma_rsv_info da850_edma_cc0_rsv = {
820 .rsv_chans = da850_dma0_rsv_chans,
821 .rsv_slots = da850_dma0_rsv_slots,
822};
823
824static struct edma_rsv_info da850_edma_cc1_rsv = {
825 .rsv_chans = da850_dma1_rsv_chans,
826 .rsv_slots = da850_dma1_rsv_slots,
827};
828
829static struct edma_rsv_info *da850_edma_rsv[2] = {
830 &da850_edma_cc0_rsv,
831 &da850_edma_cc1_rsv,
832};
833
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400834static __init void da850_evm_init(void)
835{
836 int ret;
837
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530838 ret = pmic_tps65070_init();
839 if (ret)
840 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
841 ret);
842
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530843 ret = da850_register_edma(da850_edma_rsv);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400844 if (ret)
845 pr_warning("da850_evm_init: edma registration failed: %d\n",
846 ret);
847
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400848 ret = davinci_cfg_reg_list(da850_i2c0_pins);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400849 if (ret)
850 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
851 ret);
852
853 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
854 if (ret)
855 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
856 ret);
857
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400858
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400859 ret = da8xx_register_watchdog();
860 if (ret)
861 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
862 ret);
863
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400864 if (HAS_MMC) {
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400865 ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400866 if (ret)
867 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
868 " %d\n", ret);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400869
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400870 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
871 if (ret)
872 pr_warning("da850_evm_init: can not open GPIO %d\n",
873 DA850_MMCSD_CD_PIN);
874 gpio_direction_input(DA850_MMCSD_CD_PIN);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400875
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -0400876 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
877 if (ret)
878 pr_warning("da850_evm_init: can not open GPIO %d\n",
879 DA850_MMCSD_WP_PIN);
880 gpio_direction_input(DA850_MMCSD_WP_PIN);
881
882 ret = da8xx_register_mmcsd0(&da850_mmc_config);
883 if (ret)
884 pr_warning("da850_evm_init: mmcsd0 registration failed:"
885 " %d\n", ret);
886 }
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400887
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400888 davinci_serial_init(&da850_evm_uart_config);
889
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300890 i2c_register_board_info(1, da850_evm_i2c_devices,
891 ARRAY_SIZE(da850_evm_i2c_devices));
892
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400893 /*
894 * shut down uart 0 and 1; they are not used on the board and
895 * accessing them causes endless "too much work in irq53" messages
896 * with arago fs
897 */
898 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
899 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -0400900
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400901 ret = davinci_cfg_reg_list(da850_mcasp_pins);
Chaithrika U S491214e2009-08-11 17:03:25 -0400902 if (ret)
903 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
904 ret);
905
Mark A. Greerb8864aa2009-08-28 15:05:02 -0700906 da8xx_register_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400907
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400908 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400909 if (ret)
910 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
911 ret);
912
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400913 /* Handle board specific muxing for LCD here */
Cyril Chemparathy3821d102010-03-25 17:43:48 -0400914 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400915 if (ret)
916 pr_warning("da850_evm_init: evm specific lcd mux setup "
917 "failed: %d\n", ret);
918
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400919 ret = da850_lcd_hw_init();
920 if (ret)
921 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
922 ret);
923
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800924 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
Mark A. Greerb9e63422009-09-15 18:14:19 -0700925 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400926 if (ret)
927 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
928 ret);
Mark A. Greerc51df702009-09-15 18:15:54 -0700929
930 ret = da8xx_register_rtc();
931 if (ret)
932 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
Sekhar Nori09dc2d42009-09-22 21:14:03 +0530933
Sekhar Norib987c4b2010-07-20 16:46:51 +0530934 ret = da850_register_cpufreq("pll0_sysclk3");
Sekhar Nori09dc2d42009-09-22 21:14:03 +0530935 if (ret)
936 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
937 ret);
Sekhar Nori5aeb15a2009-10-22 15:12:15 +0530938
939 ret = da8xx_register_cpuidle();
940 if (ret)
941 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
942 ret);
Sekhar Nori63534442009-12-17 18:29:33 +0530943
944 ret = da850_register_pm(&da850_pm_device);
945 if (ret)
946 pr_warning("da850_evm_init: suspend registration failed: %d\n",
947 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400948}
949
950#ifdef CONFIG_SERIAL_8250_CONSOLE
951static int __init da850_evm_console_init(void)
952{
Michael Williamson1aa5f2a2010-08-31 14:30:15 -0400953 if (!machine_is_davinci_da850_evm())
954 return 0;
955
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400956 return add_preferred_console("ttyS", 2, "115200");
957}
958console_initcall(da850_evm_console_init);
959#endif
960
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400961static void __init da850_evm_map_io(void)
962{
963 da850_init();
964}
965
Sekhar Nori48ea89e2010-07-01 19:00:50 +0530966MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400967 .boot_params = (DA8XX_DDR_BASE + 0x100),
968 .map_io = da850_evm_map_io,
Cyril Chemparathybd808942010-05-07 17:06:37 -0400969 .init_irq = cp_intc_init,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400970 .timer = &davinci_timer,
971 .init_machine = da850_evm_init,
972MACHINE_END