cm_bf561.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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/spi/spi.h>
  14. #include <linux/spi/flash.h>
  15. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  16. #include <linux/usb/isp1362.h>
  17. #endif
  18. #include <linux/ata_platform.h>
  19. #include <linux/irq.h>
  20. #include <asm/dma.h>
  21. #include <asm/bfin5xx_spi.h>
  22. #include <asm/portmux.h>
  23. #include <asm/dpmc.h>
  24. #include <linux/mtd/physmap.h>
  25. /*
  26. * Name the Board for the /proc/cpuinfo
  27. */
  28. const char bfin_board_name[] = "Bluetechnix CM BF561";
  29. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_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. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  60. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  61. {
  62. /* the modalias must be the same as spi device driver name */
  63. .modalias = "m25p80", /* Name of spi_driver for this device */
  64. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  65. .bus_num = 0, /* Framework bus number */
  66. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  67. .platform_data = &bfin_spi_flash_data,
  68. .controller_data = &spi_flash_chip_info,
  69. .mode = SPI_MODE_3,
  70. },
  71. #endif
  72. #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
  73. {
  74. .modalias = "ad183x",
  75. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  76. .bus_num = 0,
  77. .chip_select = 4,
  78. },
  79. #endif
  80. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  81. {
  82. .modalias = "mmc_spi",
  83. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  84. .bus_num = 0,
  85. .chip_select = 1,
  86. .mode = SPI_MODE_3,
  87. },
  88. #endif
  89. };
  90. /* SPI (0) */
  91. static struct resource bfin_spi0_resource[] = {
  92. [0] = {
  93. .start = SPI0_REGBASE,
  94. .end = SPI0_REGBASE + 0xFF,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. [1] = {
  98. .start = CH_SPI,
  99. .end = CH_SPI,
  100. .flags = IORESOURCE_DMA,
  101. },
  102. [2] = {
  103. .start = IRQ_SPI,
  104. .end = IRQ_SPI,
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. /* SPI controller data */
  109. static struct bfin5xx_spi_master bfin_spi0_info = {
  110. .num_chipselect = 8,
  111. .enable_dma = 1, /* master has the ability to do dma transfer */
  112. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  113. };
  114. static struct platform_device bfin_spi0_device = {
  115. .name = "bfin-spi",
  116. .id = 0, /* Bus number */
  117. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  118. .resource = bfin_spi0_resource,
  119. .dev = {
  120. .platform_data = &bfin_spi0_info, /* Passed to driver */
  121. },
  122. };
  123. #endif /* spi master and devices */
  124. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  125. static struct platform_device hitachi_fb_device = {
  126. .name = "hitachi-tx09",
  127. };
  128. #endif
  129. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  130. #include <linux/smc91x.h>
  131. static struct smc91x_platdata smc91x_info = {
  132. .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
  133. .leda = RPC_LED_100_10,
  134. .ledb = RPC_LED_TX_RX,
  135. };
  136. static struct resource smc91x_resources[] = {
  137. {
  138. .name = "smc91x-regs",
  139. .start = 0x28000300,
  140. .end = 0x28000300 + 16,
  141. .flags = IORESOURCE_MEM,
  142. }, {
  143. .start = IRQ_PF0,
  144. .end = IRQ_PF0,
  145. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  146. },
  147. };
  148. static struct platform_device smc91x_device = {
  149. .name = "smc91x",
  150. .id = 0,
  151. .num_resources = ARRAY_SIZE(smc91x_resources),
  152. .resource = smc91x_resources,
  153. .dev = {
  154. .platform_data = &smc91x_info,
  155. },
  156. };
  157. #endif
  158. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  159. #include <linux/smsc911x.h>
  160. static struct resource smsc911x_resources[] = {
  161. {
  162. .name = "smsc911x-memory",
  163. .start = 0x24008000,
  164. .end = 0x24008000 + 0xFF,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. {
  168. .start = IRQ_PF43,
  169. .end = IRQ_PF43,
  170. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  171. },
  172. };
  173. static struct smsc911x_platform_config smsc911x_config = {
  174. .flags = SMSC911X_USE_16BIT,
  175. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  176. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  177. .phy_interface = PHY_INTERFACE_MODE_MII,
  178. };
  179. static struct platform_device smsc911x_device = {
  180. .name = "smsc911x",
  181. .id = 0,
  182. .num_resources = ARRAY_SIZE(smsc911x_resources),
  183. .resource = smsc911x_resources,
  184. .dev = {
  185. .platform_data = &smsc911x_config,
  186. },
  187. };
  188. #endif
  189. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  190. static struct resource net2272_bfin_resources[] = {
  191. {
  192. .start = 0x24000000,
  193. .end = 0x24000000 + 0x100,
  194. .flags = IORESOURCE_MEM,
  195. }, {
  196. .start = IRQ_PF45,
  197. .end = IRQ_PF45,
  198. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  199. },
  200. };
  201. static struct platform_device net2272_bfin_device = {
  202. .name = "net2272",
  203. .id = -1,
  204. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  205. .resource = net2272_bfin_resources,
  206. };
  207. #endif
  208. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  209. static struct resource isp1362_hcd_resources[] = {
  210. {
  211. .start = 0x24008000,
  212. .end = 0x24008000,
  213. .flags = IORESOURCE_MEM,
  214. }, {
  215. .start = 0x24008004,
  216. .end = 0x24008004,
  217. .flags = IORESOURCE_MEM,
  218. }, {
  219. .start = IRQ_PF47,
  220. .end = IRQ_PF47,
  221. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  222. },
  223. };
  224. static struct isp1362_platform_data isp1362_priv = {
  225. .sel15Kres = 1,
  226. .clknotstop = 0,
  227. .oc_enable = 0,
  228. .int_act_high = 0,
  229. .int_edge_triggered = 0,
  230. .remote_wakeup_connected = 0,
  231. .no_power_switching = 1,
  232. .power_switching_mode = 0,
  233. };
  234. static struct platform_device isp1362_hcd_device = {
  235. .name = "isp1362-hcd",
  236. .id = 0,
  237. .dev = {
  238. .platform_data = &isp1362_priv,
  239. },
  240. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  241. .resource = isp1362_hcd_resources,
  242. };
  243. #endif
  244. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  245. #ifdef CONFIG_SERIAL_BFIN_UART0
  246. static struct resource bfin_uart0_resources[] = {
  247. {
  248. .start = BFIN_UART_THR,
  249. .end = BFIN_UART_GCTL+2,
  250. .flags = IORESOURCE_MEM,
  251. },
  252. {
  253. .start = IRQ_UART_TX,
  254. .end = IRQ_UART_TX,
  255. .flags = IORESOURCE_IRQ,
  256. },
  257. {
  258. .start = IRQ_UART_RX,
  259. .end = IRQ_UART_RX,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. {
  263. .start = IRQ_UART_ERROR,
  264. .end = IRQ_UART_ERROR,
  265. .flags = IORESOURCE_IRQ,
  266. },
  267. {
  268. .start = CH_UART_TX,
  269. .end = CH_UART_TX,
  270. .flags = IORESOURCE_DMA,
  271. },
  272. {
  273. .start = CH_UART_RX,
  274. .end = CH_UART_RX,
  275. .flags = IORESOURCE_DMA,
  276. },
  277. };
  278. static unsigned short bfin_uart0_peripherals[] = {
  279. P_UART0_TX, P_UART0_RX, 0
  280. };
  281. static struct platform_device bfin_uart0_device = {
  282. .name = "bfin-uart",
  283. .id = 0,
  284. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  285. .resource = bfin_uart0_resources,
  286. .dev = {
  287. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  288. },
  289. };
  290. #endif
  291. #endif
  292. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  293. #ifdef CONFIG_BFIN_SIR0
  294. static struct resource bfin_sir0_resources[] = {
  295. {
  296. .start = 0xFFC00400,
  297. .end = 0xFFC004FF,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. {
  301. .start = IRQ_UART0_RX,
  302. .end = IRQ_UART0_RX+1,
  303. .flags = IORESOURCE_IRQ,
  304. },
  305. {
  306. .start = CH_UART0_RX,
  307. .end = CH_UART0_RX+1,
  308. .flags = IORESOURCE_DMA,
  309. },
  310. };
  311. static struct platform_device bfin_sir0_device = {
  312. .name = "bfin_sir",
  313. .id = 0,
  314. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  315. .resource = bfin_sir0_resources,
  316. };
  317. #endif
  318. #endif
  319. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  320. #define PATA_INT IRQ_PF46
  321. static struct pata_platform_info bfin_pata_platform_data = {
  322. .ioport_shift = 2,
  323. .irq_type = IRQF_TRIGGER_HIGH,
  324. };
  325. static struct resource bfin_pata_resources[] = {
  326. {
  327. .start = 0x2400C000,
  328. .end = 0x2400C001F,
  329. .flags = IORESOURCE_MEM,
  330. },
  331. {
  332. .start = 0x2400D018,
  333. .end = 0x2400D01B,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. {
  337. .start = PATA_INT,
  338. .end = PATA_INT,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. };
  342. static struct platform_device bfin_pata_device = {
  343. .name = "pata_platform",
  344. .id = -1,
  345. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  346. .resource = bfin_pata_resources,
  347. .dev = {
  348. .platform_data = &bfin_pata_platform_data,
  349. }
  350. };
  351. #endif
  352. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  353. static struct mtd_partition para_partitions[] = {
  354. {
  355. .name = "bootloader(nor)",
  356. .size = 0x40000,
  357. .offset = 0,
  358. }, {
  359. .name = "linux kernel(nor)",
  360. .size = 0x100000,
  361. .offset = MTDPART_OFS_APPEND,
  362. }, {
  363. .name = "file system(nor)",
  364. .size = MTDPART_SIZ_FULL,
  365. .offset = MTDPART_OFS_APPEND,
  366. }
  367. };
  368. static struct physmap_flash_data para_flash_data = {
  369. .width = 2,
  370. .parts = para_partitions,
  371. .nr_parts = ARRAY_SIZE(para_partitions),
  372. };
  373. static struct resource para_flash_resource = {
  374. .start = 0x20000000,
  375. .end = 0x207fffff,
  376. .flags = IORESOURCE_MEM,
  377. };
  378. static struct platform_device para_flash_device = {
  379. .name = "physmap-flash",
  380. .id = 0,
  381. .dev = {
  382. .platform_data = &para_flash_data,
  383. },
  384. .num_resources = 1,
  385. .resource = &para_flash_resource,
  386. };
  387. #endif
  388. static const unsigned int cclk_vlev_datasheet[] =
  389. {
  390. VRPAIR(VLEV_085, 250000000),
  391. VRPAIR(VLEV_090, 300000000),
  392. VRPAIR(VLEV_095, 313000000),
  393. VRPAIR(VLEV_100, 350000000),
  394. VRPAIR(VLEV_105, 400000000),
  395. VRPAIR(VLEV_110, 444000000),
  396. VRPAIR(VLEV_115, 450000000),
  397. VRPAIR(VLEV_120, 475000000),
  398. VRPAIR(VLEV_125, 500000000),
  399. VRPAIR(VLEV_130, 600000000),
  400. };
  401. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  402. .tuple_tab = cclk_vlev_datasheet,
  403. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  404. .vr_settling_time = 25 /* us */,
  405. };
  406. static struct platform_device bfin_dpmc = {
  407. .name = "bfin dpmc",
  408. .dev = {
  409. .platform_data = &bfin_dmpc_vreg_data,
  410. },
  411. };
  412. static struct platform_device *cm_bf561_devices[] __initdata = {
  413. &bfin_dpmc,
  414. #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
  415. &hitachi_fb_device,
  416. #endif
  417. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  418. #ifdef CONFIG_SERIAL_BFIN_UART0
  419. &bfin_uart0_device,
  420. #endif
  421. #endif
  422. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  423. #ifdef CONFIG_BFIN_SIR0
  424. &bfin_sir0_device,
  425. #endif
  426. #endif
  427. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  428. &isp1362_hcd_device,
  429. #endif
  430. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  431. &smc91x_device,
  432. #endif
  433. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  434. &smsc911x_device,
  435. #endif
  436. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  437. &net2272_bfin_device,
  438. #endif
  439. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  440. &bfin_spi0_device,
  441. #endif
  442. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  443. &bfin_pata_device,
  444. #endif
  445. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  446. &para_flash_device,
  447. #endif
  448. };
  449. static int __init net2272_init(void)
  450. {
  451. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  452. int ret;
  453. ret = gpio_request(GPIO_PF46, "net2272");
  454. if (ret)
  455. return ret;
  456. /* Reset USB Chip, PF46 */
  457. gpio_direction_output(GPIO_PF46, 0);
  458. mdelay(2);
  459. gpio_set_value(GPIO_PF46, 1);
  460. #endif
  461. return 0;
  462. }
  463. static int __init cm_bf561_init(void)
  464. {
  465. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  466. platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices));
  467. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  468. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  469. #endif
  470. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  471. irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
  472. #endif
  473. if (net2272_init())
  474. pr_warning("unable to configure net2272; it probably won't work\n");
  475. return 0;
  476. }
  477. arch_initcall(cm_bf561_init);
  478. static struct platform_device *cm_bf561_early_devices[] __initdata = {
  479. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  480. #ifdef CONFIG_SERIAL_BFIN_UART0
  481. &bfin_uart0_device,
  482. #endif
  483. #endif
  484. };
  485. void __init native_machine_early_platform_add_devices(void)
  486. {
  487. printk(KERN_INFO "register early platform devices\n");
  488. early_platform_add_devices(cm_bf561_early_devices,
  489. ARRAY_SIZE(cm_bf561_early_devices));
  490. }