common.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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/ata_platform.h>
  15. #include <linux/mtd/nand.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/clk-provider.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/mv643xx_i2c.h>
  20. #include <linux/timex.h>
  21. #include <linux/kexec.h>
  22. #include <net/dsa.h>
  23. #include <asm/page.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/time.h>
  26. #include <mach/kirkwood.h>
  27. #include <mach/bridge-regs.h>
  28. #include <linux/platform_data/asoc-kirkwood.h>
  29. #include <plat/cache-feroceon-l2.h>
  30. #include <linux/platform_data/mmc-mvsdio.h>
  31. #include <linux/platform_data/mtd-orion_nand.h>
  32. #include <linux/platform_data/usb-ehci-orion.h>
  33. #include <plat/common.h>
  34. #include <plat/time.h>
  35. #include <plat/addr-map.h>
  36. #include <linux/platform_data/dma-mv_xor.h>
  37. #include "common.h"
  38. /*****************************************************************************
  39. * I/O Address Mapping
  40. ****************************************************************************/
  41. static struct map_desc kirkwood_io_desc[] __initdata = {
  42. {
  43. .virtual = (unsigned long) KIRKWOOD_REGS_VIRT_BASE,
  44. .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
  45. .length = KIRKWOOD_REGS_SIZE,
  46. .type = MT_DEVICE,
  47. },
  48. };
  49. void __init kirkwood_map_io(void)
  50. {
  51. iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
  52. }
  53. /*****************************************************************************
  54. * CLK tree
  55. ****************************************************************************/
  56. static void enable_sata0(void)
  57. {
  58. /* Enable PLL and IVREF */
  59. writel(readl(SATA0_PHY_MODE_2) | 0xf, SATA0_PHY_MODE_2);
  60. /* Enable PHY */
  61. writel(readl(SATA0_IF_CTRL) & ~0x200, SATA0_IF_CTRL);
  62. }
  63. static void disable_sata0(void)
  64. {
  65. /* Disable PLL and IVREF */
  66. writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2);
  67. /* Disable PHY */
  68. writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL);
  69. }
  70. static void enable_sata1(void)
  71. {
  72. /* Enable PLL and IVREF */
  73. writel(readl(SATA1_PHY_MODE_2) | 0xf, SATA1_PHY_MODE_2);
  74. /* Enable PHY */
  75. writel(readl(SATA1_IF_CTRL) & ~0x200, SATA1_IF_CTRL);
  76. }
  77. static void disable_sata1(void)
  78. {
  79. /* Disable PLL and IVREF */
  80. writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2);
  81. /* Disable PHY */
  82. writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL);
  83. }
  84. static void disable_pcie0(void)
  85. {
  86. writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL);
  87. while (1)
  88. if (readl(PCIE_STATUS) & 0x1)
  89. break;
  90. writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL);
  91. }
  92. static void disable_pcie1(void)
  93. {
  94. u32 dev, rev;
  95. kirkwood_pcie_id(&dev, &rev);
  96. if (dev == MV88F6282_DEV_ID) {
  97. writel(readl(PCIE1_LINK_CTRL) | 0x10, PCIE1_LINK_CTRL);
  98. while (1)
  99. if (readl(PCIE1_STATUS) & 0x1)
  100. break;
  101. writel(readl(PCIE1_LINK_CTRL) & ~0x10, PCIE1_LINK_CTRL);
  102. }
  103. }
  104. /* An extended version of the gated clk. This calls fn_en()/fn_dis
  105. * before enabling/disabling the clock. We use this to turn on/off
  106. * PHYs etc. */
  107. struct clk_gate_fn {
  108. struct clk_gate gate;
  109. void (*fn_en)(void);
  110. void (*fn_dis)(void);
  111. };
  112. #define to_clk_gate_fn(_gate) container_of(_gate, struct clk_gate_fn, gate)
  113. #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
  114. static int clk_gate_fn_enable(struct clk_hw *hw)
  115. {
  116. struct clk_gate *gate = to_clk_gate(hw);
  117. struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate);
  118. int ret;
  119. ret = clk_gate_ops.enable(hw);
  120. if (!ret && gate_fn->fn_en)
  121. gate_fn->fn_en();
  122. return ret;
  123. }
  124. static void clk_gate_fn_disable(struct clk_hw *hw)
  125. {
  126. struct clk_gate *gate = to_clk_gate(hw);
  127. struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate);
  128. if (gate_fn->fn_dis)
  129. gate_fn->fn_dis();
  130. clk_gate_ops.disable(hw);
  131. }
  132. static struct clk_ops clk_gate_fn_ops;
  133. static struct clk __init *clk_register_gate_fn(struct device *dev,
  134. const char *name,
  135. const char *parent_name, unsigned long flags,
  136. void __iomem *reg, u8 bit_idx,
  137. u8 clk_gate_flags, spinlock_t *lock,
  138. void (*fn_en)(void), void (*fn_dis)(void))
  139. {
  140. struct clk_gate_fn *gate_fn;
  141. struct clk *clk;
  142. struct clk_init_data init;
  143. gate_fn = kzalloc(sizeof(struct clk_gate_fn), GFP_KERNEL);
  144. if (!gate_fn) {
  145. pr_err("%s: could not allocate gated clk\n", __func__);
  146. return ERR_PTR(-ENOMEM);
  147. }
  148. init.name = name;
  149. init.ops = &clk_gate_fn_ops;
  150. init.flags = flags;
  151. init.parent_names = (parent_name ? &parent_name : NULL);
  152. init.num_parents = (parent_name ? 1 : 0);
  153. /* struct clk_gate assignments */
  154. gate_fn->gate.reg = reg;
  155. gate_fn->gate.bit_idx = bit_idx;
  156. gate_fn->gate.flags = clk_gate_flags;
  157. gate_fn->gate.lock = lock;
  158. gate_fn->gate.hw.init = &init;
  159. gate_fn->fn_en = fn_en;
  160. gate_fn->fn_dis = fn_dis;
  161. /* ops is the gate ops, but with our enable/disable functions */
  162. if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
  163. clk_gate_fn_ops.disable != clk_gate_fn_disable) {
  164. clk_gate_fn_ops = clk_gate_ops;
  165. clk_gate_fn_ops.enable = clk_gate_fn_enable;
  166. clk_gate_fn_ops.disable = clk_gate_fn_disable;
  167. }
  168. clk = clk_register(dev, &gate_fn->gate.hw);
  169. if (IS_ERR(clk))
  170. kfree(gate_fn);
  171. return clk;
  172. }
  173. static DEFINE_SPINLOCK(gating_lock);
  174. static struct clk *tclk;
  175. static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx)
  176. {
  177. return clk_register_gate(NULL, name, "tclk", 0, CLOCK_GATING_CTRL,
  178. bit_idx, 0, &gating_lock);
  179. }
  180. static struct clk __init *kirkwood_register_gate_fn(const char *name,
  181. u8 bit_idx,
  182. void (*fn_en)(void),
  183. void (*fn_dis)(void))
  184. {
  185. return clk_register_gate_fn(NULL, name, "tclk", 0, CLOCK_GATING_CTRL,
  186. bit_idx, 0, &gating_lock, fn_en, fn_dis);
  187. }
  188. static struct clk *ge0, *ge1;
  189. void __init kirkwood_clk_init(void)
  190. {
  191. struct clk *runit, *sata0, *sata1, *usb0, *sdio;
  192. struct clk *crypto, *xor0, *xor1, *pex0, *pex1, *audio;
  193. tclk = clk_register_fixed_rate(NULL, "tclk", NULL,
  194. CLK_IS_ROOT, kirkwood_tclk);
  195. runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT);
  196. ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0);
  197. ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1);
  198. sata0 = kirkwood_register_gate_fn("sata0", CGC_BIT_SATA0,
  199. enable_sata0, disable_sata0);
  200. sata1 = kirkwood_register_gate_fn("sata1", CGC_BIT_SATA1,
  201. enable_sata1, disable_sata1);
  202. usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0);
  203. sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO);
  204. crypto = kirkwood_register_gate("crypto", CGC_BIT_CRYPTO);
  205. xor0 = kirkwood_register_gate("xor0", CGC_BIT_XOR0);
  206. xor1 = kirkwood_register_gate("xor1", CGC_BIT_XOR1);
  207. pex0 = kirkwood_register_gate_fn("pex0", CGC_BIT_PEX0,
  208. NULL, disable_pcie0);
  209. pex1 = kirkwood_register_gate_fn("pex1", CGC_BIT_PEX1,
  210. NULL, disable_pcie1);
  211. audio = kirkwood_register_gate("audio", CGC_BIT_AUDIO);
  212. kirkwood_register_gate("tdm", CGC_BIT_TDM);
  213. kirkwood_register_gate("tsu", CGC_BIT_TSU);
  214. /* clkdev entries, mapping clks to devices */
  215. orion_clkdev_add(NULL, "orion_spi.0", runit);
  216. orion_clkdev_add(NULL, "orion_spi.1", runit);
  217. orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", ge0);
  218. orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", ge1);
  219. orion_clkdev_add(NULL, "orion_wdt", tclk);
  220. orion_clkdev_add("0", "sata_mv.0", sata0);
  221. orion_clkdev_add("1", "sata_mv.0", sata1);
  222. orion_clkdev_add(NULL, "orion-ehci.0", usb0);
  223. orion_clkdev_add(NULL, "orion_nand", runit);
  224. orion_clkdev_add(NULL, "mvsdio", sdio);
  225. orion_clkdev_add(NULL, "mv_crypto", crypto);
  226. orion_clkdev_add(NULL, MV_XOR_NAME ".0", xor0);
  227. orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1);
  228. orion_clkdev_add("0", "pcie", pex0);
  229. orion_clkdev_add("1", "pcie", pex1);
  230. orion_clkdev_add(NULL, "kirkwood-i2s", audio);
  231. orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", runit);
  232. orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".1", runit);
  233. /* Marvell says runit is used by SPI, UART, NAND, TWSI, ...,
  234. * so should never be gated.
  235. */
  236. clk_prepare_enable(runit);
  237. }
  238. /*****************************************************************************
  239. * EHCI0
  240. ****************************************************************************/
  241. void __init kirkwood_ehci_init(void)
  242. {
  243. orion_ehci_init(USB_PHYS_BASE, IRQ_KIRKWOOD_USB, EHCI_PHY_NA);
  244. }
  245. /*****************************************************************************
  246. * GE00
  247. ****************************************************************************/
  248. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  249. {
  250. orion_ge00_init(eth_data,
  251. GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
  252. IRQ_KIRKWOOD_GE00_ERR, 1600);
  253. /* The interface forgets the MAC address assigned by u-boot if
  254. the clock is turned off, so claim the clk now. */
  255. clk_prepare_enable(ge0);
  256. }
  257. /*****************************************************************************
  258. * GE01
  259. ****************************************************************************/
  260. void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  261. {
  262. orion_ge01_init(eth_data,
  263. GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
  264. IRQ_KIRKWOOD_GE01_ERR, 1600);
  265. clk_prepare_enable(ge1);
  266. }
  267. /*****************************************************************************
  268. * Ethernet switch
  269. ****************************************************************************/
  270. void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
  271. {
  272. orion_ge00_switch_init(d, irq);
  273. }
  274. /*****************************************************************************
  275. * NAND flash
  276. ****************************************************************************/
  277. static struct resource kirkwood_nand_resource = {
  278. .flags = IORESOURCE_MEM,
  279. .start = KIRKWOOD_NAND_MEM_PHYS_BASE,
  280. .end = KIRKWOOD_NAND_MEM_PHYS_BASE +
  281. KIRKWOOD_NAND_MEM_SIZE - 1,
  282. };
  283. static struct orion_nand_data kirkwood_nand_data = {
  284. .cle = 0,
  285. .ale = 1,
  286. .width = 8,
  287. };
  288. static struct platform_device kirkwood_nand_flash = {
  289. .name = "orion_nand",
  290. .id = -1,
  291. .dev = {
  292. .platform_data = &kirkwood_nand_data,
  293. },
  294. .resource = &kirkwood_nand_resource,
  295. .num_resources = 1,
  296. };
  297. void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
  298. int chip_delay)
  299. {
  300. kirkwood_nand_data.parts = parts;
  301. kirkwood_nand_data.nr_parts = nr_parts;
  302. kirkwood_nand_data.chip_delay = chip_delay;
  303. platform_device_register(&kirkwood_nand_flash);
  304. }
  305. void __init kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts,
  306. int (*dev_ready)(struct mtd_info *))
  307. {
  308. kirkwood_nand_data.parts = parts;
  309. kirkwood_nand_data.nr_parts = nr_parts;
  310. kirkwood_nand_data.dev_ready = dev_ready;
  311. platform_device_register(&kirkwood_nand_flash);
  312. }
  313. /*****************************************************************************
  314. * SoC RTC
  315. ****************************************************************************/
  316. static void __init kirkwood_rtc_init(void)
  317. {
  318. orion_rtc_init(RTC_PHYS_BASE, IRQ_KIRKWOOD_RTC);
  319. }
  320. /*****************************************************************************
  321. * SATA
  322. ****************************************************************************/
  323. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  324. {
  325. orion_sata_init(sata_data, SATA_PHYS_BASE, IRQ_KIRKWOOD_SATA);
  326. }
  327. /*****************************************************************************
  328. * SD/SDIO/MMC
  329. ****************************************************************************/
  330. static struct resource mvsdio_resources[] = {
  331. [0] = {
  332. .start = SDIO_PHYS_BASE,
  333. .end = SDIO_PHYS_BASE + SZ_1K - 1,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. [1] = {
  337. .start = IRQ_KIRKWOOD_SDIO,
  338. .end = IRQ_KIRKWOOD_SDIO,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. };
  342. static u64 mvsdio_dmamask = DMA_BIT_MASK(32);
  343. static struct platform_device kirkwood_sdio = {
  344. .name = "mvsdio",
  345. .id = -1,
  346. .dev = {
  347. .dma_mask = &mvsdio_dmamask,
  348. .coherent_dma_mask = DMA_BIT_MASK(32),
  349. },
  350. .num_resources = ARRAY_SIZE(mvsdio_resources),
  351. .resource = mvsdio_resources,
  352. };
  353. void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
  354. {
  355. u32 dev, rev;
  356. kirkwood_pcie_id(&dev, &rev);
  357. if (rev == 0 && dev != MV88F6282_DEV_ID) /* catch all Kirkwood Z0's */
  358. mvsdio_data->clock = 100000000;
  359. else
  360. mvsdio_data->clock = 200000000;
  361. kirkwood_sdio.dev.platform_data = mvsdio_data;
  362. platform_device_register(&kirkwood_sdio);
  363. }
  364. /*****************************************************************************
  365. * SPI
  366. ****************************************************************************/
  367. void __init kirkwood_spi_init(void)
  368. {
  369. orion_spi_init(SPI_PHYS_BASE);
  370. }
  371. /*****************************************************************************
  372. * I2C
  373. ****************************************************************************/
  374. void __init kirkwood_i2c_init(void)
  375. {
  376. orion_i2c_init(I2C_PHYS_BASE, IRQ_KIRKWOOD_TWSI, 8);
  377. }
  378. /*****************************************************************************
  379. * UART0
  380. ****************************************************************************/
  381. void __init kirkwood_uart0_init(void)
  382. {
  383. orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
  384. IRQ_KIRKWOOD_UART_0, tclk);
  385. }
  386. /*****************************************************************************
  387. * UART1
  388. ****************************************************************************/
  389. void __init kirkwood_uart1_init(void)
  390. {
  391. orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
  392. IRQ_KIRKWOOD_UART_1, tclk);
  393. }
  394. /*****************************************************************************
  395. * Cryptographic Engines and Security Accelerator (CESA)
  396. ****************************************************************************/
  397. void __init kirkwood_crypto_init(void)
  398. {
  399. orion_crypto_init(CRYPTO_PHYS_BASE, KIRKWOOD_SRAM_PHYS_BASE,
  400. KIRKWOOD_SRAM_SIZE, IRQ_KIRKWOOD_CRYPTO);
  401. }
  402. /*****************************************************************************
  403. * XOR0
  404. ****************************************************************************/
  405. void __init kirkwood_xor0_init(void)
  406. {
  407. orion_xor0_init(XOR0_PHYS_BASE, XOR0_HIGH_PHYS_BASE,
  408. IRQ_KIRKWOOD_XOR_00, IRQ_KIRKWOOD_XOR_01);
  409. }
  410. /*****************************************************************************
  411. * XOR1
  412. ****************************************************************************/
  413. void __init kirkwood_xor1_init(void)
  414. {
  415. orion_xor1_init(XOR1_PHYS_BASE, XOR1_HIGH_PHYS_BASE,
  416. IRQ_KIRKWOOD_XOR_10, IRQ_KIRKWOOD_XOR_11);
  417. }
  418. /*****************************************************************************
  419. * Watchdog
  420. ****************************************************************************/
  421. void __init kirkwood_wdt_init(void)
  422. {
  423. orion_wdt_init();
  424. }
  425. /*****************************************************************************
  426. * CPU idle
  427. ****************************************************************************/
  428. static struct resource kirkwood_cpuidle_resource[] = {
  429. {
  430. .flags = IORESOURCE_MEM,
  431. .start = DDR_OPERATION_BASE,
  432. .end = DDR_OPERATION_BASE + 3,
  433. },
  434. };
  435. static struct platform_device kirkwood_cpuidle = {
  436. .name = "kirkwood_cpuidle",
  437. .id = -1,
  438. .resource = kirkwood_cpuidle_resource,
  439. .num_resources = 1,
  440. };
  441. void __init kirkwood_cpuidle_init(void)
  442. {
  443. platform_device_register(&kirkwood_cpuidle);
  444. }
  445. /*****************************************************************************
  446. * Time handling
  447. ****************************************************************************/
  448. void __init kirkwood_init_early(void)
  449. {
  450. orion_time_set_base(TIMER_VIRT_BASE);
  451. /*
  452. * Some Kirkwood devices allocate their coherent buffers from atomic
  453. * context. Increase size of atomic coherent pool to make sure such
  454. * the allocations won't fail.
  455. */
  456. init_dma_coherent_pool_size(SZ_1M);
  457. }
  458. int kirkwood_tclk;
  459. static int __init kirkwood_find_tclk(void)
  460. {
  461. u32 dev, rev;
  462. kirkwood_pcie_id(&dev, &rev);
  463. if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
  464. if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
  465. return 200000000;
  466. return 166666667;
  467. }
  468. void __init kirkwood_timer_init(void)
  469. {
  470. kirkwood_tclk = kirkwood_find_tclk();
  471. orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
  472. IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  473. }
  474. /*****************************************************************************
  475. * Audio
  476. ****************************************************************************/
  477. static struct resource kirkwood_i2s_resources[] = {
  478. [0] = {
  479. .start = AUDIO_PHYS_BASE,
  480. .end = AUDIO_PHYS_BASE + SZ_16K - 1,
  481. .flags = IORESOURCE_MEM,
  482. },
  483. [1] = {
  484. .start = IRQ_KIRKWOOD_I2S,
  485. .end = IRQ_KIRKWOOD_I2S,
  486. .flags = IORESOURCE_IRQ,
  487. },
  488. };
  489. static struct kirkwood_asoc_platform_data kirkwood_i2s_data = {
  490. .burst = 128,
  491. };
  492. static struct platform_device kirkwood_i2s_device = {
  493. .name = "kirkwood-i2s",
  494. .id = -1,
  495. .num_resources = ARRAY_SIZE(kirkwood_i2s_resources),
  496. .resource = kirkwood_i2s_resources,
  497. .dev = {
  498. .platform_data = &kirkwood_i2s_data,
  499. },
  500. };
  501. static struct platform_device kirkwood_pcm_device = {
  502. .name = "kirkwood-pcm-audio",
  503. .id = -1,
  504. };
  505. void __init kirkwood_audio_init(void)
  506. {
  507. platform_device_register(&kirkwood_i2s_device);
  508. platform_device_register(&kirkwood_pcm_device);
  509. }
  510. /*****************************************************************************
  511. * General
  512. ****************************************************************************/
  513. /*
  514. * Identify device ID and revision.
  515. */
  516. char * __init kirkwood_id(void)
  517. {
  518. u32 dev, rev;
  519. kirkwood_pcie_id(&dev, &rev);
  520. if (dev == MV88F6281_DEV_ID) {
  521. if (rev == MV88F6281_REV_Z0)
  522. return "MV88F6281-Z0";
  523. else if (rev == MV88F6281_REV_A0)
  524. return "MV88F6281-A0";
  525. else if (rev == MV88F6281_REV_A1)
  526. return "MV88F6281-A1";
  527. else
  528. return "MV88F6281-Rev-Unsupported";
  529. } else if (dev == MV88F6192_DEV_ID) {
  530. if (rev == MV88F6192_REV_Z0)
  531. return "MV88F6192-Z0";
  532. else if (rev == MV88F6192_REV_A0)
  533. return "MV88F6192-A0";
  534. else if (rev == MV88F6192_REV_A1)
  535. return "MV88F6192-A1";
  536. else
  537. return "MV88F6192-Rev-Unsupported";
  538. } else if (dev == MV88F6180_DEV_ID) {
  539. if (rev == MV88F6180_REV_A0)
  540. return "MV88F6180-Rev-A0";
  541. else if (rev == MV88F6180_REV_A1)
  542. return "MV88F6180-Rev-A1";
  543. else
  544. return "MV88F6180-Rev-Unsupported";
  545. } else if (dev == MV88F6282_DEV_ID) {
  546. if (rev == MV88F6282_REV_A0)
  547. return "MV88F6282-Rev-A0";
  548. else if (rev == MV88F6282_REV_A1)
  549. return "MV88F6282-Rev-A1";
  550. else
  551. return "MV88F6282-Rev-Unsupported";
  552. } else {
  553. return "Device-Unknown";
  554. }
  555. }
  556. void __init kirkwood_l2_init(void)
  557. {
  558. #ifdef CONFIG_CACHE_FEROCEON_L2
  559. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  560. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  561. feroceon_l2_init(1);
  562. #else
  563. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  564. feroceon_l2_init(0);
  565. #endif
  566. #endif
  567. }
  568. void __init kirkwood_init(void)
  569. {
  570. pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
  571. /*
  572. * Disable propagation of mbus errors to the CPU local bus,
  573. * as this causes mbus errors (which can occur for example
  574. * for PCI aborts) to throw CPU aborts, which we're not set
  575. * up to deal with.
  576. */
  577. writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  578. kirkwood_setup_cpu_mbus();
  579. kirkwood_l2_init();
  580. /* Setup root of clk tree */
  581. kirkwood_clk_init();
  582. /* internal devices that every board has */
  583. kirkwood_rtc_init();
  584. kirkwood_wdt_init();
  585. kirkwood_xor0_init();
  586. kirkwood_xor1_init();
  587. kirkwood_crypto_init();
  588. kirkwood_cpuidle_init();
  589. #ifdef CONFIG_KEXEC
  590. kexec_reinit = kirkwood_enable_pcie;
  591. #endif
  592. }
  593. void kirkwood_restart(char mode, const char *cmd)
  594. {
  595. /*
  596. * Enable soft reset to assert RSTOUTn.
  597. */
  598. writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
  599. /*
  600. * Assert soft reset.
  601. */
  602. writel(SOFT_RESET, SYSTEM_SOFT_RESET);
  603. while (1)
  604. ;
  605. }