ev64260.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * arch/ppc/platforms/ev64260.c
  3. *
  4. * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board.
  5. *
  6. * Author: Mark A. Greer <mgreer@mvista.com>
  7. *
  8. * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. /*
  14. * The EV-64260-BP port is the result of hard work from many people from
  15. * many companies. In particular, employees of Marvell/Galileo, Mission
  16. * Critical Linux, Xyterra, and MontaVista Software were heavily involved.
  17. *
  18. * Note: I have not been able to get *all* PCI slots to work reliably
  19. * at 66 MHz. I recommend setting jumpers J15 & J16 to short pins 1&2
  20. * so that 33 MHz is used. --MAG
  21. * Note: The 750CXe and 7450 are not stable with a 125MHz or 133MHz TCLK/SYSCLK.
  22. * At 100MHz, they are solid.
  23. */
  24. #include <linux/config.h>
  25. #include <linux/delay.h>
  26. #include <linux/pci.h>
  27. #include <linux/ide.h>
  28. #include <linux/irq.h>
  29. #include <linux/fs.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/console.h>
  32. #include <linux/initrd.h>
  33. #include <linux/root_dev.h>
  34. #if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
  35. #include <linux/serial.h>
  36. #include <linux/tty.h>
  37. #include <linux/serial_core.h>
  38. #else
  39. #include <linux/mv643xx.h>
  40. #endif
  41. #include <asm/bootinfo.h>
  42. #include <asm/machdep.h>
  43. #include <asm/mv64x60.h>
  44. #include <asm/todc.h>
  45. #include <asm/time.h>
  46. #include <platforms/ev64260.h>
  47. #define BOARD_VENDOR "Marvell/Galileo"
  48. #define BOARD_MACHINE "EV-64260-BP"
  49. static struct mv64x60_handle bh;
  50. #if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
  51. extern void gen550_progress(char *, unsigned short);
  52. extern void gen550_init(int, struct uart_port *);
  53. #endif
  54. static const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */
  55. 18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
  56. };
  57. static const unsigned int cpu_745x[2][16] = { /* PLL_EXT 0 & 1 */
  58. { 1, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0 },
  59. { 0, 30, 0, 2, 0, 26, 0, 18, 0, 22, 20, 24, 28, 32, 0, 0 }
  60. };
  61. TODC_ALLOC();
  62. static int
  63. ev64260_get_bus_speed(void)
  64. {
  65. return 100000000;
  66. }
  67. static int
  68. ev64260_get_cpu_speed(void)
  69. {
  70. unsigned long pvr, hid1, pll_ext;
  71. pvr = PVR_VER(mfspr(SPRN_PVR));
  72. if (pvr != PVR_VER(PVR_7450)) {
  73. hid1 = mfspr(SPRN_HID1) >> 28;
  74. return ev64260_get_bus_speed() * cpu_7xx[hid1]/2;
  75. }
  76. else {
  77. hid1 = (mfspr(SPRN_HID1) & 0x0001e000) >> 13;
  78. pll_ext = 0; /* No way to read; must get from schematic */
  79. return ev64260_get_bus_speed() * cpu_745x[pll_ext][hid1]/2;
  80. }
  81. }
  82. unsigned long __init
  83. ev64260_find_end_of_memory(void)
  84. {
  85. return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
  86. MV64x60_TYPE_GT64260A);
  87. }
  88. /*
  89. * Marvell/Galileo EV-64260-BP Evaluation Board PCI interrupt routing.
  90. * Note: By playing with J8 and JP1-4, you can get 2 IRQ's from the first
  91. * PCI bus (in which cast, INTPIN B would be EV64260_PCI_1_IRQ).
  92. * This is the most IRQs you can get from one bus with this board, though.
  93. */
  94. static int __init
  95. ev64260_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  96. {
  97. struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
  98. if (hose->index == 0) {
  99. static char pci_irq_table[][4] =
  100. /*
  101. * PCI IDSEL/INTPIN->INTLINE
  102. * A B C D
  103. */
  104. {
  105. {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 0 */
  106. {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 0 */
  107. };
  108. const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
  109. return PCI_IRQ_TABLE_LOOKUP;
  110. }
  111. else {
  112. static char pci_irq_table[][4] =
  113. /*
  114. * PCI IDSEL/INTPIN->INTLINE
  115. * A B C D
  116. */
  117. {
  118. { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 1 */
  119. { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 1 */
  120. };
  121. const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
  122. return PCI_IRQ_TABLE_LOOKUP;
  123. }
  124. }
  125. static void __init
  126. ev64260_setup_peripherals(void)
  127. {
  128. mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
  129. EV64260_EMB_FLASH_BASE, EV64260_EMB_FLASH_SIZE, 0);
  130. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
  131. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN,
  132. EV64260_EXT_SRAM_BASE, EV64260_EXT_SRAM_SIZE, 0);
  133. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
  134. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
  135. EV64260_TODC_BASE, EV64260_TODC_SIZE, 0);
  136. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN);
  137. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
  138. EV64260_UART_BASE, EV64260_UART_SIZE, 0);
  139. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN);
  140. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
  141. EV64260_EXT_FLASH_BASE, EV64260_EXT_FLASH_SIZE, 0);
  142. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN);
  143. TODC_INIT(TODC_TYPE_DS1501, 0, 0,
  144. ioremap(EV64260_TODC_BASE, EV64260_TODC_SIZE), 8);
  145. mv64x60_clr_bits(&bh, MV64x60_CPU_CONFIG,((1<<12) | (1<<28) | (1<<29)));
  146. mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<27));
  147. if (ev64260_get_bus_speed() > 100000000)
  148. mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<23));
  149. mv64x60_set_bits(&bh, MV64x60_PCI0_PCI_DECODE_CNTL, ((1<<0) | (1<<3)));
  150. mv64x60_set_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL, ((1<<0) | (1<<3)));
  151. /*
  152. * Enabling of PCI internal-vs-external arbitration
  153. * is a platform- and errata-dependent decision.
  154. */
  155. if (bh.type == MV64x60_TYPE_GT64260A ) {
  156. mv64x60_set_bits(&bh, MV64x60_PCI0_ARBITER_CNTL, (1<<31));
  157. mv64x60_set_bits(&bh, MV64x60_PCI1_ARBITER_CNTL, (1<<31));
  158. }
  159. mv64x60_set_bits(&bh, MV64x60_CPU_MASTER_CNTL, (1<<9)); /* Only 1 cpu */
  160. /*
  161. * Turn off timer/counters. Not turning off watchdog timer because
  162. * can't read its reg on the 64260A so don't know if we'll be enabling
  163. * or disabling.
  164. */
  165. mv64x60_clr_bits(&bh, MV64x60_TIMR_CNTR_0_3_CNTL,
  166. ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
  167. mv64x60_clr_bits(&bh, GT64260_TIMR_CNTR_4_7_CNTL,
  168. ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
  169. /*
  170. * Set MPSC Multiplex RMII
  171. * NOTE: ethernet driver modifies bit 0 and 1
  172. */
  173. mv64x60_write(&bh, GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102);
  174. /*
  175. * The EV-64260-BP uses several Multi-Purpose Pins (MPP) on the 64260
  176. * bridge as interrupt inputs (via the General Purpose Ports (GPP)
  177. * register). Need to route the MPP inputs to the GPP and set the
  178. * polarity correctly.
  179. *
  180. * In MPP Control 2 Register
  181. * MPP 21 -> GPP 21 (DUART channel A intr) bits 20-23 -> 0
  182. * MPP 22 -> GPP 22 (DUART channel B intr) bits 24-27 -> 0
  183. */
  184. mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_2, (0xf<<20) | (0xf<<24) );
  185. /*
  186. * In MPP Control 3 Register
  187. * MPP 26 -> GPP 26 (RTC INT) bits 8-11 -> 0
  188. * MPP 27 -> GPP 27 (PCI 0 INTA) bits 12-15 -> 0
  189. * MPP 29 -> GPP 29 (PCI 1 INTA) bits 20-23 -> 0
  190. */
  191. mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_3, (0xf<<8)|(0xf<<12)|(0xf<<20));
  192. #define GPP_EXTERNAL_INTERRUPTS \
  193. ((1<<21) | (1<<22) | (1<<26) | (1<<27) | (1<<29))
  194. /* DUART & PCI interrupts are inputs */
  195. mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, GPP_EXTERNAL_INTERRUPTS);
  196. /* DUART & PCI interrupts are active low */
  197. mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, GPP_EXTERNAL_INTERRUPTS);
  198. /* Clear any pending interrupts for these inputs and enable them. */
  199. mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~GPP_EXTERNAL_INTERRUPTS);
  200. mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, GPP_EXTERNAL_INTERRUPTS);
  201. return;
  202. }
  203. static void __init
  204. ev64260_setup_bridge(void)
  205. {
  206. struct mv64x60_setup_info si;
  207. int i;
  208. memset(&si, 0, sizeof(si));
  209. si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
  210. si.pci_0.enable_bus = 1;
  211. si.pci_0.pci_io.cpu_base = EV64260_PCI0_IO_CPU_BASE;
  212. si.pci_0.pci_io.pci_base_hi = 0;
  213. si.pci_0.pci_io.pci_base_lo = EV64260_PCI0_IO_PCI_BASE;
  214. si.pci_0.pci_io.size = EV64260_PCI0_IO_SIZE;
  215. si.pci_0.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
  216. si.pci_0.pci_mem[0].cpu_base = EV64260_PCI0_MEM_CPU_BASE;
  217. si.pci_0.pci_mem[0].pci_base_hi = 0;
  218. si.pci_0.pci_mem[0].pci_base_lo = EV64260_PCI0_MEM_PCI_BASE;
  219. si.pci_0.pci_mem[0].size = EV64260_PCI0_MEM_SIZE;
  220. si.pci_0.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
  221. si.pci_0.pci_cmd_bits = 0;
  222. si.pci_0.latency_timer = 0x8;
  223. si.pci_1.enable_bus = 1;
  224. si.pci_1.pci_io.cpu_base = EV64260_PCI1_IO_CPU_BASE;
  225. si.pci_1.pci_io.pci_base_hi = 0;
  226. si.pci_1.pci_io.pci_base_lo = EV64260_PCI1_IO_PCI_BASE;
  227. si.pci_1.pci_io.size = EV64260_PCI1_IO_SIZE;
  228. si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
  229. si.pci_1.pci_mem[0].cpu_base = EV64260_PCI1_MEM_CPU_BASE;
  230. si.pci_1.pci_mem[0].pci_base_hi = 0;
  231. si.pci_1.pci_mem[0].pci_base_lo = EV64260_PCI1_MEM_PCI_BASE;
  232. si.pci_1.pci_mem[0].size = EV64260_PCI1_MEM_SIZE;
  233. si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
  234. si.pci_1.pci_cmd_bits = 0;
  235. si.pci_1.latency_timer = 0x8;
  236. for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
  237. si.cpu_prot_options[i] = 0;
  238. si.cpu_snoop_options[i] = GT64260_CPU_SNOOP_WB;
  239. si.pci_0.acc_cntl_options[i] =
  240. GT64260_PCI_ACC_CNTL_DREADEN |
  241. GT64260_PCI_ACC_CNTL_RDPREFETCH |
  242. GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
  243. GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
  244. GT64260_PCI_ACC_CNTL_SWAP_NONE |
  245. GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
  246. si.pci_0.snoop_options[i] = GT64260_PCI_SNOOP_WB;
  247. si.pci_1.acc_cntl_options[i] =
  248. GT64260_PCI_ACC_CNTL_DREADEN |
  249. GT64260_PCI_ACC_CNTL_RDPREFETCH |
  250. GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
  251. GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
  252. GT64260_PCI_ACC_CNTL_SWAP_NONE |
  253. GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
  254. si.pci_1.snoop_options[i] = GT64260_PCI_SNOOP_WB;
  255. }
  256. /* Lookup PCI host bridges */
  257. if (mv64x60_init(&bh, &si))
  258. printk(KERN_ERR "Bridge initialization failed.\n");
  259. pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */
  260. ppc_md.pci_swizzle = common_swizzle;
  261. ppc_md.pci_map_irq = ev64260_map_irq;
  262. ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
  263. mv64x60_set_bus(&bh, 0, 0);
  264. bh.hose_a->first_busno = 0;
  265. bh.hose_a->last_busno = 0xff;
  266. bh.hose_a->last_busno = pciauto_bus_scan(bh.hose_a, 0);
  267. bh.hose_b->first_busno = bh.hose_a->last_busno + 1;
  268. mv64x60_set_bus(&bh, 1, bh.hose_b->first_busno);
  269. bh.hose_b->last_busno = 0xff;
  270. bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b,
  271. bh.hose_b->first_busno);
  272. return;
  273. }
  274. #if defined(CONFIG_SERIAL_8250) && !defined(CONFIG_SERIAL_MPSC_CONSOLE)
  275. static void __init
  276. ev64260_early_serial_map(void)
  277. {
  278. struct uart_port port;
  279. static char first_time = 1;
  280. if (first_time) {
  281. memset(&port, 0, sizeof(port));
  282. port.membase = ioremap(EV64260_SERIAL_0, EV64260_UART_SIZE);
  283. port.irq = EV64260_UART_0_IRQ;
  284. port.uartclk = BASE_BAUD * 16;
  285. port.regshift = 2;
  286. port.iotype = SERIAL_IO_MEM;
  287. port.flags = STD_COM_FLAGS;
  288. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  289. gen550_init(0, &port);
  290. #endif
  291. if (early_serial_setup(&port) != 0)
  292. printk(KERN_WARNING "Early serial init of port 0"
  293. "failed\n");
  294. first_time = 0;
  295. }
  296. return;
  297. }
  298. #elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
  299. static void __init
  300. ev64260_early_serial_map(void)
  301. {
  302. }
  303. #endif
  304. static void __init
  305. ev64260_setup_arch(void)
  306. {
  307. if (ppc_md.progress)
  308. ppc_md.progress("ev64260_setup_arch: enter", 0);
  309. #ifdef CONFIG_BLK_DEV_INITRD
  310. if (initrd_start)
  311. ROOT_DEV = Root_RAM0;
  312. else
  313. #endif
  314. #ifdef CONFIG_ROOT_NFS
  315. ROOT_DEV = Root_NFS;
  316. #else
  317. ROOT_DEV = Root_SDA2;
  318. #endif
  319. if (ppc_md.progress)
  320. ppc_md.progress("ev64260_setup_arch: Enabling L2 cache", 0);
  321. /* Enable L2 and L3 caches (if 745x) */
  322. _set_L2CR(_get_L2CR() | L2CR_L2E);
  323. _set_L3CR(_get_L3CR() | L3CR_L3E);
  324. if (ppc_md.progress)
  325. ppc_md.progress("ev64260_setup_arch: Initializing bridge", 0);
  326. ev64260_setup_bridge(); /* set up PCI bridge(s) */
  327. ev64260_setup_peripherals(); /* set up chip selects/GPP/MPP etc */
  328. if (ppc_md.progress)
  329. ppc_md.progress("ev64260_setup_arch: bridge init complete", 0);
  330. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_MPSC_CONSOLE)
  331. ev64260_early_serial_map();
  332. #endif
  333. printk(KERN_INFO "%s %s port (C) 2001 MontaVista Software, Inc."
  334. "(source@mvista.com)\n", BOARD_VENDOR, BOARD_MACHINE);
  335. if (ppc_md.progress)
  336. ppc_md.progress("ev64260_setup_arch: exit", 0);
  337. return;
  338. }
  339. /* Platform device data fixup routines. */
  340. #if defined(CONFIG_SERIAL_MPSC)
  341. static void __init
  342. ev64260_fixup_mpsc_pdata(struct platform_device *pdev)
  343. {
  344. struct mpsc_pdata *pdata;
  345. pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
  346. pdata->max_idle = 40;
  347. pdata->default_baud = EV64260_DEFAULT_BAUD;
  348. pdata->brg_clk_src = EV64260_MPSC_CLK_SRC;
  349. pdata->brg_clk_freq = EV64260_MPSC_CLK_FREQ;
  350. return;
  351. }
  352. static int __init
  353. ev64260_platform_notify(struct device *dev)
  354. {
  355. static struct {
  356. char *bus_id;
  357. void ((*rtn)(struct platform_device *pdev));
  358. } dev_map[] = {
  359. { MPSC_CTLR_NAME ".0", ev64260_fixup_mpsc_pdata },
  360. { MPSC_CTLR_NAME ".1", ev64260_fixup_mpsc_pdata },
  361. };
  362. struct platform_device *pdev;
  363. int i;
  364. if (dev && dev->bus_id)
  365. for (i=0; i<ARRAY_SIZE(dev_map); i++)
  366. if (!strncmp(dev->bus_id, dev_map[i].bus_id,
  367. BUS_ID_SIZE)) {
  368. pdev = container_of(dev,
  369. struct platform_device, dev);
  370. dev_map[i].rtn(pdev);
  371. }
  372. return 0;
  373. }
  374. #endif
  375. static void
  376. ev64260_reset_board(void *addr)
  377. {
  378. local_irq_disable();
  379. /* disable and invalidate the L2 cache */
  380. _set_L2CR(0);
  381. _set_L2CR(0x200000);
  382. /* flush and disable L1 I/D cache */
  383. __asm__ __volatile__
  384. ("mfspr 3,1008\n\t"
  385. "ori 5,5,0xcc00\n\t"
  386. "ori 4,3,0xc00\n\t"
  387. "andc 5,3,5\n\t"
  388. "sync\n\t"
  389. "mtspr 1008,4\n\t"
  390. "isync\n\t"
  391. "sync\n\t"
  392. "mtspr 1008,5\n\t"
  393. "isync\n\t"
  394. "sync\n\t");
  395. /* unmap any other random cs's that might overlap with bootcs */
  396. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, 0, 0, 0);
  397. bh.ci->disable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
  398. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, 0, 0, 0);
  399. bh.ci->disable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN);
  400. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN, 0, 0, 0);
  401. bh.ci->disable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN);
  402. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN, 0, 0, 0);
  403. bh.ci->disable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN);
  404. /* map bootrom back in to gt @ reset defaults */
  405. mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
  406. 0xff800000, 8*1024*1024, 0);
  407. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
  408. /* move reg base back to default, setup default pci0 */
  409. mv64x60_write(&bh, MV64x60_INTERNAL_SPACE_DECODE,
  410. (1<<24) | CONFIG_MV64X60_BASE >> 20);
  411. /* NOTE: FROM NOW ON no more GT_REGS accesses.. 0x1 is not mapped
  412. * via BAT or MMU, and MSR IR/DR is ON */
  413. /* SRR0 has system reset vector, SRR1 has default MSR value */
  414. /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
  415. /* NOTE: assumes reset vector is at 0xfff00100 */
  416. __asm__ __volatile__
  417. ("mtspr 26, %0\n\t"
  418. "li 4,(1<<6)\n\t"
  419. "mtspr 27,4\n\t"
  420. "rfi\n\t"
  421. :: "r" (addr):"r4");
  422. return;
  423. }
  424. static void
  425. ev64260_restart(char *cmd)
  426. {
  427. volatile ulong i = 10000000;
  428. ev64260_reset_board((void *)0xfff00100);
  429. while (i-- > 0);
  430. panic("restart failed\n");
  431. }
  432. static void
  433. ev64260_halt(void)
  434. {
  435. local_irq_disable();
  436. while (1);
  437. /* NOTREACHED */
  438. }
  439. static void
  440. ev64260_power_off(void)
  441. {
  442. ev64260_halt();
  443. /* NOTREACHED */
  444. }
  445. static int
  446. ev64260_show_cpuinfo(struct seq_file *m)
  447. {
  448. uint pvid;
  449. pvid = mfspr(SPRN_PVR);
  450. seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
  451. seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
  452. seq_printf(m, "cpu MHz\t\t: %d\n", ev64260_get_cpu_speed()/1000/1000);
  453. seq_printf(m, "bus MHz\t\t: %d\n", ev64260_get_bus_speed()/1000/1000);
  454. return 0;
  455. }
  456. /* DS1501 RTC has too much variation to use RTC for calibration */
  457. static void __init
  458. ev64260_calibrate_decr(void)
  459. {
  460. ulong freq;
  461. freq = ev64260_get_bus_speed()/4;
  462. printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
  463. freq/1000000, freq%1000000);
  464. tb_ticks_per_jiffy = freq / HZ;
  465. tb_to_us = mulhwu_scale_factor(freq, 1000000);
  466. return;
  467. }
  468. /*
  469. * Set BAT 3 to map 0xfb000000 to 0xfc000000 of physical memory space.
  470. */
  471. static __inline__ void
  472. ev64260_set_bat(void)
  473. {
  474. mb();
  475. mtspr(SPRN_DBAT1U, 0xfb0001fe);
  476. mtspr(SPRN_DBAT1L, 0xfb00002a);
  477. mb();
  478. return;
  479. }
  480. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  481. static void __init
  482. ev64260_map_io(void)
  483. {
  484. io_block_mapping(0xfb000000, 0xfb000000, 0x01000000, _PAGE_IO);
  485. }
  486. #endif
  487. void __init
  488. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  489. unsigned long r6, unsigned long r7)
  490. {
  491. #ifdef CONFIG_BLK_DEV_INITRD
  492. extern int initrd_below_start_ok;
  493. initrd_start=initrd_end=0;
  494. initrd_below_start_ok=0;
  495. #endif /* CONFIG_BLK_DEV_INITRD */
  496. parse_bootinfo(find_bootinfo());
  497. isa_mem_base = 0;
  498. isa_io_base = EV64260_PCI0_IO_CPU_BASE;
  499. pci_dram_offset = EV64260_PCI0_MEM_CPU_BASE;
  500. loops_per_jiffy = ev64260_get_cpu_speed() / HZ;
  501. ppc_md.setup_arch = ev64260_setup_arch;
  502. ppc_md.show_cpuinfo = ev64260_show_cpuinfo;
  503. ppc_md.init_IRQ = gt64260_init_irq;
  504. ppc_md.get_irq = gt64260_get_irq;
  505. ppc_md.restart = ev64260_restart;
  506. ppc_md.power_off = ev64260_power_off;
  507. ppc_md.halt = ev64260_halt;
  508. ppc_md.find_end_of_memory = ev64260_find_end_of_memory;
  509. ppc_md.init = NULL;
  510. ppc_md.time_init = todc_time_init;
  511. ppc_md.set_rtc_time = todc_set_rtc_time;
  512. ppc_md.get_rtc_time = todc_get_rtc_time;
  513. ppc_md.nvram_read_val = todc_direct_read_val;
  514. ppc_md.nvram_write_val = todc_direct_write_val;
  515. ppc_md.calibrate_decr = ev64260_calibrate_decr;
  516. bh.p_base = CONFIG_MV64X60_NEW_BASE;
  517. ev64260_set_bat();
  518. #ifdef CONFIG_SERIAL_8250
  519. #if defined(CONFIG_SERIAL_TEXT_DEBUG)
  520. ppc_md.setup_io_mappings = ev64260_map_io;
  521. ppc_md.progress = gen550_progress;
  522. #endif
  523. #if defined(CONFIG_KGDB)
  524. ppc_md.setup_io_mappings = ev64260_map_io;
  525. ppc_md.early_serial_map = ev64260_early_serial_map;
  526. #endif
  527. #elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
  528. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  529. ppc_md.setup_io_mappings = ev64260_map_io;
  530. ppc_md.progress = mv64x60_mpsc_progress;
  531. mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
  532. #endif /* CONFIG_SERIAL_TEXT_DEBUG */
  533. #ifdef CONFIG_KGDB
  534. ppc_md.setup_io_mappings = ev64260_map_io;
  535. ppc_md.early_serial_map = ev64260_early_serial_map;
  536. #endif /* CONFIG_KGDB */
  537. #endif
  538. #if defined(CONFIG_SERIAL_MPSC)
  539. platform_notify = ev64260_platform_notify;
  540. #endif
  541. return;
  542. }