ev64260.c 18 KB

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