tcm_bf537.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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/etherdevice.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/spi/spi.h>
  16. #include <linux/spi/flash.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/ata_platform.h>
  21. #include <linux/irq.h>
  22. #include <asm/dma.h>
  23. #include <asm/bfin5xx_spi.h>
  24. #include <asm/portmux.h>
  25. #include <asm/dpmc.h>
  26. #include <linux/spi/mmc_spi.h>
  27. /*
  28. * Name the Board for the /proc/cpuinfo
  29. */
  30. const char bfin_board_name[] = "Bluetechnix TCM BF537";
  31. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  32. /* all SPI peripherals info goes here */
  33. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  34. static struct mtd_partition bfin_spi_flash_partitions[] = {
  35. {
  36. .name = "bootloader(spi)",
  37. .size = 0x00020000,
  38. .offset = 0,
  39. .mask_flags = MTD_CAP_ROM
  40. }, {
  41. .name = "linux kernel(spi)",
  42. .size = 0xe0000,
  43. .offset = 0x20000
  44. }, {
  45. .name = "file system(spi)",
  46. .size = 0x700000,
  47. .offset = 0x00100000,
  48. }
  49. };
  50. static struct flash_platform_data bfin_spi_flash_data = {
  51. .name = "m25p80",
  52. .parts = bfin_spi_flash_partitions,
  53. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  54. .type = "m25p64",
  55. };
  56. /* SPI flash chip (m25p64) */
  57. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  58. .enable_dma = 0, /* use dma transfer with this chip*/
  59. .bits_per_word = 8,
  60. };
  61. #endif
  62. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  63. /* SPI ADC chip */
  64. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  65. .enable_dma = 1, /* use dma transfer with this chip*/
  66. .bits_per_word = 16,
  67. };
  68. #endif
  69. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  70. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  71. .enable_dma = 0,
  72. .bits_per_word = 16,
  73. };
  74. #endif
  75. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  76. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  77. .enable_dma = 0,
  78. .bits_per_word = 8,
  79. };
  80. #endif
  81. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  82. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  83. {
  84. /* the modalias must be the same as spi device driver name */
  85. .modalias = "m25p80", /* Name of spi_driver for this device */
  86. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  87. .bus_num = 0, /* Framework bus number */
  88. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  89. .platform_data = &bfin_spi_flash_data,
  90. .controller_data = &spi_flash_chip_info,
  91. .mode = SPI_MODE_3,
  92. },
  93. #endif
  94. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  95. {
  96. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  97. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  98. .bus_num = 0, /* Framework bus number */
  99. .chip_select = 1, /* Framework chip select. */
  100. .platform_data = NULL, /* No spi_driver specific config */
  101. .controller_data = &spi_adc_chip_info,
  102. },
  103. #endif
  104. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  105. {
  106. .modalias = "ad1836",
  107. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  108. .bus_num = 0,
  109. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  110. .controller_data = &ad1836_spi_chip_info,
  111. },
  112. #endif
  113. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  114. {
  115. .modalias = "mmc_spi",
  116. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  117. .bus_num = 0,
  118. .chip_select = 1,
  119. .controller_data = &mmc_spi_chip_info,
  120. .mode = SPI_MODE_3,
  121. },
  122. #endif
  123. };
  124. /* SPI (0) */
  125. static struct resource bfin_spi0_resource[] = {
  126. [0] = {
  127. .start = SPI0_REGBASE,
  128. .end = SPI0_REGBASE + 0xFF,
  129. .flags = IORESOURCE_MEM,
  130. },
  131. [1] = {
  132. .start = CH_SPI,
  133. .end = CH_SPI,
  134. .flags = IORESOURCE_DMA,
  135. },
  136. [2] = {
  137. .start = IRQ_SPI,
  138. .end = IRQ_SPI,
  139. .flags = IORESOURCE_IRQ,
  140. }
  141. };
  142. /* SPI controller data */
  143. static struct bfin5xx_spi_master bfin_spi0_info = {
  144. .num_chipselect = 8,
  145. .enable_dma = 1, /* master has the ability to do dma transfer */
  146. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  147. };
  148. static struct platform_device bfin_spi0_device = {
  149. .name = "bfin-spi",
  150. .id = 0, /* Bus number */
  151. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  152. .resource = bfin_spi0_resource,
  153. .dev = {
  154. .platform_data = &bfin_spi0_info, /* Passed to driver */
  155. },
  156. };
  157. #endif /* spi master and devices */
  158. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  159. static struct platform_device rtc_device = {
  160. .name = "rtc-bfin",
  161. .id = -1,
  162. };
  163. #endif
  164. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  165. static struct platform_device hitachi_fb_device = {
  166. .name = "hitachi-tx09",
  167. };
  168. #endif
  169. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  170. #include <linux/smc91x.h>
  171. static struct smc91x_platdata smc91x_info = {
  172. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  173. .leda = RPC_LED_100_10,
  174. .ledb = RPC_LED_TX_RX,
  175. };
  176. static struct resource smc91x_resources[] = {
  177. {
  178. .start = 0x20200300,
  179. .end = 0x20200300 + 16,
  180. .flags = IORESOURCE_MEM,
  181. }, {
  182. .start = IRQ_PF14,
  183. .end = IRQ_PF14,
  184. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  185. },
  186. };
  187. static struct platform_device smc91x_device = {
  188. .name = "smc91x",
  189. .id = 0,
  190. .num_resources = ARRAY_SIZE(smc91x_resources),
  191. .resource = smc91x_resources,
  192. .dev = {
  193. .platform_data = &smc91x_info,
  194. },
  195. };
  196. #endif
  197. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  198. static struct resource isp1362_hcd_resources[] = {
  199. {
  200. .start = 0x20308000,
  201. .end = 0x20308000,
  202. .flags = IORESOURCE_MEM,
  203. }, {
  204. .start = 0x20308004,
  205. .end = 0x20308004,
  206. .flags = IORESOURCE_MEM,
  207. }, {
  208. .start = IRQ_PG15,
  209. .end = IRQ_PG15,
  210. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  211. },
  212. };
  213. static struct isp1362_platform_data isp1362_priv = {
  214. .sel15Kres = 1,
  215. .clknotstop = 0,
  216. .oc_enable = 0,
  217. .int_act_high = 0,
  218. .int_edge_triggered = 0,
  219. .remote_wakeup_connected = 0,
  220. .no_power_switching = 1,
  221. .power_switching_mode = 0,
  222. };
  223. static struct platform_device isp1362_hcd_device = {
  224. .name = "isp1362-hcd",
  225. .id = 0,
  226. .dev = {
  227. .platform_data = &isp1362_priv,
  228. },
  229. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  230. .resource = isp1362_hcd_resources,
  231. };
  232. #endif
  233. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  234. static struct resource net2272_bfin_resources[] = {
  235. {
  236. .start = 0x20300000,
  237. .end = 0x20300000 + 0x100,
  238. .flags = IORESOURCE_MEM,
  239. }, {
  240. .start = IRQ_PG13,
  241. .end = IRQ_PG13,
  242. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  243. },
  244. };
  245. static struct platform_device net2272_bfin_device = {
  246. .name = "net2272",
  247. .id = -1,
  248. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  249. .resource = net2272_bfin_resources,
  250. };
  251. #endif
  252. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  253. static struct mtd_partition cm_partitions[] = {
  254. {
  255. .name = "bootloader(nor)",
  256. .size = 0x40000,
  257. .offset = 0,
  258. }, {
  259. .name = "linux kernel(nor)",
  260. .size = 0x100000,
  261. .offset = MTDPART_OFS_APPEND,
  262. }, {
  263. .name = "file system(nor)",
  264. .size = MTDPART_SIZ_FULL,
  265. .offset = MTDPART_OFS_APPEND,
  266. }
  267. };
  268. static struct physmap_flash_data cm_flash_data = {
  269. .width = 2,
  270. .parts = cm_partitions,
  271. .nr_parts = ARRAY_SIZE(cm_partitions),
  272. };
  273. static unsigned cm_flash_gpios[] = { GPIO_PF4, GPIO_PF5 };
  274. static struct resource cm_flash_resource[] = {
  275. {
  276. .name = "cfi_probe",
  277. .start = 0x20000000,
  278. .end = 0x201fffff,
  279. .flags = IORESOURCE_MEM,
  280. }, {
  281. .start = (unsigned long)cm_flash_gpios,
  282. .end = ARRAY_SIZE(cm_flash_gpios),
  283. .flags = IORESOURCE_IRQ,
  284. }
  285. };
  286. static struct platform_device cm_flash_device = {
  287. .name = "gpio-addr-flash",
  288. .id = 0,
  289. .dev = {
  290. .platform_data = &cm_flash_data,
  291. },
  292. .num_resources = ARRAY_SIZE(cm_flash_resource),
  293. .resource = cm_flash_resource,
  294. };
  295. #endif
  296. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  297. static struct resource bfin_uart_resources[] = {
  298. {
  299. .start = 0xFFC00400,
  300. .end = 0xFFC004FF,
  301. .flags = IORESOURCE_MEM,
  302. }, {
  303. .start = 0xFFC02000,
  304. .end = 0xFFC020FF,
  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. #ifdef CONFIG_BFIN_SIR1
  342. static struct resource bfin_sir1_resources[] = {
  343. {
  344. .start = 0xFFC02000,
  345. .end = 0xFFC020FF,
  346. .flags = IORESOURCE_MEM,
  347. },
  348. {
  349. .start = IRQ_UART1_RX,
  350. .end = IRQ_UART1_RX+1,
  351. .flags = IORESOURCE_IRQ,
  352. },
  353. {
  354. .start = CH_UART1_RX,
  355. .end = CH_UART1_RX+1,
  356. .flags = IORESOURCE_DMA,
  357. },
  358. };
  359. static struct platform_device bfin_sir1_device = {
  360. .name = "bfin_sir",
  361. .id = 1,
  362. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  363. .resource = bfin_sir1_resources,
  364. };
  365. #endif
  366. #endif
  367. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  368. static struct resource bfin_twi0_resource[] = {
  369. [0] = {
  370. .start = TWI0_REGBASE,
  371. .end = TWI0_REGBASE,
  372. .flags = IORESOURCE_MEM,
  373. },
  374. [1] = {
  375. .start = IRQ_TWI,
  376. .end = IRQ_TWI,
  377. .flags = IORESOURCE_IRQ,
  378. },
  379. };
  380. static struct platform_device i2c_bfin_twi_device = {
  381. .name = "i2c-bfin-twi",
  382. .id = 0,
  383. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  384. .resource = bfin_twi0_resource,
  385. };
  386. #endif
  387. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  388. static struct platform_device bfin_sport0_uart_device = {
  389. .name = "bfin-sport-uart",
  390. .id = 0,
  391. };
  392. static struct platform_device bfin_sport1_uart_device = {
  393. .name = "bfin-sport-uart",
  394. .id = 1,
  395. };
  396. #endif
  397. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  398. static struct platform_device bfin_mii_bus = {
  399. .name = "bfin_mii_bus",
  400. };
  401. static struct platform_device bfin_mac_device = {
  402. .name = "bfin_mac",
  403. .dev.platform_data = &bfin_mii_bus,
  404. };
  405. #endif
  406. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  407. #define PATA_INT IRQ_PF14
  408. static struct pata_platform_info bfin_pata_platform_data = {
  409. .ioport_shift = 2,
  410. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  411. };
  412. static struct resource bfin_pata_resources[] = {
  413. {
  414. .start = 0x2030C000,
  415. .end = 0x2030C01F,
  416. .flags = IORESOURCE_MEM,
  417. },
  418. {
  419. .start = 0x2030D018,
  420. .end = 0x2030D01B,
  421. .flags = IORESOURCE_MEM,
  422. },
  423. {
  424. .start = PATA_INT,
  425. .end = PATA_INT,
  426. .flags = IORESOURCE_IRQ,
  427. },
  428. };
  429. static struct platform_device bfin_pata_device = {
  430. .name = "pata_platform",
  431. .id = -1,
  432. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  433. .resource = bfin_pata_resources,
  434. .dev = {
  435. .platform_data = &bfin_pata_platform_data,
  436. }
  437. };
  438. #endif
  439. static const unsigned int cclk_vlev_datasheet[] =
  440. {
  441. VRPAIR(VLEV_085, 250000000),
  442. VRPAIR(VLEV_090, 376000000),
  443. VRPAIR(VLEV_095, 426000000),
  444. VRPAIR(VLEV_100, 426000000),
  445. VRPAIR(VLEV_105, 476000000),
  446. VRPAIR(VLEV_110, 476000000),
  447. VRPAIR(VLEV_115, 476000000),
  448. VRPAIR(VLEV_120, 500000000),
  449. VRPAIR(VLEV_125, 533000000),
  450. VRPAIR(VLEV_130, 600000000),
  451. };
  452. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  453. .tuple_tab = cclk_vlev_datasheet,
  454. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  455. .vr_settling_time = 25 /* us */,
  456. };
  457. static struct platform_device bfin_dpmc = {
  458. .name = "bfin dpmc",
  459. .dev = {
  460. .platform_data = &bfin_dmpc_vreg_data,
  461. },
  462. };
  463. static struct platform_device *cm_bf537_devices[] __initdata = {
  464. &bfin_dpmc,
  465. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  466. &hitachi_fb_device,
  467. #endif
  468. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  469. &rtc_device,
  470. #endif
  471. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  472. &bfin_uart_device,
  473. #endif
  474. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  475. #ifdef CONFIG_BFIN_SIR0
  476. &bfin_sir0_device,
  477. #endif
  478. #ifdef CONFIG_BFIN_SIR1
  479. &bfin_sir1_device,
  480. #endif
  481. #endif
  482. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  483. &i2c_bfin_twi_device,
  484. #endif
  485. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  486. &bfin_sport0_uart_device,
  487. &bfin_sport1_uart_device,
  488. #endif
  489. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  490. &isp1362_hcd_device,
  491. #endif
  492. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  493. &smc91x_device,
  494. #endif
  495. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  496. &bfin_mii_bus,
  497. &bfin_mac_device,
  498. #endif
  499. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  500. &net2272_bfin_device,
  501. #endif
  502. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  503. &bfin_spi0_device,
  504. #endif
  505. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  506. &bfin_pata_device,
  507. #endif
  508. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  509. &cm_flash_device,
  510. #endif
  511. };
  512. static int __init tcm_bf537_init(void)
  513. {
  514. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  515. platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
  516. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  517. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  518. #endif
  519. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  520. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  521. #endif
  522. return 0;
  523. }
  524. arch_initcall(tcm_bf537_init);
  525. void bfin_get_ether_addr(char *addr)
  526. {
  527. random_ether_addr(addr);
  528. printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
  529. }
  530. EXPORT_SYMBOL(bfin_get_ether_addr);