cm_bf533.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /*
  2. * File: arch/blackfin/mach-bf533/boards/cm_bf533.c
  3. * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
  4. * Author: Aidan Williams <aidan@nicta.com.au> Copyright 2005
  5. *
  6. * Created: 2005
  7. * Description: Board description file
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/device.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/mtd/mtd.h>
  32. #include <linux/mtd/partitions.h>
  33. #include <linux/mtd/physmap.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #include <linux/spi/mmc_spi.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[] = "Bluetechnix CM BF533";
  49. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  50. /* all SPI peripherals info goes here */
  51. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  52. static struct mtd_partition bfin_spi_flash_partitions[] = {
  53. {
  54. .name = "bootloader(spi)",
  55. .size = 0x00020000,
  56. .offset = 0,
  57. .mask_flags = MTD_CAP_ROM
  58. }, {
  59. .name = "linux kernel(spi)",
  60. .size = 0xe0000,
  61. .offset = 0x20000
  62. }, {
  63. .name = "file system(spi)",
  64. .size = 0x700000,
  65. .offset = 0x00100000,
  66. }
  67. };
  68. static struct flash_platform_data bfin_spi_flash_data = {
  69. .name = "m25p80",
  70. .parts = bfin_spi_flash_partitions,
  71. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  72. .type = "m25p64",
  73. };
  74. /* SPI flash chip (m25p64) */
  75. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  76. .enable_dma = 0, /* use dma transfer with this chip*/
  77. .bits_per_word = 8,
  78. };
  79. #endif
  80. /* SPI ADC chip */
  81. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  82. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  83. .enable_dma = 1, /* use dma transfer with this chip*/
  84. .bits_per_word = 16,
  85. };
  86. #endif
  87. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  88. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  89. .enable_dma = 0,
  90. .bits_per_word = 16,
  91. };
  92. #endif
  93. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  94. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  95. .enable_dma = 0,
  96. .bits_per_word = 8,
  97. };
  98. #endif
  99. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  100. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  101. {
  102. /* the modalias must be the same as spi device driver name */
  103. .modalias = "m25p80", /* Name of spi_driver for this device */
  104. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  105. .bus_num = 0, /* Framework bus number */
  106. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  107. .platform_data = &bfin_spi_flash_data,
  108. .controller_data = &spi_flash_chip_info,
  109. .mode = SPI_MODE_3,
  110. },
  111. #endif
  112. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  113. {
  114. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  115. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  116. .bus_num = 0, /* Framework bus number */
  117. .chip_select = 2, /* Framework chip select. */
  118. .platform_data = NULL, /* No spi_driver specific config */
  119. .controller_data = &spi_adc_chip_info,
  120. },
  121. #endif
  122. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  123. {
  124. .modalias = "ad1836",
  125. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  126. .bus_num = 0,
  127. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  128. .controller_data = &ad1836_spi_chip_info,
  129. },
  130. #endif
  131. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  132. {
  133. .modalias = "mmc_spi",
  134. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  135. .bus_num = 0,
  136. .chip_select = 1,
  137. .controller_data = &mmc_spi_chip_info,
  138. .mode = SPI_MODE_3,
  139. },
  140. #endif
  141. };
  142. /* SPI (0) */
  143. static struct resource bfin_spi0_resource[] = {
  144. [0] = {
  145. .start = SPI0_REGBASE,
  146. .end = SPI0_REGBASE + 0xFF,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. [1] = {
  150. .start = CH_SPI,
  151. .end = CH_SPI,
  152. .flags = IORESOURCE_DMA,
  153. },
  154. [2] = {
  155. .start = IRQ_SPI,
  156. .end = IRQ_SPI,
  157. .flags = IORESOURCE_IRQ,
  158. }
  159. };
  160. /* SPI controller data */
  161. static struct bfin5xx_spi_master bfin_spi0_info = {
  162. .num_chipselect = 8,
  163. .enable_dma = 1, /* master has the ability to do dma transfer */
  164. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  165. };
  166. static struct platform_device bfin_spi0_device = {
  167. .name = "bfin-spi",
  168. .id = 0, /* Bus number */
  169. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  170. .resource = bfin_spi0_resource,
  171. .dev = {
  172. .platform_data = &bfin_spi0_info, /* Passed to driver */
  173. },
  174. };
  175. #endif /* spi master and devices */
  176. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  177. static struct platform_device rtc_device = {
  178. .name = "rtc-bfin",
  179. .id = -1,
  180. };
  181. #endif
  182. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  183. #include <linux/smc91x.h>
  184. static struct smc91x_platdata smc91x_info = {
  185. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  186. .leda = RPC_LED_100_10,
  187. .ledb = RPC_LED_TX_RX,
  188. };
  189. static struct resource smc91x_resources[] = {
  190. {
  191. .start = 0x20200300,
  192. .end = 0x20200300 + 16,
  193. .flags = IORESOURCE_MEM,
  194. }, {
  195. .start = IRQ_PF0,
  196. .end = IRQ_PF0,
  197. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  198. },
  199. };
  200. static struct platform_device smc91x_device = {
  201. .name = "smc91x",
  202. .id = 0,
  203. .num_resources = ARRAY_SIZE(smc91x_resources),
  204. .resource = smc91x_resources,
  205. .dev = {
  206. .platform_data = &smc91x_info,
  207. },
  208. };
  209. #endif
  210. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  211. #include <linux/smsc911x.h>
  212. static struct resource smsc911x_resources[] = {
  213. {
  214. .name = "smsc911x-memory",
  215. .start = 0x20308000,
  216. .end = 0x20308000 + 0xFF,
  217. .flags = IORESOURCE_MEM,
  218. }, {
  219. .start = IRQ_PF8,
  220. .end = IRQ_PF8,
  221. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  222. },
  223. };
  224. static struct smsc911x_platform_config smsc911x_config = {
  225. .flags = SMSC911X_USE_16BIT,
  226. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  227. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  228. .phy_interface = PHY_INTERFACE_MODE_MII,
  229. };
  230. static struct platform_device smsc911x_device = {
  231. .name = "smsc911x",
  232. .id = 0,
  233. .num_resources = ARRAY_SIZE(smsc911x_resources),
  234. .resource = smsc911x_resources,
  235. .dev = {
  236. .platform_data = &smsc911x_config,
  237. },
  238. };
  239. #endif
  240. static struct resource bfin_gpios_resources = {
  241. .start = 0,
  242. .end = MAX_BLACKFIN_GPIOS - 1,
  243. .flags = IORESOURCE_IRQ,
  244. };
  245. static struct platform_device bfin_gpios_device = {
  246. .name = "simple-gpio",
  247. .id = -1,
  248. .num_resources = 1,
  249. .resource = &bfin_gpios_resources,
  250. };
  251. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  252. static struct resource bfin_uart_resources[] = {
  253. {
  254. .start = 0xFFC00400,
  255. .end = 0xFFC004FF,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. };
  259. static struct platform_device bfin_uart_device = {
  260. .name = "bfin-uart",
  261. .id = 1,
  262. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  263. .resource = bfin_uart_resources,
  264. };
  265. #endif
  266. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  267. #ifdef CONFIG_BFIN_SIR0
  268. static struct resource bfin_sir0_resources[] = {
  269. {
  270. .start = 0xFFC00400,
  271. .end = 0xFFC004FF,
  272. .flags = IORESOURCE_MEM,
  273. },
  274. {
  275. .start = IRQ_UART0_RX,
  276. .end = IRQ_UART0_RX+1,
  277. .flags = IORESOURCE_IRQ,
  278. },
  279. {
  280. .start = CH_UART0_RX,
  281. .end = CH_UART0_RX+1,
  282. .flags = IORESOURCE_DMA,
  283. },
  284. };
  285. static struct platform_device bfin_sir0_device = {
  286. .name = "bfin_sir",
  287. .id = 0,
  288. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  289. .resource = bfin_sir0_resources,
  290. };
  291. #endif
  292. #endif
  293. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  294. static struct platform_device bfin_sport0_uart_device = {
  295. .name = "bfin-sport-uart",
  296. .id = 0,
  297. };
  298. static struct platform_device bfin_sport1_uart_device = {
  299. .name = "bfin-sport-uart",
  300. .id = 1,
  301. };
  302. #endif
  303. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  304. static struct resource isp1362_hcd_resources[] = {
  305. {
  306. .start = 0x20308000,
  307. .end = 0x20308000,
  308. .flags = IORESOURCE_MEM,
  309. }, {
  310. .start = 0x20308004,
  311. .end = 0x20308004,
  312. .flags = IORESOURCE_MEM,
  313. }, {
  314. .start = IRQ_PF4,
  315. .end = IRQ_PF4,
  316. .flags = IORESOURCE_IRQ,
  317. },
  318. };
  319. static struct isp1362_platform_data isp1362_priv = {
  320. .sel15Kres = 1,
  321. .clknotstop = 0,
  322. .oc_enable = 0,
  323. .int_act_high = 0,
  324. .int_edge_triggered = 0,
  325. .remote_wakeup_connected = 0,
  326. .no_power_switching = 1,
  327. .power_switching_mode = 0,
  328. };
  329. static struct platform_device isp1362_hcd_device = {
  330. .name = "isp1362-hcd",
  331. .id = 0,
  332. .dev = {
  333. .platform_data = &isp1362_priv,
  334. },
  335. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  336. .resource = isp1362_hcd_resources,
  337. };
  338. #endif
  339. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  340. static struct resource net2272_bfin_resources[] = {
  341. {
  342. .start = 0x20300000,
  343. .end = 0x20300000 + 0x100,
  344. .flags = IORESOURCE_MEM,
  345. }, {
  346. .start = IRQ_PF6,
  347. .end = IRQ_PF6,
  348. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  349. },
  350. };
  351. static struct platform_device net2272_bfin_device = {
  352. .name = "net2272",
  353. .id = -1,
  354. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  355. .resource = net2272_bfin_resources,
  356. };
  357. #endif
  358. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  359. static struct mtd_partition para_partitions[] = {
  360. {
  361. .name = "bootloader(nor)",
  362. .size = 0x40000,
  363. .offset = 0,
  364. }, {
  365. .name = "linux+rootfs(nor)",
  366. .size = MTDPART_SIZ_FULL,
  367. .offset = MTDPART_OFS_APPEND,
  368. },
  369. };
  370. static struct physmap_flash_data para_flash_data = {
  371. .width = 2,
  372. .parts = para_partitions,
  373. .nr_parts = ARRAY_SIZE(para_partitions),
  374. };
  375. static struct resource para_flash_resource = {
  376. .start = 0x20000000,
  377. .end = 0x201fffff,
  378. .flags = IORESOURCE_MEM,
  379. };
  380. static struct platform_device para_flash_device = {
  381. .name = "physmap-flash",
  382. .id = 0,
  383. .dev = {
  384. .platform_data = &para_flash_data,
  385. },
  386. .num_resources = 1,
  387. .resource = &para_flash_resource,
  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 *cm_bf533_devices[] __initdata = {
  415. &bfin_dpmc,
  416. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  417. &bfin_uart_device,
  418. #endif
  419. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  420. #ifdef CONFIG_BFIN_SIR0
  421. &bfin_sir0_device,
  422. #endif
  423. #endif
  424. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  425. &bfin_sport0_uart_device,
  426. &bfin_sport1_uart_device,
  427. #endif
  428. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  429. &rtc_device,
  430. #endif
  431. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  432. &isp1362_hcd_device,
  433. #endif
  434. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  435. &smc91x_device,
  436. #endif
  437. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  438. &smsc911x_device,
  439. #endif
  440. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  441. &net2272_bfin_device,
  442. #endif
  443. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  444. &bfin_spi0_device,
  445. #endif
  446. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  447. &para_flash_device,
  448. #endif
  449. &bfin_gpios_device,
  450. };
  451. static int __init cm_bf533_init(void)
  452. {
  453. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  454. platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
  455. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  456. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  457. #endif
  458. return 0;
  459. }
  460. arch_initcall(cm_bf533_init);