cm_bf561.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. * File: arch/blackfin/mach-bf533/boards/cm_bf561.c
  3. * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
  4. * Author: Aidan Williams <aidan@nicta.com.au> Copyright 2005
  5. *
  6. * Created: 2006
  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/spi/spi.h>
  34. #include <linux/spi/flash.h>
  35. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  36. #include <linux/usb/isp1362.h>
  37. #endif
  38. #include <linux/ata_platform.h>
  39. #include <linux/irq.h>
  40. #include <asm/dma.h>
  41. #include <asm/bfin5xx_spi.h>
  42. #include <asm/portmux.h>
  43. #include <asm/dpmc.h>
  44. #include <linux/mtd/physmap.h>
  45. /*
  46. * Name the Board for the /proc/cpuinfo
  47. */
  48. const char bfin_board_name[] = "Bluetechnix CM BF561";
  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. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  81. /* SPI ADC chip */
  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 = 1, /* 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_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  177. static struct platform_device hitachi_fb_device = {
  178. .name = "hitachi-tx09",
  179. };
  180. #endif
  181. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  182. #include <linux/smc91x.h>
  183. static struct smc91x_platdata smc91x_info = {
  184. .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
  185. .leda = RPC_LED_100_10,
  186. .ledb = RPC_LED_TX_RX,
  187. };
  188. static struct resource smc91x_resources[] = {
  189. {
  190. .name = "smc91x-regs",
  191. .start = 0x28000300,
  192. .end = 0x28000300 + 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 = 0x24008000,
  216. .end = 0x24008000 + 0xFF,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. {
  220. .start = IRQ_PF43,
  221. .end = IRQ_PF43,
  222. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  223. },
  224. };
  225. static struct smsc911x_platform_config smsc911x_config = {
  226. .flags = SMSC911X_USE_16BIT,
  227. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  228. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  229. .phy_interface = PHY_INTERFACE_MODE_MII,
  230. };
  231. static struct platform_device smsc911x_device = {
  232. .name = "smsc911x",
  233. .id = 0,
  234. .num_resources = ARRAY_SIZE(smsc911x_resources),
  235. .resource = smsc911x_resources,
  236. .dev = {
  237. .platform_data = &smsc911x_config,
  238. },
  239. };
  240. #endif
  241. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  242. static struct resource net2272_bfin_resources[] = {
  243. {
  244. .start = 0x24000000,
  245. .end = 0x24000000 + 0x100,
  246. .flags = IORESOURCE_MEM,
  247. }, {
  248. .start = IRQ_PF45,
  249. .end = IRQ_PF45,
  250. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  251. },
  252. };
  253. static struct platform_device net2272_bfin_device = {
  254. .name = "net2272",
  255. .id = -1,
  256. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  257. .resource = net2272_bfin_resources,
  258. };
  259. #endif
  260. static struct resource bfin_gpios_resources = {
  261. .start = 0,
  262. .end = MAX_BLACKFIN_GPIOS - 1,
  263. .flags = IORESOURCE_IRQ,
  264. };
  265. static struct platform_device bfin_gpios_device = {
  266. .name = "simple-gpio",
  267. .id = -1,
  268. .num_resources = 1,
  269. .resource = &bfin_gpios_resources,
  270. };
  271. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  272. static struct resource isp1362_hcd_resources[] = {
  273. {
  274. .start = 0x24008000,
  275. .end = 0x24008000,
  276. .flags = IORESOURCE_MEM,
  277. }, {
  278. .start = 0x24008004,
  279. .end = 0x24008004,
  280. .flags = IORESOURCE_MEM,
  281. }, {
  282. .start = IRQ_PF47,
  283. .end = IRQ_PF47,
  284. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  285. },
  286. };
  287. static struct isp1362_platform_data isp1362_priv = {
  288. .sel15Kres = 1,
  289. .clknotstop = 0,
  290. .oc_enable = 0,
  291. .int_act_high = 0,
  292. .int_edge_triggered = 0,
  293. .remote_wakeup_connected = 0,
  294. .no_power_switching = 1,
  295. .power_switching_mode = 0,
  296. };
  297. static struct platform_device isp1362_hcd_device = {
  298. .name = "isp1362-hcd",
  299. .id = 0,
  300. .dev = {
  301. .platform_data = &isp1362_priv,
  302. },
  303. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  304. .resource = isp1362_hcd_resources,
  305. };
  306. #endif
  307. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  308. static struct resource bfin_uart_resources[] = {
  309. {
  310. .start = 0xFFC00400,
  311. .end = 0xFFC004FF,
  312. .flags = IORESOURCE_MEM,
  313. },
  314. };
  315. static struct platform_device bfin_uart_device = {
  316. .name = "bfin-uart",
  317. .id = 1,
  318. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  319. .resource = bfin_uart_resources,
  320. };
  321. #endif
  322. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  323. #ifdef CONFIG_BFIN_SIR0
  324. static struct resource bfin_sir0_resources[] = {
  325. {
  326. .start = 0xFFC00400,
  327. .end = 0xFFC004FF,
  328. .flags = IORESOURCE_MEM,
  329. },
  330. {
  331. .start = IRQ_UART0_RX,
  332. .end = IRQ_UART0_RX+1,
  333. .flags = IORESOURCE_IRQ,
  334. },
  335. {
  336. .start = CH_UART0_RX,
  337. .end = CH_UART0_RX+1,
  338. .flags = IORESOURCE_DMA,
  339. },
  340. };
  341. static struct platform_device bfin_sir0_device = {
  342. .name = "bfin_sir",
  343. .id = 0,
  344. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  345. .resource = bfin_sir0_resources,
  346. };
  347. #endif
  348. #endif
  349. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  350. #define PATA_INT IRQ_PF46
  351. static struct pata_platform_info bfin_pata_platform_data = {
  352. .ioport_shift = 2,
  353. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  354. };
  355. static struct resource bfin_pata_resources[] = {
  356. {
  357. .start = 0x2400C000,
  358. .end = 0x2400C001F,
  359. .flags = IORESOURCE_MEM,
  360. },
  361. {
  362. .start = 0x2400D018,
  363. .end = 0x2400D01B,
  364. .flags = IORESOURCE_MEM,
  365. },
  366. {
  367. .start = PATA_INT,
  368. .end = PATA_INT,
  369. .flags = IORESOURCE_IRQ,
  370. },
  371. };
  372. static struct platform_device bfin_pata_device = {
  373. .name = "pata_platform",
  374. .id = -1,
  375. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  376. .resource = bfin_pata_resources,
  377. .dev = {
  378. .platform_data = &bfin_pata_platform_data,
  379. }
  380. };
  381. #endif
  382. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  383. static struct mtd_partition para_partitions[] = {
  384. {
  385. .name = "bootloader(nor)",
  386. .size = 0x40000,
  387. .offset = 0,
  388. }, {
  389. .name = "linux kernel(nor)",
  390. .size = 0x100000,
  391. .offset = MTDPART_OFS_APPEND,
  392. }, {
  393. .name = "file system(nor)",
  394. .size = MTDPART_SIZ_FULL,
  395. .offset = MTDPART_OFS_APPEND,
  396. }
  397. };
  398. static struct physmap_flash_data para_flash_data = {
  399. .width = 2,
  400. .parts = para_partitions,
  401. .nr_parts = ARRAY_SIZE(para_partitions),
  402. };
  403. static struct resource para_flash_resource = {
  404. .start = 0x20000000,
  405. .end = 0x207fffff,
  406. .flags = IORESOURCE_MEM,
  407. };
  408. static struct platform_device para_flash_device = {
  409. .name = "physmap-flash",
  410. .id = 0,
  411. .dev = {
  412. .platform_data = &para_flash_data,
  413. },
  414. .num_resources = 1,
  415. .resource = &para_flash_resource,
  416. };
  417. #endif
  418. static const unsigned int cclk_vlev_datasheet[] =
  419. {
  420. VRPAIR(VLEV_085, 250000000),
  421. VRPAIR(VLEV_090, 300000000),
  422. VRPAIR(VLEV_095, 313000000),
  423. VRPAIR(VLEV_100, 350000000),
  424. VRPAIR(VLEV_105, 400000000),
  425. VRPAIR(VLEV_110, 444000000),
  426. VRPAIR(VLEV_115, 450000000),
  427. VRPAIR(VLEV_120, 475000000),
  428. VRPAIR(VLEV_125, 500000000),
  429. VRPAIR(VLEV_130, 600000000),
  430. };
  431. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  432. .tuple_tab = cclk_vlev_datasheet,
  433. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  434. .vr_settling_time = 25 /* us */,
  435. };
  436. static struct platform_device bfin_dpmc = {
  437. .name = "bfin dpmc",
  438. .dev = {
  439. .platform_data = &bfin_dmpc_vreg_data,
  440. },
  441. };
  442. static struct platform_device *cm_bf561_devices[] __initdata = {
  443. &bfin_dpmc,
  444. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  445. &hitachi_fb_device,
  446. #endif
  447. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  448. &bfin_uart_device,
  449. #endif
  450. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  451. #ifdef CONFIG_BFIN_SIR0
  452. &bfin_sir0_device,
  453. #endif
  454. #endif
  455. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  456. &isp1362_hcd_device,
  457. #endif
  458. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  459. &smc91x_device,
  460. #endif
  461. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  462. &smsc911x_device,
  463. #endif
  464. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  465. &net2272_bfin_device,
  466. #endif
  467. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  468. &bfin_spi0_device,
  469. #endif
  470. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  471. &bfin_pata_device,
  472. #endif
  473. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  474. &para_flash_device,
  475. #endif
  476. &bfin_gpios_device,
  477. };
  478. static int __init cm_bf561_init(void)
  479. {
  480. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  481. platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices));
  482. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  483. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  484. #endif
  485. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  486. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  487. #endif
  488. return 0;
  489. }
  490. arch_initcall(cm_bf561_init);