ezkit.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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 IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  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 IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  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 IS_ENABLED(CONFIG_SMC91X)
  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 IS_ENABLED(CONFIG_MTD_PHYSMAP)
  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 IS_ENABLED(CONFIG_MTD_PLATRAM)
  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 IS_ENABLED(CONFIG_MTD_M25P80)
  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. };
  191. #endif
  192. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  193. #if IS_ENABLED(CONFIG_MTD_M25P80)
  194. {
  195. /* the modalias must be the same as spi device driver name */
  196. .modalias = "m25p80", /* Name of spi_driver for this device */
  197. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  198. .bus_num = 0, /* Framework bus number */
  199. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  200. .platform_data = &bfin_spi_flash_data,
  201. .controller_data = &spi_flash_chip_info,
  202. .mode = SPI_MODE_3,
  203. },
  204. #endif
  205. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
  206. {
  207. .modalias = "ad183x",
  208. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  209. .bus_num = 0,
  210. .chip_select = 4,
  211. },
  212. #endif
  213. #if IS_ENABLED(CONFIG_SPI_SPIDEV)
  214. {
  215. .modalias = "spidev",
  216. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  217. .bus_num = 0,
  218. .chip_select = 1,
  219. },
  220. #endif
  221. };
  222. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  223. /* SPI (0) */
  224. static struct resource bfin_spi0_resource[] = {
  225. [0] = {
  226. .start = SPI0_REGBASE,
  227. .end = SPI0_REGBASE + 0xFF,
  228. .flags = IORESOURCE_MEM,
  229. },
  230. [1] = {
  231. .start = CH_SPI,
  232. .end = CH_SPI,
  233. .flags = IORESOURCE_DMA,
  234. },
  235. [2] = {
  236. .start = IRQ_SPI,
  237. .end = IRQ_SPI,
  238. .flags = IORESOURCE_IRQ,
  239. }
  240. };
  241. /* SPI controller data */
  242. static struct bfin5xx_spi_master bfin_spi0_info = {
  243. .num_chipselect = 8,
  244. .enable_dma = 1, /* master has the ability to do dma transfer */
  245. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  246. };
  247. static struct platform_device bfin_spi0_device = {
  248. .name = "bfin-spi",
  249. .id = 0, /* Bus number */
  250. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  251. .resource = bfin_spi0_resource,
  252. .dev = {
  253. .platform_data = &bfin_spi0_info, /* Passed to driver */
  254. },
  255. };
  256. #endif /* spi master and devices */
  257. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  258. #ifdef CONFIG_SERIAL_BFIN_UART0
  259. static struct resource bfin_uart0_resources[] = {
  260. {
  261. .start = BFIN_UART_THR,
  262. .end = BFIN_UART_GCTL+2,
  263. .flags = IORESOURCE_MEM,
  264. },
  265. {
  266. .start = IRQ_UART0_TX,
  267. .end = IRQ_UART0_TX,
  268. .flags = IORESOURCE_IRQ,
  269. },
  270. {
  271. .start = IRQ_UART0_RX,
  272. .end = IRQ_UART0_RX,
  273. .flags = IORESOURCE_IRQ,
  274. },
  275. {
  276. .start = IRQ_UART0_ERROR,
  277. .end = IRQ_UART0_ERROR,
  278. .flags = IORESOURCE_IRQ,
  279. },
  280. {
  281. .start = CH_UART0_TX,
  282. .end = CH_UART0_TX,
  283. .flags = IORESOURCE_DMA,
  284. },
  285. {
  286. .start = CH_UART0_RX,
  287. .end = CH_UART0_RX,
  288. .flags = IORESOURCE_DMA,
  289. },
  290. };
  291. static unsigned short bfin_uart0_peripherals[] = {
  292. P_UART0_TX, P_UART0_RX, 0
  293. };
  294. static struct platform_device bfin_uart0_device = {
  295. .name = "bfin-uart",
  296. .id = 0,
  297. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  298. .resource = bfin_uart0_resources,
  299. .dev = {
  300. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  301. },
  302. };
  303. #endif
  304. #endif
  305. #if IS_ENABLED(CONFIG_BFIN_SIR)
  306. #ifdef CONFIG_BFIN_SIR0
  307. static struct resource bfin_sir0_resources[] = {
  308. {
  309. .start = 0xFFC00400,
  310. .end = 0xFFC004FF,
  311. .flags = IORESOURCE_MEM,
  312. },
  313. {
  314. .start = IRQ_UART0_RX,
  315. .end = IRQ_UART0_RX+1,
  316. .flags = IORESOURCE_IRQ,
  317. },
  318. {
  319. .start = CH_UART0_RX,
  320. .end = CH_UART0_RX+1,
  321. .flags = IORESOURCE_DMA,
  322. },
  323. };
  324. static struct platform_device bfin_sir0_device = {
  325. .name = "bfin_sir",
  326. .id = 0,
  327. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  328. .resource = bfin_sir0_resources,
  329. };
  330. #endif
  331. #endif
  332. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  333. #include <linux/input.h>
  334. #include <linux/gpio_keys.h>
  335. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  336. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  337. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  338. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  339. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  340. };
  341. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  342. .buttons = bfin_gpio_keys_table,
  343. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  344. };
  345. static struct platform_device bfin_device_gpiokeys = {
  346. .name = "gpio-keys",
  347. .dev = {
  348. .platform_data = &bfin_gpio_keys_data,
  349. },
  350. };
  351. #endif
  352. #if IS_ENABLED(CONFIG_I2C_GPIO)
  353. #include <linux/i2c-gpio.h>
  354. static struct i2c_gpio_platform_data i2c_gpio_data = {
  355. .sda_pin = GPIO_PF1,
  356. .scl_pin = GPIO_PF0,
  357. .sda_is_open_drain = 0,
  358. .scl_is_open_drain = 0,
  359. .udelay = 40,
  360. };
  361. static struct platform_device i2c_gpio_device = {
  362. .name = "i2c-gpio",
  363. .id = 0,
  364. .dev = {
  365. .platform_data = &i2c_gpio_data,
  366. },
  367. };
  368. #endif
  369. static const unsigned int cclk_vlev_datasheet[] =
  370. {
  371. VRPAIR(VLEV_085, 250000000),
  372. VRPAIR(VLEV_090, 376000000),
  373. VRPAIR(VLEV_095, 426000000),
  374. VRPAIR(VLEV_100, 426000000),
  375. VRPAIR(VLEV_105, 476000000),
  376. VRPAIR(VLEV_110, 476000000),
  377. VRPAIR(VLEV_115, 476000000),
  378. VRPAIR(VLEV_120, 600000000),
  379. VRPAIR(VLEV_125, 600000000),
  380. VRPAIR(VLEV_130, 600000000),
  381. };
  382. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  383. .tuple_tab = cclk_vlev_datasheet,
  384. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  385. .vr_settling_time = 25 /* us */,
  386. };
  387. static struct platform_device bfin_dpmc = {
  388. .name = "bfin dpmc",
  389. .dev = {
  390. .platform_data = &bfin_dmpc_vreg_data,
  391. },
  392. };
  393. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  394. #if IS_ENABLED(CONFIG_FB_BFIN_7393)
  395. {
  396. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  397. },
  398. #endif
  399. };
  400. #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
  401. static struct platform_device bfin_i2s = {
  402. .name = "bfin-i2s",
  403. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  404. /* TODO: add platform data here */
  405. };
  406. #endif
  407. #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
  408. static struct platform_device bfin_ac97 = {
  409. .name = "bfin-ac97",
  410. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  411. /* TODO: add platform data here */
  412. };
  413. #endif
  414. static struct platform_device *ezkit_devices[] __initdata = {
  415. &bfin_dpmc,
  416. #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
  417. &ezkit_flash_device_a,
  418. &ezkit_flash_device_b,
  419. #endif
  420. #if IS_ENABLED(CONFIG_MTD_PLATRAM)
  421. &sram_device_a,
  422. &sram_device_b,
  423. #endif
  424. #if IS_ENABLED(CONFIG_SMC91X)
  425. &smc91x_device,
  426. #endif
  427. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  428. &bfin_spi0_device,
  429. #endif
  430. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  431. &rtc_device,
  432. #endif
  433. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  434. #ifdef CONFIG_SERIAL_BFIN_UART0
  435. &bfin_uart0_device,
  436. #endif
  437. #endif
  438. #if IS_ENABLED(CONFIG_BFIN_SIR)
  439. #ifdef CONFIG_BFIN_SIR0
  440. &bfin_sir0_device,
  441. #endif
  442. #endif
  443. #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
  444. &bfin_device_gpiokeys,
  445. #endif
  446. #if IS_ENABLED(CONFIG_I2C_GPIO)
  447. &i2c_gpio_device,
  448. #endif
  449. #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
  450. &bfin_i2s,
  451. #endif
  452. #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
  453. &bfin_ac97,
  454. #endif
  455. };
  456. static int __init ezkit_init(void)
  457. {
  458. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  459. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  460. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  461. i2c_register_board_info(0, bfin_i2c_board_info,
  462. ARRAY_SIZE(bfin_i2c_board_info));
  463. return 0;
  464. }
  465. arch_initcall(ezkit_init);
  466. static struct platform_device *ezkit_early_devices[] __initdata = {
  467. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  468. #ifdef CONFIG_SERIAL_BFIN_UART0
  469. &bfin_uart0_device,
  470. #endif
  471. #endif
  472. };
  473. void __init native_machine_early_platform_add_devices(void)
  474. {
  475. printk(KERN_INFO "register early platform devices\n");
  476. early_platform_add_devices(ezkit_early_devices,
  477. ARRAY_SIZE(ezkit_early_devices));
  478. }