sandpoint.c 20 KB

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