common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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/ata_platform.h>
  17. #include <linux/spi/orion_spi.h>
  18. #include <net/dsa.h>
  19. #include <asm/page.h>
  20. #include <asm/timex.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/mach/time.h>
  23. #include <mach/kirkwood.h>
  24. #include <plat/cache-feroceon-l2.h>
  25. #include <plat/ehci-orion.h>
  26. #include <plat/mv_xor.h>
  27. #include <plat/orion_nand.h>
  28. #include <plat/time.h>
  29. #include "common.h"
  30. /*****************************************************************************
  31. * I/O Address Mapping
  32. ****************************************************************************/
  33. static struct map_desc kirkwood_io_desc[] __initdata = {
  34. {
  35. .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
  36. .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
  37. .length = KIRKWOOD_PCIE_IO_SIZE,
  38. .type = MT_DEVICE,
  39. }, {
  40. .virtual = KIRKWOOD_REGS_VIRT_BASE,
  41. .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
  42. .length = KIRKWOOD_REGS_SIZE,
  43. .type = MT_DEVICE,
  44. },
  45. };
  46. void __init kirkwood_map_io(void)
  47. {
  48. iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
  49. }
  50. /*****************************************************************************
  51. * EHCI
  52. ****************************************************************************/
  53. static struct orion_ehci_data kirkwood_ehci_data = {
  54. .dram = &kirkwood_mbus_dram_info,
  55. .phy_version = EHCI_PHY_NA,
  56. };
  57. static u64 ehci_dmamask = 0xffffffffUL;
  58. /*****************************************************************************
  59. * EHCI0
  60. ****************************************************************************/
  61. static struct resource kirkwood_ehci_resources[] = {
  62. {
  63. .start = USB_PHYS_BASE,
  64. .end = USB_PHYS_BASE + 0x0fff,
  65. .flags = IORESOURCE_MEM,
  66. }, {
  67. .start = IRQ_KIRKWOOD_USB,
  68. .end = IRQ_KIRKWOOD_USB,
  69. .flags = IORESOURCE_IRQ,
  70. },
  71. };
  72. static struct platform_device kirkwood_ehci = {
  73. .name = "orion-ehci",
  74. .id = 0,
  75. .dev = {
  76. .dma_mask = &ehci_dmamask,
  77. .coherent_dma_mask = 0xffffffff,
  78. .platform_data = &kirkwood_ehci_data,
  79. },
  80. .resource = kirkwood_ehci_resources,
  81. .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
  82. };
  83. void __init kirkwood_ehci_init(void)
  84. {
  85. platform_device_register(&kirkwood_ehci);
  86. }
  87. /*****************************************************************************
  88. * GE00
  89. ****************************************************************************/
  90. struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
  91. .dram = &kirkwood_mbus_dram_info,
  92. };
  93. static struct resource kirkwood_ge00_shared_resources[] = {
  94. {
  95. .name = "ge00 base",
  96. .start = GE00_PHYS_BASE + 0x2000,
  97. .end = GE00_PHYS_BASE + 0x3fff,
  98. .flags = IORESOURCE_MEM,
  99. }, {
  100. .name = "ge00 err irq",
  101. .start = IRQ_KIRKWOOD_GE00_ERR,
  102. .end = IRQ_KIRKWOOD_GE00_ERR,
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device kirkwood_ge00_shared = {
  107. .name = MV643XX_ETH_SHARED_NAME,
  108. .id = 0,
  109. .dev = {
  110. .platform_data = &kirkwood_ge00_shared_data,
  111. },
  112. .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
  113. .resource = kirkwood_ge00_shared_resources,
  114. };
  115. static struct resource kirkwood_ge00_resources[] = {
  116. {
  117. .name = "ge00 irq",
  118. .start = IRQ_KIRKWOOD_GE00_SUM,
  119. .end = IRQ_KIRKWOOD_GE00_SUM,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device kirkwood_ge00 = {
  124. .name = MV643XX_ETH_NAME,
  125. .id = 0,
  126. .num_resources = 1,
  127. .resource = kirkwood_ge00_resources,
  128. };
  129. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  130. {
  131. eth_data->shared = &kirkwood_ge00_shared;
  132. kirkwood_ge00.dev.platform_data = eth_data;
  133. platform_device_register(&kirkwood_ge00_shared);
  134. platform_device_register(&kirkwood_ge00);
  135. }
  136. /*****************************************************************************
  137. * GE01
  138. ****************************************************************************/
  139. struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
  140. .dram = &kirkwood_mbus_dram_info,
  141. .shared_smi = &kirkwood_ge00_shared,
  142. };
  143. static struct resource kirkwood_ge01_shared_resources[] = {
  144. {
  145. .name = "ge01 base",
  146. .start = GE01_PHYS_BASE + 0x2000,
  147. .end = GE01_PHYS_BASE + 0x3fff,
  148. .flags = IORESOURCE_MEM,
  149. }, {
  150. .name = "ge01 err irq",
  151. .start = IRQ_KIRKWOOD_GE01_ERR,
  152. .end = IRQ_KIRKWOOD_GE01_ERR,
  153. .flags = IORESOURCE_IRQ,
  154. },
  155. };
  156. static struct platform_device kirkwood_ge01_shared = {
  157. .name = MV643XX_ETH_SHARED_NAME,
  158. .id = 1,
  159. .dev = {
  160. .platform_data = &kirkwood_ge01_shared_data,
  161. },
  162. .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
  163. .resource = kirkwood_ge01_shared_resources,
  164. };
  165. static struct resource kirkwood_ge01_resources[] = {
  166. {
  167. .name = "ge01 irq",
  168. .start = IRQ_KIRKWOOD_GE01_SUM,
  169. .end = IRQ_KIRKWOOD_GE01_SUM,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static struct platform_device kirkwood_ge01 = {
  174. .name = MV643XX_ETH_NAME,
  175. .id = 1,
  176. .num_resources = 1,
  177. .resource = kirkwood_ge01_resources,
  178. };
  179. void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  180. {
  181. eth_data->shared = &kirkwood_ge01_shared;
  182. kirkwood_ge01.dev.platform_data = eth_data;
  183. platform_device_register(&kirkwood_ge01_shared);
  184. platform_device_register(&kirkwood_ge01);
  185. }
  186. /*****************************************************************************
  187. * Ethernet switch
  188. ****************************************************************************/
  189. static struct resource kirkwood_switch_resources[] = {
  190. {
  191. .start = 0,
  192. .end = 0,
  193. .flags = IORESOURCE_IRQ,
  194. },
  195. };
  196. static struct platform_device kirkwood_switch_device = {
  197. .name = "dsa",
  198. .id = 0,
  199. .num_resources = 0,
  200. .resource = kirkwood_switch_resources,
  201. };
  202. void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
  203. {
  204. if (irq != NO_IRQ) {
  205. kirkwood_switch_resources[0].start = irq;
  206. kirkwood_switch_resources[0].end = irq;
  207. kirkwood_switch_device.num_resources = 1;
  208. }
  209. d->mii_bus = &kirkwood_ge00_shared.dev;
  210. d->netdev = &kirkwood_ge00.dev;
  211. kirkwood_switch_device.dev.platform_data = d;
  212. platform_device_register(&kirkwood_switch_device);
  213. }
  214. /*****************************************************************************
  215. * SoC RTC
  216. ****************************************************************************/
  217. static struct resource kirkwood_rtc_resource = {
  218. .start = RTC_PHYS_BASE,
  219. .end = RTC_PHYS_BASE + SZ_16 - 1,
  220. .flags = IORESOURCE_MEM,
  221. };
  222. void __init kirkwood_rtc_init(void)
  223. {
  224. platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
  225. }
  226. /*****************************************************************************
  227. * SATA
  228. ****************************************************************************/
  229. static struct resource kirkwood_sata_resources[] = {
  230. {
  231. .name = "sata base",
  232. .start = SATA_PHYS_BASE,
  233. .end = SATA_PHYS_BASE + 0x5000 - 1,
  234. .flags = IORESOURCE_MEM,
  235. }, {
  236. .name = "sata irq",
  237. .start = IRQ_KIRKWOOD_SATA,
  238. .end = IRQ_KIRKWOOD_SATA,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. static struct platform_device kirkwood_sata = {
  243. .name = "sata_mv",
  244. .id = 0,
  245. .dev = {
  246. .coherent_dma_mask = 0xffffffff,
  247. },
  248. .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
  249. .resource = kirkwood_sata_resources,
  250. };
  251. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  252. {
  253. sata_data->dram = &kirkwood_mbus_dram_info;
  254. kirkwood_sata.dev.platform_data = sata_data;
  255. platform_device_register(&kirkwood_sata);
  256. }
  257. /*****************************************************************************
  258. * SPI
  259. ****************************************************************************/
  260. static struct orion_spi_info kirkwood_spi_plat_data = {
  261. };
  262. static struct resource kirkwood_spi_resources[] = {
  263. {
  264. .start = SPI_PHYS_BASE,
  265. .end = SPI_PHYS_BASE + SZ_512 - 1,
  266. .flags = IORESOURCE_MEM,
  267. },
  268. };
  269. static struct platform_device kirkwood_spi = {
  270. .name = "orion_spi",
  271. .id = 0,
  272. .resource = kirkwood_spi_resources,
  273. .dev = {
  274. .platform_data = &kirkwood_spi_plat_data,
  275. },
  276. .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
  277. };
  278. void __init kirkwood_spi_init()
  279. {
  280. platform_device_register(&kirkwood_spi);
  281. }
  282. /*****************************************************************************
  283. * UART0
  284. ****************************************************************************/
  285. static struct plat_serial8250_port kirkwood_uart0_data[] = {
  286. {
  287. .mapbase = UART0_PHYS_BASE,
  288. .membase = (char *)UART0_VIRT_BASE,
  289. .irq = IRQ_KIRKWOOD_UART_0,
  290. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  291. .iotype = UPIO_MEM,
  292. .regshift = 2,
  293. .uartclk = 0,
  294. }, {
  295. },
  296. };
  297. static struct resource kirkwood_uart0_resources[] = {
  298. {
  299. .start = UART0_PHYS_BASE,
  300. .end = UART0_PHYS_BASE + 0xff,
  301. .flags = IORESOURCE_MEM,
  302. }, {
  303. .start = IRQ_KIRKWOOD_UART_0,
  304. .end = IRQ_KIRKWOOD_UART_0,
  305. .flags = IORESOURCE_IRQ,
  306. },
  307. };
  308. static struct platform_device kirkwood_uart0 = {
  309. .name = "serial8250",
  310. .id = 0,
  311. .dev = {
  312. .platform_data = kirkwood_uart0_data,
  313. },
  314. .resource = kirkwood_uart0_resources,
  315. .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
  316. };
  317. void __init kirkwood_uart0_init(void)
  318. {
  319. platform_device_register(&kirkwood_uart0);
  320. }
  321. /*****************************************************************************
  322. * UART1
  323. ****************************************************************************/
  324. static struct plat_serial8250_port kirkwood_uart1_data[] = {
  325. {
  326. .mapbase = UART1_PHYS_BASE,
  327. .membase = (char *)UART1_VIRT_BASE,
  328. .irq = IRQ_KIRKWOOD_UART_1,
  329. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  330. .iotype = UPIO_MEM,
  331. .regshift = 2,
  332. .uartclk = 0,
  333. }, {
  334. },
  335. };
  336. static struct resource kirkwood_uart1_resources[] = {
  337. {
  338. .start = UART1_PHYS_BASE,
  339. .end = UART1_PHYS_BASE + 0xff,
  340. .flags = IORESOURCE_MEM,
  341. }, {
  342. .start = IRQ_KIRKWOOD_UART_1,
  343. .end = IRQ_KIRKWOOD_UART_1,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct platform_device kirkwood_uart1 = {
  348. .name = "serial8250",
  349. .id = 1,
  350. .dev = {
  351. .platform_data = kirkwood_uart1_data,
  352. },
  353. .resource = kirkwood_uart1_resources,
  354. .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
  355. };
  356. void __init kirkwood_uart1_init(void)
  357. {
  358. platform_device_register(&kirkwood_uart1);
  359. }
  360. /*****************************************************************************
  361. * XOR
  362. ****************************************************************************/
  363. static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
  364. .dram = &kirkwood_mbus_dram_info,
  365. };
  366. static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
  367. /*****************************************************************************
  368. * XOR0
  369. ****************************************************************************/
  370. static struct resource kirkwood_xor0_shared_resources[] = {
  371. {
  372. .name = "xor 0 low",
  373. .start = XOR0_PHYS_BASE,
  374. .end = XOR0_PHYS_BASE + 0xff,
  375. .flags = IORESOURCE_MEM,
  376. }, {
  377. .name = "xor 0 high",
  378. .start = XOR0_HIGH_PHYS_BASE,
  379. .end = XOR0_HIGH_PHYS_BASE + 0xff,
  380. .flags = IORESOURCE_MEM,
  381. },
  382. };
  383. static struct platform_device kirkwood_xor0_shared = {
  384. .name = MV_XOR_SHARED_NAME,
  385. .id = 0,
  386. .dev = {
  387. .platform_data = &kirkwood_xor_shared_data,
  388. },
  389. .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
  390. .resource = kirkwood_xor0_shared_resources,
  391. };
  392. static struct resource kirkwood_xor00_resources[] = {
  393. [0] = {
  394. .start = IRQ_KIRKWOOD_XOR_00,
  395. .end = IRQ_KIRKWOOD_XOR_00,
  396. .flags = IORESOURCE_IRQ,
  397. },
  398. };
  399. static struct mv_xor_platform_data kirkwood_xor00_data = {
  400. .shared = &kirkwood_xor0_shared,
  401. .hw_id = 0,
  402. .pool_size = PAGE_SIZE,
  403. };
  404. static struct platform_device kirkwood_xor00_channel = {
  405. .name = MV_XOR_NAME,
  406. .id = 0,
  407. .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
  408. .resource = kirkwood_xor00_resources,
  409. .dev = {
  410. .dma_mask = &kirkwood_xor_dmamask,
  411. .coherent_dma_mask = DMA_64BIT_MASK,
  412. .platform_data = (void *)&kirkwood_xor00_data,
  413. },
  414. };
  415. static struct resource kirkwood_xor01_resources[] = {
  416. [0] = {
  417. .start = IRQ_KIRKWOOD_XOR_01,
  418. .end = IRQ_KIRKWOOD_XOR_01,
  419. .flags = IORESOURCE_IRQ,
  420. },
  421. };
  422. static struct mv_xor_platform_data kirkwood_xor01_data = {
  423. .shared = &kirkwood_xor0_shared,
  424. .hw_id = 1,
  425. .pool_size = PAGE_SIZE,
  426. };
  427. static struct platform_device kirkwood_xor01_channel = {
  428. .name = MV_XOR_NAME,
  429. .id = 1,
  430. .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
  431. .resource = kirkwood_xor01_resources,
  432. .dev = {
  433. .dma_mask = &kirkwood_xor_dmamask,
  434. .coherent_dma_mask = DMA_64BIT_MASK,
  435. .platform_data = (void *)&kirkwood_xor01_data,
  436. },
  437. };
  438. void __init kirkwood_xor0_init(void)
  439. {
  440. platform_device_register(&kirkwood_xor0_shared);
  441. /*
  442. * two engines can't do memset simultaneously, this limitation
  443. * satisfied by removing memset support from one of the engines.
  444. */
  445. dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
  446. dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
  447. platform_device_register(&kirkwood_xor00_channel);
  448. dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
  449. dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
  450. dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
  451. platform_device_register(&kirkwood_xor01_channel);
  452. }
  453. /*****************************************************************************
  454. * XOR1
  455. ****************************************************************************/
  456. static struct resource kirkwood_xor1_shared_resources[] = {
  457. {
  458. .name = "xor 1 low",
  459. .start = XOR1_PHYS_BASE,
  460. .end = XOR1_PHYS_BASE + 0xff,
  461. .flags = IORESOURCE_MEM,
  462. }, {
  463. .name = "xor 1 high",
  464. .start = XOR1_HIGH_PHYS_BASE,
  465. .end = XOR1_HIGH_PHYS_BASE + 0xff,
  466. .flags = IORESOURCE_MEM,
  467. },
  468. };
  469. static struct platform_device kirkwood_xor1_shared = {
  470. .name = MV_XOR_SHARED_NAME,
  471. .id = 1,
  472. .dev = {
  473. .platform_data = &kirkwood_xor_shared_data,
  474. },
  475. .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
  476. .resource = kirkwood_xor1_shared_resources,
  477. };
  478. static struct resource kirkwood_xor10_resources[] = {
  479. [0] = {
  480. .start = IRQ_KIRKWOOD_XOR_10,
  481. .end = IRQ_KIRKWOOD_XOR_10,
  482. .flags = IORESOURCE_IRQ,
  483. },
  484. };
  485. static struct mv_xor_platform_data kirkwood_xor10_data = {
  486. .shared = &kirkwood_xor1_shared,
  487. .hw_id = 0,
  488. .pool_size = PAGE_SIZE,
  489. };
  490. static struct platform_device kirkwood_xor10_channel = {
  491. .name = MV_XOR_NAME,
  492. .id = 2,
  493. .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
  494. .resource = kirkwood_xor10_resources,
  495. .dev = {
  496. .dma_mask = &kirkwood_xor_dmamask,
  497. .coherent_dma_mask = DMA_64BIT_MASK,
  498. .platform_data = (void *)&kirkwood_xor10_data,
  499. },
  500. };
  501. static struct resource kirkwood_xor11_resources[] = {
  502. [0] = {
  503. .start = IRQ_KIRKWOOD_XOR_11,
  504. .end = IRQ_KIRKWOOD_XOR_11,
  505. .flags = IORESOURCE_IRQ,
  506. },
  507. };
  508. static struct mv_xor_platform_data kirkwood_xor11_data = {
  509. .shared = &kirkwood_xor1_shared,
  510. .hw_id = 1,
  511. .pool_size = PAGE_SIZE,
  512. };
  513. static struct platform_device kirkwood_xor11_channel = {
  514. .name = MV_XOR_NAME,
  515. .id = 3,
  516. .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
  517. .resource = kirkwood_xor11_resources,
  518. .dev = {
  519. .dma_mask = &kirkwood_xor_dmamask,
  520. .coherent_dma_mask = DMA_64BIT_MASK,
  521. .platform_data = (void *)&kirkwood_xor11_data,
  522. },
  523. };
  524. void __init kirkwood_xor1_init(void)
  525. {
  526. platform_device_register(&kirkwood_xor1_shared);
  527. /*
  528. * two engines can't do memset simultaneously, this limitation
  529. * satisfied by removing memset support from one of the engines.
  530. */
  531. dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
  532. dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
  533. platform_device_register(&kirkwood_xor10_channel);
  534. dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
  535. dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
  536. dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
  537. platform_device_register(&kirkwood_xor11_channel);
  538. }
  539. /*****************************************************************************
  540. * Time handling
  541. ****************************************************************************/
  542. int kirkwood_tclk;
  543. int __init kirkwood_find_tclk(void)
  544. {
  545. u32 dev, rev;
  546. kirkwood_pcie_id(&dev, &rev);
  547. if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
  548. return 200000000;
  549. return 166666667;
  550. }
  551. static void kirkwood_timer_init(void)
  552. {
  553. kirkwood_tclk = kirkwood_find_tclk();
  554. orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  555. }
  556. struct sys_timer kirkwood_timer = {
  557. .init = kirkwood_timer_init,
  558. };
  559. /*****************************************************************************
  560. * General
  561. ****************************************************************************/
  562. /*
  563. * Identify device ID and revision.
  564. */
  565. static char * __init kirkwood_id(void)
  566. {
  567. u32 dev, rev;
  568. kirkwood_pcie_id(&dev, &rev);
  569. if (dev == MV88F6281_DEV_ID) {
  570. if (rev == MV88F6281_REV_Z0)
  571. return "MV88F6281-Z0";
  572. else if (rev == MV88F6281_REV_A0)
  573. return "MV88F6281-A0";
  574. else
  575. return "MV88F6281-Rev-Unsupported";
  576. } else if (dev == MV88F6192_DEV_ID) {
  577. if (rev == MV88F6192_REV_Z0)
  578. return "MV88F6192-Z0";
  579. else if (rev == MV88F6192_REV_A0)
  580. return "MV88F6192-A0";
  581. else
  582. return "MV88F6192-Rev-Unsupported";
  583. } else if (dev == MV88F6180_DEV_ID) {
  584. if (rev == MV88F6180_REV_A0)
  585. return "MV88F6180-Rev-A0";
  586. else
  587. return "MV88F6180-Rev-Unsupported";
  588. } else {
  589. return "Device-Unknown";
  590. }
  591. }
  592. static void __init kirkwood_l2_init(void)
  593. {
  594. #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
  595. writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
  596. feroceon_l2_init(1);
  597. #else
  598. writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
  599. feroceon_l2_init(0);
  600. #endif
  601. }
  602. void __init kirkwood_init(void)
  603. {
  604. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  605. kirkwood_id(), kirkwood_tclk);
  606. kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
  607. kirkwood_spi_plat_data.tclk = kirkwood_tclk;
  608. kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
  609. kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
  610. kirkwood_setup_cpu_mbus();
  611. #ifdef CONFIG_CACHE_FEROCEON_L2
  612. kirkwood_l2_init();
  613. #endif
  614. }