cm_bf533.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2008-2009 Bluetechnix
  4. * 2005 National ICT Australia (NICTA)
  5. * Aidan Williams <aidan@nicta.com.au>
  6. *
  7. * Licensed under the GPL-2 or later.
  8. */
  9. #include <linux/device.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #include <linux/spi/mmc_spi.h>
  17. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  18. #include <linux/usb/isp1362.h>
  19. #endif
  20. #include <linux/irq.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[] = "Bluetechnix CM BF533";
  29. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  30. /* all SPI peripherals info goes here */
  31. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  32. static struct mtd_partition bfin_spi_flash_partitions[] = {
  33. {
  34. .name = "bootloader(spi)",
  35. .size = 0x00020000,
  36. .offset = 0,
  37. .mask_flags = MTD_CAP_ROM
  38. }, {
  39. .name = "linux kernel(spi)",
  40. .size = 0xe0000,
  41. .offset = 0x20000
  42. }, {
  43. .name = "file system(spi)",
  44. .size = 0x700000,
  45. .offset = 0x00100000,
  46. }
  47. };
  48. static struct flash_platform_data bfin_spi_flash_data = {
  49. .name = "m25p80",
  50. .parts = bfin_spi_flash_partitions,
  51. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  52. .type = "m25p64",
  53. };
  54. /* SPI flash chip (m25p64) */
  55. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  56. .enable_dma = 0, /* use dma transfer with this chip*/
  57. .bits_per_word = 8,
  58. };
  59. #endif
  60. /* SPI ADC chip */
  61. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  62. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  63. .enable_dma = 1, /* use dma transfer with this chip*/
  64. .bits_per_word = 16,
  65. };
  66. #endif
  67. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  68. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  69. .enable_dma = 0,
  70. .bits_per_word = 16,
  71. };
  72. #endif
  73. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  74. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  75. .enable_dma = 0,
  76. .bits_per_word = 8,
  77. };
  78. #endif
  79. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  80. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  81. {
  82. /* the modalias must be the same as spi device driver name */
  83. .modalias = "m25p80", /* Name of spi_driver for this device */
  84. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  85. .bus_num = 0, /* Framework bus number */
  86. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  87. .platform_data = &bfin_spi_flash_data,
  88. .controller_data = &spi_flash_chip_info,
  89. .mode = SPI_MODE_3,
  90. },
  91. #endif
  92. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  93. {
  94. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  95. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  96. .bus_num = 0, /* Framework bus number */
  97. .chip_select = 2, /* Framework chip select. */
  98. .platform_data = NULL, /* No spi_driver specific config */
  99. .controller_data = &spi_adc_chip_info,
  100. },
  101. #endif
  102. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  103. {
  104. .modalias = "ad1836",
  105. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  106. .bus_num = 0,
  107. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  108. .controller_data = &ad1836_spi_chip_info,
  109. },
  110. #endif
  111. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  112. {
  113. .modalias = "mmc_spi",
  114. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  115. .bus_num = 0,
  116. .chip_select = 1,
  117. .controller_data = &mmc_spi_chip_info,
  118. .mode = SPI_MODE_3,
  119. },
  120. #endif
  121. };
  122. /* SPI (0) */
  123. static struct resource bfin_spi0_resource[] = {
  124. [0] = {
  125. .start = SPI0_REGBASE,
  126. .end = SPI0_REGBASE + 0xFF,
  127. .flags = IORESOURCE_MEM,
  128. },
  129. [1] = {
  130. .start = CH_SPI,
  131. .end = CH_SPI,
  132. .flags = IORESOURCE_DMA,
  133. },
  134. [2] = {
  135. .start = IRQ_SPI,
  136. .end = IRQ_SPI,
  137. .flags = IORESOURCE_IRQ,
  138. }
  139. };
  140. /* SPI controller data */
  141. static struct bfin5xx_spi_master bfin_spi0_info = {
  142. .num_chipselect = 8,
  143. .enable_dma = 1, /* master has the ability to do dma transfer */
  144. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  145. };
  146. static struct platform_device bfin_spi0_device = {
  147. .name = "bfin-spi",
  148. .id = 0, /* Bus number */
  149. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  150. .resource = bfin_spi0_resource,
  151. .dev = {
  152. .platform_data = &bfin_spi0_info, /* Passed to driver */
  153. },
  154. };
  155. #endif /* spi master and devices */
  156. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  157. static struct platform_device rtc_device = {
  158. .name = "rtc-bfin",
  159. .id = -1,
  160. };
  161. #endif
  162. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  163. #include <linux/smc91x.h>
  164. static struct smc91x_platdata smc91x_info = {
  165. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  166. .leda = RPC_LED_100_10,
  167. .ledb = RPC_LED_TX_RX,
  168. };
  169. static struct resource smc91x_resources[] = {
  170. {
  171. .start = 0x20200300,
  172. .end = 0x20200300 + 16,
  173. .flags = IORESOURCE_MEM,
  174. }, {
  175. .start = IRQ_PF0,
  176. .end = IRQ_PF0,
  177. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  178. },
  179. };
  180. static struct platform_device smc91x_device = {
  181. .name = "smc91x",
  182. .id = 0,
  183. .num_resources = ARRAY_SIZE(smc91x_resources),
  184. .resource = smc91x_resources,
  185. .dev = {
  186. .platform_data = &smc91x_info,
  187. },
  188. };
  189. #endif
  190. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  191. #include <linux/smsc911x.h>
  192. static struct resource smsc911x_resources[] = {
  193. {
  194. .name = "smsc911x-memory",
  195. .start = 0x20308000,
  196. .end = 0x20308000 + 0xFF,
  197. .flags = IORESOURCE_MEM,
  198. }, {
  199. .start = IRQ_PF8,
  200. .end = IRQ_PF8,
  201. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  202. },
  203. };
  204. static struct smsc911x_platform_config smsc911x_config = {
  205. .flags = SMSC911X_USE_16BIT,
  206. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  207. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  208. .phy_interface = PHY_INTERFACE_MODE_MII,
  209. };
  210. static struct platform_device smsc911x_device = {
  211. .name = "smsc911x",
  212. .id = 0,
  213. .num_resources = ARRAY_SIZE(smsc911x_resources),
  214. .resource = smsc911x_resources,
  215. .dev = {
  216. .platform_data = &smsc911x_config,
  217. },
  218. };
  219. #endif
  220. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  221. static struct resource bfin_uart_resources[] = {
  222. {
  223. .start = 0xFFC00400,
  224. .end = 0xFFC004FF,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. };
  228. static struct platform_device bfin_uart_device = {
  229. .name = "bfin-uart",
  230. .id = 1,
  231. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  232. .resource = bfin_uart_resources,
  233. };
  234. #endif
  235. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  236. #ifdef CONFIG_BFIN_SIR0
  237. static struct resource bfin_sir0_resources[] = {
  238. {
  239. .start = 0xFFC00400,
  240. .end = 0xFFC004FF,
  241. .flags = IORESOURCE_MEM,
  242. },
  243. {
  244. .start = IRQ_UART0_RX,
  245. .end = IRQ_UART0_RX+1,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. {
  249. .start = CH_UART0_RX,
  250. .end = CH_UART0_RX+1,
  251. .flags = IORESOURCE_DMA,
  252. },
  253. };
  254. static struct platform_device bfin_sir0_device = {
  255. .name = "bfin_sir",
  256. .id = 0,
  257. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  258. .resource = bfin_sir0_resources,
  259. };
  260. #endif
  261. #endif
  262. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  263. static struct platform_device bfin_sport0_uart_device = {
  264. .name = "bfin-sport-uart",
  265. .id = 0,
  266. };
  267. static struct platform_device bfin_sport1_uart_device = {
  268. .name = "bfin-sport-uart",
  269. .id = 1,
  270. };
  271. #endif
  272. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  273. static struct resource isp1362_hcd_resources[] = {
  274. {
  275. .start = 0x20308000,
  276. .end = 0x20308000,
  277. .flags = IORESOURCE_MEM,
  278. }, {
  279. .start = 0x20308004,
  280. .end = 0x20308004,
  281. .flags = IORESOURCE_MEM,
  282. }, {
  283. .start = IRQ_PF4,
  284. .end = IRQ_PF4,
  285. .flags = IORESOURCE_IRQ,
  286. },
  287. };
  288. static struct isp1362_platform_data isp1362_priv = {
  289. .sel15Kres = 1,
  290. .clknotstop = 0,
  291. .oc_enable = 0,
  292. .int_act_high = 0,
  293. .int_edge_triggered = 0,
  294. .remote_wakeup_connected = 0,
  295. .no_power_switching = 1,
  296. .power_switching_mode = 0,
  297. };
  298. static struct platform_device isp1362_hcd_device = {
  299. .name = "isp1362-hcd",
  300. .id = 0,
  301. .dev = {
  302. .platform_data = &isp1362_priv,
  303. },
  304. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  305. .resource = isp1362_hcd_resources,
  306. };
  307. #endif
  308. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  309. static struct resource net2272_bfin_resources[] = {
  310. {
  311. .start = 0x20300000,
  312. .end = 0x20300000 + 0x100,
  313. .flags = IORESOURCE_MEM,
  314. }, {
  315. .start = IRQ_PF6,
  316. .end = IRQ_PF6,
  317. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  318. },
  319. };
  320. static struct platform_device net2272_bfin_device = {
  321. .name = "net2272",
  322. .id = -1,
  323. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  324. .resource = net2272_bfin_resources,
  325. };
  326. #endif
  327. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  328. static struct mtd_partition para_partitions[] = {
  329. {
  330. .name = "bootloader(nor)",
  331. .size = 0x40000,
  332. .offset = 0,
  333. }, {
  334. .name = "linux+rootfs(nor)",
  335. .size = MTDPART_SIZ_FULL,
  336. .offset = MTDPART_OFS_APPEND,
  337. },
  338. };
  339. static struct physmap_flash_data para_flash_data = {
  340. .width = 2,
  341. .parts = para_partitions,
  342. .nr_parts = ARRAY_SIZE(para_partitions),
  343. };
  344. static struct resource para_flash_resource = {
  345. .start = 0x20000000,
  346. .end = 0x201fffff,
  347. .flags = IORESOURCE_MEM,
  348. };
  349. static struct platform_device para_flash_device = {
  350. .name = "physmap-flash",
  351. .id = 0,
  352. .dev = {
  353. .platform_data = &para_flash_data,
  354. },
  355. .num_resources = 1,
  356. .resource = &para_flash_resource,
  357. };
  358. #endif
  359. static const unsigned int cclk_vlev_datasheet[] =
  360. {
  361. VRPAIR(VLEV_085, 250000000),
  362. VRPAIR(VLEV_090, 376000000),
  363. VRPAIR(VLEV_095, 426000000),
  364. VRPAIR(VLEV_100, 426000000),
  365. VRPAIR(VLEV_105, 476000000),
  366. VRPAIR(VLEV_110, 476000000),
  367. VRPAIR(VLEV_115, 476000000),
  368. VRPAIR(VLEV_120, 600000000),
  369. VRPAIR(VLEV_125, 600000000),
  370. VRPAIR(VLEV_130, 600000000),
  371. };
  372. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  373. .tuple_tab = cclk_vlev_datasheet,
  374. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  375. .vr_settling_time = 25 /* us */,
  376. };
  377. static struct platform_device bfin_dpmc = {
  378. .name = "bfin dpmc",
  379. .dev = {
  380. .platform_data = &bfin_dmpc_vreg_data,
  381. },
  382. };
  383. static struct platform_device *cm_bf533_devices[] __initdata = {
  384. &bfin_dpmc,
  385. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  386. &bfin_uart_device,
  387. #endif
  388. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  389. #ifdef CONFIG_BFIN_SIR0
  390. &bfin_sir0_device,
  391. #endif
  392. #endif
  393. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  394. &bfin_sport0_uart_device,
  395. &bfin_sport1_uart_device,
  396. #endif
  397. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  398. &rtc_device,
  399. #endif
  400. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  401. &isp1362_hcd_device,
  402. #endif
  403. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  404. &smc91x_device,
  405. #endif
  406. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  407. &smsc911x_device,
  408. #endif
  409. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  410. &net2272_bfin_device,
  411. #endif
  412. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  413. &bfin_spi0_device,
  414. #endif
  415. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  416. &para_flash_device,
  417. #endif
  418. };
  419. static int __init cm_bf533_init(void)
  420. {
  421. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  422. platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
  423. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  424. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  425. #endif
  426. return 0;
  427. }
  428. arch_initcall(cm_bf533_init);