aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/board-dm644x-evm.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@deeprootsystems.com>2009-04-14 12:30:11 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-04-27 12:50:11 -0400
commitd0e47fba054a55e0066c6ae2c807d98d086af5a9 (patch)
treeaa4b3b6312d1a5f22a3fd8f97e9ab05a805d7144 /arch/arm/mach-davinci/board-dm644x-evm.c
parent73d3c68f09e608be983013dc8b3e49aebe89298c (diff)
davinci: update DM644x support in preparation for more SoCs
Rework DM644x code into SoC specific and board specific parts. This is also to generalize the structure a bit so it's easier to add support for new SoCs in the DaVinci family. Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/board-dm644x-evm.c')
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c292
1 files changed, 259 insertions, 33 deletions
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index c2701d740a1d..5387e6b20405 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -15,15 +15,19 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/memory.h>
18 19
19#include <linux/i2c.h> 20#include <linux/i2c.h>
20#include <linux/i2c/pcf857x.h> 21#include <linux/i2c/pcf857x.h>
21#include <linux/i2c/at24.h> 22#include <linux/i2c/at24.h>
22 23#include <linux/etherdevice.h>
23#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
25#include <linux/mtd/nand.h>
24#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
25#include <linux/mtd/physmap.h> 27#include <linux/mtd/physmap.h>
26#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/phy.h>
30#include <linux/clk.h>
27 31
28#include <asm/setup.h> 32#include <asm/setup.h>
29#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -32,28 +36,34 @@
32#include <asm/mach/map.h> 36#include <asm/mach/map.h>
33#include <asm/mach/flash.h> 37#include <asm/mach/flash.h>
34 38
35#include <mach/hardware.h> 39#include <mach/dm644x.h>
36#include <mach/common.h> 40#include <mach/common.h>
37#include <mach/i2c.h> 41#include <mach/i2c.h>
42#include <mach/serial.h>
43#include <mach/mux.h>
44#include <mach/psc.h>
45#include <mach/nand.h>
46
47#define DM644X_EVM_PHY_MASK (0x2)
48#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
38 49
39#define DAVINCI_CFC_ATA_BASE 0x01C66000 50#define DAVINCI_CFC_ATA_BASE 0x01C66000
40#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
41 51
42/* other misc. init functions */ 52#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
43void __init davinci_psc_init(void); 53#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
44void __init davinci_irq_init(void); 54#define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
45void __init davinci_map_common_io(void); 55#define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
46void __init davinci_init_common_hw(void); 56#define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
47 57
48#if defined(CONFIG_MTD_PHYSMAP) || \ 58#define LXT971_PHY_ID (0x001378e2)
49 defined(CONFIG_MTD_PHYSMAP_MODULE) 59#define LXT971_PHY_MASK (0xfffffff0)
50 60
51static struct mtd_partition davinci_evm_norflash_partitions[] = { 61static struct mtd_partition davinci_evm_norflash_partitions[] = {
52 /* bootloader (U-Boot, etc) in first 4 sectors */ 62 /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
53 { 63 {
54 .name = "bootloader", 64 .name = "bootloader",
55 .offset = 0, 65 .offset = 0,
56 .size = 4 * SZ_64K, 66 .size = 5 * SZ_64K,
57 .mask_flags = MTD_WRITEABLE, /* force read-only */ 67 .mask_flags = MTD_WRITEABLE, /* force read-only */
58 }, 68 },
59 /* bootloader params in the next 1 sectors */ 69 /* bootloader params in the next 1 sectors */
@@ -103,10 +113,60 @@ static struct platform_device davinci_evm_norflash_device = {
103 .resource = &davinci_evm_norflash_resource, 113 .resource = &davinci_evm_norflash_resource,
104}; 114};
105 115
106#endif 116struct mtd_partition davinci_evm_nandflash_partition[] = {
117 /* 5 MB space at the beginning for bootloader and kernel */
118 {
119 .name = "NAND filesystem",
120 .offset = 5 * SZ_1M,
121 .size = MTDPART_SIZ_FULL,
122 .mask_flags = 0,
123 }
124};
107 125
108#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ 126static struct davinci_nand_pdata davinci_evm_nandflash_data = {
109 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) 127 .parts = davinci_evm_nandflash_partition,
128 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
129 .ecc_mode = NAND_ECC_HW,
130};
131
132static struct resource davinci_evm_nandflash_resource[] = {
133 {
134 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
135 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
136 .flags = IORESOURCE_MEM,
137 }, {
138 .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
139 .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
140 .flags = IORESOURCE_MEM,
141 },
142};
143
144static struct platform_device davinci_evm_nandflash_device = {
145 .name = "davinci_nand",
146 .id = 0,
147 .dev = {
148 .platform_data = &davinci_evm_nandflash_data,
149 },
150 .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
151 .resource = davinci_evm_nandflash_resource,
152};
153
154static u64 davinci_fb_dma_mask = DMA_32BIT_MASK;
155
156static struct platform_device davinci_fb_device = {
157 .name = "davincifb",
158 .id = -1,
159 .dev = {
160 .dma_mask = &davinci_fb_dma_mask,
161 .coherent_dma_mask = DMA_32BIT_MASK,
162 },
163 .num_resources = 0,
164};
165
166static struct platform_device rtc_dev = {
167 .name = "rtc_davinci_evm",
168 .id = -1,
169};
110 170
111static struct resource ide_resources[] = { 171static struct resource ide_resources[] = {
112 { 172 {
@@ -121,7 +181,7 @@ static struct resource ide_resources[] = {
121 }, 181 },
122}; 182};
123 183
124static u64 ide_dma_mask = DMA_BIT_MASK(32); 184static u64 ide_dma_mask = DMA_32BIT_MASK;
125 185
126static struct platform_device ide_dev = { 186static struct platform_device ide_dev = {
127 .name = "palm_bk3710", 187 .name = "palm_bk3710",
@@ -130,12 +190,10 @@ static struct platform_device ide_dev = {
130 .num_resources = ARRAY_SIZE(ide_resources), 190 .num_resources = ARRAY_SIZE(ide_resources),
131 .dev = { 191 .dev = {
132 .dma_mask = &ide_dma_mask, 192 .dma_mask = &ide_dma_mask,
133 .coherent_dma_mask = DMA_BIT_MASK(32), 193 .coherent_dma_mask = DMA_32BIT_MASK,
134 }, 194 },
135}; 195};
136 196
137#endif
138
139/*----------------------------------------------------------------------*/ 197/*----------------------------------------------------------------------*/
140 198
141/* 199/*
@@ -314,7 +372,9 @@ evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
314 gpio_request(gpio + 7, "nCF_SEL"); 372 gpio_request(gpio + 7, "nCF_SEL");
315 gpio_direction_output(gpio + 7, 1); 373 gpio_direction_output(gpio + 7, 1);
316 374
317 /* irlml6401 sustains over 3A, switches 5V in under 8 msec */ 375 /* irlml6401 switches over 1A, in under 8 msec;
376 * now it can be managed by nDRV_VBUS ...
377 */
318 setup_usb(500, 8); 378 setup_usb(500, 8);
319 379
320 return 0; 380 return 0;
@@ -346,14 +406,120 @@ static struct pcf857x_platform_data pcf_data_u35 = {
346 * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL) 406 * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
347 * - ... newer boards may have more 407 * - ... newer boards may have more
348 */ 408 */
409static struct memory_accessor *at24_mem_acc;
410
411static void at24_setup(struct memory_accessor *mem_acc, void *context)
412{
413 DECLARE_MAC_BUF(mac_str);
414 char mac_addr[6];
415
416 at24_mem_acc = mem_acc;
417
418 /* Read MAC addr from EEPROM */
419 if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, 6) == 6) {
420 printk(KERN_INFO "Read MAC addr from EEPROM: %s\n",
421 print_mac(mac_str, mac_addr));
422 }
423}
424
349static struct at24_platform_data eeprom_info = { 425static struct at24_platform_data eeprom_info = {
350 .byte_len = (256*1024) / 8, 426 .byte_len = (256*1024) / 8,
351 .page_size = 64, 427 .page_size = 64,
352 .flags = AT24_FLAG_ADDR16, 428 .flags = AT24_FLAG_ADDR16,
429 .setup = at24_setup,
430};
431
432int dm6446evm_eeprom_read(void *buf, off_t off, size_t count)
433{
434 if (at24_mem_acc)
435 return at24_mem_acc->read(at24_mem_acc, buf, off, count);
436 return -ENODEV;
437}
438EXPORT_SYMBOL(dm6446evm_eeprom_read);
439
440int dm6446evm_eeprom_write(void *buf, off_t off, size_t count)
441{
442 if (at24_mem_acc)
443 return at24_mem_acc->write(at24_mem_acc, buf, off, count);
444 return -ENODEV;
445}
446EXPORT_SYMBOL(dm6446evm_eeprom_write);
447
448/*
449 * MSP430 supports RTC, card detection, input from IR remote, and
450 * a bit more. It triggers interrupts on GPIO(7) from pressing
451 * buttons on the IR remote, and for card detect switches.
452 */
453static struct i2c_client *dm6446evm_msp;
454
455static int dm6446evm_msp_probe(struct i2c_client *client,
456 const struct i2c_device_id *id)
457{
458 dm6446evm_msp = client;
459 return 0;
460}
461
462static int dm6446evm_msp_remove(struct i2c_client *client)
463{
464 dm6446evm_msp = NULL;
465 return 0;
466}
467
468static const struct i2c_device_id dm6446evm_msp_ids[] = {
469 { "dm6446evm_msp", 0, },
470 { /* end of list */ },
471};
472
473static struct i2c_driver dm6446evm_msp_driver = {
474 .driver.name = "dm6446evm_msp",
475 .id_table = dm6446evm_msp_ids,
476 .probe = dm6446evm_msp_probe,
477 .remove = dm6446evm_msp_remove,
353}; 478};
354 479
480static int dm6444evm_msp430_get_pins(void)
481{
482 static const char txbuf[2] = { 2, 4, };
483 char buf[4];
484 struct i2c_msg msg[2] = {
485 {
486 .addr = dm6446evm_msp->addr,
487 .flags = 0,
488 .len = 2,
489 .buf = (void __force *)txbuf,
490 },
491 {
492 .addr = dm6446evm_msp->addr,
493 .flags = I2C_M_RD,
494 .len = 4,
495 .buf = buf,
496 },
497 };
498 int status;
499
500 if (!dm6446evm_msp)
501 return -ENXIO;
502
503 /* Command 4 == get input state, returns port 2 and port3 data
504 * S Addr W [A] len=2 [A] cmd=4 [A]
505 * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
506 */
507 status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
508 if (status < 0)
509 return status;
510
511 dev_dbg(&dm6446evm_msp->dev,
512 "PINS: %02x %02x %02x %02x\n",
513 buf[0], buf[1], buf[2], buf[3]);
514
515 return (buf[3] << 8) | buf[2];
516}
517
355static struct i2c_board_info __initdata i2c_info[] = { 518static struct i2c_board_info __initdata i2c_info[] = {
356 { 519 {
520 I2C_BOARD_INFO("dm6446evm_msp", 0x23),
521 },
522 {
357 I2C_BOARD_INFO("pcf8574", 0x38), 523 I2C_BOARD_INFO("pcf8574", 0x38),
358 .platform_data = &pcf_data_u2, 524 .platform_data = &pcf_data_u2,
359 }, 525 },
@@ -371,7 +537,6 @@ static struct i2c_board_info __initdata i2c_info[] = {
371 }, 537 },
372 /* ALSO: 538 /* ALSO:
373 * - tvl320aic33 audio codec (0x1b) 539 * - tvl320aic33 audio codec (0x1b)
374 * - msp430 microcontroller (0x23)
375 * - tvp5146 video decoder (0x5d) 540 * - tvp5146 video decoder (0x5d)
376 */ 541 */
377}; 542};
@@ -387,40 +552,101 @@ static struct davinci_i2c_platform_data i2c_pdata = {
387static void __init evm_init_i2c(void) 552static void __init evm_init_i2c(void)
388{ 553{
389 davinci_init_i2c(&i2c_pdata); 554 davinci_init_i2c(&i2c_pdata);
555 i2c_add_driver(&dm6446evm_msp_driver);
390 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); 556 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
391} 557}
392 558
393static struct platform_device *davinci_evm_devices[] __initdata = { 559static struct platform_device *davinci_evm_devices[] __initdata = {
394#if defined(CONFIG_MTD_PHYSMAP) || \ 560 &davinci_fb_device,
395 defined(CONFIG_MTD_PHYSMAP_MODULE) 561 &rtc_dev,
396 &davinci_evm_norflash_device, 562};
397#endif 563
398#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ 564static struct davinci_uart_config uart_config __initdata = {
399 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) 565 .enabled_uarts = (1 << 0),
400 &ide_dev,
401#endif
402}; 566};
403 567
404static void __init 568static void __init
405davinci_evm_map_io(void) 569davinci_evm_map_io(void)
406{ 570{
407 davinci_map_common_io(); 571 davinci_map_common_io();
572 dm644x_init();
408} 573}
409 574
410static __init void davinci_evm_init(void) 575static int davinci_phy_fixup(struct phy_device *phydev)
411{ 576{
577 unsigned int control;
578 /* CRITICAL: Fix for increasing PHY signal drive strength for
579 * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
580 * signal strength was low causing TX to fail randomly. The
581 * fix is to Set bit 11 (Increased MII drive strength) of PHY
582 * register 26 (Digital Config register) on this phy. */
583 control = phy_read(phydev, 26);
584 phy_write(phydev, 26, (control | 0x800));
585 return 0;
586}
587
412#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ 588#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
413 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) 589 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
590#define HAS_ATA 1
591#else
592#define HAS_ATA 0
593#endif
594
414#if defined(CONFIG_MTD_PHYSMAP) || \ 595#if defined(CONFIG_MTD_PHYSMAP) || \
415 defined(CONFIG_MTD_PHYSMAP_MODULE) 596 defined(CONFIG_MTD_PHYSMAP_MODULE)
416 printk(KERN_WARNING "WARNING: both IDE and NOR flash are enabled, " 597#define HAS_NOR 1
417 "but share pins.\n\t Disable IDE for NOR support.\n"); 598#else
599#define HAS_NOR 0
418#endif 600#endif
601
602#if defined(CONFIG_MTD_NAND_DAVINCI) || \
603 defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
604#define HAS_NAND 1
605#else
606#define HAS_NAND 0
419#endif 607#endif
420 608
609static __init void davinci_evm_init(void)
610{
611 struct clk *aemif_clk;
612
613 aemif_clk = clk_get(NULL, "aemif");
614 clk_enable(aemif_clk);
615
616 if (HAS_ATA) {
617 if (HAS_NAND || HAS_NOR)
618 pr_warning("WARNING: both IDE and Flash are "
619 "enabled, but they share AEMIF pins.\n"
620 "\tDisable IDE for NAND/NOR support.\n");
621 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
622 davinci_cfg_reg(DM644X_ATAEN);
623 davinci_cfg_reg(DM644X_HDIREN);
624 platform_device_register(&ide_dev);
625 } else if (HAS_NAND || HAS_NOR) {
626 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
627 davinci_cfg_reg(DM644X_ATAEN_DISABLE);
628
629 /* only one device will be jumpered and detected */
630 if (HAS_NAND) {
631 platform_device_register(&davinci_evm_nandflash_device);
632 evm_leds[7].default_trigger = "nand-disk";
633 if (HAS_NOR)
634 pr_warning("WARNING: both NAND and NOR flash "
635 "are enabled; disable one of them.\n");
636 } else if (HAS_NOR)
637 platform_device_register(&davinci_evm_norflash_device);
638 }
639
421 platform_add_devices(davinci_evm_devices, 640 platform_add_devices(davinci_evm_devices,
422 ARRAY_SIZE(davinci_evm_devices)); 641 ARRAY_SIZE(davinci_evm_devices));
423 evm_init_i2c(); 642 evm_init_i2c();
643
644 davinci_serial_init(&uart_config);
645
646 /* Register the fixup for PHY on DaVinci */
647 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
648 davinci_phy_fixup);
649
424} 650}
425 651
426static __init void davinci_evm_irq_init(void) 652static __init void davinci_evm_irq_init(void)
@@ -428,7 +654,7 @@ static __init void davinci_evm_irq_init(void)
428 davinci_irq_init(); 654 davinci_irq_init();
429} 655}
430 656
431MACHINE_START(DAVINCI_EVM, "DaVinci EVM") 657MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
432 /* Maintainer: MontaVista Software <source@mvista.com> */ 658 /* Maintainer: MontaVista Software <source@mvista.com> */
433 .phys_io = IO_PHYS, 659 .phys_io = IO_PHYS,
434 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, 660 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,