sandpoint.c 19 KB

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