board-dm644x-evm.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * TI DaVinci EVM board support
  3. *
  4. * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
  5. *
  6. * 2007 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/init.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/gpio.h>
  17. #include <linux/leds.h>
  18. #include <linux/memory.h>
  19. #include <linux/i2c.h>
  20. #include <linux/i2c/pcf857x.h>
  21. #include <linux/i2c/at24.h>
  22. #include <linux/etherdevice.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/nand.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/io.h>
  28. #include <linux/phy.h>
  29. #include <linux/clk.h>
  30. #include <asm/setup.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/flash.h>
  35. #include <mach/dm644x.h>
  36. #include <mach/common.h>
  37. #include <mach/emac.h>
  38. #include <mach/i2c.h>
  39. #include <mach/serial.h>
  40. #include <mach/mux.h>
  41. #include <mach/psc.h>
  42. #include <mach/nand.h>
  43. #include <mach/mmc.h>
  44. #include <mach/common.h>
  45. #define DM644X_EVM_PHY_MASK (0x2)
  46. #define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
  47. #define DAVINCI_CFC_ATA_BASE 0x01C66000
  48. #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
  49. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
  50. #define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
  51. #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
  52. #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
  53. #define LXT971_PHY_ID (0x001378e2)
  54. #define LXT971_PHY_MASK (0xfffffff0)
  55. static struct emac_platform_data dm644x_evm_emac_pdata = {
  56. .phy_mask = DM644X_EVM_PHY_MASK,
  57. .mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY,
  58. };
  59. static struct mtd_partition davinci_evm_norflash_partitions[] = {
  60. /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
  61. {
  62. .name = "bootloader",
  63. .offset = 0,
  64. .size = 5 * SZ_64K,
  65. .mask_flags = MTD_WRITEABLE, /* force read-only */
  66. },
  67. /* bootloader params in the next 1 sectors */
  68. {
  69. .name = "params",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = SZ_64K,
  72. .mask_flags = 0,
  73. },
  74. /* kernel */
  75. {
  76. .name = "kernel",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = SZ_2M,
  79. .mask_flags = 0
  80. },
  81. /* file system */
  82. {
  83. .name = "filesystem",
  84. .offset = MTDPART_OFS_APPEND,
  85. .size = MTDPART_SIZ_FULL,
  86. .mask_flags = 0
  87. }
  88. };
  89. static struct physmap_flash_data davinci_evm_norflash_data = {
  90. .width = 2,
  91. .parts = davinci_evm_norflash_partitions,
  92. .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
  93. };
  94. /* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
  95. * limits addresses to 16M, so using addresses past 16M will wrap */
  96. static struct resource davinci_evm_norflash_resource = {
  97. .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  98. .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  99. .flags = IORESOURCE_MEM,
  100. };
  101. static struct platform_device davinci_evm_norflash_device = {
  102. .name = "physmap-flash",
  103. .id = 0,
  104. .dev = {
  105. .platform_data = &davinci_evm_norflash_data,
  106. },
  107. .num_resources = 1,
  108. .resource = &davinci_evm_norflash_resource,
  109. };
  110. /* DM644x EVM includes a 64 MByte small-page NAND flash (16K blocks).
  111. * It may used instead of the (default) NOR chip to boot, using TI's
  112. * tools to install the secondary boot loader (UBL) and U-Boot.
  113. */
  114. struct mtd_partition davinci_evm_nandflash_partition[] = {
  115. /* Bootloader layout depends on whose u-boot is installed, but we
  116. * can hide all the details.
  117. * - block 0 for u-boot environment ... in mainline u-boot
  118. * - block 1 for UBL (plus up to four backup copies in blocks 2..5)
  119. * - blocks 6...? for u-boot
  120. * - blocks 16..23 for u-boot environment ... in TI's u-boot
  121. */
  122. {
  123. .name = "bootloader",
  124. .offset = 0,
  125. .size = SZ_256K + SZ_128K,
  126. .mask_flags = MTD_WRITEABLE, /* force read-only */
  127. },
  128. /* Kernel */
  129. {
  130. .name = "kernel",
  131. .offset = MTDPART_OFS_APPEND,
  132. .size = SZ_4M,
  133. .mask_flags = 0,
  134. },
  135. /* File system (older GIT kernels started this on the 5MB mark) */
  136. {
  137. .name = "filesystem",
  138. .offset = MTDPART_OFS_APPEND,
  139. .size = MTDPART_SIZ_FULL,
  140. .mask_flags = 0,
  141. }
  142. /* A few blocks at end hold a flash BBT ... created by TI's CCS
  143. * using flashwriter_nand.out, but ignored by TI's versions of
  144. * Linux and u-boot. We boot faster by using them.
  145. */
  146. };
  147. static struct davinci_nand_pdata davinci_evm_nandflash_data = {
  148. .parts = davinci_evm_nandflash_partition,
  149. .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
  150. .ecc_mode = NAND_ECC_HW,
  151. .options = NAND_USE_FLASH_BBT,
  152. };
  153. static struct resource davinci_evm_nandflash_resource[] = {
  154. {
  155. .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  156. .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  157. .flags = IORESOURCE_MEM,
  158. }, {
  159. .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
  160. .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  161. .flags = IORESOURCE_MEM,
  162. },
  163. };
  164. static struct platform_device davinci_evm_nandflash_device = {
  165. .name = "davinci_nand",
  166. .id = 0,
  167. .dev = {
  168. .platform_data = &davinci_evm_nandflash_data,
  169. },
  170. .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
  171. .resource = davinci_evm_nandflash_resource,
  172. };
  173. static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
  174. static struct platform_device davinci_fb_device = {
  175. .name = "davincifb",
  176. .id = -1,
  177. .dev = {
  178. .dma_mask = &davinci_fb_dma_mask,
  179. .coherent_dma_mask = DMA_BIT_MASK(32),
  180. },
  181. .num_resources = 0,
  182. };
  183. static struct platform_device rtc_dev = {
  184. .name = "rtc_davinci_evm",
  185. .id = -1,
  186. };
  187. static struct resource ide_resources[] = {
  188. {
  189. .start = DAVINCI_CFC_ATA_BASE,
  190. .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. {
  194. .start = IRQ_IDE,
  195. .end = IRQ_IDE,
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. };
  199. static u64 ide_dma_mask = DMA_BIT_MASK(32);
  200. static struct platform_device ide_dev = {
  201. .name = "palm_bk3710",
  202. .id = -1,
  203. .resource = ide_resources,
  204. .num_resources = ARRAY_SIZE(ide_resources),
  205. .dev = {
  206. .dma_mask = &ide_dma_mask,
  207. .coherent_dma_mask = DMA_BIT_MASK(32),
  208. },
  209. };
  210. /*----------------------------------------------------------------------*/
  211. /*
  212. * I2C GPIO expanders
  213. */
  214. #define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
  215. /* U2 -- LEDs */
  216. static struct gpio_led evm_leds[] = {
  217. { .name = "DS8", .active_low = 1,
  218. .default_trigger = "heartbeat", },
  219. { .name = "DS7", .active_low = 1, },
  220. { .name = "DS6", .active_low = 1, },
  221. { .name = "DS5", .active_low = 1, },
  222. { .name = "DS4", .active_low = 1, },
  223. { .name = "DS3", .active_low = 1, },
  224. { .name = "DS2", .active_low = 1,
  225. .default_trigger = "mmc0", },
  226. { .name = "DS1", .active_low = 1,
  227. .default_trigger = "ide-disk", },
  228. };
  229. static const struct gpio_led_platform_data evm_led_data = {
  230. .num_leds = ARRAY_SIZE(evm_leds),
  231. .leds = evm_leds,
  232. };
  233. static struct platform_device *evm_led_dev;
  234. static int
  235. evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  236. {
  237. struct gpio_led *leds = evm_leds;
  238. int status;
  239. while (ngpio--) {
  240. leds->gpio = gpio++;
  241. leds++;
  242. }
  243. /* what an extremely annoying way to be forced to handle
  244. * device unregistration ...
  245. */
  246. evm_led_dev = platform_device_alloc("leds-gpio", 0);
  247. platform_device_add_data(evm_led_dev,
  248. &evm_led_data, sizeof evm_led_data);
  249. evm_led_dev->dev.parent = &client->dev;
  250. status = platform_device_add(evm_led_dev);
  251. if (status < 0) {
  252. platform_device_put(evm_led_dev);
  253. evm_led_dev = NULL;
  254. }
  255. return status;
  256. }
  257. static int
  258. evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  259. {
  260. if (evm_led_dev) {
  261. platform_device_unregister(evm_led_dev);
  262. evm_led_dev = NULL;
  263. }
  264. return 0;
  265. }
  266. static struct pcf857x_platform_data pcf_data_u2 = {
  267. .gpio_base = PCF_Uxx_BASE(0),
  268. .setup = evm_led_setup,
  269. .teardown = evm_led_teardown,
  270. };
  271. /* U18 - A/V clock generator and user switch */
  272. static int sw_gpio;
  273. static ssize_t
  274. sw_show(struct device *d, struct device_attribute *a, char *buf)
  275. {
  276. char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
  277. strcpy(buf, s);
  278. return strlen(s);
  279. }
  280. static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
  281. static int
  282. evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  283. {
  284. int status;
  285. /* export dip switch option */
  286. sw_gpio = gpio + 7;
  287. status = gpio_request(sw_gpio, "user_sw");
  288. if (status == 0)
  289. status = gpio_direction_input(sw_gpio);
  290. if (status == 0)
  291. status = device_create_file(&client->dev, &dev_attr_user_sw);
  292. else
  293. gpio_free(sw_gpio);
  294. if (status != 0)
  295. sw_gpio = -EINVAL;
  296. /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
  297. gpio_request(gpio + 3, "pll_fs2");
  298. gpio_direction_output(gpio + 3, 0);
  299. gpio_request(gpio + 2, "pll_fs1");
  300. gpio_direction_output(gpio + 2, 0);
  301. gpio_request(gpio + 1, "pll_sr");
  302. gpio_direction_output(gpio + 1, 0);
  303. return 0;
  304. }
  305. static int
  306. evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  307. {
  308. gpio_free(gpio + 1);
  309. gpio_free(gpio + 2);
  310. gpio_free(gpio + 3);
  311. if (sw_gpio > 0) {
  312. device_remove_file(&client->dev, &dev_attr_user_sw);
  313. gpio_free(sw_gpio);
  314. }
  315. return 0;
  316. }
  317. static struct pcf857x_platform_data pcf_data_u18 = {
  318. .gpio_base = PCF_Uxx_BASE(1),
  319. .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
  320. .setup = evm_u18_setup,
  321. .teardown = evm_u18_teardown,
  322. };
  323. /* U35 - various I/O signals used to manage USB, CF, ATA, etc */
  324. static int
  325. evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  326. {
  327. /* p0 = nDRV_VBUS (initial: don't supply it) */
  328. gpio_request(gpio + 0, "nDRV_VBUS");
  329. gpio_direction_output(gpio + 0, 1);
  330. /* p1 = VDDIMX_EN */
  331. gpio_request(gpio + 1, "VDDIMX_EN");
  332. gpio_direction_output(gpio + 1, 1);
  333. /* p2 = VLYNQ_EN */
  334. gpio_request(gpio + 2, "VLYNQ_EN");
  335. gpio_direction_output(gpio + 2, 1);
  336. /* p3 = n3V3_CF_RESET (initial: stay in reset) */
  337. gpio_request(gpio + 3, "nCF_RESET");
  338. gpio_direction_output(gpio + 3, 0);
  339. /* (p4 unused) */
  340. /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
  341. gpio_request(gpio + 5, "WLAN_RESET");
  342. gpio_direction_output(gpio + 5, 1);
  343. /* p6 = nATA_SEL (initial: select) */
  344. gpio_request(gpio + 6, "nATA_SEL");
  345. gpio_direction_output(gpio + 6, 0);
  346. /* p7 = nCF_SEL (initial: deselect) */
  347. gpio_request(gpio + 7, "nCF_SEL");
  348. gpio_direction_output(gpio + 7, 1);
  349. /* irlml6401 switches over 1A, in under 8 msec;
  350. * now it can be managed by nDRV_VBUS ...
  351. */
  352. setup_usb(500, 8);
  353. return 0;
  354. }
  355. static int
  356. evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
  357. {
  358. gpio_free(gpio + 7);
  359. gpio_free(gpio + 6);
  360. gpio_free(gpio + 5);
  361. gpio_free(gpio + 3);
  362. gpio_free(gpio + 2);
  363. gpio_free(gpio + 1);
  364. gpio_free(gpio + 0);
  365. return 0;
  366. }
  367. static struct pcf857x_platform_data pcf_data_u35 = {
  368. .gpio_base = PCF_Uxx_BASE(2),
  369. .setup = evm_u35_setup,
  370. .teardown = evm_u35_teardown,
  371. };
  372. /*----------------------------------------------------------------------*/
  373. /* Most of this EEPROM is unused, but U-Boot uses some data:
  374. * - 0x7f00, 6 bytes Ethernet Address
  375. * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
  376. * - ... newer boards may have more
  377. */
  378. static struct memory_accessor *at24_mem_acc;
  379. static void at24_setup(struct memory_accessor *mem_acc, void *context)
  380. {
  381. char mac_addr[ETH_ALEN];
  382. at24_mem_acc = mem_acc;
  383. /* Read MAC addr from EEPROM */
  384. if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
  385. ETH_ALEN) {
  386. printk(KERN_INFO "Read MAC addr from EEPROM: %pM\n", mac_addr);
  387. memcpy(dm644x_evm_emac_pdata.mac_addr, mac_addr, ETH_ALEN);
  388. }
  389. }
  390. static struct at24_platform_data eeprom_info = {
  391. .byte_len = (256*1024) / 8,
  392. .page_size = 64,
  393. .flags = AT24_FLAG_ADDR16,
  394. .setup = at24_setup,
  395. };
  396. /*
  397. * MSP430 supports RTC, card detection, input from IR remote, and
  398. * a bit more. It triggers interrupts on GPIO(7) from pressing
  399. * buttons on the IR remote, and for card detect switches.
  400. */
  401. static struct i2c_client *dm6446evm_msp;
  402. static int dm6446evm_msp_probe(struct i2c_client *client,
  403. const struct i2c_device_id *id)
  404. {
  405. dm6446evm_msp = client;
  406. return 0;
  407. }
  408. static int dm6446evm_msp_remove(struct i2c_client *client)
  409. {
  410. dm6446evm_msp = NULL;
  411. return 0;
  412. }
  413. static const struct i2c_device_id dm6446evm_msp_ids[] = {
  414. { "dm6446evm_msp", 0, },
  415. { /* end of list */ },
  416. };
  417. static struct i2c_driver dm6446evm_msp_driver = {
  418. .driver.name = "dm6446evm_msp",
  419. .id_table = dm6446evm_msp_ids,
  420. .probe = dm6446evm_msp_probe,
  421. .remove = dm6446evm_msp_remove,
  422. };
  423. static int dm6444evm_msp430_get_pins(void)
  424. {
  425. static const char txbuf[2] = { 2, 4, };
  426. char buf[4];
  427. struct i2c_msg msg[2] = {
  428. {
  429. .addr = dm6446evm_msp->addr,
  430. .flags = 0,
  431. .len = 2,
  432. .buf = (void __force *)txbuf,
  433. },
  434. {
  435. .addr = dm6446evm_msp->addr,
  436. .flags = I2C_M_RD,
  437. .len = 4,
  438. .buf = buf,
  439. },
  440. };
  441. int status;
  442. if (!dm6446evm_msp)
  443. return -ENXIO;
  444. /* Command 4 == get input state, returns port 2 and port3 data
  445. * S Addr W [A] len=2 [A] cmd=4 [A]
  446. * RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P
  447. */
  448. status = i2c_transfer(dm6446evm_msp->adapter, msg, 2);
  449. if (status < 0)
  450. return status;
  451. dev_dbg(&dm6446evm_msp->dev,
  452. "PINS: %02x %02x %02x %02x\n",
  453. buf[0], buf[1], buf[2], buf[3]);
  454. return (buf[3] << 8) | buf[2];
  455. }
  456. static int dm6444evm_mmc_get_cd(int module)
  457. {
  458. int status = dm6444evm_msp430_get_pins();
  459. return (status < 0) ? status : !(status & BIT(1));
  460. }
  461. static int dm6444evm_mmc_get_ro(int module)
  462. {
  463. int status = dm6444evm_msp430_get_pins();
  464. return (status < 0) ? status : status & BIT(6 + 8);
  465. }
  466. static struct davinci_mmc_config dm6446evm_mmc_config = {
  467. .get_cd = dm6444evm_mmc_get_cd,
  468. .get_ro = dm6444evm_mmc_get_ro,
  469. .wires = 4,
  470. .version = MMC_CTLR_VERSION_1
  471. };
  472. static struct i2c_board_info __initdata i2c_info[] = {
  473. {
  474. I2C_BOARD_INFO("dm6446evm_msp", 0x23),
  475. },
  476. {
  477. I2C_BOARD_INFO("pcf8574", 0x38),
  478. .platform_data = &pcf_data_u2,
  479. },
  480. {
  481. I2C_BOARD_INFO("pcf8574", 0x39),
  482. .platform_data = &pcf_data_u18,
  483. },
  484. {
  485. I2C_BOARD_INFO("pcf8574", 0x3a),
  486. .platform_data = &pcf_data_u35,
  487. },
  488. {
  489. I2C_BOARD_INFO("24c256", 0x50),
  490. .platform_data = &eeprom_info,
  491. },
  492. /* ALSO:
  493. * - tvl320aic33 audio codec (0x1b)
  494. * - tvp5146 video decoder (0x5d)
  495. */
  496. };
  497. /* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
  498. * which requires 100 usec of idle bus after i2c writes sent to it.
  499. */
  500. static struct davinci_i2c_platform_data i2c_pdata = {
  501. .bus_freq = 20 /* kHz */,
  502. .bus_delay = 100 /* usec */,
  503. };
  504. static void __init evm_init_i2c(void)
  505. {
  506. davinci_init_i2c(&i2c_pdata);
  507. i2c_add_driver(&dm6446evm_msp_driver);
  508. i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
  509. }
  510. static struct platform_device *davinci_evm_devices[] __initdata = {
  511. &davinci_fb_device,
  512. &rtc_dev,
  513. };
  514. static struct davinci_uart_config uart_config __initdata = {
  515. .enabled_uarts = (1 << 0),
  516. };
  517. static void __init
  518. davinci_evm_map_io(void)
  519. {
  520. dm644x_init();
  521. }
  522. static int davinci_phy_fixup(struct phy_device *phydev)
  523. {
  524. unsigned int control;
  525. /* CRITICAL: Fix for increasing PHY signal drive strength for
  526. * TX lockup issue. On DaVinci EVM, the Intel LXT971 PHY
  527. * signal strength was low causing TX to fail randomly. The
  528. * fix is to Set bit 11 (Increased MII drive strength) of PHY
  529. * register 26 (Digital Config register) on this phy. */
  530. control = phy_read(phydev, 26);
  531. phy_write(phydev, 26, (control | 0x800));
  532. return 0;
  533. }
  534. #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  535. defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
  536. #define HAS_ATA 1
  537. #else
  538. #define HAS_ATA 0
  539. #endif
  540. #if defined(CONFIG_MTD_PHYSMAP) || \
  541. defined(CONFIG_MTD_PHYSMAP_MODULE)
  542. #define HAS_NOR 1
  543. #else
  544. #define HAS_NOR 0
  545. #endif
  546. #if defined(CONFIG_MTD_NAND_DAVINCI) || \
  547. defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
  548. #define HAS_NAND 1
  549. #else
  550. #define HAS_NAND 0
  551. #endif
  552. static __init void davinci_evm_init(void)
  553. {
  554. struct clk *aemif_clk;
  555. aemif_clk = clk_get(NULL, "aemif");
  556. clk_enable(aemif_clk);
  557. if (HAS_ATA) {
  558. if (HAS_NAND || HAS_NOR)
  559. pr_warning("WARNING: both IDE and Flash are "
  560. "enabled, but they share AEMIF pins.\n"
  561. "\tDisable IDE for NAND/NOR support.\n");
  562. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  563. davinci_cfg_reg(DM644X_ATAEN);
  564. davinci_cfg_reg(DM644X_HDIREN);
  565. platform_device_register(&ide_dev);
  566. } else if (HAS_NAND || HAS_NOR) {
  567. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  568. davinci_cfg_reg(DM644X_ATAEN_DISABLE);
  569. /* only one device will be jumpered and detected */
  570. if (HAS_NAND) {
  571. platform_device_register(&davinci_evm_nandflash_device);
  572. evm_leds[7].default_trigger = "nand-disk";
  573. if (HAS_NOR)
  574. pr_warning("WARNING: both NAND and NOR flash "
  575. "are enabled; disable one of them.\n");
  576. } else if (HAS_NOR)
  577. platform_device_register(&davinci_evm_norflash_device);
  578. }
  579. platform_add_devices(davinci_evm_devices,
  580. ARRAY_SIZE(davinci_evm_devices));
  581. evm_init_i2c();
  582. davinci_setup_mmc(0, &dm6446evm_mmc_config);
  583. davinci_serial_init(&uart_config);
  584. dm644x_init_emac(&dm644x_evm_emac_pdata);
  585. /* Register the fixup for PHY on DaVinci */
  586. phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
  587. davinci_phy_fixup);
  588. }
  589. static __init void davinci_evm_irq_init(void)
  590. {
  591. davinci_irq_init();
  592. }
  593. MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
  594. /* Maintainer: MontaVista Software <source@mvista.com> */
  595. .phys_io = IO_PHYS,
  596. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  597. .boot_params = (DAVINCI_DDR_BASE + 0x100),
  598. .map_io = davinci_evm_map_io,
  599. .init_irq = davinci_evm_irq_init,
  600. .timer = &davinci_timer,
  601. .init_machine = davinci_evm_init,
  602. MACHINE_END