sandpoint.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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) initalizes 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/ide.h>
  73. #include <linux/seq_file.h>
  74. #include <linux/root_dev.h>
  75. #include <linux/serial.h>
  76. #include <linux/tty.h> /* for linux/serial_core.h */
  77. #include <linux/serial_core.h>
  78. #include <linux/serial_8250.h>
  79. #include <asm/system.h>
  80. #include <asm/pgtable.h>
  81. #include <asm/page.h>
  82. #include <asm/time.h>
  83. #include <asm/dma.h>
  84. #include <asm/io.h>
  85. #include <asm/machdep.h>
  86. #include <asm/prom.h>
  87. #include <asm/smp.h>
  88. #include <asm/vga.h>
  89. #include <asm/open_pic.h>
  90. #include <asm/i8259.h>
  91. #include <asm/todc.h>
  92. #include <asm/bootinfo.h>
  93. #include <asm/mpc10x.h>
  94. #include <asm/pci-bridge.h>
  95. #include <asm/kgdb.h>
  96. #include <asm/ppc_sys.h>
  97. #include "sandpoint.h"
  98. /* Set non-zero if an X2 Sandpoint detected. */
  99. static int sandpoint_is_x2;
  100. unsigned char __res[sizeof(bd_t)];
  101. static void sandpoint_halt(void);
  102. static void sandpoint_probe_type(void);
  103. /*
  104. * Define all of the IRQ senses and polarities. Taken from the
  105. * Sandpoint X3 User's manual.
  106. */
  107. static u_char sandpoint_openpic_initsenses[] __initdata = {
  108. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 0: SIOINT */
  109. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 2: PCI Slot 1 */
  110. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 3: PCI Slot 2 */
  111. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 4: PCI Slot 3 */
  112. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 5: PCI Slot 4 */
  113. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* 8: IDE (INT C) */
  114. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE) /* 9: IDE (INT D) */
  115. };
  116. /*
  117. * Motorola SPS Sandpoint interrupt routing.
  118. */
  119. static inline int
  120. x3_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  121. {
  122. static char pci_irq_table[][4] =
  123. /*
  124. * PCI IDSEL/INTPIN->INTLINE
  125. * A B C D
  126. */
  127. {
  128. { 16, 0, 0, 0 }, /* IDSEL 11 - i8259 on Winbond */
  129. { 0, 0, 0, 0 }, /* IDSEL 12 - unused */
  130. { 18, 21, 20, 19 }, /* IDSEL 13 - PCI slot 1 */
  131. { 19, 18, 21, 20 }, /* IDSEL 14 - PCI slot 2 */
  132. { 20, 19, 18, 21 }, /* IDSEL 15 - PCI slot 3 */
  133. { 21, 20, 19, 18 }, /* IDSEL 16 - PCI slot 4 */
  134. };
  135. const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
  136. return PCI_IRQ_TABLE_LOOKUP;
  137. }
  138. static inline int
  139. x2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  140. {
  141. static char pci_irq_table[][4] =
  142. /*
  143. * PCI IDSEL/INTPIN->INTLINE
  144. * A B C D
  145. */
  146. {
  147. { 18, 0, 0, 0 }, /* IDSEL 11 - i8259 on Windbond */
  148. { 0, 0, 0, 0 }, /* IDSEL 12 - unused */
  149. { 16, 17, 18, 19 }, /* IDSEL 13 - PCI slot 1 */
  150. { 17, 18, 19, 16 }, /* IDSEL 14 - PCI slot 2 */
  151. { 18, 19, 16, 17 }, /* IDSEL 15 - PCI slot 3 */
  152. { 19, 16, 17, 18 }, /* IDSEL 16 - PCI slot 4 */
  153. };
  154. const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
  155. return PCI_IRQ_TABLE_LOOKUP;
  156. }
  157. static void __init
  158. sandpoint_setup_winbond_83553(struct pci_controller *hose)
  159. {
  160. int devfn;
  161. /*
  162. * Route IDE interrupts directly to the 8259's IRQ 14 & 15.
  163. * We can't route the IDE interrupt to PCI INTC# or INTD# because those
  164. * woule interfere with the PMC's INTC# and INTD# lines.
  165. */
  166. /*
  167. * Winbond Fcn 0
  168. */
  169. devfn = PCI_DEVFN(11,0);
  170. early_write_config_byte(hose,
  171. 0,
  172. devfn,
  173. 0x43, /* IDE Interrupt Routing Control */
  174. 0xef);
  175. early_write_config_word(hose,
  176. 0,
  177. devfn,
  178. 0x44, /* PCI Interrupt Routing Control */
  179. 0x0000);
  180. /* Want ISA memory cycles to be forwarded to PCI bus */
  181. early_write_config_byte(hose,
  182. 0,
  183. devfn,
  184. 0x48, /* ISA-to-PCI Addr Decoder Control */
  185. 0xf0);
  186. /* Enable Port 92. */
  187. early_write_config_byte(hose,
  188. 0,
  189. devfn,
  190. 0x4e, /* AT System Control Register */
  191. 0x06);
  192. /*
  193. * Winbond Fcn 1
  194. */
  195. devfn = PCI_DEVFN(11,1);
  196. /* Put IDE controller into native mode. */
  197. early_write_config_byte(hose,
  198. 0,
  199. devfn,
  200. 0x09, /* Programming interface Register */
  201. 0x8f);
  202. /* Init IRQ routing, enable both ports, disable fast 16 */
  203. early_write_config_dword(hose,
  204. 0,
  205. devfn,
  206. 0x40, /* IDE Control/Status Register */
  207. 0x00ff0011);
  208. return;
  209. }
  210. /* On the sandpoint X2, we must avoid sending configuration cycles to
  211. * device #12 (IDSEL addr = AD12).
  212. */
  213. static int
  214. x2_exclude_device(u_char bus, u_char devfn)
  215. {
  216. if ((bus == 0) && (PCI_SLOT(devfn) == SANDPOINT_HOST_BRIDGE_IDSEL))
  217. return PCIBIOS_DEVICE_NOT_FOUND;
  218. else
  219. return PCIBIOS_SUCCESSFUL;
  220. }
  221. static void __init
  222. sandpoint_find_bridges(void)
  223. {
  224. struct pci_controller *hose;
  225. hose = pcibios_alloc_controller();
  226. if (!hose)
  227. return;
  228. hose->first_busno = 0;
  229. hose->last_busno = 0xff;
  230. if (mpc10x_bridge_init(hose,
  231. MPC10X_MEM_MAP_B,
  232. MPC10X_MEM_MAP_B,
  233. MPC10X_MAPB_EUMB_BASE) == 0) {
  234. /* Do early winbond init, then scan PCI bus */
  235. sandpoint_setup_winbond_83553(hose);
  236. hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
  237. ppc_md.pcibios_fixup = NULL;
  238. ppc_md.pcibios_fixup_bus = NULL;
  239. ppc_md.pci_swizzle = common_swizzle;
  240. if (sandpoint_is_x2) {
  241. ppc_md.pci_map_irq = x2_map_irq;
  242. ppc_md.pci_exclude_device = x2_exclude_device;
  243. } else
  244. ppc_md.pci_map_irq = x3_map_irq;
  245. }
  246. else {
  247. if (ppc_md.progress)
  248. ppc_md.progress("Bridge init failed", 0x100);
  249. printk("Host bridge init failed\n");
  250. }
  251. return;
  252. }
  253. static void __init
  254. sandpoint_setup_arch(void)
  255. {
  256. /* Probe for Sandpoint model */
  257. sandpoint_probe_type();
  258. if (sandpoint_is_x2)
  259. epic_serial_mode = 0;
  260. loops_per_jiffy = 100000000 / HZ;
  261. #ifdef CONFIG_BLK_DEV_INITRD
  262. if (initrd_start)
  263. ROOT_DEV = Root_RAM0;
  264. else
  265. #endif
  266. #ifdef CONFIG_ROOT_NFS
  267. ROOT_DEV = Root_NFS;
  268. #else
  269. ROOT_DEV = Root_HDA1;
  270. #endif
  271. /* Lookup PCI host bridges */
  272. sandpoint_find_bridges();
  273. if (strncmp (cur_ppc_sys_spec->ppc_sys_name, "8245", 4) == 0)
  274. {
  275. bd_t *bp = (bd_t *)__res;
  276. struct plat_serial8250_port *pdata;
  277. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC10X_UART0);
  278. if (pdata)
  279. {
  280. pdata[0].uartclk = bp->bi_busfreq;
  281. }
  282. #ifdef CONFIG_SANDPOINT_ENABLE_UART1
  283. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC10X_UART1);
  284. if (pdata)
  285. {
  286. pdata[0].uartclk = bp->bi_busfreq;
  287. }
  288. #else
  289. ppc_sys_device_remove(MPC10X_UART1);
  290. #endif
  291. }
  292. printk(KERN_INFO "Motorola SPS Sandpoint Test Platform\n");
  293. printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  294. /* DINK32 12.3 and below do not correctly enable any caches.
  295. * We will do this now with good known values. Future versions
  296. * of DINK32 are supposed to get this correct.
  297. */
  298. if (cpu_has_feature(CPU_FTR_SPEC7450))
  299. /* 745x is different. We only want to pass along enable. */
  300. _set_L2CR(L2CR_L2E);
  301. else if (cpu_has_feature(CPU_FTR_L2CR))
  302. /* All modules have 1MB of L2. We also assume that an
  303. * L2 divisor of 3 will work.
  304. */
  305. _set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3
  306. | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);
  307. #if 0
  308. /* Untested right now. */
  309. if (cpu_has_feature(CPU_FTR_L3CR)) {
  310. /* Magic value. */
  311. _set_L3CR(0x8f032000);
  312. }
  313. #endif
  314. }
  315. #define SANDPOINT_87308_CFG_ADDR 0x15c
  316. #define SANDPOINT_87308_CFG_DATA 0x15d
  317. #define SANDPOINT_87308_CFG_INB(addr, byte) { \
  318. outb((addr), SANDPOINT_87308_CFG_ADDR); \
  319. (byte) = inb(SANDPOINT_87308_CFG_DATA); \
  320. }
  321. #define SANDPOINT_87308_CFG_OUTB(addr, byte) { \
  322. outb((addr), SANDPOINT_87308_CFG_ADDR); \
  323. outb((byte), SANDPOINT_87308_CFG_DATA); \
  324. }
  325. #define SANDPOINT_87308_SELECT_DEV(dev_num) { \
  326. SANDPOINT_87308_CFG_OUTB(0x07, (dev_num)); \
  327. }
  328. #define SANDPOINT_87308_DEV_ENABLE(dev_num) { \
  329. SANDPOINT_87308_SELECT_DEV(dev_num); \
  330. SANDPOINT_87308_CFG_OUTB(0x30, 0x01); \
  331. }
  332. /*
  333. * To probe the Sandpoint type, we need to check for a connection between GPIO
  334. * pins 6 and 7 on the NS87308 SuperIO.
  335. */
  336. static void __init sandpoint_probe_type(void)
  337. {
  338. u8 x;
  339. /* First, ensure that the GPIO pins are enabled. */
  340. SANDPOINT_87308_SELECT_DEV(0x07); /* Select GPIO logical device */
  341. SANDPOINT_87308_CFG_OUTB(0x60, 0x07); /* Base address 0x700 */
  342. SANDPOINT_87308_CFG_OUTB(0x61, 0x00);
  343. SANDPOINT_87308_CFG_OUTB(0x30, 0x01); /* Enable */
  344. /* Now, set pin 7 to output and pin 6 to input. */
  345. outb((inb(0x701) | 0x80) & 0xbf, 0x701);
  346. /* Set push-pull output */
  347. outb(inb(0x702) | 0x80, 0x702);
  348. /* Set pull-up on input */
  349. outb(inb(0x703) | 0x40, 0x703);
  350. /* Set output high and check */
  351. x = inb(0x700);
  352. outb(x | 0x80, 0x700);
  353. x = inb(0x700);
  354. sandpoint_is_x2 = ! (x & 0x40);
  355. if (ppc_md.progress && sandpoint_is_x2)
  356. ppc_md.progress("High output says X2", 0);
  357. /* Set output low and check */
  358. outb(x & 0x7f, 0x700);
  359. sandpoint_is_x2 |= inb(0x700) & 0x40;
  360. if (ppc_md.progress && sandpoint_is_x2)
  361. ppc_md.progress("Low output says X2", 0);
  362. if (ppc_md.progress && ! sandpoint_is_x2)
  363. ppc_md.progress("Sandpoint is X3", 0);
  364. }
  365. /*
  366. * Fix IDE interrupts.
  367. */
  368. static int __init
  369. sandpoint_fix_winbond_83553(void)
  370. {
  371. /* Make some 8259 interrupt level sensitive */
  372. outb(0xe0, 0x4d0);
  373. outb(0xde, 0x4d1);
  374. return 0;
  375. }
  376. arch_initcall(sandpoint_fix_winbond_83553);
  377. /*
  378. * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip.
  379. */
  380. static int __init
  381. sandpoint_setup_natl_87308(void)
  382. {
  383. u_char reg;
  384. /*
  385. * Enable all the devices on the Super I/O chip.
  386. */
  387. SANDPOINT_87308_SELECT_DEV(0x00); /* Select kbd logical device */
  388. SANDPOINT_87308_CFG_OUTB(0xf0, 0x00); /* Set KBC clock to 8 Mhz */
  389. SANDPOINT_87308_DEV_ENABLE(0x00); /* Enable keyboard */
  390. SANDPOINT_87308_DEV_ENABLE(0x01); /* Enable mouse */
  391. SANDPOINT_87308_DEV_ENABLE(0x02); /* Enable rtc */
  392. SANDPOINT_87308_DEV_ENABLE(0x03); /* Enable fdc (floppy) */
  393. SANDPOINT_87308_DEV_ENABLE(0x04); /* Enable parallel */
  394. SANDPOINT_87308_DEV_ENABLE(0x05); /* Enable UART 2 */
  395. SANDPOINT_87308_CFG_OUTB(0xf0, 0x82); /* Enable bank select regs */
  396. SANDPOINT_87308_DEV_ENABLE(0x06); /* Enable UART 1 */
  397. SANDPOINT_87308_CFG_OUTB(0xf0, 0x82); /* Enable bank select regs */
  398. /* Set up floppy in PS/2 mode */
  399. outb(0x09, SIO_CONFIG_RA);
  400. reg = inb(SIO_CONFIG_RD);
  401. reg = (reg & 0x3F) | 0x40;
  402. outb(reg, SIO_CONFIG_RD);
  403. outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */
  404. return 0;
  405. }
  406. arch_initcall(sandpoint_setup_natl_87308);
  407. static int __init
  408. sandpoint_request_io(void)
  409. {
  410. request_region(0x00,0x20,"dma1");
  411. request_region(0x20,0x20,"pic1");
  412. request_region(0x40,0x20,"timer");
  413. request_region(0x80,0x10,"dma page reg");
  414. request_region(0xa0,0x20,"pic2");
  415. request_region(0xc0,0x20,"dma2");
  416. return 0;
  417. }
  418. arch_initcall(sandpoint_request_io);
  419. /*
  420. * Interrupt setup and service. Interrrupts on the Sandpoint come
  421. * from the four PCI slots plus the 8259 in the Winbond Super I/O (SIO).
  422. * The 8259 is cascaded from EPIC IRQ0, IRQ1-4 map to PCI slots 1-4,
  423. * IDE is on EPIC 7 and 8.
  424. */
  425. static void __init
  426. sandpoint_init_IRQ(void)
  427. {
  428. int i;
  429. OpenPIC_InitSenses = sandpoint_openpic_initsenses;
  430. OpenPIC_NumInitSenses = sizeof(sandpoint_openpic_initsenses);
  431. mpc10x_set_openpic();
  432. openpic_hookup_cascade(sandpoint_is_x2 ? 17 : NUM_8259_INTERRUPTS, "82c59 cascade",
  433. i8259_irq);
  434. /*
  435. * The EPIC allows for a read in the range of 0xFEF00000 ->
  436. * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.
  437. */
  438. i8259_init(0xfef00000, 0);
  439. }
  440. static unsigned long __init
  441. sandpoint_find_end_of_memory(void)
  442. {
  443. bd_t *bp = (bd_t *)__res;
  444. if (bp->bi_memsize)
  445. return bp->bi_memsize;
  446. /* DINK32 13.0 correctly initalizes things, so iff you use
  447. * this you _should_ be able to change this instead of a
  448. * hardcoded value. */
  449. #if 0
  450. return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
  451. #else
  452. return 32*1024*1024;
  453. #endif
  454. }
  455. static void __init
  456. sandpoint_map_io(void)
  457. {
  458. io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
  459. }
  460. static void
  461. sandpoint_restart(char *cmd)
  462. {
  463. local_irq_disable();
  464. /* Set exception prefix high - to the firmware */
  465. _nmask_and_or_msr(0, MSR_IP);
  466. /* Reset system via Port 92 */
  467. outb(0x00, 0x92);
  468. outb(0x01, 0x92);
  469. for(;;); /* Spin until reset happens */
  470. }
  471. static void
  472. sandpoint_power_off(void)
  473. {
  474. local_irq_disable();
  475. for(;;); /* No way to shut power off with software */
  476. /* NOTREACHED */
  477. }
  478. static void
  479. sandpoint_halt(void)
  480. {
  481. sandpoint_power_off();
  482. /* NOTREACHED */
  483. }
  484. static int
  485. sandpoint_show_cpuinfo(struct seq_file *m)
  486. {
  487. seq_printf(m, "vendor\t\t: Motorola SPS\n");
  488. seq_printf(m, "machine\t\t: Sandpoint\n");
  489. return 0;
  490. }
  491. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  492. /*
  493. * IDE support.
  494. */
  495. static int sandpoint_ide_ports_known = 0;
  496. static unsigned long sandpoint_ide_regbase[MAX_HWIFS];
  497. static unsigned long sandpoint_ide_ctl_regbase[MAX_HWIFS];
  498. static unsigned long sandpoint_idedma_regbase;
  499. static void
  500. sandpoint_ide_probe(void)
  501. {
  502. struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  503. PCI_DEVICE_ID_WINBOND_82C105, NULL);
  504. if (pdev) {
  505. sandpoint_ide_regbase[0]=pdev->resource[0].start;
  506. sandpoint_ide_regbase[1]=pdev->resource[2].start;
  507. sandpoint_ide_ctl_regbase[0]=pdev->resource[1].start;
  508. sandpoint_ide_ctl_regbase[1]=pdev->resource[3].start;
  509. sandpoint_idedma_regbase=pdev->resource[4].start;
  510. pci_dev_put(pdev);
  511. }
  512. sandpoint_ide_ports_known = 1;
  513. }
  514. static int
  515. sandpoint_ide_default_irq(unsigned long base)
  516. {
  517. if (sandpoint_ide_ports_known == 0)
  518. sandpoint_ide_probe();
  519. if (base == sandpoint_ide_regbase[0])
  520. return SANDPOINT_IDE_INT0;
  521. else if (base == sandpoint_ide_regbase[1])
  522. return SANDPOINT_IDE_INT1;
  523. else
  524. return 0;
  525. }
  526. static unsigned long
  527. sandpoint_ide_default_io_base(int index)
  528. {
  529. if (sandpoint_ide_ports_known == 0)
  530. sandpoint_ide_probe();
  531. return sandpoint_ide_regbase[index];
  532. }
  533. static void __init
  534. sandpoint_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
  535. unsigned long ctrl_port, int *irq)
  536. {
  537. unsigned long reg = data_port;
  538. uint alt_status_base;
  539. int i;
  540. for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  541. hw->io_ports[i] = reg++;
  542. }
  543. if (data_port == sandpoint_ide_regbase[0]) {
  544. alt_status_base = sandpoint_ide_ctl_regbase[0] + 2;
  545. hw->irq = 14;
  546. }
  547. else if (data_port == sandpoint_ide_regbase[1]) {
  548. alt_status_base = sandpoint_ide_ctl_regbase[1] + 2;
  549. hw->irq = 15;
  550. }
  551. else {
  552. alt_status_base = 0;
  553. hw->irq = 0;
  554. }
  555. if (ctrl_port) {
  556. hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
  557. } else {
  558. hw->io_ports[IDE_CONTROL_OFFSET] = alt_status_base;
  559. }
  560. if (irq != NULL) {
  561. *irq = hw->irq;
  562. }
  563. }
  564. #endif
  565. /*
  566. * Set BAT 3 to map 0xf8000000 to end of physical memory space 1-to-1.
  567. */
  568. static __inline__ void
  569. sandpoint_set_bat(void)
  570. {
  571. unsigned long bat3u, bat3l;
  572. __asm__ __volatile__(
  573. " lis %0,0xf800\n \
  574. ori %1,%0,0x002a\n \
  575. ori %0,%0,0x0ffe\n \
  576. mtspr 0x21e,%0\n \
  577. mtspr 0x21f,%1\n \
  578. isync\n \
  579. sync "
  580. : "=r" (bat3u), "=r" (bat3l));
  581. }
  582. TODC_ALLOC();
  583. void __init
  584. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  585. unsigned long r6, unsigned long r7)
  586. {
  587. parse_bootinfo(find_bootinfo());
  588. /* ASSUMPTION: If both r3 (bd_t pointer) and r6 (cmdline pointer)
  589. * are non-zero, then we should use the board info from the bd_t
  590. * structure and the cmdline pointed to by r6 instead of the
  591. * information from birecs, if any. Otherwise, use the information
  592. * from birecs as discovered by the preceeding call to
  593. * parse_bootinfo(). This rule should work with both PPCBoot, which
  594. * uses a bd_t board info structure, and the kernel boot wrapper,
  595. * which uses birecs.
  596. */
  597. if (r3 && r6) {
  598. /* copy board info structure */
  599. memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
  600. /* copy command line */
  601. *(char *)(r7+KERNELBASE) = 0;
  602. strcpy(cmd_line, (char *)(r6+KERNELBASE));
  603. }
  604. #ifdef CONFIG_BLK_DEV_INITRD
  605. /* take care of initrd if we have one */
  606. if (r4) {
  607. initrd_start = r4 + KERNELBASE;
  608. initrd_end = r5 + KERNELBASE;
  609. }
  610. #endif /* CONFIG_BLK_DEV_INITRD */
  611. /* Map in board regs, etc. */
  612. sandpoint_set_bat();
  613. isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
  614. isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
  615. pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
  616. ISA_DMA_THRESHOLD = 0x00ffffff;
  617. DMA_MODE_READ = 0x44;
  618. DMA_MODE_WRITE = 0x48;
  619. ppc_do_canonicalize_irqs = 1;
  620. ppc_md.setup_arch = sandpoint_setup_arch;
  621. ppc_md.show_cpuinfo = sandpoint_show_cpuinfo;
  622. ppc_md.init_IRQ = sandpoint_init_IRQ;
  623. ppc_md.get_irq = openpic_get_irq;
  624. ppc_md.restart = sandpoint_restart;
  625. ppc_md.power_off = sandpoint_power_off;
  626. ppc_md.halt = sandpoint_halt;
  627. ppc_md.find_end_of_memory = sandpoint_find_end_of_memory;
  628. ppc_md.setup_io_mappings = sandpoint_map_io;
  629. TODC_INIT(TODC_TYPE_PC97307, 0x70, 0x00, 0x71, 8);
  630. ppc_md.time_init = todc_time_init;
  631. ppc_md.set_rtc_time = todc_set_rtc_time;
  632. ppc_md.get_rtc_time = todc_get_rtc_time;
  633. ppc_md.calibrate_decr = todc_calibrate_decr;
  634. ppc_md.nvram_read_val = todc_mc146818_read_val;
  635. ppc_md.nvram_write_val = todc_mc146818_write_val;
  636. #ifdef CONFIG_KGDB
  637. ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
  638. #endif
  639. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  640. ppc_md.progress = gen550_progress;
  641. #endif
  642. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  643. ppc_ide_md.default_irq = sandpoint_ide_default_irq;
  644. ppc_ide_md.default_io_base = sandpoint_ide_default_io_base;
  645. ppc_ide_md.ide_init_hwif = sandpoint_ide_init_hwif_ports;
  646. #endif
  647. }