common.c 26 KB

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