sandpoint.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Board setup routines for the Motorola SPS Sandpoint Test Platform.
  3. *
  4. * Author: Mark A. Greer
  5. * mgreer@mvista.com
  6. *
  7. * 2000-2003 (c) MontaVista Software, Inc. This file is licensed under
  8. * the terms of the GNU General Public License version 2. This program
  9. * is licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. */
  12. /*
  13. * This file adds support for the Motorola SPS Sandpoint Test Platform.
  14. * These boards have a PPMC slot for the processor so any combination
  15. * of cpu and host bridge can be attached. This port is for an 8240 PPMC
  16. * module from Motorola SPS and other closely related cpu/host bridge
  17. * combinations (e.g., 750/755/7400 with MPC107 host bridge).
  18. * The sandpoint itself has a Windbond 83c553 (PCI-ISA bridge, 2 DMA ctlrs, 2
  19. * cascaded 8259 interrupt ctlrs, 8254 Timer/Counter, and an IDE ctlr), a
  20. * National 87308 (RTC, 2 UARTs, Keyboard & mouse ctlrs, and a floppy ctlr),
  21. * and 4 PCI slots (only 2 of which are usable; the other 2 are keyed for 3.3V
  22. * but are really 5V).
  23. *
  24. * The firmware on the sandpoint is called DINK (not my acronym :). This port
  25. * depends on DINK to do some basic initialization (e.g., initialize the memory
  26. * ctlr) and to ensure that the processor is using MAP B (CHRP map).
  27. *
  28. * The switch settings for the Sandpoint board MUST be as follows:
  29. * S3: down
  30. * S4: up
  31. * S5: up
  32. * S6: down
  33. *
  34. * 'down' is in the direction from the PCI slots towards the PPMC slot;
  35. * 'up' is in the direction from the PPMC slot towards the PCI slots.
  36. * Be careful, the way the sandpoint board is installed in XT chasses will
  37. * make the directions reversed.
  38. *
  39. * Since Motorola listened to our suggestions for improvement, we now have
  40. * the Sandpoint X3 board. All of the PCI slots are available, it uses
  41. * the serial interrupt interface (just a hardware thing we need to
  42. * configure properly).
  43. *
  44. * Use the default X3 switch settings. The interrupts are then:
  45. * EPIC Source
  46. * 0 SIOINT (8259, active low)
  47. * 1 PCI #1
  48. * 2 PCI #2
  49. * 3 PCI #3
  50. * 4 PCI #4
  51. * 7 Winbond INTC (IDE interrupt)
  52. * 8 Winbond INTD (IDE interrupt)
  53. *
  54. *
  55. * Motorola has finally released a version of DINK32 that correctly
  56. * (seemingly) initializes the memory controller correctly, regardless
  57. * of the amount of memory in the system. Once a method of determining
  58. * what version of DINK initializes the system for us, if applicable, is
  59. * found, we can hopefully stop hardcoding 32MB of RAM.
  60. */
  61. #include <linux/stddef.h>
  62. #include <linux/kernel.h>
  63. #include <linux/init.h>
  64. #include <linux/errno.h>
  65. #include <linux/reboot.h>
  66. #include <linux/pci.h>
  67. #include <linux/kdev_t.h>
  68. #include <linux/major.h>
  69. #include <linux/initrd.h>
  70. #include <linux/console.h>
  71. #include <linux/delay.h>
  72. #include <linux/seq_file.h>
  73. #include <linux/root_dev.h>
  74. #include <linux/serial.h>
  75. #include <linux/tty.h> /* for linux/serial_core.h */
  76. #include <linux/serial_core.h>
  77. #include <linux/serial_8250.h>
  78. #include <asm/system.h>
  79. #include <asm/pgtable.h>
  80. #include <asm/page.h>
  81. #include <asm/time.h>
  82. #include <asm/dma.h>
  83. #include <asm/io.h>
  84. #include <asm/machdep.h>
  85. #include <asm/prom.h>
  86. #include <asm/smp.h>
  87. #include <asm/vga.h>
  88. #include <asm/open_pic.h>
  89. #include <asm/i8259.h>
  90. #include <asm/todc.h>
  91. #include <asm/bootinfo.h>
  92. #include <asm/mpc10x.h>
  93. #include <asm/pci-bridge.h>
  94. #include <asm/kgdb.h>
  95. #include <asm/ppc_sys.h>
  96. #include "sandpoint.h"
  97. /* Set non-zero if an X2 Sandpoint detected. */
  98. static int sandpoint_is_x2;
  99. unsigned char __res[sizeof(bd_t)];
  100. static void sandpoint_halt(void);
  101. static void sandpoint_probe_type(void);
  102. /*
  103. * Define all of the IRQ senses and polarities. Taken from the
  104. * Sandpoint X3 User's manual.
  105. */
  106. static u_char sandpoint_openpic_initsenses[] __initdata = {
  107. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 0: SIOINT */
  108. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 2: PCI Slot 1 */
  109. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 3: PCI Slot 2 */
  110. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 4: PCI Slot 3 */
  111. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 5: PCI Slot 4 */
  112. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 8: IDE (INT C) */
  113. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE) /* 9: IDE (INT D) */
  114. };
  115. /*
  116. * Motorola SPS Sandpoint interrupt routing.
  117. */
  118. static inline int
  119. x3_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  120. {
  121. static char pci_irq_table[][4] =
  122. /*
  123. * PCI IDSEL/INTPIN->INTLINE
  124. * A B C D
  125. */
  126. {
  127. { 16, 0, 0, 0 }, /* IDSEL 11 - i8259 on Winbond */
  128. { 0, 0, 0, 0 }, /* IDSEL 12 - unused */
  129. { 18, 21, 20, 19 }, /* IDSEL 13 - PCI slot 1 */
  130. { 19, 18, 21, 20 }, /* IDSEL 14 - PCI slot 2 */
  131. { 20, 19, 18, 21 }, /* IDSEL 15 - PCI slot 3 */
  132. { 21, 20, 19, 18 }, /* IDSEL 16 - PCI slot 4 */
  133. };
  134. const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
  135. return PCI_IRQ_TABLE_LOOKUP;
  136. }
  137. static inline int
  138. x2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  139. {
  140. static char pci_irq_table[][4] =
  141. /*
  142. * PCI IDSEL/INTPIN->INTLINE
  143. * A B C D
  144. */
  145. {
  146. { 18, 0, 0, 0 }, /* IDSEL 11 - i8259 on Windbond */
  147. { 0, 0, 0, 0 }, /* IDSEL 12 - unused */
  148. { 16, 17, 18, 19 }, /* IDSEL 13 - PCI slot 1 */
  149. { 17, 18, 19, 16 }, /* IDSEL 14 - PCI slot 2 */
  150. { 18, 19, 16, 17 }, /* IDSEL 15 - PCI slot 3 */
  151. { 19, 16, 17, 18 }, /* IDSEL 16 - PCI slot 4 */
  152. };
  153. const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
  154. return PCI_IRQ_TABLE_LOOKUP;
  155. }
  156. static void __init
  157. sandpoint_setup_winbond_83553(struct pci_controller *hose)
  158. {
  159. int devfn;
  160. /*
  161. * Route IDE interrupts directly to the 8259's IRQ 14 & 15.
  162. * We can't route the IDE interrupt to PCI INTC# or INTD# because those
  163. * woule interfere with the PMC's INTC# and INTD# lines.
  164. */
  165. /*
  166. * Winbond Fcn 0
  167. */
  168. devfn = PCI_DEVFN(11,0);
  169. early_write_config_byte(hose,
  170. 0,
  171. devfn,
  172. 0x43, /* IDE Interrupt Routing Control */
  173. 0xef);
  174. early_write_config_word(hose,
  175. 0,
  176. devfn,
  177. 0x44, /* PCI Interrupt Routing Control */
  178. 0x0000);
  179. /* Want ISA memory cycles to be forwarded to PCI bus */
  180. early_write_config_byte(hose,
  181. 0,
  182. devfn,
  183. 0x48, /* ISA-to-PCI Addr Decoder Control */
  184. 0xf0);
  185. /* Enable Port 92. */
  186. early_write_config_byte(hose,
  187. 0,
  188. devfn,
  189. 0x4e, /* AT System Control Register */
  190. 0x06);
  191. /*
  192. * Winbond Fcn 1
  193. */
  194. devfn = PCI_DEVFN(11,1);
  195. /* Put IDE controller into native mode. */
  196. early_write_config_byte(hose,
  197. 0,
  198. devfn,
  199. 0x09, /* Programming interface Register */
  200. 0x8f);
  201. /* Init IRQ routing, enable both ports, disable fast 16 */
  202. early_write_config_dword(hose,
  203. 0,
  204. devfn,
  205. 0x40, /* IDE Control/Status Register */
  206. 0x00ff0011);
  207. return;
  208. }
  209. /* On the sandpoint X2, we must avoid sending configuration cycles to
  210. * device #12 (IDSEL addr = AD12).
  211. */
  212. static int
  213. x2_exclude_device(u_char bus, u_char devfn)
  214. {
  215. if ((bus == 0) && (PCI_SLOT(devfn) == SANDPOINT_HOST_BRIDGE_IDSEL))
  216. return PCIBIOS_DEVICE_NOT_FOUND;
  217. else
  218. return PCIBIOS_SUCCESSFUL;
  219. }
  220. static void __init
  221. sandpoint_find_bridges(void)
  222. {
  223. struct pci_controller *hose;
  224. hose = pcibios_alloc_controller();
  225. if (!hose)
  226. return;
  227. hose->first_busno = 0;
  228. hose->last_busno = 0xff;
  229. if (mpc10x_bridge_init(hose,
  230. MPC10X_MEM_MAP_B,
  231. MPC10X_MEM_MAP_B,
  232. MPC10X_MAPB_EUMB_BASE) == 0) {
  233. /* Do early winbond init, then scan PCI bus */
  234. sandpoint_setup_winbond_83553(hose);
  235. hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
  236. ppc_md.pcibios_fixup = NULL;
  237. ppc_md.pcibios_fixup_bus = NULL;
  238. ppc_md.pci_swizzle = common_swizzle;
  239. if (sandpoint_is_x2) {
  240. ppc_md.pci_map_irq = x2_map_irq;
  241. ppc_md.pci_exclude_device = x2_exclude_device;
  242. } else
  243. ppc_md.pci_map_irq = x3_map_irq;
  244. }
  245. else {
  246. if (ppc_md.progress)
  247. ppc_md.progress("Bridge init failed", 0x100);
  248. printk("Host bridge init failed\n");
  249. }
  250. return;
  251. }
  252. static void __init
  253. sandpoint_setup_arch(void)
  254. {
  255. /* Probe for Sandpoint model */
  256. sandpoint_probe_type();
  257. if (sandpoint_is_x2)
  258. epic_serial_mode = 0;
  259. loops_per_jiffy = 100000000 / HZ;
  260. #ifdef CONFIG_BLK_DEV_INITRD
  261. if (initrd_start)
  262. ROOT_DEV = Root_RAM0;
  263. else
  264. #endif
  265. #ifdef CONFIG_ROOT_NFS
  266. ROOT_DEV = Root_NFS;
  267. #else
  268. ROOT_DEV = Root_HDA1;
  269. #endif
  270. /* Lookup PCI host bridges */
  271. sandpoint_find_bridges();
  272. if (strncmp (cur_ppc_sys_spec->ppc_sys_name, "8245", 4) == 0)
  273. {
  274. bd_t *bp = (bd_t *)__res;
  275. struct plat_serial8250_port *pdata;
  276. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC10X_UART0);
  277. if (pdata)
  278. {
  279. pdata[0].uartclk = bp->bi_busfreq;
  280. }
  281. #ifdef CONFIG_SANDPOINT_ENABLE_UART1
  282. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC10X_UART1);
  283. if (pdata)
  284. {
  285. pdata[0].uartclk = bp->bi_busfreq;
  286. }
  287. #else
  288. ppc_sys_device_remove(MPC10X_UART1);
  289. #endif
  290. }
  291. printk(KERN_INFO "Motorola SPS Sandpoint Test Platform\n");
  292. printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  293. /* DINK32 12.3 and below do not correctly enable any caches.
  294. * We will do this now with good known values. Future versions
  295. * of DINK32 are supposed to get this correct.
  296. */
  297. if (cpu_has_feature(CPU_FTR_SPEC7450))
  298. /* 745x is different. We only want to pass along enable. */
  299. _set_L2CR(L2CR_L2E);
  300. else if (cpu_has_feature(CPU_FTR_L2CR))
  301. /* All modules have 1MB of L2. We also assume that an
  302. * L2 divisor of 3 will work.
  303. */
  304. _set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3
  305. | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);
  306. #if 0
  307. /* Untested right now. */
  308. if (cpu_has_feature(CPU_FTR_L3CR)) {
  309. /* Magic value. */
  310. _set_L3CR(0x8f032000);
  311. }
  312. #endif
  313. }
  314. #define SANDPOINT_87308_CFG_ADDR 0x15c
  315. #define SANDPOINT_87308_CFG_DATA 0x15d
  316. #define SANDPOINT_87308_CFG_INB(addr, byte) { \
  317. outb((addr), SANDPOINT_87308_CFG_ADDR); \
  318. (byte) = inb(SANDPOINT_87308_CFG_DATA); \
  319. }
  320. #define SANDPOINT_87308_CFG_OUTB(addr, byte) { \
  321. outb((addr), SANDPOINT_87308_CFG_ADDR); \
  322. outb((byte), SANDPOINT_87308_CFG_DATA); \
  323. }
  324. #define SANDPOINT_87308_SELECT_DEV(dev_num) { \
  325. SANDPOINT_87308_CFG_OUTB(0x07, (dev_num)); \
  326. }
  327. #define SANDPOINT_87308_DEV_ENABLE(dev_num) { \
  328. SANDPOINT_87308_SELECT_DEV(dev_num); \
  329. SANDPOINT_87308_CFG_OUTB(0x30, 0x01); \
  330. }
  331. /*
  332. * To probe the Sandpoint type, we need to check for a connection between GPIO
  333. * pins 6 and 7 on the NS87308 SuperIO.
  334. */
  335. static void __init sandpoint_probe_type(void)
  336. {
  337. u8 x;
  338. /* First, ensure that the GPIO pins are enabled. */
  339. SANDPOINT_87308_SELECT_DEV(0x07); /* Select GPIO logical device */
  340. SANDPOINT_87308_CFG_OUTB(0x60, 0x07); /* Base address 0x700 */
  341. SANDPOINT_87308_CFG_OUTB(0x61, 0x00);
  342. SANDPOINT_87308_CFG_OUTB(0x30, 0x01); /* Enable */
  343. /* Now, set pin 7 to output and pin 6 to input. */
  344. outb((inb(0x701) | 0x80) & 0xbf, 0x701);
  345. /* Set push-pull output */
  346. outb(inb(0x702) | 0x80, 0x702);
  347. /* Set pull-up on input */
  348. outb(inb(0x703) | 0x40, 0x703);
  349. /* Set output high and check */
  350. x = inb(0x700);
  351. outb(x | 0x80, 0x700);
  352. x = inb(0x700);
  353. sandpoint_is_x2 = ! (x & 0x40);
  354. if (ppc_md.progress && sandpoint_is_x2)
  355. ppc_md.progress("High output says X2", 0);
  356. /* Set output low and check */
  357. outb(x & 0x7f, 0x700);
  358. sandpoint_is_x2 |= inb(0x700) & 0x40;
  359. if (ppc_md.progress && sandpoint_is_x2)
  360. ppc_md.progress("Low output says X2", 0);
  361. if (ppc_md.progress && ! sandpoint_is_x2)
  362. ppc_md.progress("Sandpoint is X3", 0);
  363. }
  364. /*
  365. * Fix IDE interrupts.
  366. */
  367. static int __init
  368. sandpoint_fix_winbond_83553(void)
  369. {
  370. /* Make some 8259 interrupt level sensitive */
  371. outb(0xe0, 0x4d0);
  372. outb(0xde, 0x4d1);
  373. return 0;
  374. }
  375. arch_initcall(sandpoint_fix_winbond_83553);
  376. /*
  377. * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip.
  378. */
  379. static int __init
  380. sandpoint_setup_natl_87308(void)
  381. {
  382. u_char reg;
  383. /*
  384. * Enable all the devices on the Super I/O chip.
  385. */
  386. SANDPOINT_87308_SELECT_DEV(0x00); /* Select kbd logical device */
  387. SANDPOINT_87308_CFG_OUTB(0xf0, 0x00); /* Set KBC clock to 8 Mhz */
  388. SANDPOINT_87308_DEV_ENABLE(0x00); /* Enable keyboard */
  389. SANDPOINT_87308_DEV_ENABLE(0x01); /* Enable mouse */
  390. SANDPOINT_87308_DEV_ENABLE(0x02); /* Enable rtc */
  391. SANDPOINT_87308_DEV_ENABLE(0x03); /* Enable fdc (floppy) */
  392. SANDPOINT_87308_DEV_ENABLE(0x04); /* Enable parallel */
  393. SANDPOINT_87308_DEV_ENABLE(0x05); /* Enable UART 2 */
  394. SANDPOINT_87308_CFG_OUTB(0xf0, 0x82); /* Enable bank select regs */
  395. SANDPOINT_87308_DEV_ENABLE(0x06); /* Enable UART 1 */
  396. SANDPOINT_87308_CFG_OUTB(0xf0, 0x82); /* Enable bank select regs */
  397. /* Set up floppy in PS/2 mode */
  398. outb(0x09, SIO_CONFIG_RA);
  399. reg = inb(SIO_CONFIG_RD);
  400. reg = (reg & 0x3F) | 0x40;
  401. outb(reg, SIO_CONFIG_RD);
  402. outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */
  403. return 0;
  404. }
  405. arch_initcall(sandpoint_setup_natl_87308);
  406. static int __init
  407. sandpoint_request_io(void)
  408. {
  409. request_region(0x00,0x20,"dma1");
  410. request_region(0x20,0x20,"pic1");
  411. request_region(0x40,0x20,"timer");
  412. request_region(0x80,0x10,"dma page reg");
  413. request_region(0xa0,0x20,"pic2");
  414. request_region(0xc0,0x20,"dma2");
  415. return 0;
  416. }
  417. arch_initcall(sandpoint_request_io);
  418. /*
  419. * Interrupt setup and service. Interrupts on the Sandpoint come
  420. * from the four PCI slots plus the 8259 in the Winbond Super I/O (SIO).
  421. * The 8259 is cascaded from EPIC IRQ0, IRQ1-4 map to PCI slots 1-4,
  422. * IDE is on EPIC 7 and 8.
  423. */
  424. static void __init
  425. sandpoint_init_IRQ(void)
  426. {
  427. int i;
  428. OpenPIC_InitSenses = sandpoint_openpic_initsenses;
  429. OpenPIC_NumInitSenses = sizeof(sandpoint_openpic_initsenses);
  430. mpc10x_set_openpic();
  431. openpic_hookup_cascade(sandpoint_is_x2 ? 17 : NUM_8259_INTERRUPTS, "82c59 cascade",
  432. i8259_irq);
  433. /*
  434. * The EPIC allows for a read in the range of 0xFEF00000 ->
  435. * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.
  436. */
  437. i8259_init(0xfef00000, 0);
  438. }
  439. static unsigned long __init
  440. sandpoint_find_end_of_memory(void)
  441. {
  442. bd_t *bp = (bd_t *)__res;
  443. if (bp->bi_memsize)
  444. return bp->bi_memsize;
  445. /* DINK32 13.0 correctly initializes things, so iff you use
  446. * this you _should_ be able to change this instead of a
  447. * hardcoded value. */
  448. #if 0
  449. return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
  450. #else
  451. return 32*1024*1024;
  452. #endif
  453. }
  454. static void __init
  455. sandpoint_map_io(void)
  456. {
  457. io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
  458. }
  459. static void
  460. sandpoint_restart(char *cmd)
  461. {
  462. local_irq_disable();
  463. /* Set exception prefix high - to the firmware */
  464. _nmask_and_or_msr(0, MSR_IP);
  465. /* Reset system via Port 92 */
  466. outb(0x00, 0x92);
  467. outb(0x01, 0x92);
  468. for(;;); /* Spin until reset happens */
  469. }
  470. static void
  471. sandpoint_power_off(void)
  472. {
  473. local_irq_disable();
  474. for(;;); /* No way to shut power off with software */
  475. /* NOTREACHED */
  476. }
  477. static void
  478. sandpoint_halt(void)
  479. {
  480. sandpoint_power_off();
  481. /* NOTREACHED */
  482. }
  483. static int
  484. sandpoint_show_cpuinfo(struct seq_file *m)
  485. {
  486. seq_printf(m, "vendor\t\t: Motorola SPS\n");
  487. seq_printf(m, "machine\t\t: Sandpoint\n");
  488. return 0;
  489. }
  490. /*
  491. * Set BAT 3 to map 0xf8000000 to end of physical memory space 1-to-1.
  492. */
  493. static __inline__ void
  494. sandpoint_set_bat(void)
  495. {
  496. unsigned long bat3u, bat3l;
  497. __asm__ __volatile__(
  498. " lis %0,0xf800\n \
  499. ori %1,%0,0x002a\n \
  500. ori %0,%0,0x0ffe\n \
  501. mtspr 0x21e,%0\n \
  502. mtspr 0x21f,%1\n \
  503. isync\n \
  504. sync "
  505. : "=r" (bat3u), "=r" (bat3l));
  506. }
  507. TODC_ALLOC();
  508. void __init
  509. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  510. unsigned long r6, unsigned long r7)
  511. {
  512. parse_bootinfo(find_bootinfo());
  513. /* ASSUMPTION: If both r3 (bd_t pointer) and r6 (cmdline pointer)
  514. * are non-zero, then we should use the board info from the bd_t
  515. * structure and the cmdline pointed to by r6 instead of the
  516. * information from birecs, if any. Otherwise, use the information
  517. * from birecs as discovered by the preceding call to
  518. * parse_bootinfo(). This rule should work with both PPCBoot, which
  519. * uses a bd_t board info structure, and the kernel boot wrapper,
  520. * which uses birecs.
  521. */
  522. if (r3 && r6) {
  523. /* copy board info structure */
  524. memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
  525. /* copy command line */
  526. *(char *)(r7+KERNELBASE) = 0;
  527. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  528. }
  529. #ifdef CONFIG_BLK_DEV_INITRD
  530. /* take care of initrd if we have one */
  531. if (r4) {
  532. initrd_start = r4 + KERNELBASE;
  533. initrd_end = r5 + KERNELBASE;
  534. }
  535. #endif /* CONFIG_BLK_DEV_INITRD */
  536. /* Map in board regs, etc. */
  537. sandpoint_set_bat();
  538. isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
  539. isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
  540. pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
  541. ISA_DMA_THRESHOLD = 0x00ffffff;
  542. DMA_MODE_READ = 0x44;
  543. DMA_MODE_WRITE = 0x48;
  544. ppc_do_canonicalize_irqs = 1;
  545. ppc_md.setup_arch = sandpoint_setup_arch;
  546. ppc_md.show_cpuinfo = sandpoint_show_cpuinfo;
  547. ppc_md.init_IRQ = sandpoint_init_IRQ;
  548. ppc_md.get_irq = openpic_get_irq;
  549. ppc_md.restart = sandpoint_restart;
  550. ppc_md.power_off = sandpoint_power_off;
  551. ppc_md.halt = sandpoint_halt;
  552. ppc_md.find_end_of_memory = sandpoint_find_end_of_memory;
  553. ppc_md.setup_io_mappings = sandpoint_map_io;
  554. TODC_INIT(TODC_TYPE_PC97307, 0x70, 0x00, 0x71, 8);
  555. ppc_md.time_init = todc_time_init;
  556. ppc_md.set_rtc_time = todc_set_rtc_time;
  557. ppc_md.get_rtc_time = todc_get_rtc_time;
  558. ppc_md.calibrate_decr = todc_calibrate_decr;
  559. ppc_md.nvram_read_val = todc_mc146818_read_val;
  560. ppc_md.nvram_write_val = todc_mc146818_write_val;
  561. #ifdef CONFIG_KGDB
  562. ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
  563. #endif
  564. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  565. ppc_md.progress = gen550_progress;
  566. #endif
  567. }