ezkit.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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/plat-ram.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  17. #include <linux/usb/isp1362.h>
  18. #endif
  19. #include <linux/irq.h>
  20. #include <linux/i2c.h>
  21. #include <asm/dma.h>
  22. #include <asm/bfin5xx_spi.h>
  23. #include <asm/portmux.h>
  24. #include <asm/dpmc.h>
  25. /*
  26. * Name the Board for the /proc/cpuinfo
  27. */
  28. const char bfin_board_name[] = "ADI BF533-EZKIT";
  29. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  30. static struct platform_device rtc_device = {
  31. .name = "rtc-bfin",
  32. .id = -1,
  33. };
  34. #endif
  35. /*
  36. * USB-LAN EzExtender board
  37. * Driver needs to know address, irq and flag pin.
  38. */
  39. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  40. #include <linux/smc91x.h>
  41. static struct smc91x_platdata smc91x_info = {
  42. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  43. .leda = RPC_LED_100_10,
  44. .ledb = RPC_LED_TX_RX,
  45. };
  46. static struct resource smc91x_resources[] = {
  47. {
  48. .name = "smc91x-regs",
  49. .start = 0x20310300,
  50. .end = 0x20310300 + 16,
  51. .flags = IORESOURCE_MEM,
  52. }, {
  53. .start = IRQ_PF9,
  54. .end = IRQ_PF9,
  55. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  56. },
  57. };
  58. static struct platform_device smc91x_device = {
  59. .name = "smc91x",
  60. .id = 0,
  61. .num_resources = ARRAY_SIZE(smc91x_resources),
  62. .resource = smc91x_resources,
  63. .dev = {
  64. .platform_data = &smc91x_info,
  65. },
  66. };
  67. #endif
  68. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  69. static struct mtd_partition ezkit_partitions_a[] = {
  70. {
  71. .name = "bootloader(nor a)",
  72. .size = 0x40000,
  73. .offset = 0,
  74. }, {
  75. .name = "linux kernel(nor a)",
  76. .size = MTDPART_SIZ_FULL,
  77. .offset = MTDPART_OFS_APPEND,
  78. },
  79. };
  80. static struct physmap_flash_data ezkit_flash_data_a = {
  81. .width = 2,
  82. .parts = ezkit_partitions_a,
  83. .nr_parts = ARRAY_SIZE(ezkit_partitions_a),
  84. };
  85. static struct resource ezkit_flash_resource_a = {
  86. .start = 0x20000000,
  87. .end = 0x200fffff,
  88. .flags = IORESOURCE_MEM,
  89. };
  90. static struct platform_device ezkit_flash_device_a = {
  91. .name = "physmap-flash",
  92. .id = 0,
  93. .dev = {
  94. .platform_data = &ezkit_flash_data_a,
  95. },
  96. .num_resources = 1,
  97. .resource = &ezkit_flash_resource_a,
  98. };
  99. static struct mtd_partition ezkit_partitions_b[] = {
  100. {
  101. .name = "file system(nor b)",
  102. .size = MTDPART_SIZ_FULL,
  103. .offset = MTDPART_OFS_APPEND,
  104. },
  105. };
  106. static struct physmap_flash_data ezkit_flash_data_b = {
  107. .width = 2,
  108. .parts = ezkit_partitions_b,
  109. .nr_parts = ARRAY_SIZE(ezkit_partitions_b),
  110. };
  111. static struct resource ezkit_flash_resource_b = {
  112. .start = 0x20100000,
  113. .end = 0x201fffff,
  114. .flags = IORESOURCE_MEM,
  115. };
  116. static struct platform_device ezkit_flash_device_b = {
  117. .name = "physmap-flash",
  118. .id = 4,
  119. .dev = {
  120. .platform_data = &ezkit_flash_data_b,
  121. },
  122. .num_resources = 1,
  123. .resource = &ezkit_flash_resource_b,
  124. };
  125. #endif
  126. #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
  127. static struct platdata_mtd_ram sram_data_a = {
  128. .mapname = "Flash A SRAM",
  129. .bankwidth = 2,
  130. };
  131. static struct resource sram_resource_a = {
  132. .start = 0x20240000,
  133. .end = 0x2024ffff,
  134. .flags = IORESOURCE_MEM,
  135. };
  136. static struct platform_device sram_device_a = {
  137. .name = "mtd-ram",
  138. .id = 8,
  139. .dev = {
  140. .platform_data = &sram_data_a,
  141. },
  142. .num_resources = 1,
  143. .resource = &sram_resource_a,
  144. };
  145. static struct platdata_mtd_ram sram_data_b = {
  146. .mapname = "Flash B SRAM",
  147. .bankwidth = 2,
  148. };
  149. static struct resource sram_resource_b = {
  150. .start = 0x202c0000,
  151. .end = 0x202cffff,
  152. .flags = IORESOURCE_MEM,
  153. };
  154. static struct platform_device sram_device_b = {
  155. .name = "mtd-ram",
  156. .id = 9,
  157. .dev = {
  158. .platform_data = &sram_data_b,
  159. },
  160. .num_resources = 1,
  161. .resource = &sram_resource_b,
  162. };
  163. #endif
  164. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  165. static struct mtd_partition bfin_spi_flash_partitions[] = {
  166. {
  167. .name = "bootloader(spi)",
  168. .size = 0x00020000,
  169. .offset = 0,
  170. .mask_flags = MTD_CAP_ROM
  171. }, {
  172. .name = "linux kernel(spi)",
  173. .size = 0xe0000,
  174. .offset = MTDPART_OFS_APPEND,
  175. }, {
  176. .name = "file system(spi)",
  177. .size = MTDPART_SIZ_FULL,
  178. .offset = MTDPART_OFS_APPEND,
  179. }
  180. };
  181. static struct flash_platform_data bfin_spi_flash_data = {
  182. .name = "m25p80",
  183. .parts = bfin_spi_flash_partitions,
  184. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  185. .type = "m25p64",
  186. };
  187. /* SPI flash chip (m25p64) */
  188. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  189. .enable_dma = 0, /* use dma transfer with this chip*/
  190. .bits_per_word = 8,
  191. };
  192. #endif
  193. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  194. /* SPI ADC chip */
  195. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  196. .enable_dma = 1, /* use dma transfer with this chip*/
  197. .bits_per_word = 16,
  198. };
  199. #endif
  200. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  201. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  202. .enable_dma = 0,
  203. .bits_per_word = 16,
  204. };
  205. #endif
  206. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  207. static struct bfin5xx_spi_chip spidev_chip_info = {
  208. .enable_dma = 0,
  209. .bits_per_word = 8,
  210. };
  211. #endif
  212. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  213. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  214. {
  215. /* the modalias must be the same as spi device driver name */
  216. .modalias = "m25p80", /* Name of spi_driver for this device */
  217. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  218. .bus_num = 0, /* Framework bus number */
  219. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  220. .platform_data = &bfin_spi_flash_data,
  221. .controller_data = &spi_flash_chip_info,
  222. .mode = SPI_MODE_3,
  223. },
  224. #endif
  225. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  226. {
  227. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  228. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  229. .bus_num = 0, /* Framework bus number */
  230. .chip_select = 1, /* Framework chip select. */
  231. .platform_data = NULL, /* No spi_driver specific config */
  232. .controller_data = &spi_adc_chip_info,
  233. },
  234. #endif
  235. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  236. {
  237. .modalias = "ad1836",
  238. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  239. .bus_num = 0,
  240. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  241. .controller_data = &ad1836_spi_chip_info,
  242. },
  243. #endif
  244. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  245. {
  246. .modalias = "spidev",
  247. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  248. .bus_num = 0,
  249. .chip_select = 1,
  250. .controller_data = &spidev_chip_info,
  251. },
  252. #endif
  253. };
  254. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  255. /* SPI (0) */
  256. static struct resource bfin_spi0_resource[] = {
  257. [0] = {
  258. .start = SPI0_REGBASE,
  259. .end = SPI0_REGBASE + 0xFF,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = CH_SPI,
  264. .end = CH_SPI,
  265. .flags = IORESOURCE_DMA,
  266. },
  267. [2] = {
  268. .start = IRQ_SPI,
  269. .end = IRQ_SPI,
  270. .flags = IORESOURCE_IRQ,
  271. }
  272. };
  273. /* SPI controller data */
  274. static struct bfin5xx_spi_master bfin_spi0_info = {
  275. .num_chipselect = 8,
  276. .enable_dma = 1, /* master has the ability to do dma transfer */
  277. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  278. };
  279. static struct platform_device bfin_spi0_device = {
  280. .name = "bfin-spi",
  281. .id = 0, /* Bus number */
  282. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  283. .resource = bfin_spi0_resource,
  284. .dev = {
  285. .platform_data = &bfin_spi0_info, /* Passed to driver */
  286. },
  287. };
  288. #endif /* spi master and devices */
  289. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  290. static struct resource bfin_uart_resources[] = {
  291. {
  292. .start = 0xFFC00400,
  293. .end = 0xFFC004FF,
  294. .flags = IORESOURCE_MEM,
  295. },
  296. };
  297. static struct platform_device bfin_uart_device = {
  298. .name = "bfin-uart",
  299. .id = 1,
  300. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  301. .resource = bfin_uart_resources,
  302. };
  303. #endif
  304. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  305. #ifdef CONFIG_BFIN_SIR0
  306. static struct resource bfin_sir0_resources[] = {
  307. {
  308. .start = 0xFFC00400,
  309. .end = 0xFFC004FF,
  310. .flags = IORESOURCE_MEM,
  311. },
  312. {
  313. .start = IRQ_UART0_RX,
  314. .end = IRQ_UART0_RX+1,
  315. .flags = IORESOURCE_IRQ,
  316. },
  317. {
  318. .start = CH_UART0_RX,
  319. .end = CH_UART0_RX+1,
  320. .flags = IORESOURCE_DMA,
  321. },
  322. };
  323. static struct platform_device bfin_sir0_device = {
  324. .name = "bfin_sir",
  325. .id = 0,
  326. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  327. .resource = bfin_sir0_resources,
  328. };
  329. #endif
  330. #endif
  331. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  332. #include <linux/input.h>
  333. #include <linux/gpio_keys.h>
  334. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  335. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  336. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  337. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  338. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  339. };
  340. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  341. .buttons = bfin_gpio_keys_table,
  342. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  343. };
  344. static struct platform_device bfin_device_gpiokeys = {
  345. .name = "gpio-keys",
  346. .dev = {
  347. .platform_data = &bfin_gpio_keys_data,
  348. },
  349. };
  350. #endif
  351. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  352. #include <linux/i2c-gpio.h>
  353. static struct i2c_gpio_platform_data i2c_gpio_data = {
  354. .sda_pin = 1,
  355. .scl_pin = 0,
  356. .sda_is_open_drain = 0,
  357. .scl_is_open_drain = 0,
  358. .udelay = 40,
  359. };
  360. static struct platform_device i2c_gpio_device = {
  361. .name = "i2c-gpio",
  362. .id = 0,
  363. .dev = {
  364. .platform_data = &i2c_gpio_data,
  365. },
  366. };
  367. #endif
  368. static const unsigned int cclk_vlev_datasheet[] =
  369. {
  370. VRPAIR(VLEV_085, 250000000),
  371. VRPAIR(VLEV_090, 376000000),
  372. VRPAIR(VLEV_095, 426000000),
  373. VRPAIR(VLEV_100, 426000000),
  374. VRPAIR(VLEV_105, 476000000),
  375. VRPAIR(VLEV_110, 476000000),
  376. VRPAIR(VLEV_115, 476000000),
  377. VRPAIR(VLEV_120, 600000000),
  378. VRPAIR(VLEV_125, 600000000),
  379. VRPAIR(VLEV_130, 600000000),
  380. };
  381. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  382. .tuple_tab = cclk_vlev_datasheet,
  383. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  384. .vr_settling_time = 25 /* us */,
  385. };
  386. static struct platform_device bfin_dpmc = {
  387. .name = "bfin dpmc",
  388. .dev = {
  389. .platform_data = &bfin_dmpc_vreg_data,
  390. },
  391. };
  392. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  393. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  394. {
  395. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  396. },
  397. #endif
  398. };
  399. static struct platform_device *ezkit_devices[] __initdata = {
  400. &bfin_dpmc,
  401. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  402. &ezkit_flash_device_a,
  403. &ezkit_flash_device_b,
  404. #endif
  405. #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
  406. &sram_device_a,
  407. &sram_device_b,
  408. #endif
  409. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  410. &smc91x_device,
  411. #endif
  412. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  413. &bfin_spi0_device,
  414. #endif
  415. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  416. &rtc_device,
  417. #endif
  418. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  419. &bfin_uart_device,
  420. #endif
  421. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  422. #ifdef CONFIG_BFIN_SIR0
  423. &bfin_sir0_device,
  424. #endif
  425. #endif
  426. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  427. &bfin_device_gpiokeys,
  428. #endif
  429. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  430. &i2c_gpio_device,
  431. #endif
  432. };
  433. static int __init ezkit_init(void)
  434. {
  435. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  436. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  437. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  438. i2c_register_board_info(0, bfin_i2c_board_info,
  439. ARRAY_SIZE(bfin_i2c_board_info));
  440. return 0;
  441. }
  442. arch_initcall(ezkit_init);