ezkit.c 12 KB

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