board-dm644x-evm.c 18 KB

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