ezkit.c 13 KB

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