ezkit.c 11 KB

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