common.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. /*
  2. * arch/arm/mach-kirkwood/common.c
  3. *
  4. * Core functions for Marvell Kirkwood SoCs
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/mbus.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/mv643xx_i2c.h>
  17. #include <linux/ata_platform.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/spi/orion_spi.h>
  20. #include <net/dsa.h>
  21. #include <asm/page.h>
  22. #include <asm/timex.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/time.h>
  25. #include <mach/kirkwood.h>
  26. #include <mach/bridge-regs.h>
  27. #include <plat/cache-feroceon-l2.h>
  28. #include <plat/ehci-orion.h>
  29. #include <plat/mvsdio.h>
  30. #include <plat/mv_xor.h>
  31. #include <plat/orion_nand.h>
  32. #include <plat/orion_wdt.h>
  33. #include <plat/time.h>
  34. #include "common.h"
  35. /*****************************************************************************
  36. * I/O Address Mapping
  37. ****************************************************************************/
  38. static struct map_desc kirkwood_io_desc[] __initdata = {
  39. {
  40. .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
  41. .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
  42. .length = KIRKWOOD_PCIE_IO_SIZE,
  43. .type = MT_DEVICE,
  44. }, {
  45. .virtual = KIRKWOOD_REGS_VIRT_BASE,
  46. .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
  47. .length = KIRKWOOD_REGS_SIZE,
  48. .type = MT_DEVICE,
  49. },
  50. };
  51. void __init kirkwood_map_io(void)
  52. {
  53. iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
  54. }
  55. /*
  56. * Default clock control bits. Any bit _not_ set in this variable
  57. * will be cleared from the hardware after platform devices have been
  58. * registered. Some reserved bits must be set to 1.
  59. */
  60. unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED;
  61. /*****************************************************************************
  62. * EHCI
  63. ****************************************************************************/
  64. static struct orion_ehci_data kirkwood_ehci_data = {
  65. .dram = &kirkwood_mbus_dram_info,
  66. .phy_version = EHCI_PHY_NA,
  67. };
  68. static u64 ehci_dmamask = 0xffffffffUL;
  69. /*****************************************************************************
  70. * EHCI0
  71. ****************************************************************************/
  72. static struct resource kirkwood_ehci_resources[] = {
  73. {
  74. .start = USB_PHYS_BASE,
  75. .end = USB_PHYS_BASE + 0x0fff,
  76. .flags = IORESOURCE_MEM,
  77. }, {
  78. .start = IRQ_KIRKWOOD_USB,
  79. .end = IRQ_KIRKWOOD_USB,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct platform_device kirkwood_ehci = {
  84. .name = "orion-ehci",
  85. .id = 0,
  86. .dev = {
  87. .dma_mask = &ehci_dmamask,
  88. .coherent_dma_mask = 0xffffffff,
  89. .platform_data = &kirkwood_ehci_data,
  90. },
  91. .resource = kirkwood_ehci_resources,
  92. .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
  93. };
  94. void __init kirkwood_ehci_init(void)
  95. {
  96. kirkwood_clk_ctrl |= CGC_USB0;
  97. platform_device_register(&kirkwood_ehci);
  98. }
  99. /*****************************************************************************
  100. * GE00
  101. ****************************************************************************/
  102. struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
  103. .dram = &kirkwood_mbus_dram_info,
  104. };
  105. static struct resource kirkwood_ge00_shared_resources[] = {
  106. {
  107. .name = "ge00 base",
  108. .start = GE00_PHYS_BASE + 0x2000,
  109. .end = GE00_PHYS_BASE + 0x3fff,
  110. .flags = IORESOURCE_MEM,
  111. }, {
  112. .name = "ge00 err irq",
  113. .start = IRQ_KIRKWOOD_GE00_ERR,
  114. .end = IRQ_KIRKWOOD_GE00_ERR,
  115. .flags = IORESOURCE_IRQ,
  116. },
  117. };
  118. static struct platform_device kirkwood_ge00_shared = {
  119. .name = MV643XX_ETH_SHARED_NAME,
  120. .id = 0,
  121. .dev = {
  122. .platform_data = &kirkwood_ge00_shared_data,
  123. },
  124. .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
  125. .resource = kirkwood_ge00_shared_resources,
  126. };
  127. static struct resource kirkwood_ge00_resources[] = {
  128. {
  129. .name = "ge00 irq",
  130. .start = IRQ_KIRKWOOD_GE00_SUM,
  131. .end = IRQ_KIRKWOOD_GE00_SUM,
  132. .flags = IORESOURCE_IRQ,
  133. },
  134. };
  135. static struct platform_device kirkwood_ge00 = {
  136. .name = MV643XX_ETH_NAME,
  137. .id = 0,
  138. .num_resources = 1,
  139. .resource = kirkwood_ge00_resources,
  140. .dev = {
  141. .coherent_dma_mask = 0xffffffff,
  142. },
  143. };
  144. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  145. {
  146. kirkwood_clk_ctrl |= CGC_GE0;
  147. eth_data->shared = &kirkwood_ge00_shared;
  148. kirkwood_ge00.dev.platform_data = eth_data;
  149. platform_device_register(&kirkwood_ge00_shared);
  150. platform_device_register(&kirkwood_ge00);
  151. }
  152. /*****************************************************************************
  153. * GE01
  154. ****************************************************************************/
  155. struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
  156. .dram = &kirkwood_mbus_dram_info,
  157. .shared_smi = &kirkwood_ge00_shared,
  158. };
  159. static struct resource kirkwood_ge01_shared_resources[] = {
  160. {
  161. .name = "ge01 base",
  162. .start = GE01_PHYS_BASE + 0x2000,
  163. .end = GE01_PHYS_BASE + 0x3fff,
  164. .flags = IORESOURCE_MEM,
  165. }, {
  166. .name = "ge01 err irq",
  167. .start = IRQ_KIRKWOOD_GE01_ERR,
  168. .end = IRQ_KIRKWOOD_GE01_ERR,
  169. .flags = IORESOURCE_IRQ,
  170. },
  171. };
  172. static struct platform_device kirkwood_ge01_shared = {
  173. .name = MV643XX_ETH_SHARED_NAME,
  174. .id = 1,
  175. .dev = {
  176. .platform_data = &kirkwood_ge01_shared_data,
  177. },
  178. .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
  179. .resource = kirkwood_ge01_shared_resources,
  180. };
  181. static struct resource kirkwood_ge01_resources[] = {
  182. {
  183. .name = "ge01 irq",
  184. .start = IRQ_KIRKWOOD_GE01_SUM,
  185. .end = IRQ_KIRKWOOD_GE01_SUM,
  186. .flags = IORESOURCE_IRQ,
  187. },
  188. };
  189. static struct platform_device kirkwood_ge01 = {
  190. .name = MV643XX_ETH_NAME,
  191. .id = 1,
  192. .num_resources = 1,
  193. .resource = kirkwood_ge01_resources,
  194. .dev = {
  195. .coherent_dma_mask = 0xffffffff,
  196. },
  197. };
  198. void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  199. {
  200. kirkwood_clk_ctrl |= CGC_GE1;
  201. eth_data->shared = &kirkwood_ge01_shared;
  202. kirkwood_ge01.dev.platform_data = eth_data;
  203. platform_device_register(&kirkwood_ge01_shared);
  204. platform_device_register(&kirkwood_ge01);
  205. }
  206. /*****************************************************************************
  207. * Ethernet switch
  208. ****************************************************************************/
  209. static struct resource kirkwood_switch_resources[] = {
  210. {
  211. .start = 0,
  212. .end = 0,
  213. .flags = IORESOURCE_IRQ,
  214. },
  215. };
  216. static struct platform_device kirkwood_switch_device = {
  217. .name = "dsa",
  218. .id = 0,
  219. .num_resources = 0,
  220. .resource = kirkwood_switch_resources,
  221. };
  222. void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
  223. {
  224. int i;
  225. if (irq != NO_IRQ) {
  226. kirkwood_switch_resources[0].start = irq;
  227. kirkwood_switch_resources[0].end = irq;
  228. kirkwood_switch_device.num_resources = 1;
  229. }
  230. d->netdev = &kirkwood_ge00.dev;
  231. for (i = 0; i < d->nr_chips; i++)
  232. d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
  233. kirkwood_switch_device.dev.platform_data = d;
  234. platform_device_register(&kirkwood_switch_device);
  235. }
  236. /*****************************************************************************
  237. * NAND flash
  238. ****************************************************************************/
  239. static struct resource kirkwood_nand_resource = {
  240. .flags = IORESOURCE_MEM,
  241. .start = KIRKWOOD_NAND_MEM_PHYS_BASE,
  242. .end = KIRKWOOD_NAND_MEM_PHYS_BASE +
  243. KIRKWOOD_NAND_MEM_SIZE - 1,
  244. };
  245. static struct orion_nand_data kirkwood_nand_data = {
  246. .cle = 0,
  247. .ale = 1,
  248. .width = 8,
  249. };
  250. static struct platform_device kirkwood_nand_flash = {
  251. .name = "orion_nand",
  252. .id = -1,
  253. .dev = {
  254. .platform_data = &kirkwood_nand_data,
  255. },
  256. .resource = &kirkwood_nand_resource,
  257. .num_resources = 1,
  258. };
  259. void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
  260. int chip_delay)
  261. {
  262. kirkwood_clk_ctrl |= CGC_RUNIT;
  263. kirkwood_nand_data.parts = parts;
  264. kirkwood_nand_data.nr_parts = nr_parts;
  265. kirkwood_nand_data.chip_delay = chip_delay;
  266. platform_device_register(&kirkwood_nand_flash);
  267. }
  268. /*****************************************************************************
  269. * SoC RTC
  270. ****************************************************************************/
  271. static struct resource kirkwood_rtc_resource = {
  272. .start = RTC_PHYS_BASE,
  273. .end = RTC_PHYS_BASE + SZ_16 - 1,
  274. .flags = IORESOURCE_MEM,
  275. };
  276. static void __init kirkwood_rtc_init(void)
  277. {
  278. platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
  279. }
  280. /*****************************************************************************
  281. * SATA
  282. ****************************************************************************/
  283. static struct resource kirkwood_sata_resources[] = {
  284. {
  285. .name = "sata base",
  286. .start = SATA_PHYS_BASE,
  287. .end = SATA_PHYS_BASE + 0x5000 - 1,
  288. .flags = IORESOURCE_MEM,
  289. }, {
  290. .name = "sata irq",
  291. .start = IRQ_KIRKWOOD_SATA,
  292. .end = IRQ_KIRKWOOD_SATA,
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static struct platform_device kirkwood_sata = {
  297. .name = "sata_mv",
  298. .id = 0,
  299. .dev = {
  300. .coherent_dma_mask = 0xffffffff,
  301. },
  302. .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
  303. .resource = kirkwood_sata_resources,
  304. };
  305. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  306. {
  307. kirkwood_clk_ctrl |= CGC_SATA0;
  308. if (sata_data->n_ports > 1)
  309. kirkwood_clk_ctrl |= CGC_SATA1;
  310. sata_data->dram = &kirkwood_mbus_dram_info;
  311. kirkwood_sata.dev.platform_data = sata_data;
  312. platform_device_register(&kirkwood_sata);
  313. }
  314. /*****************************************************************************
  315. * SD/SDIO/MMC
  316. ****************************************************************************/
  317. static struct resource mvsdio_resources[] = {
  318. [0] = {
  319. .start = SDIO_PHYS_BASE,
  320. .end = SDIO_PHYS_BASE + SZ_1K - 1,
  321. .flags = IORESOURCE_MEM,
  322. },
  323. [1] = {
  324. .start = IRQ_KIRKWOOD_SDIO,
  325. .end = IRQ_KIRKWOOD_SDIO,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. };
  329. static u64 mvsdio_dmamask = 0xffffffffUL;
  330. static struct platform_device kirkwood_sdio = {
  331. .name = "mvsdio",
  332. .id = -1,
  333. .dev = {
  334. .dma_mask = &mvsdio_dmamask,
  335. .coherent_dma_mask = 0xffffffff,
  336. },
  337. .num_resources = ARRAY_SIZE(mvsdio_resources),
  338. .resource = mvsdio_resources,
  339. };
  340. void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
  341. {
  342. u32 dev, rev;
  343. kirkwood_pcie_id(&dev, &rev);
  344. if (rev == 0) /* catch all Kirkwood Z0's */
  345. mvsdio_data->clock = 100000000;
  346. else
  347. mvsdio_data->clock = 200000000;
  348. mvsdio_data->dram = &kirkwood_mbus_dram_info;
  349. kirkwood_clk_ctrl |= CGC_SDIO;
  350. kirkwood_sdio.dev.platform_data = mvsdio_data;
  351. platform_device_register(&kirkwood_sdio);
  352. }
  353. /*****************************************************************************
  354. * SPI
  355. ****************************************************************************/
  356. static struct orion_spi_info kirkwood_spi_plat_data = {
  357. };
  358. static struct resource kirkwood_spi_resources[] = {
  359. {
  360. .start = SPI_PHYS_BASE,
  361. .end = SPI_PHYS_BASE + SZ_512 - 1,
  362. .flags = IORESOURCE_MEM,
  363. },
  364. };
  365. static struct platform_device kirkwood_spi = {
  366. .name = "orion_spi",
  367. .id = 0,
  368. .resource = kirkwood_spi_resources,
  369. .dev = {
  370. .platform_data = &kirkwood_spi_plat_data,
  371. },
  372. .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
  373. };
  374. void __init kirkwood_spi_init()
  375. {
  376. kirkwood_clk_ctrl |= CGC_RUNIT;
  377. platform_device_register(&kirkwood_spi);
  378. }
  379. /*****************************************************************************
  380. * I2C
  381. ****************************************************************************/
  382. static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
  383. .freq_m = 8, /* assumes 166 MHz TCLK */
  384. .freq_n = 3,
  385. .timeout = 1000, /* Default timeout of 1 second */
  386. };
  387. static struct resource kirkwood_i2c_resources[] = {
  388. {
  389. .start = I2C_PHYS_BASE,
  390. .end = I2C_PHYS_BASE + 0x1f,
  391. .flags = IORESOURCE_MEM,
  392. }, {
  393. .start = IRQ_KIRKWOOD_TWSI,
  394. .end = IRQ_KIRKWOOD_TWSI,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. };
  398. static struct platform_device kirkwood_i2c = {
  399. .name = MV64XXX_I2C_CTLR_NAME,
  400. .id = 0,
  401. .num_resources = ARRAY_SIZE(kirkwood_i2c_resources),
  402. .resource = kirkwood_i2c_resources,
  403. .dev = {
  404. .platform_data = &kirkwood_i2c_pdata,
  405. },
  406. };
  407. void __init kirkwood_i2c_init(void)
  408. {
  409. platform_device_register(&kirkwood_i2c);
  410. }
  411. /*****************************************************************************
  412. * UART0
  413. ****************************************************************************/
  414. static struct plat_serial8250_port kirkwood_uart0_data[] = {
  415. {
  416. .mapbase = UART0_PHYS_BASE,
  417. .membase = (char *)UART0_VIRT_BASE,
  418. .irq = IRQ_KIRKWOOD_UART_0,
  419. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  420. .iotype = UPIO_MEM,
  421. .regshift = 2,
  422. .uartclk = 0,
  423. }, {
  424. },
  425. };
  426. static struct resource kirkwood_uart0_resources[] = {
  427. {
  428. .start = UART0_PHYS_BASE,
  429. .end = UART0_PHYS_BASE + 0xff,
  430. .flags = IORESOURCE_MEM,
  431. }, {
  432. .start = IRQ_KIRKWOOD_UART_0,
  433. .end = IRQ_KIRKWOOD_UART_0,
  434. .flags = IORESOURCE_IRQ,
  435. },
  436. };
  437. static struct platform_device kirkwood_uart0 = {
  438. .name = "serial8250",
  439. .id = 0,
  440. .dev = {
  441. .platform_data = kirkwood_uart0_data,
  442. },
  443. .resource = kirkwood_uart0_resources,
  444. .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
  445. };
  446. void __init kirkwood_uart0_init(void)
  447. {
  448. platform_device_register(&kirkwood_uart0);
  449. }
  450. /*****************************************************************************
  451. * UART1
  452. ****************************************************************************/
  453. static struct plat_serial8250_port kirkwood_uart1_data[] = {
  454. {
  455. .mapbase = UART1_PHYS_BASE,
  456. .membase = (char *)UART1_VIRT_BASE,
  457. .irq = IRQ_KIRKWOOD_UART_1,
  458. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  459. .iotype = UPIO_MEM,
  460. .regshift = 2,
  461. .uartclk = 0,
  462. }, {
  463. },
  464. };
  465. static struct resource kirkwood_uart1_resources[] = {
  466. {
  467. .start = UART1_PHYS_BASE,
  468. .end = UART1_PHYS_BASE + 0xff,
  469. .flags = IORESOURCE_MEM,
  470. }, {
  471. .start = IRQ_KIRKWOOD_UART_1,
  472. .end = IRQ_KIRKWOOD_UART_1,
  473. .flags = IORESOURCE_IRQ,
  474. },
  475. };
  476. static struct platform_device kirkwood_uart1 = {
  477. .name = "serial8250",
  478. .id = 1,
  479. .dev = {
  480. .platform_data = kirkwood_uart1_data,
  481. },
  482. .resource = kirkwood_uart1_resources,
  483. .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
  484. };
  485. void __init kirkwood_uart1_init(void)
  486. {
  487. platform_device_register(&kirkwood_uart1);
  488. }
  489. /*****************************************************************************
  490. * XOR
  491. ****************************************************************************/
  492. static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
  493. .dram = &kirkwood_mbus_dram_info,
  494. };
  495. static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
  496. /*****************************************************************************
  497. * XOR0
  498. ****************************************************************************/
  499. static struct resource kirkwood_xor0_shared_resources[] = {
  500. {
  501. .name = "xor 0 low",
  502. .start = XOR0_PHYS_BASE,
  503. .end = XOR0_PHYS_BASE + 0xff,
  504. .flags = IORESOURCE_MEM,
  505. }, {
  506. .name = "xor 0 high",
  507. .start = XOR0_HIGH_PHYS_BASE,
  508. .end = XOR0_HIGH_PHYS_BASE + 0xff,
  509. .flags = IORESOURCE_MEM,
  510. },
  511. };
  512. static struct platform_device kirkwood_xor0_shared = {
  513. .name = MV_XOR_SHARED_NAME,
  514. .id = 0,
  515. .dev = {
  516. .platform_data = &kirkwood_xor_shared_data,
  517. },
  518. .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
  519. .resource = kirkwood_xor0_shared_resources,
  520. };
  521. static struct resource kirkwood_xor00_resources[] = {
  522. [0] = {
  523. .start = IRQ_KIRKWOOD_XOR_00,
  524. .end = IRQ_KIRKWOOD_XOR_00,
  525. .flags = IORESOURCE_IRQ,
  526. },
  527. };
  528. static struct mv_xor_platform_data kirkwood_xor00_data = {
  529. .shared = &kirkwood_xor0_shared,
  530. .hw_id = 0,
  531. .pool_size = PAGE_SIZE,
  532. };
  533. static struct platform_device kirkwood_xor00_channel = {
  534. .name = MV_XOR_NAME,
  535. .id = 0,
  536. .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
  537. .resource = kirkwood_xor00_resources,
  538. .dev = {
  539. .dma_mask = &kirkwood_xor_dmamask,
  540. .coherent_dma_mask = DMA_BIT_MASK(64),
  541. .platform_data = (void *)&kirkwood_xor00_data,
  542. },
  543. };
  544. static struct resource kirkwood_xor01_resources[] = {
  545. [0] = {
  546. .start = IRQ_KIRKWOOD_XOR_01,
  547. .end = IRQ_KIRKWOOD_XOR_01,
  548. .flags = IORESOURCE_IRQ,
  549. },
  550. };
  551. static struct mv_xor_platform_data kirkwood_xor01_data = {
  552. .shared = &kirkwood_xor0_shared,
  553. .hw_id = 1,
  554. .pool_size = PAGE_SIZE,
  555. };
  556. static struct platform_device kirkwood_xor01_channel = {
  557. .name = MV_XOR_NAME,
  558. .id = 1,
  559. .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
  560. .resource = kirkwood_xor01_resources,
  561. .dev = {
  562. .dma_mask = &kirkwood_xor_dmamask,
  563. .coherent_dma_mask = DMA_BIT_MASK(64),
  564. .platform_data = (void *)&kirkwood_xor01_data,
  565. },
  566. };
  567. static void __init kirkwood_xor0_init(void)
  568. {
  569. kirkwood_clk_ctrl |= CGC_XOR0;
  570. platform_device_register(&kirkwood_xor0_shared);
  571. /*
  572. * two engines can't do memset simultaneously, this limitation
  573. * satisfied by removing memset support from one of the engines.
  574. */
  575. dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
  576. dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
  577. platform_device_register(&kirkwood_xor00_channel);
  578. dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
  579. dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
  580. dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
  581. platform_device_register(&kirkwood_xor01_channel);
  582. }
  583. /*****************************************************************************
  584. * XOR1
  585. ****************************************************************************/
  586. static struct resource kirkwood_xor1_shared_resources[] = {
  587. {
  588. .name = "xor 1 low",
  589. .start = XOR1_PHYS_BASE,
  590. .end = XOR1_PHYS_BASE + 0xff,
  591. .flags = IORESOURCE_MEM,
  592. }, {
  593. .name = "xor 1 high",
  594. .start = XOR1_HIGH_PHYS_BASE,
  595. .end = XOR1_HIGH_PHYS_BASE + 0xff,
  596. .flags = IORESOURCE_MEM,
  597. },
  598. };
  599. static struct platform_device kirkwood_xor1_shared = {
  600. .name = MV_XOR_SHARED_NAME,
  601. .id = 1,
  602. .dev = {
  603. .platform_data = &kirkwood_xor_shared_data,
  604. },
  605. .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
  606. .resource = kirkwood_xor1_shared_resources,
  607. };
  608. static struct resource kirkwood_xor10_resources[] = {
  609. [0] = {
  610. .start = IRQ_KIRKWOOD_XOR_10,
  611. .end = IRQ_KIRKWOOD_XOR_10,
  612. .flags = IORESOURCE_IRQ,
  613. },
  614. };
  615. static struct mv_xor_platform_data kirkwood_xor10_data = {
  616. .shared = &kirkwood_xor1_shared,
  617. .hw_id = 0,
  618. .pool_size = PAGE_SIZE,
  619. };
  620. static struct platform_device kirkwood_xor10_channel = {
  621. .name = MV_XOR_NAME,
  622. .id = 2,
  623. .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
  624. .resource = kirkwood_xor10_resources,
  625. .dev = {
  626. .dma_mask = &kirkwood_xor_dmamask,
  627. .coherent_dma_mask = DMA_BIT_MASK(64),
  628. .platform_data = (void *)&kirkwood_xor10_data,
  629. },
  630. };
  631. static struct resource kirkwood_xor11_resources[] = {
  632. [0] = {
  633. .start = IRQ_KIRKWOOD_XOR_11,
  634. .end = IRQ_KIRKWOOD_XOR_11,
  635. .flags = IORESOURCE_IRQ,
  636. },
  637. };
  638. static struct mv_xor_platform_data kirkwood_xor11_data = {
  639. .shared = &kirkwood_xor1_shared,
  640. .hw_id = 1,
  641. .pool_size = PAGE_SIZE,
  642. };
  643. static struct platform_device kirkwood_xor11_channel = {
  644. .name = MV_XOR_NAME,
  645. .id = 3,
  646. .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
  647. .resource = kirkwood_xor11_resources,
  648. .dev = {
  649. .dma_mask = &kirkwood_xor_dmamask,
  650. .coherent_dma_mask = DMA_BIT_MASK(64),
  651. .platform_data = (void *)&kirkwood_xor11_data,
  652. },
  653. };
  654. static void __init kirkwood_xor1_init(void)
  655. {
  656. kirkwood_clk_ctrl |= CGC_XOR1;
  657. platform_device_register(&kirkwood_xor1_shared);
  658. /*
  659. * two engines can't do memset simultaneously, this limitation
  660. * satisfied by removing memset support from one of the engines.
  661. */
  662. dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
  663. dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
  664. platform_device_register(&kirkwood_xor10_channel);
  665. dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
  666. dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
  667. dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
  668. platform_device_register(&kirkwood_xor11_channel);
  669. }
  670. /*****************************************************************************
  671. * Watchdog
  672. ****************************************************************************/
  673. static struct orion_wdt_platform_data kirkwood_wdt_data = {
  674. .tclk = 0,
  675. };
  676. static struct platform_device kirkwood_wdt_device = {
  677. .name = "orion_wdt",
  678. .id = -1,
  679. .dev = {
  680. .platform_data = &kirkwood_wdt_data,
  681. },
  682. .num_resources = 0,
  683. };
  684. static void __init kirkwood_wdt_init(void)
  685. {
  686. kirkwood_wdt_data.tclk = kirkwood_tclk;
  687. platform_device_register(&kirkwood_wdt_device);
  688. }
  689. /*****************************************************************************
  690. * Time handling
  691. ****************************************************************************/
  692. int kirkwood_tclk;
  693. int __init kirkwood_find_tclk(void)
  694. {
  695. u32 dev, rev;
  696. kirkwood_pcie_id(&dev, &rev);
  697. if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
  698. return 200000000;
  699. return 166666667;
  700. }
  701. static void kirkwood_timer_init(void)
  702. {
  703. kirkwood_tclk = kirkwood_find_tclk();
  704. orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  705. }
  706. struct sys_timer kirkwood_timer = {
  707. .init = kirkwood_timer_init,
  708. };
  709. /*****************************************************************************
  710. * General
  711. ****************************************************************************/
  712. /*
  713. * Identify device ID and revision.
  714. */
  715. static char * __init kirkwood_id(void)
  716. {
  717. u32 dev, rev;
  718. kirkwood_pcie_id(&dev, &rev);
  719. if (dev == MV88F6281_DEV_ID) {
  720. if (rev == MV88F6281_REV_Z0)
  721. return "MV88F6281-Z0";
  722. else if (rev == MV88F6281_REV_A0)
  723. return "MV88F6281-A0";
  724. else
  725. return "MV88F6281-Rev-Unsupported";
  726. } else if (dev == MV88F6192_DEV_ID) {
  727. if (rev == MV88F6192_REV_Z0)
  728. return "MV88F6192-Z0";
  729. else if (rev == MV88F6192_REV_A0)
  730. return "MV88F6192-A0";
  731. else
  732. return "MV88F6192-Rev-Unsupported";
  733. } else if (dev == MV88F6180_DEV_ID) {
  734. if (rev == MV88F6180_REV_A0)
  735. return "MV88F6180-Rev-A0";
  736. else
  737. return "MV88F6180-Rev-Unsupported";
  738. } else {
  739. return "Device-Unknown";
  740. }
  741. }
  742. static void __init kirkwood_l2_init(void)
  743. {
  744. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  745. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  746. feroceon_l2_init(1);
  747. #else
  748. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  749. feroceon_l2_init(0);
  750. #endif
  751. }
  752. void __init kirkwood_init(void)
  753. {
  754. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  755. kirkwood_id(), kirkwood_tclk);
  756. kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
  757. kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
  758. kirkwood_spi_plat_data.tclk = kirkwood_tclk;
  759. kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
  760. kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
  761. kirkwood_setup_cpu_mbus();
  762. #ifdef CONFIG_CACHE_FEROCEON_L2
  763. kirkwood_l2_init();
  764. #endif
  765. /* internal devices that every board has */
  766. kirkwood_rtc_init();
  767. kirkwood_wdt_init();
  768. kirkwood_xor0_init();
  769. kirkwood_xor1_init();
  770. }
  771. static int __init kirkwood_clock_gate(void)
  772. {
  773. unsigned int curr = readl(CLOCK_GATING_CTRL);
  774. printk(KERN_DEBUG "Gating clock of unused units\n");
  775. printk(KERN_DEBUG "before: 0x%08x\n", curr);
  776. /* Make sure those units are accessible */
  777. writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0, CLOCK_GATING_CTRL);
  778. /* For SATA: first shutdown the phy */
  779. if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
  780. /* Disable PLL and IVREF */
  781. writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2);
  782. /* Disable PHY */
  783. writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL);
  784. }
  785. if (!(kirkwood_clk_ctrl & CGC_SATA1)) {
  786. /* Disable PLL and IVREF */
  787. writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2);
  788. /* Disable PHY */
  789. writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL);
  790. }
  791. /* For PCIe: first shutdown the phy */
  792. if (!(kirkwood_clk_ctrl & CGC_PEX0)) {
  793. writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL);
  794. while (1)
  795. if (readl(PCIE_STATUS) & 0x1)
  796. break;
  797. writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL);
  798. }
  799. /* Now gate clock the required units */
  800. writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL);
  801. printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL));
  802. return 0;
  803. }
  804. late_initcall(kirkwood_clock_gate);