blob: 85a2c7e1e6846a15107cca5895467e3756ca416e [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>
Sekhar Norifdce5562011-02-24 10:39:27 +053032#include <linux/spi/spi.h>
33#include <linux/spi/flash.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040034
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040038#include <mach/cp_intc.h>
39#include <mach/da8xx.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040040#include <mach/nand.h>
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -040041#include <mach/mux.h>
Sekhar Nori18a85052010-08-09 15:46:39 +053042#include <mach/aemif.h>
Sekhar Norifdce5562011-02-24 10:39:27 +053043#include <mach/spi.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040044
Cyril Chemparathy782f2d72010-09-15 10:11:25 -040045#define DA850_EVM_PHY_ID "0:00"
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -040046#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040047#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040048
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -040049#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
50#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
51
Chaithrika U S22067712009-09-30 17:00:53 -040052#define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
53
Sekhar Norifdce5562011-02-24 10:39:27 +053054static struct mtd_partition da850evm_spiflash_part[] = {
55 [0] = {
56 .name = "UBL",
57 .offset = 0,
58 .size = SZ_64K,
59 .mask_flags = MTD_WRITEABLE,
60 },
61 [1] = {
62 .name = "U-Boot",
63 .offset = MTDPART_OFS_APPEND,
64 .size = SZ_512K,
65 .mask_flags = MTD_WRITEABLE,
66 },
67 [2] = {
68 .name = "U-Boot-Env",
69 .offset = MTDPART_OFS_APPEND,
70 .size = SZ_64K,
71 .mask_flags = MTD_WRITEABLE,
72 },
73 [3] = {
74 .name = "Kernel",
75 .offset = MTDPART_OFS_APPEND,
76 .size = SZ_2M + SZ_512K,
77 .mask_flags = 0,
78 },
79 [4] = {
80 .name = "Filesystem",
81 .offset = MTDPART_OFS_APPEND,
82 .size = SZ_4M,
83 .mask_flags = 0,
84 },
85 [5] = {
86 .name = "MAC-Address",
87 .offset = SZ_8M - SZ_64K,
88 .size = SZ_64K,
89 .mask_flags = MTD_WRITEABLE,
90 },
91};
92
93static struct flash_platform_data da850evm_spiflash_data = {
94 .name = "m25p80",
95 .parts = da850evm_spiflash_part,
96 .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
97 .type = "m25p64",
98};
99
100static struct davinci_spi_config da850evm_spiflash_cfg = {
101 .io_type = SPI_IO_TYPE_DMA,
102 .c2tdelay = 8,
103 .t2cdelay = 8,
104};
105
106static struct spi_board_info da850evm_spi_info[] = {
107 {
108 .modalias = "m25p80",
109 .platform_data = &da850evm_spiflash_data,
110 .controller_data = &da850evm_spiflash_cfg,
111 .mode = SPI_MODE_0,
112 .max_speed_hz = 30000000,
113 .bus_num = 1,
114 .chip_select = 0,
115 },
116};
117
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -0400118static struct mtd_partition da850_evm_norflash_partition[] = {
119 {
Sudhakar Rajashekharae2abd5a2009-11-18 11:48:37 +0530120 .name = "bootloaders + env",
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -0400121 .offset = 0,
Sudhakar Rajashekharae2abd5a2009-11-18 11:48:37 +0530122 .size = SZ_512K,
123 .mask_flags = MTD_WRITEABLE,
124 },
125 {
126 .name = "kernel",
127 .offset = MTDPART_OFS_APPEND,
128 .size = SZ_2M,
129 .mask_flags = 0,
130 },
131 {
132 .name = "filesystem",
133 .offset = MTDPART_OFS_APPEND,
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -0400134 .size = MTDPART_SIZ_FULL,
135 .mask_flags = 0,
136 },
137};
138
139static struct physmap_flash_data da850_evm_norflash_data = {
140 .width = 2,
141 .parts = da850_evm_norflash_partition,
142 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
143};
144
145static struct resource da850_evm_norflash_resource[] = {
146 {
147 .start = DA8XX_AEMIF_CS2_BASE,
148 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
149 .flags = IORESOURCE_MEM,
150 },
151};
152
153static struct platform_device da850_evm_norflash_device = {
154 .name = "physmap-flash",
155 .id = 0,
156 .dev = {
157 .platform_data = &da850_evm_norflash_data,
158 },
159 .num_resources = 1,
160 .resource = da850_evm_norflash_resource,
161};
162
Sekhar Nori63534442009-12-17 18:29:33 +0530163static struct davinci_pm_config da850_pm_pdata = {
164 .sleepcount = 128,
165};
166
167static struct platform_device da850_pm_device = {
168 .name = "pm-davinci",
169 .dev = {
170 .platform_data = &da850_pm_pdata,
171 },
172 .id = -1,
173};
174
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400175/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
176 * (128K blocks). It may be used instead of the (default) SPI flash
177 * to boot, using TI's tools to install the secondary boot loader
178 * (UBL) and U-Boot.
179 */
Sekhar Noridb549d22010-06-28 17:16:38 +0530180static struct mtd_partition da850_evm_nandflash_partition[] = {
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400181 {
182 .name = "u-boot env",
183 .offset = 0,
184 .size = SZ_128K,
185 .mask_flags = MTD_WRITEABLE,
186 },
187 {
188 .name = "UBL",
189 .offset = MTDPART_OFS_APPEND,
190 .size = SZ_128K,
191 .mask_flags = MTD_WRITEABLE,
192 },
193 {
194 .name = "u-boot",
195 .offset = MTDPART_OFS_APPEND,
196 .size = 4 * SZ_128K,
197 .mask_flags = MTD_WRITEABLE,
198 },
199 {
200 .name = "kernel",
201 .offset = 0x200000,
202 .size = SZ_2M,
203 .mask_flags = 0,
204 },
205 {
206 .name = "filesystem",
207 .offset = MTDPART_OFS_APPEND,
208 .size = MTDPART_SIZ_FULL,
209 .mask_flags = 0,
210 },
211};
212
Sekhar Nori18a85052010-08-09 15:46:39 +0530213static struct davinci_aemif_timing da850_evm_nandflash_timing = {
214 .wsetup = 24,
215 .wstrobe = 21,
216 .whold = 14,
217 .rsetup = 19,
218 .rstrobe = 50,
219 .rhold = 0,
220 .ta = 20,
221};
222
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400223static struct davinci_nand_pdata da850_evm_nandflash_data = {
224 .parts = da850_evm_nandflash_partition,
225 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
226 .ecc_mode = NAND_ECC_HW,
Sudhakar Rajashekharafc42e332009-11-18 12:11:41 +0530227 .ecc_bits = 4,
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400228 .options = NAND_USE_FLASH_BBT,
Sekhar Nori18a85052010-08-09 15:46:39 +0530229 .timing = &da850_evm_nandflash_timing,
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400230};
231
232static struct resource da850_evm_nandflash_resource[] = {
233 {
234 .start = DA8XX_AEMIF_CS3_BASE,
235 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
236 .flags = IORESOURCE_MEM,
237 },
238 {
239 .start = DA8XX_AEMIF_CTL_BASE,
240 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
241 .flags = IORESOURCE_MEM,
242 },
243};
244
245static struct platform_device da850_evm_nandflash_device = {
246 .name = "davinci_nand",
247 .id = 1,
248 .dev = {
249 .platform_data = &da850_evm_nandflash_data,
250 },
251 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
252 .resource = da850_evm_nandflash_resource,
253};
254
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530255static struct platform_device *da850_evm_devices[] __initdata = {
256 &da850_evm_nandflash_device,
257 &da850_evm_norflash_device,
258};
259
260#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
261#define DA8XX_AEMIF_ASIZE_16BIT 0x1
262
263static void __init da850_evm_init_nor(void)
264{
265 void __iomem *aemif_addr;
266
267 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
268
269 /* Configure data bus width of CS2 to 16 bit */
270 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
271 DA8XX_AEMIF_ASIZE_16BIT,
272 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
273
274 iounmap(aemif_addr);
275}
276
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400277static const short da850_evm_nand_pins[] = {
278 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
279 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
280 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
281 DA850_NEMA_WE, DA850_NEMA_OE,
282 -1
283};
284
285static const short da850_evm_nor_pins[] = {
286 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
287 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
288 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
289 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
290 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
291 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
292 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
293 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
294 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
295 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
296 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
297 DA850_EMA_A_22, DA850_EMA_A_23,
298 -1
299};
300
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530301#if defined(CONFIG_MMC_DAVINCI) || \
302 defined(CONFIG_MMC_DAVINCI_MODULE)
303#define HAS_MMC 1
304#else
305#define HAS_MMC 0
306#endif
307
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400308static inline void da850_evm_setup_nor_nand(void)
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530309{
310 int ret = 0;
311
Sergei Shtylyovb688c2f2011-02-25 12:26:36 +0530312 if (!HAS_MMC) {
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400313 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530314 if (ret)
315 pr_warning("da850_evm_init: nand mux setup failed: "
316 "%d\n", ret);
317
Sergei Shtylyovf48ecc22010-08-01 21:15:16 +0400318 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
Sudhakar Rajashekhara039c5ee2009-11-03 11:51:09 +0530319 if (ret)
320 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
321 ret);
322
323 da850_evm_init_nor();
324
325 platform_add_devices(da850_evm_devices,
326 ARRAY_SIZE(da850_evm_devices));
327 }
328}
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400329
Sekhar Noribae10582009-10-21 21:18:22 +0530330#ifdef CONFIG_DA850_UI_RMII
331static inline void da850_evm_setup_emac_rmii(int rmii_sel)
332{
333 struct davinci_soc_info *soc_info = &davinci_soc_info;
334
335 soc_info->emac_pdata->rmii_en = 1;
Ben Gardiner47e7cb12010-11-15 09:42:52 -0500336 gpio_set_value_cansleep(rmii_sel, 0);
Sekhar Noribae10582009-10-21 21:18:22 +0530337}
338#else
339static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
340#endif
341
Ben Gardiner75929f52010-12-09 16:51:04 -0500342
343#define DA850_KEYS_DEBOUNCE_MS 10
344/*
345 * At 200ms polling interval it is possible to miss an
346 * event by tapping very lightly on the push button but most
347 * pushes do result in an event; longer intervals require the
348 * user to hold the button whereas shorter intervals require
349 * more CPU time for polling.
350 */
351#define DA850_GPIO_KEYS_POLL_MS 200
352
353enum da850_evm_ui_exp_pins {
354 DA850_EVM_UI_EXP_SEL_C = 5,
355 DA850_EVM_UI_EXP_SEL_B,
356 DA850_EVM_UI_EXP_SEL_A,
357 DA850_EVM_UI_EXP_PB8,
358 DA850_EVM_UI_EXP_PB7,
359 DA850_EVM_UI_EXP_PB6,
360 DA850_EVM_UI_EXP_PB5,
361 DA850_EVM_UI_EXP_PB4,
362 DA850_EVM_UI_EXP_PB3,
363 DA850_EVM_UI_EXP_PB2,
364 DA850_EVM_UI_EXP_PB1,
365};
366
367static const char const *da850_evm_ui_exp[] = {
368 [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
369 [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
370 [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
371 [DA850_EVM_UI_EXP_PB8] = "pb8",
372 [DA850_EVM_UI_EXP_PB7] = "pb7",
373 [DA850_EVM_UI_EXP_PB6] = "pb6",
374 [DA850_EVM_UI_EXP_PB5] = "pb5",
375 [DA850_EVM_UI_EXP_PB4] = "pb4",
376 [DA850_EVM_UI_EXP_PB3] = "pb3",
377 [DA850_EVM_UI_EXP_PB2] = "pb2",
378 [DA850_EVM_UI_EXP_PB1] = "pb1",
379};
380
381#define DA850_N_UI_PB 8
382
383static struct gpio_keys_button da850_evm_ui_keys[] = {
384 [0 ... DA850_N_UI_PB - 1] = {
385 .type = EV_KEY,
386 .active_low = 1,
387 .wakeup = 0,
388 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
389 .code = -1, /* assigned at runtime */
390 .gpio = -1, /* assigned at runtime */
391 .desc = NULL, /* assigned at runtime */
392 },
393};
394
395static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
396 .buttons = da850_evm_ui_keys,
397 .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
398 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
399};
400
401static struct platform_device da850_evm_ui_keys_device = {
402 .name = "gpio-keys-polled",
403 .id = 0,
404 .dev = {
405 .platform_data = &da850_evm_ui_keys_pdata
406 },
407};
408
409static void da850_evm_ui_keys_init(unsigned gpio)
410{
411 int i;
412 struct gpio_keys_button *button;
413
414 for (i = 0; i < DA850_N_UI_PB; i++) {
415 button = &da850_evm_ui_keys[i];
416 button->code = KEY_F8 - i;
417 button->desc = (char *)
418 da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
419 button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
420 }
421}
422
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400423static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
424 unsigned ngpio, void *c)
425{
426 int sel_a, sel_b, sel_c, ret;
427
Ben Gardiner53c28972010-12-09 16:51:05 -0500428 sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
429 sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
430 sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400431
Ben Gardiner53c28972010-12-09 16:51:05 -0500432 ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400433 if (ret) {
434 pr_warning("Cannot open UI expander pin %d\n", sel_a);
435 goto exp_setup_sela_fail;
436 }
437
Ben Gardiner53c28972010-12-09 16:51:05 -0500438 ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400439 if (ret) {
440 pr_warning("Cannot open UI expander pin %d\n", sel_b);
441 goto exp_setup_selb_fail;
442 }
443
Ben Gardiner53c28972010-12-09 16:51:05 -0500444 ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400445 if (ret) {
446 pr_warning("Cannot open UI expander pin %d\n", sel_c);
447 goto exp_setup_selc_fail;
448 }
449
450 /* deselect all functionalities */
451 gpio_direction_output(sel_a, 1);
452 gpio_direction_output(sel_b, 1);
453 gpio_direction_output(sel_c, 1);
454
Ben Gardiner75929f52010-12-09 16:51:04 -0500455 da850_evm_ui_keys_init(gpio);
456 ret = platform_device_register(&da850_evm_ui_keys_device);
457 if (ret) {
458 pr_warning("Could not register UI GPIO expander push-buttons");
459 goto exp_setup_keys_fail;
460 }
461
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400462 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
463
464 da850_evm_setup_nor_nand();
465
Sekhar Noribae10582009-10-21 21:18:22 +0530466 da850_evm_setup_emac_rmii(sel_a);
Chaithrika U S22067712009-09-30 17:00:53 -0400467
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400468 return 0;
469
Ben Gardiner75929f52010-12-09 16:51:04 -0500470exp_setup_keys_fail:
471 gpio_free(sel_c);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400472exp_setup_selc_fail:
473 gpio_free(sel_b);
474exp_setup_selb_fail:
475 gpio_free(sel_a);
476exp_setup_sela_fail:
477 return ret;
478}
479
480static int da850_evm_ui_expander_teardown(struct i2c_client *client,
481 unsigned gpio, unsigned ngpio, void *c)
482{
Ben Gardiner75929f52010-12-09 16:51:04 -0500483 platform_device_unregister(&da850_evm_ui_keys_device);
484
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400485 /* deselect all functionalities */
Ben Gardiner53c28972010-12-09 16:51:05 -0500486 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
487 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
488 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400489
Ben Gardiner53c28972010-12-09 16:51:05 -0500490 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
491 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
492 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400493
494 return 0;
495}
496
Ben Gardiner70b30932010-12-09 16:51:06 -0500497/* assign the baseboard expander's GPIOs after the UI board's */
498#define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
499#define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
500
501enum da850_evm_bb_exp_pins {
502 DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
503 DA850_EVM_BB_EXP_SW_RST,
504 DA850_EVM_BB_EXP_TP_23,
505 DA850_EVM_BB_EXP_TP_22,
506 DA850_EVM_BB_EXP_TP_21,
507 DA850_EVM_BB_EXP_USER_PB1,
508 DA850_EVM_BB_EXP_USER_LED2,
509 DA850_EVM_BB_EXP_USER_LED1,
510 DA850_EVM_BB_EXP_USER_SW1,
511 DA850_EVM_BB_EXP_USER_SW2,
512 DA850_EVM_BB_EXP_USER_SW3,
513 DA850_EVM_BB_EXP_USER_SW4,
514 DA850_EVM_BB_EXP_USER_SW5,
515 DA850_EVM_BB_EXP_USER_SW6,
516 DA850_EVM_BB_EXP_USER_SW7,
517 DA850_EVM_BB_EXP_USER_SW8
518};
519
520static const char const *da850_evm_bb_exp[] = {
521 [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
522 [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
523 [DA850_EVM_BB_EXP_TP_23] = "tp_23",
524 [DA850_EVM_BB_EXP_TP_22] = "tp_22",
525 [DA850_EVM_BB_EXP_TP_21] = "tp_21",
526 [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
527 [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
528 [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
529 [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
530 [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
531 [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
532 [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
533 [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
534 [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
535 [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
536 [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
537};
538
539#define DA850_N_BB_USER_SW 8
540
541static struct gpio_keys_button da850_evm_bb_keys[] = {
542 [0] = {
543 .type = EV_KEY,
544 .active_low = 1,
545 .wakeup = 0,
546 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
547 .code = KEY_PROG1,
548 .desc = NULL, /* assigned at runtime */
549 .gpio = -1, /* assigned at runtime */
550 },
551 [1 ... DA850_N_BB_USER_SW] = {
552 .type = EV_SW,
553 .active_low = 1,
554 .wakeup = 0,
555 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
556 .code = -1, /* assigned at runtime */
557 .desc = NULL, /* assigned at runtime */
558 .gpio = -1, /* assigned at runtime */
559 },
560};
561
562static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
563 .buttons = da850_evm_bb_keys,
564 .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
565 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
566};
567
568static struct platform_device da850_evm_bb_keys_device = {
569 .name = "gpio-keys-polled",
570 .id = 1,
571 .dev = {
572 .platform_data = &da850_evm_bb_keys_pdata
573 },
574};
575
576static void da850_evm_bb_keys_init(unsigned gpio)
577{
578 int i;
579 struct gpio_keys_button *button;
580
581 button = &da850_evm_bb_keys[0];
582 button->desc = (char *)
583 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
584 button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
585
586 for (i = 0; i < DA850_N_BB_USER_SW; i++) {
587 button = &da850_evm_bb_keys[i + 1];
588 button->code = SW_LID + i;
589 button->desc = (char *)
590 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
591 button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
592 }
593}
594
595#define DA850_N_BB_USER_LED 2
596
597static struct gpio_led da850_evm_bb_leds[] = {
598 [0 ... DA850_N_BB_USER_LED - 1] = {
599 .active_low = 1,
600 .gpio = -1, /* assigned at runtime */
601 .name = NULL, /* assigned at runtime */
602 },
603};
604
605static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
606 .leds = da850_evm_bb_leds,
607 .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
608};
609
610static struct platform_device da850_evm_bb_leds_device = {
611 .name = "leds-gpio",
612 .id = -1,
613 .dev = {
614 .platform_data = &da850_evm_bb_leds_pdata
615 }
616};
617
618static void da850_evm_bb_leds_init(unsigned gpio)
619{
620 int i;
621 struct gpio_led *led;
622
623 for (i = 0; i < DA850_N_BB_USER_LED; i++) {
624 led = &da850_evm_bb_leds[i];
625
626 led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
627 led->name =
628 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
629 }
630}
631
632static int da850_evm_bb_expander_setup(struct i2c_client *client,
633 unsigned gpio, unsigned ngpio,
634 void *c)
635{
636 int ret;
637
638 /*
639 * Register the switches and pushbutton on the baseboard as a gpio-keys
640 * device.
641 */
642 da850_evm_bb_keys_init(gpio);
643 ret = platform_device_register(&da850_evm_bb_keys_device);
644 if (ret) {
645 pr_warning("Could not register baseboard GPIO expander keys");
646 goto io_exp_setup_sw_fail;
647 }
648
649 da850_evm_bb_leds_init(gpio);
650 ret = platform_device_register(&da850_evm_bb_leds_device);
651 if (ret) {
652 pr_warning("Could not register baseboard GPIO expander LEDS");
653 goto io_exp_setup_leds_fail;
654 }
655
656 return 0;
657
658io_exp_setup_leds_fail:
659 platform_device_unregister(&da850_evm_bb_keys_device);
660io_exp_setup_sw_fail:
661 return ret;
662}
663
664static int da850_evm_bb_expander_teardown(struct i2c_client *client,
665 unsigned gpio, unsigned ngpio, void *c)
666{
667 platform_device_unregister(&da850_evm_bb_leds_device);
668 platform_device_unregister(&da850_evm_bb_keys_device);
669
670 return 0;
671}
672
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400673static struct pca953x_platform_data da850_evm_ui_expander_info = {
674 .gpio_base = DAVINCI_N_GPIO,
675 .setup = da850_evm_ui_expander_setup,
676 .teardown = da850_evm_ui_expander_teardown,
Ben Gardiner75929f52010-12-09 16:51:04 -0500677 .names = da850_evm_ui_exp,
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400678};
679
Ben Gardiner70b30932010-12-09 16:51:06 -0500680static struct pca953x_platform_data da850_evm_bb_expander_info = {
681 .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
682 .setup = da850_evm_bb_expander_setup,
683 .teardown = da850_evm_bb_expander_teardown,
684 .names = da850_evm_bb_exp,
685};
686
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300687static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
688 {
689 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Chaithrika U S75e2ea62009-09-30 17:00:28 -0400690 },
691 {
692 I2C_BOARD_INFO("tca6416", 0x20),
693 .platform_data = &da850_evm_ui_expander_info,
694 },
Ben Gardiner70b30932010-12-09 16:51:06 -0500695 {
696 I2C_BOARD_INFO("tca6416", 0x21),
697 .platform_data = &da850_evm_bb_expander_info,
698 },
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +0300699};
700
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400701static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
702 .bus_freq = 100, /* kHz */
703 .bus_delay = 0, /* usec */
704};
705
706static struct davinci_uart_config da850_evm_uart_config __initdata = {
707 .enabled_uarts = 0x7,
708};
709
Chaithrika U S491214e2009-08-11 17:03:25 -0400710/* davinci da850 evm audio machine driver */
711static u8 da850_iis_serializer_direction[] = {
712 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
713 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
714 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
715 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
716};
717
718static struct snd_platform_data da850_evm_snd_data = {
719 .tx_dma_offset = 0x2000,
720 .rx_dma_offset = 0x2000,
721 .op_mode = DAVINCI_MCASP_IIS_MODE,
722 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
723 .tdm_slots = 2,
724 .serial_dir = da850_iis_serializer_direction,
Sekhar Nori48519f02010-07-19 12:31:16 +0530725 .asp_chan_q = EVENTQ_1,
Chaithrika U S491214e2009-08-11 17:03:25 -0400726 .version = MCASP_VERSION_2,
727 .txnumevt = 1,
728 .rxnumevt = 1,
729};
730
Michael Williamsonc840fc72011-01-18 12:21:44 -0500731static const short da850_evm_mcasp_pins[] __initconst = {
732 DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
733 DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
734 DA850_AXR_11, DA850_AXR_12,
735 -1
736};
737
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400738static int da850_evm_mmc_get_ro(int index)
739{
740 return gpio_get_value(DA850_MMCSD_WP_PIN);
741}
742
743static int da850_evm_mmc_get_cd(int index)
744{
745 return !gpio_get_value(DA850_MMCSD_CD_PIN);
746}
747
748static struct davinci_mmc_config da850_mmc_config = {
749 .get_ro = da850_evm_mmc_get_ro,
750 .get_cd = da850_evm_mmc_get_cd,
751 .wires = 4,
Chaithrika U S0046d0b2009-11-03 15:46:14 +0530752 .max_freq = 50000000,
753 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400754 .version = MMC_CTLR_VERSION_2,
755};
756
Michael Williamson5a0d80ea2011-01-18 12:21:45 -0500757static const short da850_evm_mmcsd0_pins[] __initconst = {
758 DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
759 DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
760 DA850_GPIO4_0, DA850_GPIO4_1,
761 -1
762};
763
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800764static void da850_panel_power_ctrl(int val)
765{
766 /* lcd backlight */
767 gpio_set_value(DA850_LCD_BL_PIN, val);
768
769 /* lcd power */
770 gpio_set_value(DA850_LCD_PWR_PIN, val);
771}
772
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400773static int da850_lcd_hw_init(void)
774{
775 int status;
776
777 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
778 if (status < 0)
779 return status;
780
781 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
782 if (status < 0) {
783 gpio_free(DA850_LCD_BL_PIN);
784 return status;
785 }
786
787 gpio_direction_output(DA850_LCD_BL_PIN, 0);
788 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
789
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800790 /* Switch off panel power and backlight */
791 da850_panel_power_ctrl(0);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400792
Chaithrika U Sd52f2352009-12-15 16:46:46 -0800793 /* Switch on panel power and backlight */
794 da850_panel_power_ctrl(1);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400795
796 return 0;
797}
Chaithrika U S491214e2009-08-11 17:03:25 -0400798
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530799/* TPS65070 voltage regulator support */
800
801/* 3.3V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530802static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530803 {
804 .supply = "usb0_vdda33",
805 },
806 {
807 .supply = "usb1_vdda33",
808 },
809};
810
811/* 3.3V or 1.8V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530812static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530813 {
814 .supply = "dvdd3318_a",
815 },
816 {
817 .supply = "dvdd3318_b",
818 },
819 {
820 .supply = "dvdd3318_c",
821 },
822};
823
824/* 1.2V */
Sekhar Noridb549d22010-06-28 17:16:38 +0530825static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530826 {
827 .supply = "cvdd",
828 },
829};
830
831/* 1.8V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530832static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530833 {
834 .supply = "sata_vddr",
835 },
836 {
837 .supply = "usb0_vdda18",
838 },
839 {
840 .supply = "usb1_vdda18",
841 },
842 {
843 .supply = "ddr_dvdd18",
844 },
845};
846
847/* 1.2V LDO */
Sekhar Noridb549d22010-06-28 17:16:38 +0530848static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530849 {
850 .supply = "sata_vdd",
851 },
852 {
853 .supply = "pll0_vdda",
854 },
855 {
856 .supply = "pll1_vdda",
857 },
858 {
859 .supply = "usbs_cvdd",
860 },
861 {
862 .supply = "vddarnwa1",
863 },
864};
865
Sekhar Nori8b245992010-07-12 17:56:21 +0530866/* We take advantage of the fact that both defdcdc{2,3} are tied high */
867static struct tps6507x_reg_platform_data tps6507x_platform_data = {
868 .defdcdc_default = true,
869};
870
Sekhar Noridb549d22010-06-28 17:16:38 +0530871static struct regulator_init_data tps65070_regulator_data[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530872 /* dcdc1 */
873 {
874 .constraints = {
875 .min_uV = 3150000,
876 .max_uV = 3450000,
877 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
878 REGULATOR_CHANGE_STATUS),
879 .boot_on = 1,
880 },
881 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
882 .consumer_supplies = tps65070_dcdc1_consumers,
883 },
884
885 /* dcdc2 */
886 {
887 .constraints = {
888 .min_uV = 1710000,
889 .max_uV = 3450000,
890 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
891 REGULATOR_CHANGE_STATUS),
892 .boot_on = 1,
893 },
894 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
895 .consumer_supplies = tps65070_dcdc2_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530896 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530897 },
898
899 /* dcdc3 */
900 {
901 .constraints = {
902 .min_uV = 950000,
Sekhar Nori28bd2c32010-12-20 21:31:34 +0530903 .max_uV = 1350000,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530904 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
905 REGULATOR_CHANGE_STATUS),
906 .boot_on = 1,
907 },
908 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
909 .consumer_supplies = tps65070_dcdc3_consumers,
Sekhar Nori8b245992010-07-12 17:56:21 +0530910 .driver_data = &tps6507x_platform_data,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530911 },
912
913 /* ldo1 */
914 {
915 .constraints = {
916 .min_uV = 1710000,
917 .max_uV = 1890000,
918 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
919 REGULATOR_CHANGE_STATUS),
920 .boot_on = 1,
921 },
922 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
923 .consumer_supplies = tps65070_ldo1_consumers,
924 },
925
926 /* ldo2 */
927 {
928 .constraints = {
929 .min_uV = 1140000,
930 .max_uV = 1320000,
931 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
932 REGULATOR_CHANGE_STATUS),
933 .boot_on = 1,
934 },
935 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
936 .consumer_supplies = tps65070_ldo2_consumers,
937 },
938};
939
Todd Fischerda1e3682010-04-05 17:53:13 -0600940static struct touchscreen_init_data tps6507x_touchscreen_data = {
941 .poll_period = 30, /* ms between touch samples */
942 .min_pressure = 0x30, /* minimum pressure to trigger touch */
943 .vref = 0, /* turn off vref when not using A/D */
944 .vendor = 0, /* /sys/class/input/input?/id/vendor */
945 .product = 65070, /* /sys/class/input/input?/id/product */
946 .version = 0x100, /* /sys/class/input/input?/id/version */
947};
948
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600949static struct tps6507x_board tps_board = {
950 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
Todd Fischerda1e3682010-04-05 17:53:13 -0600951 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600952};
953
Ben Gardiner3506f272010-11-19 16:43:04 -0500954static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530955 {
956 I2C_BOARD_INFO("tps6507x", 0x48),
Todd Fischer0bc20bb2010-04-05 20:23:57 -0600957 .platform_data = &tps_board,
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530958 },
959};
960
961static int __init pmic_tps65070_init(void)
962{
Ben Gardiner3506f272010-11-19 16:43:04 -0500963 return i2c_register_board_info(1, da850_evm_tps65070_info,
964 ARRAY_SIZE(da850_evm_tps65070_info));
Sekhar Noria9eb1f62009-09-22 21:14:04 +0530965}
966
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400967static const short da850_evm_lcdc_pins[] = {
968 DA850_GPIO2_8, DA850_GPIO2_15,
969 -1
970};
971
Sergei Shtylyov85b83072010-08-01 21:17:00 +0400972static const short da850_evm_mii_pins[] = {
973 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
974 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
975 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
976 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
977 DA850_MDIO_D,
978 -1
979};
980
981static const short da850_evm_rmii_pins[] = {
982 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
983 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
984 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
985 DA850_MDIO_D,
986 -1
987};
988
Sekhar Noribae10582009-10-21 21:18:22 +0530989static int __init da850_evm_config_emac(void)
Chaithrika U S22067712009-09-30 17:00:53 -0400990{
991 void __iomem *cfg_chip3_base;
992 int ret;
993 u32 val;
Sekhar Noribae10582009-10-21 21:18:22 +0530994 struct davinci_soc_info *soc_info = &davinci_soc_info;
995 u8 rmii_en = soc_info->emac_pdata->rmii_en;
996
997 if (!machine_is_davinci_da850_evm())
998 return 0;
Chaithrika U S22067712009-09-30 17:00:53 -0400999
Sekhar Norid2de0582009-11-16 17:21:32 +05301000 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
Chaithrika U S22067712009-09-30 17:00:53 -04001001
Chaithrika U S22067712009-09-30 17:00:53 -04001002 val = __raw_readl(cfg_chip3_base);
Sekhar Nori17fadd92009-10-21 21:18:24 +05301003
1004 if (rmii_en) {
Chaithrika U S22067712009-09-30 17:00:53 -04001005 val |= BIT(8);
Sergei Shtylyov85b83072010-08-01 21:17:00 +04001006 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +05301007 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
1008 " functional\n");
1009 } else {
1010 val &= ~BIT(8);
Sergei Shtylyov85b83072010-08-01 21:17:00 +04001011 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
Sekhar Nori17fadd92009-10-21 21:18:24 +05301012 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
1013 " functional\n");
1014 }
1015
Chaithrika U S22067712009-09-30 17:00:53 -04001016 if (ret)
1017 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
1018 ret);
1019
Sekhar Nori17fadd92009-10-21 21:18:24 +05301020 /* configure the CFGCHIP3 register for RMII or MII */
1021 __raw_writel(val, cfg_chip3_base);
1022
Chaithrika U S22067712009-09-30 17:00:53 -04001023 ret = davinci_cfg_reg(DA850_GPIO2_6);
1024 if (ret)
1025 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
1026 "failed\n");
1027
1028 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
1029 if (ret) {
1030 pr_warning("Cannot open GPIO %d\n",
1031 DA850_MII_MDIO_CLKEN_PIN);
1032 return ret;
1033 }
1034
Sekhar Nori17fadd92009-10-21 21:18:24 +05301035 /* Enable/Disable MII MDIO clock */
1036 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
Chaithrika U S22067712009-09-30 17:00:53 -04001037
Cyril Chemparathy782f2d72010-09-15 10:11:25 -04001038 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
Sekhar Noribae10582009-10-21 21:18:22 +05301039
1040 ret = da8xx_register_emac();
1041 if (ret)
1042 pr_warning("da850_evm_init: emac registration failed: %d\n",
1043 ret);
1044
Chaithrika U S22067712009-09-30 17:00:53 -04001045 return 0;
1046}
Sekhar Noribae10582009-10-21 21:18:22 +05301047device_initcall(da850_evm_config_emac);
Chaithrika U S22067712009-09-30 17:00:53 -04001048
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +05301049/*
1050 * The following EDMA channels/slots are not being used by drivers (for
1051 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
1052 * they are being reserved for codecs on the DSP side.
1053 */
1054static const s16 da850_dma0_rsv_chans[][2] = {
1055 /* (offset, number) */
1056 { 8, 6},
1057 {24, 4},
1058 {30, 2},
1059 {-1, -1}
1060};
1061
1062static const s16 da850_dma0_rsv_slots[][2] = {
1063 /* (offset, number) */
1064 { 8, 6},
1065 {24, 4},
1066 {30, 50},
1067 {-1, -1}
1068};
1069
1070static const s16 da850_dma1_rsv_chans[][2] = {
1071 /* (offset, number) */
1072 { 0, 28},
1073 {30, 2},
1074 {-1, -1}
1075};
1076
1077static const s16 da850_dma1_rsv_slots[][2] = {
1078 /* (offset, number) */
1079 { 0, 28},
1080 {30, 90},
1081 {-1, -1}
1082};
1083
1084static struct edma_rsv_info da850_edma_cc0_rsv = {
1085 .rsv_chans = da850_dma0_rsv_chans,
1086 .rsv_slots = da850_dma0_rsv_slots,
1087};
1088
1089static struct edma_rsv_info da850_edma_cc1_rsv = {
1090 .rsv_chans = da850_dma1_rsv_chans,
1091 .rsv_slots = da850_dma1_rsv_slots,
1092};
1093
1094static struct edma_rsv_info *da850_edma_rsv[2] = {
1095 &da850_edma_cc0_rsv,
1096 &da850_edma_cc1_rsv,
1097};
1098
Sekhar Nori28bd2c32010-12-20 21:31:34 +05301099#ifdef CONFIG_CPU_FREQ
1100static __init int da850_evm_init_cpufreq(void)
1101{
1102 switch (system_rev & 0xF) {
1103 case 3:
1104 da850_max_speed = 456000;
1105 break;
1106 case 2:
1107 da850_max_speed = 408000;
1108 break;
1109 case 1:
1110 da850_max_speed = 372000;
1111 break;
1112 }
1113
1114 return da850_register_cpufreq("pll0_sysclk3");
1115}
1116#else
1117static __init int da850_evm_init_cpufreq(void) { return 0; }
1118#endif
1119
Sekhar Nori8bb2c482011-07-06 06:01:24 +00001120#define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
1121
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001122static __init void da850_evm_init(void)
1123{
1124 int ret;
1125
Sekhar Noria9eb1f62009-09-22 21:14:04 +05301126 ret = pmic_tps65070_init();
1127 if (ret)
1128 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
1129 ret);
1130
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +05301131 ret = da850_register_edma(da850_edma_rsv);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001132 if (ret)
1133 pr_warning("da850_evm_init: edma registration failed: %d\n",
1134 ret);
1135
Cyril Chemparathy3821d102010-03-25 17:43:48 -04001136 ret = davinci_cfg_reg_list(da850_i2c0_pins);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001137 if (ret)
1138 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
1139 ret);
1140
1141 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
1142 if (ret)
1143 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
1144 ret);
1145
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -04001146
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001147 ret = da8xx_register_watchdog();
1148 if (ret)
1149 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
1150 ret);
1151
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -04001152 if (HAS_MMC) {
Michael Williamson5a0d80ea2011-01-18 12:21:45 -05001153 ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -04001154 if (ret)
1155 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
1156 " %d\n", ret);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -04001157
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -04001158 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
1159 if (ret)
1160 pr_warning("da850_evm_init: can not open GPIO %d\n",
1161 DA850_MMCSD_CD_PIN);
1162 gpio_direction_input(DA850_MMCSD_CD_PIN);
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -04001163
Sudhakar Rajashekhara820c4fe2009-08-13 18:16:28 -04001164 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
1165 if (ret)
1166 pr_warning("da850_evm_init: can not open GPIO %d\n",
1167 DA850_MMCSD_WP_PIN);
1168 gpio_direction_input(DA850_MMCSD_WP_PIN);
1169
1170 ret = da8xx_register_mmcsd0(&da850_mmc_config);
1171 if (ret)
1172 pr_warning("da850_evm_init: mmcsd0 registration failed:"
1173 " %d\n", ret);
1174 }
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -04001175
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001176 davinci_serial_init(&da850_evm_uart_config);
1177
Chaithrika U S1a7ff8f2009-08-25 15:20:05 +03001178 i2c_register_board_info(1, da850_evm_i2c_devices,
1179 ARRAY_SIZE(da850_evm_i2c_devices));
1180
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001181 /*
1182 * shut down uart 0 and 1; they are not used on the board and
1183 * accessing them causes endless "too much work in irq53" messages
1184 * with arago fs
1185 */
1186 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
1187 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -04001188
Michael Williamsonc840fc72011-01-18 12:21:44 -05001189 ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
Chaithrika U S491214e2009-08-11 17:03:25 -04001190 if (ret)
1191 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
1192 ret);
1193
Mark A. Greerb8864aa2009-08-28 15:05:02 -07001194 da8xx_register_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -04001195
Cyril Chemparathy3821d102010-03-25 17:43:48 -04001196 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -04001197 if (ret)
1198 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
1199 ret);
1200
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -04001201 /* Handle board specific muxing for LCD here */
Cyril Chemparathy3821d102010-03-25 17:43:48 -04001202 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -04001203 if (ret)
1204 pr_warning("da850_evm_init: evm specific lcd mux setup "
1205 "failed: %d\n", ret);
1206
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -04001207 ret = da850_lcd_hw_init();
1208 if (ret)
1209 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
1210 ret);
1211
Chaithrika U Sd52f2352009-12-15 16:46:46 -08001212 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
Mark A. Greerb9e63422009-09-15 18:14:19 -07001213 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -04001214 if (ret)
1215 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
1216 ret);
Mark A. Greerc51df702009-09-15 18:15:54 -07001217
1218 ret = da8xx_register_rtc();
1219 if (ret)
1220 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
Sekhar Nori09dc2d42009-09-22 21:14:03 +05301221
Sekhar Nori28bd2c32010-12-20 21:31:34 +05301222 ret = da850_evm_init_cpufreq();
Sekhar Nori09dc2d42009-09-22 21:14:03 +05301223 if (ret)
1224 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
1225 ret);
Sekhar Nori5aeb15a2009-10-22 15:12:15 +05301226
1227 ret = da8xx_register_cpuidle();
1228 if (ret)
1229 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
1230 ret);
Sekhar Nori63534442009-12-17 18:29:33 +05301231
1232 ret = da850_register_pm(&da850_pm_device);
1233 if (ret)
1234 pr_warning("da850_evm_init: suspend registration failed: %d\n",
1235 ret);
Sekhar Norifdce5562011-02-24 10:39:27 +05301236
1237 ret = da8xx_register_spi(1, da850evm_spi_info,
1238 ARRAY_SIZE(da850evm_spi_info));
1239 if (ret)
1240 pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
1241 ret);
Sekhar Nori8bb2c482011-07-06 06:01:24 +00001242
1243 ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
1244 if (ret)
1245 pr_warning("da850_evm_init: sata registration failed: %d\n",
1246 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001247}
1248
1249#ifdef CONFIG_SERIAL_8250_CONSOLE
1250static int __init da850_evm_console_init(void)
1251{
Michael Williamson1aa5f2a2010-08-31 14:30:15 -04001252 if (!machine_is_davinci_da850_evm())
1253 return 0;
1254
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001255 return add_preferred_console("ttyS", 2, "115200");
1256}
1257console_initcall(da850_evm_console_init);
1258#endif
1259
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001260static void __init da850_evm_map_io(void)
1261{
1262 da850_init();
1263}
1264
Sekhar Nori48ea89e2010-07-01 19:00:50 +05301265MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
Nicolas Pitree7e56012011-07-05 22:38:11 -04001266 .atag_offset = 0x100,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001267 .map_io = da850_evm_map_io,
Cyril Chemparathybd808942010-05-07 17:06:37 -04001268 .init_irq = cp_intc_init,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001269 .timer = &davinci_timer,
1270 .init_machine = da850_evm_init,
Nicolas Pitref68deab2011-07-05 22:28:08 -04001271 .dma_zone_size = SZ_128M,
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001272MACHINE_END