ev64260.c 18 KB

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