ev64260.c 18 KB

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