common.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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 = (unsigned long) 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 = (unsigned long) 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 = (unsigned long) 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, CLOCK_GATING_CTRL,
  188. bit_idx, 0, &gating_lock);
  189. }
  190. static struct clk __init *kirkwood_register_gate_fn(const char *name,
  191. u8 bit_idx,
  192. void (*fn_en)(void),
  193. void (*fn_dis)(void))
  194. {
  195. return clk_register_gate_fn(NULL, name, "tclk", 0, CLOCK_GATING_CTRL,
  196. bit_idx, 0, &gating_lock, fn_en, fn_dis);
  197. }
  198. static struct clk *ge0, *ge1;
  199. void __init kirkwood_clk_init(void)
  200. {
  201. struct clk *runit, *sata0, *sata1, *usb0, *sdio;
  202. struct clk *crypto, *xor0, *xor1, *pex0, *pex1, *audio;
  203. tclk = clk_register_fixed_rate(NULL, "tclk", NULL,
  204. CLK_IS_ROOT, kirkwood_tclk);
  205. runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT);
  206. ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0);
  207. ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1);
  208. sata0 = kirkwood_register_gate_fn("sata0", CGC_BIT_SATA0,
  209. enable_sata0, disable_sata0);
  210. sata1 = kirkwood_register_gate_fn("sata1", CGC_BIT_SATA1,
  211. enable_sata1, disable_sata1);
  212. usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0);
  213. sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO);
  214. crypto = kirkwood_register_gate("crypto", CGC_BIT_CRYPTO);
  215. xor0 = kirkwood_register_gate("xor0", CGC_BIT_XOR0);
  216. xor1 = kirkwood_register_gate("xor1", CGC_BIT_XOR1);
  217. pex0 = kirkwood_register_gate_fn("pex0", CGC_BIT_PEX0,
  218. NULL, disable_pcie0);
  219. pex1 = kirkwood_register_gate_fn("pex1", CGC_BIT_PEX1,
  220. NULL, disable_pcie1);
  221. audio = kirkwood_register_gate("audio", CGC_BIT_AUDIO);
  222. kirkwood_register_gate("tdm", CGC_BIT_TDM);
  223. kirkwood_register_gate("tsu", CGC_BIT_TSU);
  224. /* clkdev entries, mapping clks to devices */
  225. orion_clkdev_add(NULL, "orion_spi.0", runit);
  226. orion_clkdev_add(NULL, "orion_spi.1", runit);
  227. orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", ge0);
  228. orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", ge1);
  229. orion_clkdev_add(NULL, "orion_wdt", tclk);
  230. orion_clkdev_add("0", "sata_mv.0", sata0);
  231. orion_clkdev_add("1", "sata_mv.0", sata1);
  232. orion_clkdev_add(NULL, "orion-ehci.0", usb0);
  233. orion_clkdev_add(NULL, "orion_nand", runit);
  234. orion_clkdev_add(NULL, "mvsdio", sdio);
  235. orion_clkdev_add(NULL, "mv_crypto", crypto);
  236. orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".0", xor0);
  237. orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".1", xor1);
  238. orion_clkdev_add("0", "pcie", pex0);
  239. orion_clkdev_add("1", "pcie", pex1);
  240. orion_clkdev_add(NULL, "kirkwood-i2s", audio);
  241. orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", runit);
  242. /* Marvell says runit is used by SPI, UART, NAND, TWSI, ...,
  243. * so should never be gated.
  244. */
  245. clk_prepare_enable(runit);
  246. }
  247. /*****************************************************************************
  248. * EHCI0
  249. ****************************************************************************/
  250. void __init kirkwood_ehci_init(void)
  251. {
  252. orion_ehci_init(USB_PHYS_BASE, IRQ_KIRKWOOD_USB, EHCI_PHY_NA);
  253. }
  254. /*****************************************************************************
  255. * GE00
  256. ****************************************************************************/
  257. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  258. {
  259. orion_ge00_init(eth_data,
  260. GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
  261. IRQ_KIRKWOOD_GE00_ERR, 1600);
  262. /* The interface forgets the MAC address assigned by u-boot if
  263. the clock is turned off, so claim the clk now. */
  264. clk_prepare_enable(ge0);
  265. }
  266. /*****************************************************************************
  267. * GE01
  268. ****************************************************************************/
  269. void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  270. {
  271. orion_ge01_init(eth_data,
  272. GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
  273. IRQ_KIRKWOOD_GE01_ERR, 1600);
  274. clk_prepare_enable(ge1);
  275. }
  276. /*****************************************************************************
  277. * Ethernet switch
  278. ****************************************************************************/
  279. void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
  280. {
  281. orion_ge00_switch_init(d, irq);
  282. }
  283. /*****************************************************************************
  284. * NAND flash
  285. ****************************************************************************/
  286. static struct resource kirkwood_nand_resource = {
  287. .flags = IORESOURCE_MEM,
  288. .start = KIRKWOOD_NAND_MEM_PHYS_BASE,
  289. .end = KIRKWOOD_NAND_MEM_PHYS_BASE +
  290. KIRKWOOD_NAND_MEM_SIZE - 1,
  291. };
  292. static struct orion_nand_data kirkwood_nand_data = {
  293. .cle = 0,
  294. .ale = 1,
  295. .width = 8,
  296. };
  297. static struct platform_device kirkwood_nand_flash = {
  298. .name = "orion_nand",
  299. .id = -1,
  300. .dev = {
  301. .platform_data = &kirkwood_nand_data,
  302. },
  303. .resource = &kirkwood_nand_resource,
  304. .num_resources = 1,
  305. };
  306. void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts,
  307. int chip_delay)
  308. {
  309. kirkwood_nand_data.parts = parts;
  310. kirkwood_nand_data.nr_parts = nr_parts;
  311. kirkwood_nand_data.chip_delay = chip_delay;
  312. platform_device_register(&kirkwood_nand_flash);
  313. }
  314. void __init kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts,
  315. int (*dev_ready)(struct mtd_info *))
  316. {
  317. kirkwood_nand_data.parts = parts;
  318. kirkwood_nand_data.nr_parts = nr_parts;
  319. kirkwood_nand_data.dev_ready = dev_ready;
  320. platform_device_register(&kirkwood_nand_flash);
  321. }
  322. /*****************************************************************************
  323. * SoC RTC
  324. ****************************************************************************/
  325. static void __init kirkwood_rtc_init(void)
  326. {
  327. orion_rtc_init(RTC_PHYS_BASE, IRQ_KIRKWOOD_RTC);
  328. }
  329. /*****************************************************************************
  330. * SATA
  331. ****************************************************************************/
  332. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  333. {
  334. orion_sata_init(sata_data, SATA_PHYS_BASE, IRQ_KIRKWOOD_SATA);
  335. }
  336. /*****************************************************************************
  337. * SD/SDIO/MMC
  338. ****************************************************************************/
  339. static struct resource mvsdio_resources[] = {
  340. [0] = {
  341. .start = SDIO_PHYS_BASE,
  342. .end = SDIO_PHYS_BASE + SZ_1K - 1,
  343. .flags = IORESOURCE_MEM,
  344. },
  345. [1] = {
  346. .start = IRQ_KIRKWOOD_SDIO,
  347. .end = IRQ_KIRKWOOD_SDIO,
  348. .flags = IORESOURCE_IRQ,
  349. },
  350. };
  351. static u64 mvsdio_dmamask = DMA_BIT_MASK(32);
  352. static struct platform_device kirkwood_sdio = {
  353. .name = "mvsdio",
  354. .id = -1,
  355. .dev = {
  356. .dma_mask = &mvsdio_dmamask,
  357. .coherent_dma_mask = DMA_BIT_MASK(32),
  358. },
  359. .num_resources = ARRAY_SIZE(mvsdio_resources),
  360. .resource = mvsdio_resources,
  361. };
  362. void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
  363. {
  364. u32 dev, rev;
  365. kirkwood_pcie_id(&dev, &rev);
  366. if (rev == 0 && dev != MV88F6282_DEV_ID) /* catch all Kirkwood Z0's */
  367. mvsdio_data->clock = 100000000;
  368. else
  369. mvsdio_data->clock = 200000000;
  370. kirkwood_sdio.dev.platform_data = mvsdio_data;
  371. platform_device_register(&kirkwood_sdio);
  372. }
  373. /*****************************************************************************
  374. * SPI
  375. ****************************************************************************/
  376. void __init kirkwood_spi_init()
  377. {
  378. orion_spi_init(SPI_PHYS_BASE);
  379. }
  380. /*****************************************************************************
  381. * I2C
  382. ****************************************************************************/
  383. void __init kirkwood_i2c_init(void)
  384. {
  385. orion_i2c_init(I2C_PHYS_BASE, IRQ_KIRKWOOD_TWSI, 8);
  386. }
  387. /*****************************************************************************
  388. * UART0
  389. ****************************************************************************/
  390. void __init kirkwood_uart0_init(void)
  391. {
  392. orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
  393. IRQ_KIRKWOOD_UART_0, tclk);
  394. }
  395. /*****************************************************************************
  396. * UART1
  397. ****************************************************************************/
  398. void __init kirkwood_uart1_init(void)
  399. {
  400. orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
  401. IRQ_KIRKWOOD_UART_1, tclk);
  402. }
  403. /*****************************************************************************
  404. * Cryptographic Engines and Security Accelerator (CESA)
  405. ****************************************************************************/
  406. void __init kirkwood_crypto_init(void)
  407. {
  408. orion_crypto_init(CRYPTO_PHYS_BASE, KIRKWOOD_SRAM_PHYS_BASE,
  409. KIRKWOOD_SRAM_SIZE, IRQ_KIRKWOOD_CRYPTO);
  410. }
  411. /*****************************************************************************
  412. * XOR0
  413. ****************************************************************************/
  414. void __init kirkwood_xor0_init(void)
  415. {
  416. orion_xor0_init(XOR0_PHYS_BASE, XOR0_HIGH_PHYS_BASE,
  417. IRQ_KIRKWOOD_XOR_00, IRQ_KIRKWOOD_XOR_01);
  418. }
  419. /*****************************************************************************
  420. * XOR1
  421. ****************************************************************************/
  422. void __init kirkwood_xor1_init(void)
  423. {
  424. orion_xor1_init(XOR1_PHYS_BASE, XOR1_HIGH_PHYS_BASE,
  425. IRQ_KIRKWOOD_XOR_10, IRQ_KIRKWOOD_XOR_11);
  426. }
  427. /*****************************************************************************
  428. * Watchdog
  429. ****************************************************************************/
  430. void __init kirkwood_wdt_init(void)
  431. {
  432. orion_wdt_init();
  433. }
  434. /*****************************************************************************
  435. * Time handling
  436. ****************************************************************************/
  437. void __init kirkwood_init_early(void)
  438. {
  439. orion_time_set_base((unsigned long) TIMER_VIRT_BASE);
  440. /*
  441. * Some Kirkwood devices allocate their coherent buffers from atomic
  442. * context. Increase size of atomic coherent pool to make sure such
  443. * the allocations won't fail.
  444. */
  445. init_dma_coherent_pool_size(SZ_1M);
  446. }
  447. int kirkwood_tclk;
  448. static int __init kirkwood_find_tclk(void)
  449. {
  450. u32 dev, rev;
  451. kirkwood_pcie_id(&dev, &rev);
  452. if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
  453. if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
  454. return 200000000;
  455. return 166666667;
  456. }
  457. static void __init kirkwood_timer_init(void)
  458. {
  459. kirkwood_tclk = kirkwood_find_tclk();
  460. orion_time_init((unsigned long) BRIDGE_VIRT_BASE,
  461. BRIDGE_INT_TIMER1_CLR,
  462. IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  463. }
  464. struct sys_timer kirkwood_timer = {
  465. .init = kirkwood_timer_init,
  466. };
  467. /*****************************************************************************
  468. * Audio
  469. ****************************************************************************/
  470. static struct resource kirkwood_i2s_resources[] = {
  471. [0] = {
  472. .start = AUDIO_PHYS_BASE,
  473. .end = AUDIO_PHYS_BASE + SZ_16K - 1,
  474. .flags = IORESOURCE_MEM,
  475. },
  476. [1] = {
  477. .start = IRQ_KIRKWOOD_I2S,
  478. .end = IRQ_KIRKWOOD_I2S,
  479. .flags = IORESOURCE_IRQ,
  480. },
  481. };
  482. static struct kirkwood_asoc_platform_data kirkwood_i2s_data = {
  483. .burst = 128,
  484. };
  485. static struct platform_device kirkwood_i2s_device = {
  486. .name = "kirkwood-i2s",
  487. .id = -1,
  488. .num_resources = ARRAY_SIZE(kirkwood_i2s_resources),
  489. .resource = kirkwood_i2s_resources,
  490. .dev = {
  491. .platform_data = &kirkwood_i2s_data,
  492. },
  493. };
  494. static struct platform_device kirkwood_pcm_device = {
  495. .name = "kirkwood-pcm-audio",
  496. .id = -1,
  497. };
  498. void __init kirkwood_audio_init(void)
  499. {
  500. platform_device_register(&kirkwood_i2s_device);
  501. platform_device_register(&kirkwood_pcm_device);
  502. }
  503. /*****************************************************************************
  504. * General
  505. ****************************************************************************/
  506. /*
  507. * Identify device ID and revision.
  508. */
  509. char * __init kirkwood_id(void)
  510. {
  511. u32 dev, rev;
  512. kirkwood_pcie_id(&dev, &rev);
  513. if (dev == MV88F6281_DEV_ID) {
  514. if (rev == MV88F6281_REV_Z0)
  515. return "MV88F6281-Z0";
  516. else if (rev == MV88F6281_REV_A0)
  517. return "MV88F6281-A0";
  518. else if (rev == MV88F6281_REV_A1)
  519. return "MV88F6281-A1";
  520. else
  521. return "MV88F6281-Rev-Unsupported";
  522. } else if (dev == MV88F6192_DEV_ID) {
  523. if (rev == MV88F6192_REV_Z0)
  524. return "MV88F6192-Z0";
  525. else if (rev == MV88F6192_REV_A0)
  526. return "MV88F6192-A0";
  527. else if (rev == MV88F6192_REV_A1)
  528. return "MV88F6192-A1";
  529. else
  530. return "MV88F6192-Rev-Unsupported";
  531. } else if (dev == MV88F6180_DEV_ID) {
  532. if (rev == MV88F6180_REV_A0)
  533. return "MV88F6180-Rev-A0";
  534. else if (rev == MV88F6180_REV_A1)
  535. return "MV88F6180-Rev-A1";
  536. else
  537. return "MV88F6180-Rev-Unsupported";
  538. } else if (dev == MV88F6282_DEV_ID) {
  539. if (rev == MV88F6282_REV_A0)
  540. return "MV88F6282-Rev-A0";
  541. else if (rev == MV88F6282_REV_A1)
  542. return "MV88F6282-Rev-A1";
  543. else
  544. return "MV88F6282-Rev-Unsupported";
  545. } else {
  546. return "Device-Unknown";
  547. }
  548. }
  549. void __init kirkwood_l2_init(void)
  550. {
  551. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  552. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  553. feroceon_l2_init(1);
  554. #else
  555. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  556. feroceon_l2_init(0);
  557. #endif
  558. }
  559. void __init kirkwood_init(void)
  560. {
  561. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  562. kirkwood_id(), kirkwood_tclk);
  563. /*
  564. * Disable propagation of mbus errors to the CPU local bus,
  565. * as this causes mbus errors (which can occur for example
  566. * for PCI aborts) to throw CPU aborts, which we're not set
  567. * up to deal with.
  568. */
  569. writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  570. kirkwood_setup_cpu_mbus();
  571. #ifdef CONFIG_CACHE_FEROCEON_L2
  572. kirkwood_l2_init();
  573. #endif
  574. /* Setup root of clk tree */
  575. kirkwood_clk_init();
  576. /* internal devices that every board has */
  577. kirkwood_rtc_init();
  578. kirkwood_wdt_init();
  579. kirkwood_xor0_init();
  580. kirkwood_xor1_init();
  581. kirkwood_crypto_init();
  582. #ifdef CONFIG_KEXEC
  583. kexec_reinit = kirkwood_enable_pcie;
  584. #endif
  585. }
  586. void kirkwood_restart(char mode, const char *cmd)
  587. {
  588. /*
  589. * Enable soft reset to assert RSTOUTn.
  590. */
  591. writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK);
  592. /*
  593. * Assert soft reset.
  594. */
  595. writel(SOFT_RESET, SYSTEM_SOFT_RESET);
  596. while (1)
  597. ;
  598. }