common.c 19 KB

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