ezkit.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_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_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  236. {
  237. .modalias = "ad183x",
  238. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  239. .bus_num = 0,
  240. .chip_select = 4,
  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. #ifdef CONFIG_SERIAL_BFIN_UART0
  291. static struct resource bfin_uart0_resources[] = {
  292. {
  293. .start = BFIN_UART_THR,
  294. .end = BFIN_UART_GCTL+2,
  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 = IRQ_UART0_ERROR,
  304. .end = IRQ_UART0_ERROR,
  305. .flags = IORESOURCE_IRQ,
  306. },
  307. {
  308. .start = CH_UART0_TX,
  309. .end = CH_UART0_TX,
  310. .flags = IORESOURCE_DMA,
  311. },
  312. {
  313. .start = CH_UART0_RX,
  314. .end = CH_UART0_RX,
  315. .flags = IORESOURCE_DMA,
  316. },
  317. };
  318. static unsigned short bfin_uart0_peripherals[] = {
  319. P_UART0_TX, P_UART0_RX, 0
  320. };
  321. static struct platform_device bfin_uart0_device = {
  322. .name = "bfin-uart",
  323. .id = 0,
  324. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  325. .resource = bfin_uart0_resources,
  326. .dev = {
  327. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  328. },
  329. };
  330. #endif
  331. #endif
  332. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  333. #ifdef CONFIG_BFIN_SIR0
  334. static struct resource bfin_sir0_resources[] = {
  335. {
  336. .start = 0xFFC00400,
  337. .end = 0xFFC004FF,
  338. .flags = IORESOURCE_MEM,
  339. },
  340. {
  341. .start = IRQ_UART0_RX,
  342. .end = IRQ_UART0_RX+1,
  343. .flags = IORESOURCE_IRQ,
  344. },
  345. {
  346. .start = CH_UART0_RX,
  347. .end = CH_UART0_RX+1,
  348. .flags = IORESOURCE_DMA,
  349. },
  350. };
  351. static struct platform_device bfin_sir0_device = {
  352. .name = "bfin_sir",
  353. .id = 0,
  354. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  355. .resource = bfin_sir0_resources,
  356. };
  357. #endif
  358. #endif
  359. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  360. #include <linux/input.h>
  361. #include <linux/gpio_keys.h>
  362. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  363. {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
  364. {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
  365. {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
  366. {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
  367. };
  368. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  369. .buttons = bfin_gpio_keys_table,
  370. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  371. };
  372. static struct platform_device bfin_device_gpiokeys = {
  373. .name = "gpio-keys",
  374. .dev = {
  375. .platform_data = &bfin_gpio_keys_data,
  376. },
  377. };
  378. #endif
  379. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  380. #include <linux/i2c-gpio.h>
  381. static struct i2c_gpio_platform_data i2c_gpio_data = {
  382. .sda_pin = GPIO_PF1,
  383. .scl_pin = GPIO_PF0,
  384. .sda_is_open_drain = 0,
  385. .scl_is_open_drain = 0,
  386. .udelay = 40,
  387. };
  388. static struct platform_device i2c_gpio_device = {
  389. .name = "i2c-gpio",
  390. .id = 0,
  391. .dev = {
  392. .platform_data = &i2c_gpio_data,
  393. },
  394. };
  395. #endif
  396. static const unsigned int cclk_vlev_datasheet[] =
  397. {
  398. VRPAIR(VLEV_085, 250000000),
  399. VRPAIR(VLEV_090, 376000000),
  400. VRPAIR(VLEV_095, 426000000),
  401. VRPAIR(VLEV_100, 426000000),
  402. VRPAIR(VLEV_105, 476000000),
  403. VRPAIR(VLEV_110, 476000000),
  404. VRPAIR(VLEV_115, 476000000),
  405. VRPAIR(VLEV_120, 600000000),
  406. VRPAIR(VLEV_125, 600000000),
  407. VRPAIR(VLEV_130, 600000000),
  408. };
  409. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  410. .tuple_tab = cclk_vlev_datasheet,
  411. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  412. .vr_settling_time = 25 /* us */,
  413. };
  414. static struct platform_device bfin_dpmc = {
  415. .name = "bfin dpmc",
  416. .dev = {
  417. .platform_data = &bfin_dmpc_vreg_data,
  418. },
  419. };
  420. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  421. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  422. {
  423. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  424. },
  425. #endif
  426. };
  427. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  428. static struct platform_device bfin_i2s = {
  429. .name = "bfin-i2s",
  430. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  431. /* TODO: add platform data here */
  432. };
  433. #endif
  434. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  435. static struct platform_device bfin_tdm = {
  436. .name = "bfin-tdm",
  437. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  438. /* TODO: add platform data here */
  439. };
  440. #endif
  441. #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
  442. static struct platform_device bfin_ac97 = {
  443. .name = "bfin-ac97",
  444. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  445. /* TODO: add platform data here */
  446. };
  447. #endif
  448. static struct platform_device *ezkit_devices[] __initdata = {
  449. &bfin_dpmc,
  450. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  451. &ezkit_flash_device_a,
  452. &ezkit_flash_device_b,
  453. #endif
  454. #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
  455. &sram_device_a,
  456. &sram_device_b,
  457. #endif
  458. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  459. &smc91x_device,
  460. #endif
  461. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  462. &bfin_spi0_device,
  463. #endif
  464. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  465. &rtc_device,
  466. #endif
  467. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  468. #ifdef CONFIG_SERIAL_BFIN_UART0
  469. &bfin_uart0_device,
  470. #endif
  471. #endif
  472. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  473. #ifdef CONFIG_BFIN_SIR0
  474. &bfin_sir0_device,
  475. #endif
  476. #endif
  477. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  478. &bfin_device_gpiokeys,
  479. #endif
  480. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  481. &i2c_gpio_device,
  482. #endif
  483. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  484. &bfin_i2s,
  485. #endif
  486. #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
  487. &bfin_tdm,
  488. #endif
  489. #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
  490. &bfin_ac97,
  491. #endif
  492. };
  493. static int __init ezkit_init(void)
  494. {
  495. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  496. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  497. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  498. i2c_register_board_info(0, bfin_i2c_board_info,
  499. ARRAY_SIZE(bfin_i2c_board_info));
  500. return 0;
  501. }
  502. arch_initcall(ezkit_init);
  503. static struct platform_device *ezkit_early_devices[] __initdata = {
  504. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  505. #ifdef CONFIG_SERIAL_BFIN_UART0
  506. &bfin_uart0_device,
  507. #endif
  508. #endif
  509. };
  510. void __init native_machine_early_platform_add_devices(void)
  511. {
  512. printk(KERN_INFO "register early platform devices\n");
  513. early_platform_add_devices(ezkit_early_devices,
  514. ARRAY_SIZE(ezkit_early_devices));
  515. }