board-dm644x-evm.c 17 KB

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