cm_bf533.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. };
  58. #endif
  59. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  60. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  61. .enable_dma = 0,
  62. };
  63. #endif
  64. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  65. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  66. {
  67. /* the modalias must be the same as spi device driver name */
  68. .modalias = "m25p80", /* Name of spi_driver for this device */
  69. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  70. .bus_num = 0, /* Framework bus number */
  71. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  72. .platform_data = &bfin_spi_flash_data,
  73. .controller_data = &spi_flash_chip_info,
  74. .mode = SPI_MODE_3,
  75. },
  76. #endif
  77. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  78. {
  79. .modalias = "ad183x",
  80. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  81. .bus_num = 0,
  82. .chip_select = 4,
  83. },
  84. #endif
  85. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  86. {
  87. .modalias = "mmc_spi",
  88. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  89. .bus_num = 0,
  90. .chip_select = 1,
  91. .controller_data = &mmc_spi_chip_info,
  92. .mode = SPI_MODE_3,
  93. },
  94. #endif
  95. };
  96. /* SPI (0) */
  97. static struct resource bfin_spi0_resource[] = {
  98. [0] = {
  99. .start = SPI0_REGBASE,
  100. .end = SPI0_REGBASE + 0xFF,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [1] = {
  104. .start = CH_SPI,
  105. .end = CH_SPI,
  106. .flags = IORESOURCE_DMA,
  107. },
  108. [2] = {
  109. .start = IRQ_SPI,
  110. .end = IRQ_SPI,
  111. .flags = IORESOURCE_IRQ,
  112. }
  113. };
  114. /* SPI controller data */
  115. static struct bfin5xx_spi_master bfin_spi0_info = {
  116. .num_chipselect = 8,
  117. .enable_dma = 1, /* master has the ability to do dma transfer */
  118. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  119. };
  120. static struct platform_device bfin_spi0_device = {
  121. .name = "bfin-spi",
  122. .id = 0, /* Bus number */
  123. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  124. .resource = bfin_spi0_resource,
  125. .dev = {
  126. .platform_data = &bfin_spi0_info, /* Passed to driver */
  127. },
  128. };
  129. #endif /* spi master and devices */
  130. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  131. static struct platform_device rtc_device = {
  132. .name = "rtc-bfin",
  133. .id = -1,
  134. };
  135. #endif
  136. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  137. #include <linux/smc91x.h>
  138. static struct smc91x_platdata smc91x_info = {
  139. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  140. .leda = RPC_LED_100_10,
  141. .ledb = RPC_LED_TX_RX,
  142. };
  143. static struct resource smc91x_resources[] = {
  144. {
  145. .start = 0x20200300,
  146. .end = 0x20200300 + 16,
  147. .flags = IORESOURCE_MEM,
  148. }, {
  149. .start = IRQ_PF0,
  150. .end = IRQ_PF0,
  151. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  152. },
  153. };
  154. static struct platform_device smc91x_device = {
  155. .name = "smc91x",
  156. .id = 0,
  157. .num_resources = ARRAY_SIZE(smc91x_resources),
  158. .resource = smc91x_resources,
  159. .dev = {
  160. .platform_data = &smc91x_info,
  161. },
  162. };
  163. #endif
  164. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  165. #include <linux/smsc911x.h>
  166. static struct resource smsc911x_resources[] = {
  167. {
  168. .name = "smsc911x-memory",
  169. .start = 0x20308000,
  170. .end = 0x20308000 + 0xFF,
  171. .flags = IORESOURCE_MEM,
  172. }, {
  173. .start = IRQ_PF8,
  174. .end = IRQ_PF8,
  175. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  176. },
  177. };
  178. static struct smsc911x_platform_config smsc911x_config = {
  179. .flags = SMSC911X_USE_16BIT,
  180. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  181. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  182. .phy_interface = PHY_INTERFACE_MODE_MII,
  183. };
  184. static struct platform_device smsc911x_device = {
  185. .name = "smsc911x",
  186. .id = 0,
  187. .num_resources = ARRAY_SIZE(smsc911x_resources),
  188. .resource = smsc911x_resources,
  189. .dev = {
  190. .platform_data = &smsc911x_config,
  191. },
  192. };
  193. #endif
  194. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  195. #ifdef CONFIG_SERIAL_BFIN_UART0
  196. static struct resource bfin_uart0_resources[] = {
  197. {
  198. .start = BFIN_UART_THR,
  199. .end = BFIN_UART_GCTL+2,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. {
  203. .start = IRQ_UART0_RX,
  204. .end = IRQ_UART0_RX + 1,
  205. .flags = IORESOURCE_IRQ,
  206. },
  207. {
  208. .start = IRQ_UART0_ERROR,
  209. .end = IRQ_UART0_ERROR,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. {
  213. .start = CH_UART0_TX,
  214. .end = CH_UART0_TX,
  215. .flags = IORESOURCE_DMA,
  216. },
  217. {
  218. .start = CH_UART0_RX,
  219. .end = CH_UART0_RX,
  220. .flags = IORESOURCE_DMA,
  221. },
  222. };
  223. static unsigned short bfin_uart0_peripherals[] = {
  224. P_UART0_TX, P_UART0_RX, 0
  225. };
  226. static struct platform_device bfin_uart0_device = {
  227. .name = "bfin-uart",
  228. .id = 0,
  229. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  230. .resource = bfin_uart0_resources,
  231. .dev = {
  232. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  233. },
  234. };
  235. #endif
  236. #endif
  237. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  238. #ifdef CONFIG_BFIN_SIR0
  239. static struct resource bfin_sir0_resources[] = {
  240. {
  241. .start = 0xFFC00400,
  242. .end = 0xFFC004FF,
  243. .flags = IORESOURCE_MEM,
  244. },
  245. {
  246. .start = IRQ_UART0_RX,
  247. .end = IRQ_UART0_RX+1,
  248. .flags = IORESOURCE_IRQ,
  249. },
  250. {
  251. .start = CH_UART0_RX,
  252. .end = CH_UART0_RX+1,
  253. .flags = IORESOURCE_DMA,
  254. },
  255. };
  256. static struct platform_device bfin_sir0_device = {
  257. .name = "bfin_sir",
  258. .id = 0,
  259. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  260. .resource = bfin_sir0_resources,
  261. };
  262. #endif
  263. #endif
  264. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  265. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  266. static struct resource bfin_sport0_uart_resources[] = {
  267. {
  268. .start = SPORT0_TCR1,
  269. .end = SPORT0_MRCS3+4,
  270. .flags = IORESOURCE_MEM,
  271. },
  272. {
  273. .start = IRQ_SPORT0_RX,
  274. .end = IRQ_SPORT0_RX+1,
  275. .flags = IORESOURCE_IRQ,
  276. },
  277. {
  278. .start = IRQ_SPORT0_ERROR,
  279. .end = IRQ_SPORT0_ERROR,
  280. .flags = IORESOURCE_IRQ,
  281. },
  282. };
  283. static unsigned short bfin_sport0_peripherals[] = {
  284. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  285. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  286. };
  287. static struct platform_device bfin_sport0_uart_device = {
  288. .name = "bfin-sport-uart",
  289. .id = 0,
  290. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  291. .resource = bfin_sport0_uart_resources,
  292. .dev = {
  293. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  294. },
  295. };
  296. #endif
  297. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  298. static struct resource bfin_sport1_uart_resources[] = {
  299. {
  300. .start = SPORT1_TCR1,
  301. .end = SPORT1_MRCS3+4,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. {
  305. .start = IRQ_SPORT1_RX,
  306. .end = IRQ_SPORT1_RX+1,
  307. .flags = IORESOURCE_IRQ,
  308. },
  309. {
  310. .start = IRQ_SPORT1_ERROR,
  311. .end = IRQ_SPORT1_ERROR,
  312. .flags = IORESOURCE_IRQ,
  313. },
  314. };
  315. static unsigned short bfin_sport1_peripherals[] = {
  316. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  317. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  318. };
  319. static struct platform_device bfin_sport1_uart_device = {
  320. .name = "bfin-sport-uart",
  321. .id = 1,
  322. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  323. .resource = bfin_sport1_uart_resources,
  324. .dev = {
  325. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  326. },
  327. };
  328. #endif
  329. #endif
  330. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  331. static struct resource isp1362_hcd_resources[] = {
  332. {
  333. .start = 0x20308000,
  334. .end = 0x20308000,
  335. .flags = IORESOURCE_MEM,
  336. }, {
  337. .start = 0x20308004,
  338. .end = 0x20308004,
  339. .flags = IORESOURCE_MEM,
  340. }, {
  341. .start = IRQ_PF4,
  342. .end = IRQ_PF4,
  343. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  344. },
  345. };
  346. static struct isp1362_platform_data isp1362_priv = {
  347. .sel15Kres = 1,
  348. .clknotstop = 0,
  349. .oc_enable = 0,
  350. .int_act_high = 0,
  351. .int_edge_triggered = 0,
  352. .remote_wakeup_connected = 0,
  353. .no_power_switching = 1,
  354. .power_switching_mode = 0,
  355. };
  356. static struct platform_device isp1362_hcd_device = {
  357. .name = "isp1362-hcd",
  358. .id = 0,
  359. .dev = {
  360. .platform_data = &isp1362_priv,
  361. },
  362. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  363. .resource = isp1362_hcd_resources,
  364. };
  365. #endif
  366. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  367. static struct resource net2272_bfin_resources[] = {
  368. {
  369. .start = 0x20300000,
  370. .end = 0x20300000 + 0x100,
  371. .flags = IORESOURCE_MEM,
  372. }, {
  373. .start = IRQ_PF6,
  374. .end = IRQ_PF6,
  375. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  376. },
  377. };
  378. static struct platform_device net2272_bfin_device = {
  379. .name = "net2272",
  380. .id = -1,
  381. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  382. .resource = net2272_bfin_resources,
  383. };
  384. #endif
  385. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  386. static struct mtd_partition para_partitions[] = {
  387. {
  388. .name = "bootloader(nor)",
  389. .size = 0x40000,
  390. .offset = 0,
  391. }, {
  392. .name = "linux+rootfs(nor)",
  393. .size = MTDPART_SIZ_FULL,
  394. .offset = MTDPART_OFS_APPEND,
  395. },
  396. };
  397. static struct physmap_flash_data para_flash_data = {
  398. .width = 2,
  399. .parts = para_partitions,
  400. .nr_parts = ARRAY_SIZE(para_partitions),
  401. };
  402. static struct resource para_flash_resource = {
  403. .start = 0x20000000,
  404. .end = 0x201fffff,
  405. .flags = IORESOURCE_MEM,
  406. };
  407. static struct platform_device para_flash_device = {
  408. .name = "physmap-flash",
  409. .id = 0,
  410. .dev = {
  411. .platform_data = &para_flash_data,
  412. },
  413. .num_resources = 1,
  414. .resource = &para_flash_resource,
  415. };
  416. #endif
  417. static const unsigned int cclk_vlev_datasheet[] =
  418. {
  419. VRPAIR(VLEV_085, 250000000),
  420. VRPAIR(VLEV_090, 376000000),
  421. VRPAIR(VLEV_095, 426000000),
  422. VRPAIR(VLEV_100, 426000000),
  423. VRPAIR(VLEV_105, 476000000),
  424. VRPAIR(VLEV_110, 476000000),
  425. VRPAIR(VLEV_115, 476000000),
  426. VRPAIR(VLEV_120, 600000000),
  427. VRPAIR(VLEV_125, 600000000),
  428. VRPAIR(VLEV_130, 600000000),
  429. };
  430. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  431. .tuple_tab = cclk_vlev_datasheet,
  432. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  433. .vr_settling_time = 25 /* us */,
  434. };
  435. static struct platform_device bfin_dpmc = {
  436. .name = "bfin dpmc",
  437. .dev = {
  438. .platform_data = &bfin_dmpc_vreg_data,
  439. },
  440. };
  441. static struct platform_device *cm_bf533_devices[] __initdata = {
  442. &bfin_dpmc,
  443. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  444. #ifdef CONFIG_SERIAL_BFIN_UART0
  445. &bfin_uart0_device,
  446. #endif
  447. #endif
  448. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  449. #ifdef CONFIG_BFIN_SIR0
  450. &bfin_sir0_device,
  451. #endif
  452. #endif
  453. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  454. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  455. &bfin_sport0_uart_device,
  456. #endif
  457. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  458. &bfin_sport1_uart_device,
  459. #endif
  460. #endif
  461. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  462. &rtc_device,
  463. #endif
  464. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  465. &isp1362_hcd_device,
  466. #endif
  467. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  468. &smc91x_device,
  469. #endif
  470. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  471. &smsc911x_device,
  472. #endif
  473. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  474. &net2272_bfin_device,
  475. #endif
  476. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  477. &bfin_spi0_device,
  478. #endif
  479. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  480. &para_flash_device,
  481. #endif
  482. };
  483. static int __init cm_bf533_init(void)
  484. {
  485. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  486. platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
  487. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  488. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  489. #endif
  490. return 0;
  491. }
  492. arch_initcall(cm_bf533_init);
  493. static struct platform_device *cm_bf533_early_devices[] __initdata = {
  494. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  495. #ifdef CONFIG_SERIAL_BFIN_UART0
  496. &bfin_uart0_device,
  497. #endif
  498. #endif
  499. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  500. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  501. &bfin_sport0_uart_device,
  502. #endif
  503. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  504. &bfin_sport1_uart_device,
  505. #endif
  506. #endif
  507. };
  508. void __init native_machine_early_platform_add_devices(void)
  509. {
  510. printk(KERN_INFO "register early platform devices\n");
  511. early_platform_add_devices(cm_bf533_early_devices,
  512. ARRAY_SIZE(cm_bf533_early_devices));
  513. }