generic_board.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. * File: arch/blackfin/mach-bf537/boards/generic_board.c
  3. * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  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/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #include <linux/usb_isp1362.h>
  37. #include <linux/irq.h>
  38. #include <linux/usb_sl811.h>
  39. #include <asm/bfin5xx_spi.h>
  40. /*
  41. * Name the Board for the /proc/cpuinfo
  42. */
  43. char *bfin_board_name = "UNKNOWN BOARD";
  44. /*
  45. * Driver needs to know address, irq and flag pin.
  46. */
  47. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  48. static struct resource bfin_pcmcia_cf_resources[] = {
  49. {
  50. .start = 0x20310000, /* IO PORT */
  51. .end = 0x20312000,
  52. .flags = IORESOURCE_MEM,
  53. }, {
  54. .start = 0x20311000, /* Attribute Memory */
  55. .end = 0x20311FFF,
  56. .flags = IORESOURCE_MEM,
  57. }, {
  58. .start = IRQ_PROG_INTA,
  59. .end = IRQ_PROG_INTA,
  60. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  61. }, {
  62. .start = IRQ_PF4,
  63. .end = IRQ_PF4,
  64. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  65. }, {
  66. .start = 6, /* Card Detect PF6 */
  67. .end = 6,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct platform_device bfin_pcmcia_cf_device = {
  72. .name = "bfin_cf_pcmcia",
  73. .id = -1,
  74. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  75. .resource = bfin_pcmcia_cf_resources,
  76. };
  77. #endif
  78. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  79. static struct platform_device rtc_device = {
  80. .name = "rtc-bfin",
  81. .id = -1,
  82. };
  83. #endif
  84. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  85. static struct resource smc91x_resources[] = {
  86. {
  87. .name = "smc91x-regs",
  88. .start = 0x20300300,
  89. .end = 0x20300300 + 16,
  90. .flags = IORESOURCE_MEM,
  91. }, {
  92. .start = IRQ_PROG_INTB,
  93. .end = IRQ_PROG_INTB,
  94. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  95. }, {
  96. /*
  97. * denotes the flag pin and is used directly if
  98. * CONFIG_IRQCHIP_DEMUX_GPIO is defined.
  99. */
  100. .start = IRQ_PF7,
  101. .end = IRQ_PF7,
  102. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  103. },
  104. };
  105. static struct platform_device smc91x_device = {
  106. .name = "smc91x",
  107. .id = 0,
  108. .num_resources = ARRAY_SIZE(smc91x_resources),
  109. .resource = smc91x_resources,
  110. };
  111. #endif
  112. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  113. static struct resource sl811_hcd_resources[] = {
  114. {
  115. .start = 0x20340000,
  116. .end = 0x20340000,
  117. .flags = IORESOURCE_MEM,
  118. }, {
  119. .start = 0x20340004,
  120. .end = 0x20340004,
  121. .flags = IORESOURCE_MEM,
  122. }, {
  123. .start = IRQ_PROG_INTA,
  124. .end = IRQ_PROG_INTA,
  125. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  126. }, {
  127. .start = IRQ_PF0 + CONFIG_USB_SL811_BFIN_GPIO,
  128. .end = IRQ_PF0 + CONFIG_USB_SL811_BFIN_GPIO,
  129. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  130. },
  131. };
  132. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  133. void sl811_port_power(struct device *dev, int is_on)
  134. {
  135. unsigned short mask = (1<<CONFIG_USB_SL811_BFIN_GPIO_VBUS);
  136. bfin_write_PORT_FER(bfin_read_PORT_FER() & ~mask);
  137. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | mask);
  138. if (is_on)
  139. bfin_write_FIO_FLAG_S(mask);
  140. else
  141. bfin_write_FIO_FLAG_C(mask);
  142. }
  143. #endif
  144. static struct sl811_platform_data sl811_priv = {
  145. .potpg = 10,
  146. .power = 250, /* == 500mA */
  147. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  148. .port_power = &sl811_port_power,
  149. #endif
  150. };
  151. static struct platform_device sl811_hcd_device = {
  152. .name = "sl811-hcd",
  153. .id = 0,
  154. .dev = {
  155. .platform_data = &sl811_priv,
  156. },
  157. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  158. .resource = sl811_hcd_resources,
  159. };
  160. #endif
  161. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  162. static struct resource isp1362_hcd_resources[] = {
  163. {
  164. .start = 0x20360000,
  165. .end = 0x20360000,
  166. .flags = IORESOURCE_MEM,
  167. }, {
  168. .start = 0x20360004,
  169. .end = 0x20360004,
  170. .flags = IORESOURCE_MEM,
  171. }, {
  172. .start = IRQ_PROG_INTA,
  173. .end = IRQ_PROG_INTA,
  174. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  175. }, {
  176. .start = IRQ_PF0 + CONFIG_USB_ISP1362_BFIN_GPIO,
  177. .end = IRQ_PF0 + CONFIG_USB_ISP1362_BFIN_GPIO,
  178. .flags = IORESOURCE_IRQ,
  179. },
  180. };
  181. static struct isp1362_platform_data isp1362_priv = {
  182. .sel15Kres = 1,
  183. .clknotstop = 0,
  184. .oc_enable = 0,
  185. .int_act_high = 0,
  186. .int_edge_triggered = 0,
  187. .remote_wakeup_connected = 0,
  188. .no_power_switching = 1,
  189. .power_switching_mode = 0,
  190. };
  191. static struct platform_device isp1362_hcd_device = {
  192. .name = "isp1362-hcd",
  193. .id = 0,
  194. .dev = {
  195. .platform_data = &isp1362_priv,
  196. },
  197. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  198. .resource = isp1362_hcd_resources,
  199. };
  200. #endif
  201. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  202. static struct platform_device bfin_mac_device = {
  203. .name = "bfin_mac",
  204. };
  205. #endif
  206. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  207. static struct resource net2272_bfin_resources[] = {
  208. {
  209. .start = 0x20300000,
  210. .end = 0x20300000 + 0x100,
  211. .flags = IORESOURCE_MEM,
  212. }, {
  213. .start = IRQ_PF7,
  214. .end = IRQ_PF7,
  215. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  216. },
  217. };
  218. static struct platform_device net2272_bfin_device = {
  219. .name = "net2272",
  220. .id = -1,
  221. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  222. .resource = net2272_bfin_resources,
  223. };
  224. #endif
  225. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  226. /* all SPI peripherals info goes here */
  227. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  228. static struct mtd_partition bfin_spi_flash_partitions[] = {
  229. {
  230. .name = "bootloader",
  231. .size = 0x00020000,
  232. .offset = 0,
  233. .mask_flags = MTD_CAP_ROM
  234. }, {
  235. .name = "kernel",
  236. .size = 0xe0000,
  237. .offset = 0x20000
  238. }, {
  239. .name = "file system",
  240. .size = 0x700000,
  241. .offset = 0x00100000,
  242. }
  243. };
  244. static struct flash_platform_data bfin_spi_flash_data = {
  245. .name = "m25p80",
  246. .parts = bfin_spi_flash_partitions,
  247. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  248. .type = "m25p64",
  249. };
  250. /* SPI flash chip (m25p64) */
  251. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  252. .enable_dma = 0, /* use dma transfer with this chip*/
  253. .bits_per_word = 8,
  254. };
  255. #endif
  256. #if defined(CONFIG_SPI_ADC_BF533) \
  257. || defined(CONFIG_SPI_ADC_BF533_MODULE)
  258. /* SPI ADC chip */
  259. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  260. .enable_dma = 1, /* use dma transfer with this chip*/
  261. .bits_per_word = 16,
  262. };
  263. #endif
  264. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  265. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  266. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  267. .enable_dma = 0,
  268. .bits_per_word = 16,
  269. };
  270. #endif
  271. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  272. static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
  273. .enable_dma = 0,
  274. .bits_per_word = 16,
  275. };
  276. #endif
  277. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  278. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  279. {
  280. /* the modalias must be the same as spi device driver name */
  281. .modalias = "m25p80", /* Name of spi_driver for this device */
  282. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  283. .bus_num = 1, /* Framework bus number */
  284. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  285. .platform_data = &bfin_spi_flash_data,
  286. .controller_data = &spi_flash_chip_info,
  287. .mode = SPI_MODE_3,
  288. },
  289. #endif
  290. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  291. {
  292. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  293. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  294. .bus_num = 1, /* Framework bus number */
  295. .chip_select = 1, /* Framework chip select. */
  296. .platform_data = NULL, /* No spi_driver specific config */
  297. .controller_data = &spi_adc_chip_info,
  298. },
  299. #endif
  300. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  301. {
  302. .modalias = "ad1836-spi",
  303. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  304. .bus_num = 1,
  305. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  306. .controller_data = &ad1836_spi_chip_info,
  307. },
  308. #endif
  309. #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
  310. {
  311. .modalias = "ad9960-spi",
  312. .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
  313. .bus_num = 1,
  314. .chip_select = 1,
  315. .controller_data = &ad9960_spi_chip_info,
  316. },
  317. #endif
  318. };
  319. /* SPI controller data */
  320. static struct bfin5xx_spi_master spi_bfin_master_info = {
  321. .num_chipselect = 8,
  322. .enable_dma = 1, /* master has the ability to do dma transfer */
  323. };
  324. static struct platform_device spi_bfin_master_device = {
  325. .name = "bfin-spi-master",
  326. .id = 1, /* Bus number */
  327. .dev = {
  328. .platform_data = &spi_bfin_master_info, /* Passed to driver */
  329. },
  330. };
  331. #endif /* spi master and devices */
  332. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  333. static struct platform_device bfin_fb_device = {
  334. .name = "bf537-fb",
  335. };
  336. #endif
  337. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  338. static struct resource bfin_uart_resources[] = {
  339. {
  340. .start = 0xFFC00400,
  341. .end = 0xFFC004FF,
  342. .flags = IORESOURCE_MEM,
  343. }, {
  344. .start = 0xFFC02000,
  345. .end = 0xFFC020FF,
  346. .flags = IORESOURCE_MEM,
  347. },
  348. };
  349. static struct platform_device bfin_uart_device = {
  350. .name = "bfin-uart",
  351. .id = 1,
  352. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  353. .resource = bfin_uart_resources,
  354. };
  355. #endif
  356. static struct platform_device *stamp_devices[] __initdata = {
  357. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  358. &rtc_device,
  359. #endif
  360. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  361. &bfin_pcmcia_cf_device,
  362. #endif
  363. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  364. &sl811_hcd_device,
  365. #endif
  366. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  367. &isp1362_hcd_device,
  368. #endif
  369. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  370. &smc91x_device,
  371. #endif
  372. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  373. &bfin_mac_device,
  374. #endif
  375. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  376. &net2272_bfin_device,
  377. #endif
  378. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  379. &spi_bfin_master_device,
  380. #endif
  381. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  382. &bfin_fb_device,
  383. #endif
  384. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  385. &bfin_uart_device,
  386. #endif
  387. };
  388. static int __init stamp_init(void)
  389. {
  390. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  391. platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  392. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  393. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  394. #endif
  395. return 0;
  396. }
  397. arch_initcall(stamp_init);