common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. * arch/arm/mach-orion5x/common.c
  3. *
  4. * Core functions for Marvell Orion 5x SoCs
  5. *
  6. * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/serial_8250.h>
  16. #include <linux/mbus.h>
  17. #include <linux/mv643xx_eth.h>
  18. #include <linux/mv643xx_i2c.h>
  19. #include <linux/ata_platform.h>
  20. #include <linux/spi/orion_spi.h>
  21. #include <net/dsa.h>
  22. #include <asm/page.h>
  23. #include <asm/setup.h>
  24. #include <asm/timex.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/time.h>
  28. #include <mach/hardware.h>
  29. #include <mach/orion5x.h>
  30. #include <plat/ehci-orion.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 orion5x_io_desc[] __initdata = {
  40. {
  41. .virtual = ORION5X_REGS_VIRT_BASE,
  42. .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE),
  43. .length = ORION5X_REGS_SIZE,
  44. .type = MT_DEVICE,
  45. }, {
  46. .virtual = ORION5X_PCIE_IO_VIRT_BASE,
  47. .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE),
  48. .length = ORION5X_PCIE_IO_SIZE,
  49. .type = MT_DEVICE,
  50. }, {
  51. .virtual = ORION5X_PCI_IO_VIRT_BASE,
  52. .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE),
  53. .length = ORION5X_PCI_IO_SIZE,
  54. .type = MT_DEVICE,
  55. }, {
  56. .virtual = ORION5X_PCIE_WA_VIRT_BASE,
  57. .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),
  58. .length = ORION5X_PCIE_WA_SIZE,
  59. .type = MT_DEVICE,
  60. },
  61. };
  62. void __init orion5x_map_io(void)
  63. {
  64. iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
  65. }
  66. /*****************************************************************************
  67. * EHCI
  68. ****************************************************************************/
  69. static struct orion_ehci_data orion5x_ehci_data = {
  70. .dram = &orion5x_mbus_dram_info,
  71. .phy_version = EHCI_PHY_ORION,
  72. };
  73. static u64 ehci_dmamask = 0xffffffffUL;
  74. /*****************************************************************************
  75. * EHCI0
  76. ****************************************************************************/
  77. static struct resource orion5x_ehci0_resources[] = {
  78. {
  79. .start = ORION5X_USB0_PHYS_BASE,
  80. .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1,
  81. .flags = IORESOURCE_MEM,
  82. }, {
  83. .start = IRQ_ORION5X_USB0_CTRL,
  84. .end = IRQ_ORION5X_USB0_CTRL,
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. static struct platform_device orion5x_ehci0 = {
  89. .name = "orion-ehci",
  90. .id = 0,
  91. .dev = {
  92. .dma_mask = &ehci_dmamask,
  93. .coherent_dma_mask = 0xffffffff,
  94. .platform_data = &orion5x_ehci_data,
  95. },
  96. .resource = orion5x_ehci0_resources,
  97. .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
  98. };
  99. void __init orion5x_ehci0_init(void)
  100. {
  101. platform_device_register(&orion5x_ehci0);
  102. }
  103. /*****************************************************************************
  104. * EHCI1
  105. ****************************************************************************/
  106. static struct resource orion5x_ehci1_resources[] = {
  107. {
  108. .start = ORION5X_USB1_PHYS_BASE,
  109. .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
  110. .flags = IORESOURCE_MEM,
  111. }, {
  112. .start = IRQ_ORION5X_USB1_CTRL,
  113. .end = IRQ_ORION5X_USB1_CTRL,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device orion5x_ehci1 = {
  118. .name = "orion-ehci",
  119. .id = 1,
  120. .dev = {
  121. .dma_mask = &ehci_dmamask,
  122. .coherent_dma_mask = 0xffffffff,
  123. .platform_data = &orion5x_ehci_data,
  124. },
  125. .resource = orion5x_ehci1_resources,
  126. .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
  127. };
  128. void __init orion5x_ehci1_init(void)
  129. {
  130. platform_device_register(&orion5x_ehci1);
  131. }
  132. /*****************************************************************************
  133. * GigE
  134. ****************************************************************************/
  135. struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
  136. .dram = &orion5x_mbus_dram_info,
  137. };
  138. static struct resource orion5x_eth_shared_resources[] = {
  139. {
  140. .start = ORION5X_ETH_PHYS_BASE + 0x2000,
  141. .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
  142. .flags = IORESOURCE_MEM,
  143. }, {
  144. .start = IRQ_ORION5X_ETH_ERR,
  145. .end = IRQ_ORION5X_ETH_ERR,
  146. .flags = IORESOURCE_IRQ,
  147. },
  148. };
  149. static struct platform_device orion5x_eth_shared = {
  150. .name = MV643XX_ETH_SHARED_NAME,
  151. .id = 0,
  152. .dev = {
  153. .platform_data = &orion5x_eth_shared_data,
  154. },
  155. .num_resources = ARRAY_SIZE(orion5x_eth_shared_resources),
  156. .resource = orion5x_eth_shared_resources,
  157. };
  158. static struct resource orion5x_eth_resources[] = {
  159. {
  160. .name = "eth irq",
  161. .start = IRQ_ORION5X_ETH_SUM,
  162. .end = IRQ_ORION5X_ETH_SUM,
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. static struct platform_device orion5x_eth = {
  167. .name = MV643XX_ETH_NAME,
  168. .id = 0,
  169. .num_resources = 1,
  170. .resource = orion5x_eth_resources,
  171. .dev = {
  172. .coherent_dma_mask = 0xffffffff,
  173. },
  174. };
  175. void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
  176. {
  177. eth_data->shared = &orion5x_eth_shared;
  178. orion5x_eth.dev.platform_data = eth_data;
  179. platform_device_register(&orion5x_eth_shared);
  180. platform_device_register(&orion5x_eth);
  181. }
  182. /*****************************************************************************
  183. * Ethernet switch
  184. ****************************************************************************/
  185. static struct resource orion5x_switch_resources[] = {
  186. {
  187. .start = 0,
  188. .end = 0,
  189. .flags = IORESOURCE_IRQ,
  190. },
  191. };
  192. static struct platform_device orion5x_switch_device = {
  193. .name = "dsa",
  194. .id = 0,
  195. .num_resources = 0,
  196. .resource = orion5x_switch_resources,
  197. };
  198. void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq)
  199. {
  200. int i;
  201. if (irq != NO_IRQ) {
  202. orion5x_switch_resources[0].start = irq;
  203. orion5x_switch_resources[0].end = irq;
  204. orion5x_switch_device.num_resources = 1;
  205. }
  206. d->netdev = &orion5x_eth.dev;
  207. for (i = 0; i < d->nr_chips; i++)
  208. d->chip[i].mii_bus = &orion5x_eth_shared.dev;
  209. orion5x_switch_device.dev.platform_data = d;
  210. platform_device_register(&orion5x_switch_device);
  211. }
  212. /*****************************************************************************
  213. * I2C
  214. ****************************************************************************/
  215. static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
  216. .freq_m = 8, /* assumes 166 MHz TCLK */
  217. .freq_n = 3,
  218. .timeout = 1000, /* Default timeout of 1 second */
  219. };
  220. static struct resource orion5x_i2c_resources[] = {
  221. {
  222. .start = I2C_PHYS_BASE,
  223. .end = I2C_PHYS_BASE + 0x1f,
  224. .flags = IORESOURCE_MEM,
  225. }, {
  226. .start = IRQ_ORION5X_I2C,
  227. .end = IRQ_ORION5X_I2C,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. };
  231. static struct platform_device orion5x_i2c = {
  232. .name = MV64XXX_I2C_CTLR_NAME,
  233. .id = 0,
  234. .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
  235. .resource = orion5x_i2c_resources,
  236. .dev = {
  237. .platform_data = &orion5x_i2c_pdata,
  238. },
  239. };
  240. void __init orion5x_i2c_init(void)
  241. {
  242. platform_device_register(&orion5x_i2c);
  243. }
  244. /*****************************************************************************
  245. * SATA
  246. ****************************************************************************/
  247. static struct resource orion5x_sata_resources[] = {
  248. {
  249. .name = "sata base",
  250. .start = ORION5X_SATA_PHYS_BASE,
  251. .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
  252. .flags = IORESOURCE_MEM,
  253. }, {
  254. .name = "sata irq",
  255. .start = IRQ_ORION5X_SATA,
  256. .end = IRQ_ORION5X_SATA,
  257. .flags = IORESOURCE_IRQ,
  258. },
  259. };
  260. static struct platform_device orion5x_sata = {
  261. .name = "sata_mv",
  262. .id = 0,
  263. .dev = {
  264. .coherent_dma_mask = 0xffffffff,
  265. },
  266. .num_resources = ARRAY_SIZE(orion5x_sata_resources),
  267. .resource = orion5x_sata_resources,
  268. };
  269. void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
  270. {
  271. sata_data->dram = &orion5x_mbus_dram_info;
  272. orion5x_sata.dev.platform_data = sata_data;
  273. platform_device_register(&orion5x_sata);
  274. }
  275. /*****************************************************************************
  276. * SPI
  277. ****************************************************************************/
  278. static struct orion_spi_info orion5x_spi_plat_data = {
  279. .tclk = 0,
  280. .enable_clock_fix = 1,
  281. };
  282. static struct resource orion5x_spi_resources[] = {
  283. {
  284. .name = "spi base",
  285. .start = SPI_PHYS_BASE,
  286. .end = SPI_PHYS_BASE + 0x1f,
  287. .flags = IORESOURCE_MEM,
  288. },
  289. };
  290. static struct platform_device orion5x_spi = {
  291. .name = "orion_spi",
  292. .id = 0,
  293. .dev = {
  294. .platform_data = &orion5x_spi_plat_data,
  295. },
  296. .num_resources = ARRAY_SIZE(orion5x_spi_resources),
  297. .resource = orion5x_spi_resources,
  298. };
  299. void __init orion5x_spi_init()
  300. {
  301. platform_device_register(&orion5x_spi);
  302. }
  303. /*****************************************************************************
  304. * UART0
  305. ****************************************************************************/
  306. static struct plat_serial8250_port orion5x_uart0_data[] = {
  307. {
  308. .mapbase = UART0_PHYS_BASE,
  309. .membase = (char *)UART0_VIRT_BASE,
  310. .irq = IRQ_ORION5X_UART0,
  311. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  312. .iotype = UPIO_MEM,
  313. .regshift = 2,
  314. .uartclk = 0,
  315. }, {
  316. },
  317. };
  318. static struct resource orion5x_uart0_resources[] = {
  319. {
  320. .start = UART0_PHYS_BASE,
  321. .end = UART0_PHYS_BASE + 0xff,
  322. .flags = IORESOURCE_MEM,
  323. }, {
  324. .start = IRQ_ORION5X_UART0,
  325. .end = IRQ_ORION5X_UART0,
  326. .flags = IORESOURCE_IRQ,
  327. },
  328. };
  329. static struct platform_device orion5x_uart0 = {
  330. .name = "serial8250",
  331. .id = PLAT8250_DEV_PLATFORM,
  332. .dev = {
  333. .platform_data = orion5x_uart0_data,
  334. },
  335. .resource = orion5x_uart0_resources,
  336. .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
  337. };
  338. void __init orion5x_uart0_init(void)
  339. {
  340. platform_device_register(&orion5x_uart0);
  341. }
  342. /*****************************************************************************
  343. * UART1
  344. ****************************************************************************/
  345. static struct plat_serial8250_port orion5x_uart1_data[] = {
  346. {
  347. .mapbase = UART1_PHYS_BASE,
  348. .membase = (char *)UART1_VIRT_BASE,
  349. .irq = IRQ_ORION5X_UART1,
  350. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  351. .iotype = UPIO_MEM,
  352. .regshift = 2,
  353. .uartclk = 0,
  354. }, {
  355. },
  356. };
  357. static struct resource orion5x_uart1_resources[] = {
  358. {
  359. .start = UART1_PHYS_BASE,
  360. .end = UART1_PHYS_BASE + 0xff,
  361. .flags = IORESOURCE_MEM,
  362. }, {
  363. .start = IRQ_ORION5X_UART1,
  364. .end = IRQ_ORION5X_UART1,
  365. .flags = IORESOURCE_IRQ,
  366. },
  367. };
  368. static struct platform_device orion5x_uart1 = {
  369. .name = "serial8250",
  370. .id = PLAT8250_DEV_PLATFORM1,
  371. .dev = {
  372. .platform_data = orion5x_uart1_data,
  373. },
  374. .resource = orion5x_uart1_resources,
  375. .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
  376. };
  377. void __init orion5x_uart1_init(void)
  378. {
  379. platform_device_register(&orion5x_uart1);
  380. }
  381. /*****************************************************************************
  382. * XOR engine
  383. ****************************************************************************/
  384. struct mv_xor_platform_shared_data orion5x_xor_shared_data = {
  385. .dram = &orion5x_mbus_dram_info,
  386. };
  387. static struct resource orion5x_xor_shared_resources[] = {
  388. {
  389. .name = "xor low",
  390. .start = ORION5X_XOR_PHYS_BASE,
  391. .end = ORION5X_XOR_PHYS_BASE + 0xff,
  392. .flags = IORESOURCE_MEM,
  393. }, {
  394. .name = "xor high",
  395. .start = ORION5X_XOR_PHYS_BASE + 0x200,
  396. .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
  397. .flags = IORESOURCE_MEM,
  398. },
  399. };
  400. static struct platform_device orion5x_xor_shared = {
  401. .name = MV_XOR_SHARED_NAME,
  402. .id = 0,
  403. .dev = {
  404. .platform_data = &orion5x_xor_shared_data,
  405. },
  406. .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
  407. .resource = orion5x_xor_shared_resources,
  408. };
  409. static u64 orion5x_xor_dmamask = DMA_BIT_MASK(32);
  410. static struct resource orion5x_xor0_resources[] = {
  411. [0] = {
  412. .start = IRQ_ORION5X_XOR0,
  413. .end = IRQ_ORION5X_XOR0,
  414. .flags = IORESOURCE_IRQ,
  415. },
  416. };
  417. static struct mv_xor_platform_data orion5x_xor0_data = {
  418. .shared = &orion5x_xor_shared,
  419. .hw_id = 0,
  420. .pool_size = PAGE_SIZE,
  421. };
  422. static struct platform_device orion5x_xor0_channel = {
  423. .name = MV_XOR_NAME,
  424. .id = 0,
  425. .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
  426. .resource = orion5x_xor0_resources,
  427. .dev = {
  428. .dma_mask = &orion5x_xor_dmamask,
  429. .coherent_dma_mask = DMA_BIT_MASK(64),
  430. .platform_data = (void *)&orion5x_xor0_data,
  431. },
  432. };
  433. static struct resource orion5x_xor1_resources[] = {
  434. [0] = {
  435. .start = IRQ_ORION5X_XOR1,
  436. .end = IRQ_ORION5X_XOR1,
  437. .flags = IORESOURCE_IRQ,
  438. },
  439. };
  440. static struct mv_xor_platform_data orion5x_xor1_data = {
  441. .shared = &orion5x_xor_shared,
  442. .hw_id = 1,
  443. .pool_size = PAGE_SIZE,
  444. };
  445. static struct platform_device orion5x_xor1_channel = {
  446. .name = MV_XOR_NAME,
  447. .id = 1,
  448. .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
  449. .resource = orion5x_xor1_resources,
  450. .dev = {
  451. .dma_mask = &orion5x_xor_dmamask,
  452. .coherent_dma_mask = DMA_BIT_MASK(64),
  453. .platform_data = (void *)&orion5x_xor1_data,
  454. },
  455. };
  456. void __init orion5x_xor_init(void)
  457. {
  458. platform_device_register(&orion5x_xor_shared);
  459. /*
  460. * two engines can't do memset simultaneously, this limitation
  461. * satisfied by removing memset support from one of the engines.
  462. */
  463. dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
  464. dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
  465. platform_device_register(&orion5x_xor0_channel);
  466. dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
  467. dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
  468. dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
  469. platform_device_register(&orion5x_xor1_channel);
  470. }
  471. static struct resource orion5x_crypto_res[] = {
  472. {
  473. .name = "regs",
  474. .start = ORION5X_CRYPTO_PHYS_BASE,
  475. .end = ORION5X_CRYPTO_PHYS_BASE + 0xffff,
  476. .flags = IORESOURCE_MEM,
  477. }, {
  478. .name = "sram",
  479. .start = ORION5X_SRAM_PHYS_BASE,
  480. .end = ORION5X_SRAM_PHYS_BASE + SZ_8K - 1,
  481. .flags = IORESOURCE_MEM,
  482. }, {
  483. .name = "crypto interrupt",
  484. .start = IRQ_ORION5X_CESA,
  485. .end = IRQ_ORION5X_CESA,
  486. .flags = IORESOURCE_IRQ,
  487. },
  488. };
  489. static struct platform_device orion5x_crypto_device = {
  490. .name = "mv_crypto",
  491. .id = -1,
  492. .num_resources = ARRAY_SIZE(orion5x_crypto_res),
  493. .resource = orion5x_crypto_res,
  494. };
  495. static int __init orion5x_crypto_init(void)
  496. {
  497. int ret;
  498. ret = orion5x_setup_sram_win();
  499. if (ret)
  500. return ret;
  501. return platform_device_register(&orion5x_crypto_device);
  502. }
  503. /*****************************************************************************
  504. * Watchdog
  505. ****************************************************************************/
  506. static struct orion_wdt_platform_data orion5x_wdt_data = {
  507. .tclk = 0,
  508. };
  509. static struct platform_device orion5x_wdt_device = {
  510. .name = "orion_wdt",
  511. .id = -1,
  512. .dev = {
  513. .platform_data = &orion5x_wdt_data,
  514. },
  515. .num_resources = 0,
  516. };
  517. void __init orion5x_wdt_init(void)
  518. {
  519. orion5x_wdt_data.tclk = orion5x_tclk;
  520. platform_device_register(&orion5x_wdt_device);
  521. }
  522. /*****************************************************************************
  523. * Time handling
  524. ****************************************************************************/
  525. int orion5x_tclk;
  526. int __init orion5x_find_tclk(void)
  527. {
  528. u32 dev, rev;
  529. orion5x_pcie_id(&dev, &rev);
  530. if (dev == MV88F6183_DEV_ID &&
  531. (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
  532. return 133333333;
  533. return 166666667;
  534. }
  535. static void orion5x_timer_init(void)
  536. {
  537. orion5x_tclk = orion5x_find_tclk();
  538. orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
  539. }
  540. struct sys_timer orion5x_timer = {
  541. .init = orion5x_timer_init,
  542. };
  543. /*****************************************************************************
  544. * General
  545. ****************************************************************************/
  546. /*
  547. * Identify device ID and rev from PCIe configuration header space '0'.
  548. */
  549. static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
  550. {
  551. orion5x_pcie_id(dev, rev);
  552. if (*dev == MV88F5281_DEV_ID) {
  553. if (*rev == MV88F5281_REV_D2) {
  554. *dev_name = "MV88F5281-D2";
  555. } else if (*rev == MV88F5281_REV_D1) {
  556. *dev_name = "MV88F5281-D1";
  557. } else if (*rev == MV88F5281_REV_D0) {
  558. *dev_name = "MV88F5281-D0";
  559. } else {
  560. *dev_name = "MV88F5281-Rev-Unsupported";
  561. }
  562. } else if (*dev == MV88F5182_DEV_ID) {
  563. if (*rev == MV88F5182_REV_A2) {
  564. *dev_name = "MV88F5182-A2";
  565. } else {
  566. *dev_name = "MV88F5182-Rev-Unsupported";
  567. }
  568. } else if (*dev == MV88F5181_DEV_ID) {
  569. if (*rev == MV88F5181_REV_B1) {
  570. *dev_name = "MV88F5181-Rev-B1";
  571. } else if (*rev == MV88F5181L_REV_A1) {
  572. *dev_name = "MV88F5181L-Rev-A1";
  573. } else {
  574. *dev_name = "MV88F5181(L)-Rev-Unsupported";
  575. }
  576. } else if (*dev == MV88F6183_DEV_ID) {
  577. if (*rev == MV88F6183_REV_B0) {
  578. *dev_name = "MV88F6183-Rev-B0";
  579. } else {
  580. *dev_name = "MV88F6183-Rev-Unsupported";
  581. }
  582. } else {
  583. *dev_name = "Device-Unknown";
  584. }
  585. }
  586. void __init orion5x_init(void)
  587. {
  588. char *dev_name;
  589. u32 dev, rev;
  590. orion5x_id(&dev, &rev, &dev_name);
  591. printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
  592. orion5x_eth_shared_data.t_clk = orion5x_tclk;
  593. orion5x_spi_plat_data.tclk = orion5x_tclk;
  594. orion5x_uart0_data[0].uartclk = orion5x_tclk;
  595. orion5x_uart1_data[0].uartclk = orion5x_tclk;
  596. /*
  597. * Setup Orion address map
  598. */
  599. orion5x_setup_cpu_mbus_bridge();
  600. /*
  601. * Don't issue "Wait for Interrupt" instruction if we are
  602. * running on D0 5281 silicon.
  603. */
  604. if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
  605. printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
  606. disable_hlt();
  607. }
  608. /*
  609. * The 5082/5181l/5182/6082/6082l/6183 have crypto
  610. * while 5180n/5181/5281 don't have crypto.
  611. */
  612. if ((dev == MV88F5181_DEV_ID && rev >= MV88F5181L_REV_A0) ||
  613. dev == MV88F5182_DEV_ID || dev == MV88F6183_DEV_ID)
  614. orion5x_crypto_init();
  615. /*
  616. * Register watchdog driver
  617. */
  618. orion5x_wdt_init();
  619. }
  620. /*
  621. * Many orion-based systems have buggy bootloader implementations.
  622. * This is a common fixup for bogus memory tags.
  623. */
  624. void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
  625. char **from, struct meminfo *meminfo)
  626. {
  627. for (; t->hdr.size; t = tag_next(t))
  628. if (t->hdr.tag == ATAG_MEM &&
  629. (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
  630. t->u.mem.start & ~PAGE_MASK)) {
  631. printk(KERN_WARNING
  632. "Clearing invalid memory bank %dKB@0x%08x\n",
  633. t->u.mem.size / 1024, t->u.mem.start);
  634. t->hdr.tag = 0;
  635. }
  636. }