ezkit.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2005 National ICT Australia (NICTA)
  4. * Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <linux/mtd/physmap.h>
  13. #include <linux/spi/spi.h>
  14. #include <linux/irq.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/delay.h>
  17. #include <asm/dma.h>
  18. #include <asm/bfin5xx_spi.h>
  19. #include <asm/portmux.h>
  20. #include <asm/dpmc.h>
  21. /*
  22. * Name the Board for the /proc/cpuinfo
  23. */
  24. const char bfin_board_name[] = "ADI BF561-EZKIT";
  25. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  26. #include <linux/usb/isp1760.h>
  27. static struct resource bfin_isp1760_resources[] = {
  28. [0] = {
  29. .start = 0x2C0F0000,
  30. .end = 0x203C0000 + 0xfffff,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. [1] = {
  34. .start = IRQ_PF10,
  35. .end = IRQ_PF10,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. };
  39. static struct isp1760_platform_data isp1760_priv = {
  40. .is_isp1761 = 0,
  41. .bus_width_16 = 1,
  42. .port1_otg = 0,
  43. .analog_oc = 0,
  44. .dack_polarity_high = 0,
  45. .dreq_polarity_high = 0,
  46. };
  47. static struct platform_device bfin_isp1760_device = {
  48. .name = "isp1760",
  49. .id = 0,
  50. .dev = {
  51. .platform_data = &isp1760_priv,
  52. },
  53. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  54. .resource = bfin_isp1760_resources,
  55. };
  56. #endif
  57. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  58. #include <linux/usb/isp1362.h>
  59. static struct resource isp1362_hcd_resources[] = {
  60. {
  61. .start = 0x2c060000,
  62. .end = 0x2c060000,
  63. .flags = IORESOURCE_MEM,
  64. }, {
  65. .start = 0x2c060004,
  66. .end = 0x2c060004,
  67. .flags = IORESOURCE_MEM,
  68. }, {
  69. .start = IRQ_PF8,
  70. .end = IRQ_PF8,
  71. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  72. },
  73. };
  74. static struct isp1362_platform_data isp1362_priv = {
  75. .sel15Kres = 1,
  76. .clknotstop = 0,
  77. .oc_enable = 0,
  78. .int_act_high = 0,
  79. .int_edge_triggered = 0,
  80. .remote_wakeup_connected = 0,
  81. .no_power_switching = 1,
  82. .power_switching_mode = 0,
  83. };
  84. static struct platform_device isp1362_hcd_device = {
  85. .name = "isp1362-hcd",
  86. .id = 0,
  87. .dev = {
  88. .platform_data = &isp1362_priv,
  89. },
  90. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  91. .resource = isp1362_hcd_resources,
  92. };
  93. #endif
  94. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  95. static struct resource net2272_bfin_resources[] = {
  96. {
  97. .start = 0x2C000000,
  98. .end = 0x2C000000 + 0x7F,
  99. .flags = IORESOURCE_MEM,
  100. }, {
  101. .start = IRQ_PF10,
  102. .end = IRQ_PF10,
  103. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  104. },
  105. };
  106. static struct platform_device net2272_bfin_device = {
  107. .name = "net2272",
  108. .id = -1,
  109. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  110. .resource = net2272_bfin_resources,
  111. };
  112. #endif
  113. /*
  114. * USB-LAN EzExtender board
  115. * Driver needs to know address, irq and flag pin.
  116. */
  117. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  118. #include <linux/smc91x.h>
  119. static struct smc91x_platdata smc91x_info = {
  120. .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
  121. .leda = RPC_LED_100_10,
  122. .ledb = RPC_LED_TX_RX,
  123. };
  124. static struct resource smc91x_resources[] = {
  125. {
  126. .name = "smc91x-regs",
  127. .start = 0x2C010300,
  128. .end = 0x2C010300 + 16,
  129. .flags = IORESOURCE_MEM,
  130. }, {
  131. .start = IRQ_PF9,
  132. .end = IRQ_PF9,
  133. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  134. },
  135. };
  136. static struct platform_device smc91x_device = {
  137. .name = "smc91x",
  138. .id = 0,
  139. .num_resources = ARRAY_SIZE(smc91x_resources),
  140. .resource = smc91x_resources,
  141. .dev = {
  142. .platform_data = &smc91x_info,
  143. },
  144. };
  145. #endif
  146. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  147. #ifdef CONFIG_SERIAL_BFIN_UART0
  148. static struct resource bfin_uart0_resources[] = {
  149. {
  150. .start = BFIN_UART_THR,
  151. .end = BFIN_UART_GCTL+2,
  152. .flags = IORESOURCE_MEM,
  153. },
  154. {
  155. .start = IRQ_UART_RX,
  156. .end = IRQ_UART_RX+1,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. {
  160. .start = IRQ_UART_ERROR,
  161. .end = IRQ_UART_ERROR,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. {
  165. .start = CH_UART_TX,
  166. .end = CH_UART_TX,
  167. .flags = IORESOURCE_DMA,
  168. },
  169. {
  170. .start = CH_UART_RX,
  171. .end = CH_UART_RX,
  172. .flags = IORESOURCE_DMA,
  173. },
  174. };
  175. static unsigned short bfin_uart0_peripherals[] = {
  176. P_UART0_TX, P_UART0_RX, 0
  177. };
  178. static struct platform_device bfin_uart0_device = {
  179. .name = "bfin-uart",
  180. .id = 0,
  181. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  182. .resource = bfin_uart0_resources,
  183. .dev = {
  184. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  185. },
  186. };
  187. #endif
  188. #endif
  189. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  190. #ifdef CONFIG_BFIN_SIR0
  191. static struct resource bfin_sir0_resources[] = {
  192. {
  193. .start = 0xFFC00400,
  194. .end = 0xFFC004FF,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. {
  198. .start = IRQ_UART0_RX,
  199. .end = IRQ_UART0_RX+1,
  200. .flags = IORESOURCE_IRQ,
  201. },
  202. {
  203. .start = CH_UART0_RX,
  204. .end = CH_UART0_RX+1,
  205. .flags = IORESOURCE_DMA,
  206. },
  207. };
  208. static struct platform_device bfin_sir0_device = {
  209. .name = "bfin_sir",
  210. .id = 0,
  211. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  212. .resource = bfin_sir0_resources,
  213. };
  214. #endif
  215. #endif
  216. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  217. static struct mtd_partition ezkit_partitions[] = {
  218. {
  219. .name = "bootloader(nor)",
  220. .size = 0x40000,
  221. .offset = 0,
  222. }, {
  223. .name = "linux kernel(nor)",
  224. .size = 0x1C0000,
  225. .offset = MTDPART_OFS_APPEND,
  226. }, {
  227. .name = "file system(nor)",
  228. .size = MTDPART_SIZ_FULL,
  229. .offset = MTDPART_OFS_APPEND,
  230. }
  231. };
  232. static struct physmap_flash_data ezkit_flash_data = {
  233. .width = 2,
  234. .parts = ezkit_partitions,
  235. .nr_parts = ARRAY_SIZE(ezkit_partitions),
  236. };
  237. static struct resource ezkit_flash_resource = {
  238. .start = 0x20000000,
  239. .end = 0x207fffff,
  240. .flags = IORESOURCE_MEM,
  241. };
  242. static struct platform_device ezkit_flash_device = {
  243. .name = "physmap-flash",
  244. .id = 0,
  245. .dev = {
  246. .platform_data = &ezkit_flash_data,
  247. },
  248. .num_resources = 1,
  249. .resource = &ezkit_flash_resource,
  250. };
  251. #endif
  252. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
  253. || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  254. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  255. .enable_dma = 0,
  256. .bits_per_word = 16,
  257. };
  258. #endif
  259. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  260. static struct bfin5xx_spi_chip spidev_chip_info = {
  261. .enable_dma = 0,
  262. .bits_per_word = 8,
  263. };
  264. #endif
  265. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  266. /* SPI (0) */
  267. static struct resource bfin_spi0_resource[] = {
  268. [0] = {
  269. .start = SPI0_REGBASE,
  270. .end = SPI0_REGBASE + 0xFF,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. [1] = {
  274. .start = CH_SPI,
  275. .end = CH_SPI,
  276. .flags = IORESOURCE_DMA,
  277. },
  278. [2] = {
  279. .start = IRQ_SPI,
  280. .end = IRQ_SPI,
  281. .flags = IORESOURCE_IRQ,
  282. }
  283. };
  284. /* SPI controller data */
  285. static struct bfin5xx_spi_master bfin_spi0_info = {
  286. .num_chipselect = 8,
  287. .enable_dma = 1, /* master has the ability to do dma transfer */
  288. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  289. };
  290. static struct platform_device bfin_spi0_device = {
  291. .name = "bfin-spi",
  292. .id = 0, /* Bus number */
  293. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  294. .resource = bfin_spi0_resource,
  295. .dev = {
  296. .platform_data = &bfin_spi0_info, /* Passed to driver */
  297. },
  298. };
  299. #endif
  300. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  301. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
  302. || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  303. {
  304. .modalias = "ad183x",
  305. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  306. .bus_num = 0,
  307. .chip_select = 4,
  308. .platform_data = "ad1836", /* only includes chip name for the moment */
  309. .controller_data = &ad1836_spi_chip_info,
  310. .mode = SPI_MODE_3,
  311. },
  312. #endif
  313. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  314. {
  315. .modalias = "spidev",
  316. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  317. .bus_num = 0,
  318. .chip_select = 1,
  319. .controller_data = &spidev_chip_info,
  320. },
  321. #endif
  322. };
  323. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  324. #include <linux/input.h>
  325. #include <linux/gpio_keys.h>
  326. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  327. {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
  328. {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
  329. {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
  330. {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
  331. };
  332. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  333. .buttons = bfin_gpio_keys_table,
  334. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  335. };
  336. static struct platform_device bfin_device_gpiokeys = {
  337. .name = "gpio-keys",
  338. .dev = {
  339. .platform_data = &bfin_gpio_keys_data,
  340. },
  341. };
  342. #endif
  343. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  344. #include <linux/i2c-gpio.h>
  345. static struct i2c_gpio_platform_data i2c_gpio_data = {
  346. .sda_pin = GPIO_PF1,
  347. .scl_pin = GPIO_PF0,
  348. .sda_is_open_drain = 0,
  349. .scl_is_open_drain = 0,
  350. .udelay = 40,
  351. };
  352. static struct platform_device i2c_gpio_device = {
  353. .name = "i2c-gpio",
  354. .id = 0,
  355. .dev = {
  356. .platform_data = &i2c_gpio_data,
  357. },
  358. };
  359. #endif
  360. static const unsigned int cclk_vlev_datasheet[] =
  361. {
  362. VRPAIR(VLEV_085, 250000000),
  363. VRPAIR(VLEV_090, 300000000),
  364. VRPAIR(VLEV_095, 313000000),
  365. VRPAIR(VLEV_100, 350000000),
  366. VRPAIR(VLEV_105, 400000000),
  367. VRPAIR(VLEV_110, 444000000),
  368. VRPAIR(VLEV_115, 450000000),
  369. VRPAIR(VLEV_120, 475000000),
  370. VRPAIR(VLEV_125, 500000000),
  371. VRPAIR(VLEV_130, 600000000),
  372. };
  373. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  374. .tuple_tab = cclk_vlev_datasheet,
  375. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  376. .vr_settling_time = 25 /* us */,
  377. };
  378. static struct platform_device bfin_dpmc = {
  379. .name = "bfin dpmc",
  380. .dev = {
  381. .platform_data = &bfin_dmpc_vreg_data,
  382. },
  383. };
  384. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  385. static struct platform_device bfin_i2s = {
  386. .name = "bfin-i2s",
  387. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  388. /* TODO: add platform data here */
  389. };
  390. #endif
  391. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  392. static struct platform_device bfin_tdm = {
  393. .name = "bfin-tdm",
  394. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  395. /* TODO: add platform data here */
  396. };
  397. #endif
  398. #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
  399. static struct platform_device bfin_ac97 = {
  400. .name = "bfin-ac97",
  401. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  402. /* TODO: add platform data here */
  403. };
  404. #endif
  405. static struct platform_device *ezkit_devices[] __initdata = {
  406. &bfin_dpmc,
  407. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  408. &smc91x_device,
  409. #endif
  410. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  411. &net2272_bfin_device,
  412. #endif
  413. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  414. &bfin_isp1760_device,
  415. #endif
  416. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  417. &bfin_spi0_device,
  418. #endif
  419. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  420. #ifdef CONFIG_SERIAL_BFIN_UART0
  421. &bfin_uart0_device,
  422. #endif
  423. #endif
  424. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  425. #ifdef CONFIG_BFIN_SIR0
  426. &bfin_sir0_device,
  427. #endif
  428. #endif
  429. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  430. &bfin_device_gpiokeys,
  431. #endif
  432. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  433. &i2c_gpio_device,
  434. #endif
  435. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  436. &isp1362_hcd_device,
  437. #endif
  438. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  439. &ezkit_flash_device,
  440. #endif
  441. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  442. &bfin_i2s,
  443. #endif
  444. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  445. &bfin_tdm,
  446. #endif
  447. #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
  448. &bfin_ac97,
  449. #endif
  450. };
  451. static int __init ezkit_init(void)
  452. {
  453. int ret;
  454. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  455. ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  456. if (ret < 0)
  457. return ret;
  458. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  459. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
  460. SSYNC();
  461. #endif
  462. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  463. bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
  464. bfin_write_FIO0_FLAG_S(1 << 15);
  465. SSYNC();
  466. /*
  467. * This initialization lasts for approximately 4500 MCLKs.
  468. * MCLK = 12.288MHz
  469. */
  470. udelay(400);
  471. #endif
  472. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  473. return 0;
  474. }
  475. arch_initcall(ezkit_init);
  476. static struct platform_device *ezkit_early_devices[] __initdata = {
  477. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  478. #ifdef CONFIG_SERIAL_BFIN_UART0
  479. &bfin_uart0_device,
  480. #endif
  481. #endif
  482. };
  483. void __init native_machine_early_platform_add_devices(void)
  484. {
  485. printk(KERN_INFO "register early platform devices\n");
  486. early_platform_add_devices(ezkit_early_devices,
  487. ARRAY_SIZE(ezkit_early_devices));
  488. }