common.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. /*
  2. * arch/arm/mach-mv78xx0/common.c
  3. *
  4. * Core functions for Marvell MV78xx0 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/ethtool.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/mach/time.h>
  21. #include <mach/mv78xx0.h>
  22. #include <mach/bridge-regs.h>
  23. #include <plat/cache-feroceon-l2.h>
  24. #include <plat/ehci-orion.h>
  25. #include <plat/orion_nand.h>
  26. #include <plat/time.h>
  27. #include "common.h"
  28. /*****************************************************************************
  29. * Common bits
  30. ****************************************************************************/
  31. int mv78xx0_core_index(void)
  32. {
  33. u32 extra;
  34. /*
  35. * Read Extra Features register.
  36. */
  37. __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra));
  38. return !!(extra & 0x00004000);
  39. }
  40. static int get_hclk(void)
  41. {
  42. int hclk;
  43. /*
  44. * HCLK tick rate is configured by DEV_D[7:5] pins.
  45. */
  46. switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) {
  47. case 0:
  48. hclk = 166666667;
  49. break;
  50. case 1:
  51. hclk = 200000000;
  52. break;
  53. case 2:
  54. hclk = 266666667;
  55. break;
  56. case 3:
  57. hclk = 333333333;
  58. break;
  59. case 4:
  60. hclk = 400000000;
  61. break;
  62. default:
  63. panic("unknown HCLK PLL setting: %.8x\n",
  64. readl(SAMPLE_AT_RESET_LOW));
  65. }
  66. return hclk;
  67. }
  68. static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
  69. {
  70. u32 cfg;
  71. /*
  72. * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
  73. * PCLK/L2CLK by bits [19:14].
  74. */
  75. if (core_index == 0) {
  76. cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f;
  77. } else {
  78. cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f;
  79. }
  80. /*
  81. * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
  82. * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
  83. */
  84. *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1;
  85. /*
  86. * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
  87. * ratio (1, 2, 3).
  88. */
  89. *l2clk = *pclk / (((cfg >> 4) & 3) + 1);
  90. }
  91. static int get_tclk(void)
  92. {
  93. int tclk;
  94. /*
  95. * TCLK tick rate is configured by DEV_A[2:0] strap pins.
  96. */
  97. switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
  98. case 1:
  99. tclk = 166666667;
  100. break;
  101. case 3:
  102. tclk = 200000000;
  103. break;
  104. default:
  105. panic("unknown TCLK PLL setting: %.8x\n",
  106. readl(SAMPLE_AT_RESET_HIGH));
  107. }
  108. return tclk;
  109. }
  110. /*****************************************************************************
  111. * I/O Address Mapping
  112. ****************************************************************************/
  113. static struct map_desc mv78xx0_io_desc[] __initdata = {
  114. {
  115. .virtual = MV78XX0_CORE_REGS_VIRT_BASE,
  116. .pfn = 0,
  117. .length = MV78XX0_CORE_REGS_SIZE,
  118. .type = MT_DEVICE,
  119. }, {
  120. .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
  121. .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
  122. .length = MV78XX0_PCIE_IO_SIZE * 8,
  123. .type = MT_DEVICE,
  124. }, {
  125. .virtual = MV78XX0_REGS_VIRT_BASE,
  126. .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE),
  127. .length = MV78XX0_REGS_SIZE,
  128. .type = MT_DEVICE,
  129. },
  130. };
  131. void __init mv78xx0_map_io(void)
  132. {
  133. unsigned long phys;
  134. /*
  135. * Map the right set of per-core registers depending on
  136. * which core we are running on.
  137. */
  138. if (mv78xx0_core_index() == 0) {
  139. phys = MV78XX0_CORE0_REGS_PHYS_BASE;
  140. } else {
  141. phys = MV78XX0_CORE1_REGS_PHYS_BASE;
  142. }
  143. mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys);
  144. iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc));
  145. }
  146. /*****************************************************************************
  147. * EHCI
  148. ****************************************************************************/
  149. static struct orion_ehci_data mv78xx0_ehci_data = {
  150. .dram = &mv78xx0_mbus_dram_info,
  151. .phy_version = EHCI_PHY_NA,
  152. };
  153. static u64 ehci_dmamask = 0xffffffffUL;
  154. /*****************************************************************************
  155. * EHCI0
  156. ****************************************************************************/
  157. static struct resource mv78xx0_ehci0_resources[] = {
  158. {
  159. .start = USB0_PHYS_BASE,
  160. .end = USB0_PHYS_BASE + 0x0fff,
  161. .flags = IORESOURCE_MEM,
  162. }, {
  163. .start = IRQ_MV78XX0_USB_0,
  164. .end = IRQ_MV78XX0_USB_0,
  165. .flags = IORESOURCE_IRQ,
  166. },
  167. };
  168. static struct platform_device mv78xx0_ehci0 = {
  169. .name = "orion-ehci",
  170. .id = 0,
  171. .dev = {
  172. .dma_mask = &ehci_dmamask,
  173. .coherent_dma_mask = 0xffffffff,
  174. .platform_data = &mv78xx0_ehci_data,
  175. },
  176. .resource = mv78xx0_ehci0_resources,
  177. .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources),
  178. };
  179. void __init mv78xx0_ehci0_init(void)
  180. {
  181. platform_device_register(&mv78xx0_ehci0);
  182. }
  183. /*****************************************************************************
  184. * EHCI1
  185. ****************************************************************************/
  186. static struct resource mv78xx0_ehci1_resources[] = {
  187. {
  188. .start = USB1_PHYS_BASE,
  189. .end = USB1_PHYS_BASE + 0x0fff,
  190. .flags = IORESOURCE_MEM,
  191. }, {
  192. .start = IRQ_MV78XX0_USB_1,
  193. .end = IRQ_MV78XX0_USB_1,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device mv78xx0_ehci1 = {
  198. .name = "orion-ehci",
  199. .id = 1,
  200. .dev = {
  201. .dma_mask = &ehci_dmamask,
  202. .coherent_dma_mask = 0xffffffff,
  203. .platform_data = &mv78xx0_ehci_data,
  204. },
  205. .resource = mv78xx0_ehci1_resources,
  206. .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources),
  207. };
  208. void __init mv78xx0_ehci1_init(void)
  209. {
  210. platform_device_register(&mv78xx0_ehci1);
  211. }
  212. /*****************************************************************************
  213. * EHCI2
  214. ****************************************************************************/
  215. static struct resource mv78xx0_ehci2_resources[] = {
  216. {
  217. .start = USB2_PHYS_BASE,
  218. .end = USB2_PHYS_BASE + 0x0fff,
  219. .flags = IORESOURCE_MEM,
  220. }, {
  221. .start = IRQ_MV78XX0_USB_2,
  222. .end = IRQ_MV78XX0_USB_2,
  223. .flags = IORESOURCE_IRQ,
  224. },
  225. };
  226. static struct platform_device mv78xx0_ehci2 = {
  227. .name = "orion-ehci",
  228. .id = 2,
  229. .dev = {
  230. .dma_mask = &ehci_dmamask,
  231. .coherent_dma_mask = 0xffffffff,
  232. .platform_data = &mv78xx0_ehci_data,
  233. },
  234. .resource = mv78xx0_ehci2_resources,
  235. .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources),
  236. };
  237. void __init mv78xx0_ehci2_init(void)
  238. {
  239. platform_device_register(&mv78xx0_ehci2);
  240. }
  241. /*****************************************************************************
  242. * GE00
  243. ****************************************************************************/
  244. struct mv643xx_eth_shared_platform_data mv78xx0_ge00_shared_data = {
  245. .t_clk = 0,
  246. .dram = &mv78xx0_mbus_dram_info,
  247. };
  248. static struct resource mv78xx0_ge00_shared_resources[] = {
  249. {
  250. .name = "ge00 base",
  251. .start = GE00_PHYS_BASE + 0x2000,
  252. .end = GE00_PHYS_BASE + 0x3fff,
  253. .flags = IORESOURCE_MEM,
  254. }, {
  255. .name = "ge err irq",
  256. .start = IRQ_MV78XX0_GE_ERR,
  257. .end = IRQ_MV78XX0_GE_ERR,
  258. .flags = IORESOURCE_IRQ,
  259. },
  260. };
  261. static struct platform_device mv78xx0_ge00_shared = {
  262. .name = MV643XX_ETH_SHARED_NAME,
  263. .id = 0,
  264. .dev = {
  265. .platform_data = &mv78xx0_ge00_shared_data,
  266. },
  267. .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
  268. .resource = mv78xx0_ge00_shared_resources,
  269. };
  270. static struct resource mv78xx0_ge00_resources[] = {
  271. {
  272. .name = "ge00 irq",
  273. .start = IRQ_MV78XX0_GE00_SUM,
  274. .end = IRQ_MV78XX0_GE00_SUM,
  275. .flags = IORESOURCE_IRQ,
  276. },
  277. };
  278. static struct platform_device mv78xx0_ge00 = {
  279. .name = MV643XX_ETH_NAME,
  280. .id = 0,
  281. .num_resources = 1,
  282. .resource = mv78xx0_ge00_resources,
  283. };
  284. void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  285. {
  286. eth_data->shared = &mv78xx0_ge00_shared;
  287. mv78xx0_ge00.dev.platform_data = eth_data;
  288. platform_device_register(&mv78xx0_ge00_shared);
  289. platform_device_register(&mv78xx0_ge00);
  290. }
  291. /*****************************************************************************
  292. * GE01
  293. ****************************************************************************/
  294. struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
  295. .t_clk = 0,
  296. .dram = &mv78xx0_mbus_dram_info,
  297. .shared_smi = &mv78xx0_ge00_shared,
  298. };
  299. static struct resource mv78xx0_ge01_shared_resources[] = {
  300. {
  301. .name = "ge01 base",
  302. .start = GE01_PHYS_BASE + 0x2000,
  303. .end = GE01_PHYS_BASE + 0x3fff,
  304. .flags = IORESOURCE_MEM,
  305. },
  306. };
  307. static struct platform_device mv78xx0_ge01_shared = {
  308. .name = MV643XX_ETH_SHARED_NAME,
  309. .id = 1,
  310. .dev = {
  311. .platform_data = &mv78xx0_ge01_shared_data,
  312. },
  313. .num_resources = 1,
  314. .resource = mv78xx0_ge01_shared_resources,
  315. };
  316. static struct resource mv78xx0_ge01_resources[] = {
  317. {
  318. .name = "ge01 irq",
  319. .start = IRQ_MV78XX0_GE01_SUM,
  320. .end = IRQ_MV78XX0_GE01_SUM,
  321. .flags = IORESOURCE_IRQ,
  322. },
  323. };
  324. static struct platform_device mv78xx0_ge01 = {
  325. .name = MV643XX_ETH_NAME,
  326. .id = 1,
  327. .num_resources = 1,
  328. .resource = mv78xx0_ge01_resources,
  329. };
  330. void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
  331. {
  332. eth_data->shared = &mv78xx0_ge01_shared;
  333. mv78xx0_ge01.dev.platform_data = eth_data;
  334. platform_device_register(&mv78xx0_ge01_shared);
  335. platform_device_register(&mv78xx0_ge01);
  336. }
  337. /*****************************************************************************
  338. * GE10
  339. ****************************************************************************/
  340. struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
  341. .t_clk = 0,
  342. .dram = &mv78xx0_mbus_dram_info,
  343. .shared_smi = &mv78xx0_ge00_shared,
  344. };
  345. static struct resource mv78xx0_ge10_shared_resources[] = {
  346. {
  347. .name = "ge10 base",
  348. .start = GE10_PHYS_BASE + 0x2000,
  349. .end = GE10_PHYS_BASE + 0x3fff,
  350. .flags = IORESOURCE_MEM,
  351. },
  352. };
  353. static struct platform_device mv78xx0_ge10_shared = {
  354. .name = MV643XX_ETH_SHARED_NAME,
  355. .id = 2,
  356. .dev = {
  357. .platform_data = &mv78xx0_ge10_shared_data,
  358. },
  359. .num_resources = 1,
  360. .resource = mv78xx0_ge10_shared_resources,
  361. };
  362. static struct resource mv78xx0_ge10_resources[] = {
  363. {
  364. .name = "ge10 irq",
  365. .start = IRQ_MV78XX0_GE10_SUM,
  366. .end = IRQ_MV78XX0_GE10_SUM,
  367. .flags = IORESOURCE_IRQ,
  368. },
  369. };
  370. static struct platform_device mv78xx0_ge10 = {
  371. .name = MV643XX_ETH_NAME,
  372. .id = 2,
  373. .num_resources = 1,
  374. .resource = mv78xx0_ge10_resources,
  375. };
  376. void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
  377. {
  378. u32 dev, rev;
  379. eth_data->shared = &mv78xx0_ge10_shared;
  380. mv78xx0_ge10.dev.platform_data = eth_data;
  381. /*
  382. * On the Z0, ge10 and ge11 are internally connected back
  383. * to back, and not brought out.
  384. */
  385. mv78xx0_pcie_id(&dev, &rev);
  386. if (dev == MV78X00_Z0_DEV_ID) {
  387. eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
  388. eth_data->speed = SPEED_1000;
  389. eth_data->duplex = DUPLEX_FULL;
  390. }
  391. platform_device_register(&mv78xx0_ge10_shared);
  392. platform_device_register(&mv78xx0_ge10);
  393. }
  394. /*****************************************************************************
  395. * GE11
  396. ****************************************************************************/
  397. struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
  398. .t_clk = 0,
  399. .dram = &mv78xx0_mbus_dram_info,
  400. .shared_smi = &mv78xx0_ge00_shared,
  401. };
  402. static struct resource mv78xx0_ge11_shared_resources[] = {
  403. {
  404. .name = "ge11 base",
  405. .start = GE11_PHYS_BASE + 0x2000,
  406. .end = GE11_PHYS_BASE + 0x3fff,
  407. .flags = IORESOURCE_MEM,
  408. },
  409. };
  410. static struct platform_device mv78xx0_ge11_shared = {
  411. .name = MV643XX_ETH_SHARED_NAME,
  412. .id = 3,
  413. .dev = {
  414. .platform_data = &mv78xx0_ge11_shared_data,
  415. },
  416. .num_resources = 1,
  417. .resource = mv78xx0_ge11_shared_resources,
  418. };
  419. static struct resource mv78xx0_ge11_resources[] = {
  420. {
  421. .name = "ge11 irq",
  422. .start = IRQ_MV78XX0_GE11_SUM,
  423. .end = IRQ_MV78XX0_GE11_SUM,
  424. .flags = IORESOURCE_IRQ,
  425. },
  426. };
  427. static struct platform_device mv78xx0_ge11 = {
  428. .name = MV643XX_ETH_NAME,
  429. .id = 3,
  430. .num_resources = 1,
  431. .resource = mv78xx0_ge11_resources,
  432. };
  433. void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
  434. {
  435. u32 dev, rev;
  436. eth_data->shared = &mv78xx0_ge11_shared;
  437. mv78xx0_ge11.dev.platform_data = eth_data;
  438. /*
  439. * On the Z0, ge10 and ge11 are internally connected back
  440. * to back, and not brought out.
  441. */
  442. mv78xx0_pcie_id(&dev, &rev);
  443. if (dev == MV78X00_Z0_DEV_ID) {
  444. eth_data->phy_addr = MV643XX_ETH_PHY_NONE;
  445. eth_data->speed = SPEED_1000;
  446. eth_data->duplex = DUPLEX_FULL;
  447. }
  448. platform_device_register(&mv78xx0_ge11_shared);
  449. platform_device_register(&mv78xx0_ge11);
  450. }
  451. /*****************************************************************************
  452. * I2C bus 0
  453. ****************************************************************************/
  454. static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = {
  455. .freq_m = 8, /* assumes 166 MHz TCLK */
  456. .freq_n = 3,
  457. .timeout = 1000, /* Default timeout of 1 second */
  458. };
  459. static struct resource mv78xx0_i2c_0_resources[] = {
  460. {
  461. .name = "i2c 0 base",
  462. .start = I2C_0_PHYS_BASE,
  463. .end = I2C_0_PHYS_BASE + 0x1f,
  464. .flags = IORESOURCE_MEM,
  465. }, {
  466. .name = "i2c 0 irq",
  467. .start = IRQ_MV78XX0_I2C_0,
  468. .end = IRQ_MV78XX0_I2C_0,
  469. .flags = IORESOURCE_IRQ,
  470. },
  471. };
  472. static struct platform_device mv78xx0_i2c_0 = {
  473. .name = MV64XXX_I2C_CTLR_NAME,
  474. .id = 0,
  475. .num_resources = ARRAY_SIZE(mv78xx0_i2c_0_resources),
  476. .resource = mv78xx0_i2c_0_resources,
  477. .dev = {
  478. .platform_data = &mv78xx0_i2c_0_pdata,
  479. },
  480. };
  481. /*****************************************************************************
  482. * I2C bus 1
  483. ****************************************************************************/
  484. static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = {
  485. .freq_m = 8, /* assumes 166 MHz TCLK */
  486. .freq_n = 3,
  487. .timeout = 1000, /* Default timeout of 1 second */
  488. };
  489. static struct resource mv78xx0_i2c_1_resources[] = {
  490. {
  491. .name = "i2c 1 base",
  492. .start = I2C_1_PHYS_BASE,
  493. .end = I2C_1_PHYS_BASE + 0x1f,
  494. .flags = IORESOURCE_MEM,
  495. }, {
  496. .name = "i2c 1 irq",
  497. .start = IRQ_MV78XX0_I2C_1,
  498. .end = IRQ_MV78XX0_I2C_1,
  499. .flags = IORESOURCE_IRQ,
  500. },
  501. };
  502. static struct platform_device mv78xx0_i2c_1 = {
  503. .name = MV64XXX_I2C_CTLR_NAME,
  504. .id = 1,
  505. .num_resources = ARRAY_SIZE(mv78xx0_i2c_1_resources),
  506. .resource = mv78xx0_i2c_1_resources,
  507. .dev = {
  508. .platform_data = &mv78xx0_i2c_1_pdata,
  509. },
  510. };
  511. void __init mv78xx0_i2c_init(void)
  512. {
  513. platform_device_register(&mv78xx0_i2c_0);
  514. platform_device_register(&mv78xx0_i2c_1);
  515. }
  516. /*****************************************************************************
  517. * SATA
  518. ****************************************************************************/
  519. static struct resource mv78xx0_sata_resources[] = {
  520. {
  521. .name = "sata base",
  522. .start = SATA_PHYS_BASE,
  523. .end = SATA_PHYS_BASE + 0x5000 - 1,
  524. .flags = IORESOURCE_MEM,
  525. }, {
  526. .name = "sata irq",
  527. .start = IRQ_MV78XX0_SATA,
  528. .end = IRQ_MV78XX0_SATA,
  529. .flags = IORESOURCE_IRQ,
  530. },
  531. };
  532. static struct platform_device mv78xx0_sata = {
  533. .name = "sata_mv",
  534. .id = 0,
  535. .dev = {
  536. .coherent_dma_mask = 0xffffffff,
  537. },
  538. .num_resources = ARRAY_SIZE(mv78xx0_sata_resources),
  539. .resource = mv78xx0_sata_resources,
  540. };
  541. void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
  542. {
  543. sata_data->dram = &mv78xx0_mbus_dram_info;
  544. mv78xx0_sata.dev.platform_data = sata_data;
  545. platform_device_register(&mv78xx0_sata);
  546. }
  547. /*****************************************************************************
  548. * UART0
  549. ****************************************************************************/
  550. static struct plat_serial8250_port mv78xx0_uart0_data[] = {
  551. {
  552. .mapbase = UART0_PHYS_BASE,
  553. .membase = (char *)UART0_VIRT_BASE,
  554. .irq = IRQ_MV78XX0_UART_0,
  555. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  556. .iotype = UPIO_MEM,
  557. .regshift = 2,
  558. .uartclk = 0,
  559. }, {
  560. },
  561. };
  562. static struct resource mv78xx0_uart0_resources[] = {
  563. {
  564. .start = UART0_PHYS_BASE,
  565. .end = UART0_PHYS_BASE + 0xff,
  566. .flags = IORESOURCE_MEM,
  567. }, {
  568. .start = IRQ_MV78XX0_UART_0,
  569. .end = IRQ_MV78XX0_UART_0,
  570. .flags = IORESOURCE_IRQ,
  571. },
  572. };
  573. static struct platform_device mv78xx0_uart0 = {
  574. .name = "serial8250",
  575. .id = 0,
  576. .dev = {
  577. .platform_data = mv78xx0_uart0_data,
  578. },
  579. .resource = mv78xx0_uart0_resources,
  580. .num_resources = ARRAY_SIZE(mv78xx0_uart0_resources),
  581. };
  582. void __init mv78xx0_uart0_init(void)
  583. {
  584. platform_device_register(&mv78xx0_uart0);
  585. }
  586. /*****************************************************************************
  587. * UART1
  588. ****************************************************************************/
  589. static struct plat_serial8250_port mv78xx0_uart1_data[] = {
  590. {
  591. .mapbase = UART1_PHYS_BASE,
  592. .membase = (char *)UART1_VIRT_BASE,
  593. .irq = IRQ_MV78XX0_UART_1,
  594. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  595. .iotype = UPIO_MEM,
  596. .regshift = 2,
  597. .uartclk = 0,
  598. }, {
  599. },
  600. };
  601. static struct resource mv78xx0_uart1_resources[] = {
  602. {
  603. .start = UART1_PHYS_BASE,
  604. .end = UART1_PHYS_BASE + 0xff,
  605. .flags = IORESOURCE_MEM,
  606. }, {
  607. .start = IRQ_MV78XX0_UART_1,
  608. .end = IRQ_MV78XX0_UART_1,
  609. .flags = IORESOURCE_IRQ,
  610. },
  611. };
  612. static struct platform_device mv78xx0_uart1 = {
  613. .name = "serial8250",
  614. .id = 1,
  615. .dev = {
  616. .platform_data = mv78xx0_uart1_data,
  617. },
  618. .resource = mv78xx0_uart1_resources,
  619. .num_resources = ARRAY_SIZE(mv78xx0_uart1_resources),
  620. };
  621. void __init mv78xx0_uart1_init(void)
  622. {
  623. platform_device_register(&mv78xx0_uart1);
  624. }
  625. /*****************************************************************************
  626. * UART2
  627. ****************************************************************************/
  628. static struct plat_serial8250_port mv78xx0_uart2_data[] = {
  629. {
  630. .mapbase = UART2_PHYS_BASE,
  631. .membase = (char *)UART2_VIRT_BASE,
  632. .irq = IRQ_MV78XX0_UART_2,
  633. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  634. .iotype = UPIO_MEM,
  635. .regshift = 2,
  636. .uartclk = 0,
  637. }, {
  638. },
  639. };
  640. static struct resource mv78xx0_uart2_resources[] = {
  641. {
  642. .start = UART2_PHYS_BASE,
  643. .end = UART2_PHYS_BASE + 0xff,
  644. .flags = IORESOURCE_MEM,
  645. }, {
  646. .start = IRQ_MV78XX0_UART_2,
  647. .end = IRQ_MV78XX0_UART_2,
  648. .flags = IORESOURCE_IRQ,
  649. },
  650. };
  651. static struct platform_device mv78xx0_uart2 = {
  652. .name = "serial8250",
  653. .id = 2,
  654. .dev = {
  655. .platform_data = mv78xx0_uart2_data,
  656. },
  657. .resource = mv78xx0_uart2_resources,
  658. .num_resources = ARRAY_SIZE(mv78xx0_uart2_resources),
  659. };
  660. void __init mv78xx0_uart2_init(void)
  661. {
  662. platform_device_register(&mv78xx0_uart2);
  663. }
  664. /*****************************************************************************
  665. * UART3
  666. ****************************************************************************/
  667. static struct plat_serial8250_port mv78xx0_uart3_data[] = {
  668. {
  669. .mapbase = UART3_PHYS_BASE,
  670. .membase = (char *)UART3_VIRT_BASE,
  671. .irq = IRQ_MV78XX0_UART_3,
  672. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  673. .iotype = UPIO_MEM,
  674. .regshift = 2,
  675. .uartclk = 0,
  676. }, {
  677. },
  678. };
  679. static struct resource mv78xx0_uart3_resources[] = {
  680. {
  681. .start = UART3_PHYS_BASE,
  682. .end = UART3_PHYS_BASE + 0xff,
  683. .flags = IORESOURCE_MEM,
  684. }, {
  685. .start = IRQ_MV78XX0_UART_3,
  686. .end = IRQ_MV78XX0_UART_3,
  687. .flags = IORESOURCE_IRQ,
  688. },
  689. };
  690. static struct platform_device mv78xx0_uart3 = {
  691. .name = "serial8250",
  692. .id = 3,
  693. .dev = {
  694. .platform_data = mv78xx0_uart3_data,
  695. },
  696. .resource = mv78xx0_uart3_resources,
  697. .num_resources = ARRAY_SIZE(mv78xx0_uart3_resources),
  698. };
  699. void __init mv78xx0_uart3_init(void)
  700. {
  701. platform_device_register(&mv78xx0_uart3);
  702. }
  703. /*****************************************************************************
  704. * Time handling
  705. ****************************************************************************/
  706. static void mv78xx0_timer_init(void)
  707. {
  708. orion_time_init(IRQ_MV78XX0_TIMER_1, get_tclk());
  709. }
  710. struct sys_timer mv78xx0_timer = {
  711. .init = mv78xx0_timer_init,
  712. };
  713. /*****************************************************************************
  714. * General
  715. ****************************************************************************/
  716. static char * __init mv78xx0_id(void)
  717. {
  718. u32 dev, rev;
  719. mv78xx0_pcie_id(&dev, &rev);
  720. if (dev == MV78X00_Z0_DEV_ID) {
  721. if (rev == MV78X00_REV_Z0)
  722. return "MV78X00-Z0";
  723. else
  724. return "MV78X00-Rev-Unsupported";
  725. } else if (dev == MV78100_DEV_ID) {
  726. if (rev == MV78100_REV_A0)
  727. return "MV78100-A0";
  728. else
  729. return "MV78100-Rev-Unsupported";
  730. } else if (dev == MV78200_DEV_ID) {
  731. if (rev == MV78100_REV_A0)
  732. return "MV78200-A0";
  733. else
  734. return "MV78200-Rev-Unsupported";
  735. } else {
  736. return "Device-Unknown";
  737. }
  738. }
  739. static int __init is_l2_writethrough(void)
  740. {
  741. return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH);
  742. }
  743. void __init mv78xx0_init(void)
  744. {
  745. int core_index;
  746. int hclk;
  747. int pclk;
  748. int l2clk;
  749. int tclk;
  750. core_index = mv78xx0_core_index();
  751. hclk = get_hclk();
  752. get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
  753. tclk = get_tclk();
  754. printk(KERN_INFO "%s ", mv78xx0_id());
  755. printk("core #%d, ", core_index);
  756. printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
  757. printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
  758. printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
  759. printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000);
  760. mv78xx0_setup_cpu_mbus();
  761. #ifdef CONFIG_CACHE_FEROCEON_L2
  762. feroceon_l2_init(is_l2_writethrough());
  763. #endif
  764. mv78xx0_ge00_shared_data.t_clk = tclk;
  765. mv78xx0_ge01_shared_data.t_clk = tclk;
  766. mv78xx0_ge10_shared_data.t_clk = tclk;
  767. mv78xx0_ge11_shared_data.t_clk = tclk;
  768. mv78xx0_uart0_data[0].uartclk = tclk;
  769. mv78xx0_uart1_data[0].uartclk = tclk;
  770. mv78xx0_uart2_data[0].uartclk = tclk;
  771. mv78xx0_uart3_data[0].uartclk = tclk;
  772. }