acvilon.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*
  2. * File: arch/blackfin/mach-bf561/acvilon.c
  3. * Based on: arch/blackfin/mach-bf561/ezkit.c
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. * Copyright 2009 CJSC "NII STT"
  12. *
  13. * Bugs:
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. *
  30. *
  31. * For more information about Acvilon BF561 SoM please
  32. * go to http://www.niistt.ru/
  33. *
  34. */
  35. #include <linux/device.h>
  36. #include <linux/platform_device.h>
  37. #include <linux/mtd/mtd.h>
  38. #include <linux/mtd/partitions.h>
  39. #include <linux/mtd/physmap.h>
  40. #include <linux/mtd/nand.h>
  41. #include <linux/mtd/plat-ram.h>
  42. #include <linux/spi/spi.h>
  43. #include <linux/spi/flash.h>
  44. #include <linux/irq.h>
  45. #include <linux/interrupt.h>
  46. #include <linux/jiffies.h>
  47. #include <linux/i2c-pca-platform.h>
  48. #include <linux/delay.h>
  49. #include <linux/io.h>
  50. #include <asm/dma.h>
  51. #include <asm/bfin5xx_spi.h>
  52. #include <asm/portmux.h>
  53. #include <asm/dpmc.h>
  54. #include <asm/cacheflush.h>
  55. #include <linux/i2c.h>
  56. /*
  57. * Name the Board for the /proc/cpuinfo
  58. */
  59. const char bfin_board_name[] = "Acvilon board";
  60. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  61. #include <linux/usb/isp1760.h>
  62. static struct resource bfin_isp1760_resources[] = {
  63. [0] = {
  64. .start = 0x20000000,
  65. .end = 0x20000000 + 0x000fffff,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = IRQ_PF15,
  70. .end = IRQ_PF15,
  71. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  72. },
  73. };
  74. static struct isp1760_platform_data isp1760_priv = {
  75. .is_isp1761 = 0,
  76. .port1_disable = 0,
  77. .bus_width_16 = 1,
  78. .port1_otg = 0,
  79. .analog_oc = 0,
  80. .dack_polarity_high = 0,
  81. .dreq_polarity_high = 0,
  82. };
  83. static struct platform_device bfin_isp1760_device = {
  84. .name = "isp1760-hcd",
  85. .id = 0,
  86. .dev = {
  87. .platform_data = &isp1760_priv,
  88. },
  89. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  90. .resource = bfin_isp1760_resources,
  91. };
  92. #endif
  93. static struct resource bfin_i2c_pca_resources[] = {
  94. {
  95. .name = "pca9564-regs",
  96. .start = 0x2C000000,
  97. .end = 0x2C000000 + 16,
  98. .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
  99. }, {
  100. .start = IRQ_PF8,
  101. .end = IRQ_PF8,
  102. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  103. },
  104. };
  105. struct i2c_pca9564_pf_platform_data pca9564_platform_data = {
  106. .gpio = -1,
  107. .i2c_clock_speed = 330000,
  108. .timeout = HZ,
  109. };
  110. /* PCA9564 I2C Bus driver */
  111. static struct platform_device bfin_i2c_pca_device = {
  112. .name = "i2c-pca-platform",
  113. .id = 0,
  114. .num_resources = ARRAY_SIZE(bfin_i2c_pca_resources),
  115. .resource = bfin_i2c_pca_resources,
  116. .dev = {
  117. .platform_data = &pca9564_platform_data,
  118. }
  119. };
  120. /* I2C devices fitted. */
  121. static struct i2c_board_info acvilon_i2c_devs[] __initdata = {
  122. {
  123. I2C_BOARD_INFO("ds1339", 0x68),
  124. },
  125. {
  126. I2C_BOARD_INFO("tcn75", 0x49),
  127. },
  128. };
  129. #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
  130. static struct platdata_mtd_ram mtd_ram_data = {
  131. .mapname = "rootfs(RAM)",
  132. .bankwidth = 4,
  133. };
  134. static struct resource mtd_ram_resource = {
  135. .start = 0x4000000,
  136. .end = 0x5ffffff,
  137. .flags = IORESOURCE_MEM,
  138. };
  139. static struct platform_device mtd_ram_device = {
  140. .name = "mtd-ram",
  141. .id = 0,
  142. .dev = {
  143. .platform_data = &mtd_ram_data,
  144. },
  145. .num_resources = 1,
  146. .resource = &mtd_ram_resource,
  147. };
  148. #endif
  149. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  150. #include <linux/smsc911x.h>
  151. static struct resource smsc911x_resources[] = {
  152. {
  153. .name = "smsc911x-memory",
  154. .start = 0x28000000,
  155. .end = 0x28000000 + 0xFF,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. {
  159. .start = IRQ_PF7,
  160. .end = IRQ_PF7,
  161. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  162. },
  163. };
  164. static struct smsc911x_platform_config smsc911x_config = {
  165. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  166. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  167. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  168. .phy_interface = PHY_INTERFACE_MODE_MII,
  169. };
  170. static struct platform_device smsc911x_device = {
  171. .name = "smsc911x",
  172. .id = 0,
  173. .num_resources = ARRAY_SIZE(smsc911x_resources),
  174. .resource = smsc911x_resources,
  175. .dev = {
  176. .platform_data = &smsc911x_config,
  177. },
  178. };
  179. #endif
  180. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  181. #ifdef CONFIG_SERIAL_BFIN_UART0
  182. static struct resource bfin_uart0_resources[] = {
  183. {
  184. .start = BFIN_UART_THR,
  185. .end = BFIN_UART_GCTL + 2,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. {
  189. .start = IRQ_UART_TX,
  190. .end = IRQ_UART_TX,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. {
  194. .start = IRQ_UART_RX,
  195. .end = IRQ_UART_RX,
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. {
  199. .start = IRQ_UART_ERROR,
  200. .end = IRQ_UART_ERROR,
  201. .flags = IORESOURCE_IRQ,
  202. },
  203. {
  204. .start = CH_UART_TX,
  205. .end = CH_UART_TX,
  206. .flags = IORESOURCE_DMA,
  207. },
  208. {
  209. .start = CH_UART_RX,
  210. .end = CH_UART_RX,
  211. .flags = IORESOURCE_DMA,
  212. },
  213. };
  214. static unsigned short bfin_uart0_peripherals[] = {
  215. P_UART0_TX, P_UART0_RX, 0
  216. };
  217. static struct platform_device bfin_uart0_device = {
  218. .name = "bfin-uart",
  219. .id = 0,
  220. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  221. .resource = bfin_uart0_resources,
  222. .dev = {
  223. /* Passed to driver */
  224. .platform_data = &bfin_uart0_peripherals,
  225. },
  226. };
  227. #endif
  228. #endif
  229. #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  230. const char *part_probes[] = { "cmdlinepart", NULL };
  231. static struct mtd_partition bfin_plat_nand_partitions[] = {
  232. {
  233. .name = "params(nand)",
  234. .size = 32 * 1024 * 1024,
  235. .offset = 0,
  236. }, {
  237. .name = "userfs(nand)",
  238. .size = MTDPART_SIZ_FULL,
  239. .offset = MTDPART_OFS_APPEND,
  240. },
  241. };
  242. #define BFIN_NAND_PLAT_CLE 2
  243. #define BFIN_NAND_PLAT_ALE 3
  244. static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  245. unsigned int ctrl)
  246. {
  247. struct nand_chip *this = mtd->priv;
  248. if (cmd == NAND_CMD_NONE)
  249. return;
  250. if (ctrl & NAND_CLE)
  251. writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
  252. else
  253. writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
  254. }
  255. #define BFIN_NAND_PLAT_READY GPIO_PF10
  256. static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
  257. {
  258. return gpio_get_value(BFIN_NAND_PLAT_READY);
  259. }
  260. static struct platform_nand_data bfin_plat_nand_data = {
  261. .chip = {
  262. .nr_chips = 1,
  263. .chip_delay = 30,
  264. .part_probe_types = part_probes,
  265. .partitions = bfin_plat_nand_partitions,
  266. .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
  267. },
  268. .ctrl = {
  269. .cmd_ctrl = bfin_plat_nand_cmd_ctrl,
  270. .dev_ready = bfin_plat_nand_dev_ready,
  271. },
  272. };
  273. #define MAX(x, y) (x > y ? x : y)
  274. static struct resource bfin_plat_nand_resources = {
  275. .start = 0x24000000,
  276. .end = 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
  277. .flags = IORESOURCE_MEM,
  278. };
  279. static struct platform_device bfin_async_nand_device = {
  280. .name = "gen_nand",
  281. .id = -1,
  282. .num_resources = 1,
  283. .resource = &bfin_plat_nand_resources,
  284. .dev = {
  285. .platform_data = &bfin_plat_nand_data,
  286. },
  287. };
  288. static void bfin_plat_nand_init(void)
  289. {
  290. gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
  291. }
  292. #else
  293. static void bfin_plat_nand_init(void)
  294. {
  295. }
  296. #endif
  297. #if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)
  298. static struct mtd_partition bfin_spi_dataflash_partitions[] = {
  299. {
  300. .name = "bootloader",
  301. .size = 0x4200,
  302. .offset = 0,
  303. .mask_flags = MTD_CAP_ROM},
  304. {
  305. .name = "u-boot",
  306. .size = 0x42000,
  307. .offset = MTDPART_OFS_APPEND,
  308. },
  309. {
  310. .name = "u-boot(params)",
  311. .size = 0x4200,
  312. .offset = MTDPART_OFS_APPEND,
  313. },
  314. {
  315. .name = "kernel",
  316. .size = 0x294000,
  317. .offset = MTDPART_OFS_APPEND,
  318. },
  319. {
  320. .name = "params",
  321. .size = 0x42000,
  322. .offset = MTDPART_OFS_APPEND,
  323. },
  324. {
  325. .name = "rootfs",
  326. .size = MTDPART_SIZ_FULL,
  327. .offset = MTDPART_OFS_APPEND,
  328. }
  329. };
  330. static struct flash_platform_data bfin_spi_dataflash_data = {
  331. .name = "SPI Dataflash",
  332. .parts = bfin_spi_dataflash_partitions,
  333. .nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),
  334. };
  335. /* DataFlash chip */
  336. static struct bfin5xx_spi_chip data_flash_chip_info = {
  337. .enable_dma = 0, /* use dma transfer with this chip */
  338. };
  339. #endif
  340. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  341. /* SPI (0) */
  342. static struct resource bfin_spi0_resource[] = {
  343. [0] = {
  344. .start = SPI0_REGBASE,
  345. .end = SPI0_REGBASE + 0xFF,
  346. .flags = IORESOURCE_MEM,
  347. },
  348. [1] = {
  349. .start = CH_SPI,
  350. .end = CH_SPI,
  351. .flags = IORESOURCE_DMA,
  352. },
  353. [2] = {
  354. .start = IRQ_SPI,
  355. .end = IRQ_SPI,
  356. .flags = IORESOURCE_IRQ,
  357. },
  358. };
  359. /* SPI controller data */
  360. static struct bfin5xx_spi_master bfin_spi0_info = {
  361. .num_chipselect = 8,
  362. .enable_dma = 1, /* master has the ability to do dma transfer */
  363. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  364. };
  365. static struct platform_device bfin_spi0_device = {
  366. .name = "bfin-spi",
  367. .id = 0, /* Bus number */
  368. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  369. .resource = bfin_spi0_resource,
  370. .dev = {
  371. .platform_data = &bfin_spi0_info, /* Passed to driver */
  372. },
  373. };
  374. #endif
  375. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  376. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  377. {
  378. .modalias = "spidev",
  379. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  380. .bus_num = 0,
  381. .chip_select = 3,
  382. },
  383. #endif
  384. #if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)
  385. { /* DataFlash chip */
  386. .modalias = "mtd_dataflash",
  387. .max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */
  388. .bus_num = 0, /* Framework bus number */
  389. .chip_select = 2, /* Framework chip select */
  390. .platform_data = &bfin_spi_dataflash_data,
  391. .controller_data = &data_flash_chip_info,
  392. .mode = SPI_MODE_3,
  393. },
  394. #endif
  395. };
  396. static struct resource bfin_gpios_resources = {
  397. .start = 31,
  398. /* .end = MAX_BLACKFIN_GPIOS - 1, */
  399. .end = 32,
  400. .flags = IORESOURCE_IRQ,
  401. };
  402. static struct platform_device bfin_gpios_device = {
  403. .name = "simple-gpio",
  404. .id = -1,
  405. .num_resources = 1,
  406. .resource = &bfin_gpios_resources,
  407. };
  408. static const unsigned int cclk_vlev_datasheet[] = {
  409. VRPAIR(VLEV_085, 250000000),
  410. VRPAIR(VLEV_090, 300000000),
  411. VRPAIR(VLEV_095, 313000000),
  412. VRPAIR(VLEV_100, 350000000),
  413. VRPAIR(VLEV_105, 400000000),
  414. VRPAIR(VLEV_110, 444000000),
  415. VRPAIR(VLEV_115, 450000000),
  416. VRPAIR(VLEV_120, 475000000),
  417. VRPAIR(VLEV_125, 500000000),
  418. VRPAIR(VLEV_130, 600000000),
  419. };
  420. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  421. .tuple_tab = cclk_vlev_datasheet,
  422. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  423. .vr_settling_time = 25 /* us */ ,
  424. };
  425. static struct platform_device bfin_dpmc = {
  426. .name = "bfin dpmc",
  427. .dev = {
  428. .platform_data = &bfin_dmpc_vreg_data,
  429. },
  430. };
  431. static struct platform_device *acvilon_devices[] __initdata = {
  432. &bfin_dpmc,
  433. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  434. &bfin_spi0_device,
  435. #endif
  436. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  437. #ifdef CONFIG_SERIAL_BFIN_UART0
  438. &bfin_uart0_device,
  439. #endif
  440. #endif
  441. &bfin_gpios_device,
  442. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  443. &smsc911x_device,
  444. #endif
  445. &bfin_i2c_pca_device,
  446. #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  447. &bfin_async_nand_device,
  448. #endif
  449. #if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
  450. &mtd_ram_device,
  451. #endif
  452. };
  453. static int __init acvilon_init(void)
  454. {
  455. int ret;
  456. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  457. bfin_plat_nand_init();
  458. ret =
  459. platform_add_devices(acvilon_devices, ARRAY_SIZE(acvilon_devices));
  460. if (ret < 0)
  461. return ret;
  462. i2c_register_board_info(0, acvilon_i2c_devs,
  463. ARRAY_SIZE(acvilon_i2c_devs));
  464. bfin_write_FIO0_FLAG_C(1 << 14);
  465. msleep(5);
  466. bfin_write_FIO0_FLAG_S(1 << 14);
  467. spi_register_board_info(bfin_spi_board_info,
  468. ARRAY_SIZE(bfin_spi_board_info));
  469. return 0;
  470. }
  471. arch_initcall(acvilon_init);
  472. static struct platform_device *acvilon_early_devices[] __initdata = {
  473. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  474. #ifdef CONFIG_SERIAL_BFIN_UART0
  475. &bfin_uart0_device,
  476. #endif
  477. #endif
  478. };
  479. void __init native_machine_early_platform_add_devices(void)
  480. {
  481. printk(KERN_INFO "register early platform devices\n");
  482. early_platform_add_devices(acvilon_early_devices,
  483. ARRAY_SIZE(acvilon_early_devices));
  484. }