ezkit.c 13 KB

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