common.c 26 KB

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