Import 2.3.18pre1
[davej-history.git] / arch / sparc / kernel / auxio.c
blob099c14eca7682a99fa0a92485aa55c4e151b5ba6
1 /* auxio.c: Probing for the Sparc AUXIO register at boot time.
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4 */
6 #include <linux/stddef.h>
7 #include <linux/init.h>
8 #include <linux/config.h>
9 #include <asm/oplib.h>
10 #include <asm/io.h>
11 #include <asm/auxio.h>
13 /* Probe and map in the Auxiliary I/O register */
14 unsigned char *auxio_register;
16 void __init auxio_probe(void)
18 int node, auxio_nd;
19 struct linux_prom_registers auxregs[1];
21 switch (sparc_cpu_model) {
22 case sun4d:
23 case sun4:
24 auxio_register = 0;
25 return;
26 default:
27 break;
29 node = prom_getchild(prom_root_node);
30 auxio_nd = prom_searchsiblings(node, "auxiliary-io");
31 if(!auxio_nd) {
32 node = prom_searchsiblings(node, "obio");
33 node = prom_getchild(node);
34 auxio_nd = prom_searchsiblings(node, "auxio");
35 if(!auxio_nd) {
36 #ifdef CONFIG_PCI
37 /* There may be auxio on Ebus */
38 auxio_register = 0;
39 return;
40 #else
41 if(prom_searchsiblings(node, "leds")) {
42 /* VME chassis sun4m machine, no auxio exists. */
43 auxio_register = 0;
44 return;
46 prom_printf("Cannot find auxio node, cannot continue...\n");
47 prom_halt();
48 #endif
51 prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs));
52 prom_apply_obio_ranges(auxregs, 0x1);
53 /* Map the register both read and write */
54 auxio_register = (unsigned char *) sparc_alloc_io(auxregs[0].phys_addr, 0,
55 auxregs[0].reg_size,
56 "auxiliaryIO",
57 auxregs[0].which_io, 0x0);
58 /* Fix the address on sun4m and sun4c. */
59 if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 ||
60 sparc_cpu_model == sun4c)
61 auxio_register = (unsigned char *) ((int)auxio_register | 3);
63 TURN_ON_LED;
67 /* sun4m power control register (AUXIO2) */
69 volatile unsigned char * auxio_power_register = NULL;
71 void __init auxio_power_probe(void)
73 struct linux_prom_registers regs;
74 int node;
76 /* Attempt to find the sun4m power control node. */
77 node = prom_getchild(prom_root_node);
78 node = prom_searchsiblings(node, "obio");
79 node = prom_getchild(node);
80 node = prom_searchsiblings(node, "power");
81 if (node == 0 || node == -1)
82 return;
84 /* Map the power control register. */
85 prom_getproperty(node, "reg", (char *)&regs, sizeof(regs));
86 prom_apply_obio_ranges(&regs, 1);
87 auxio_power_register = (volatile unsigned char *)
88 sparc_alloc_io(regs.phys_addr, 0, regs.reg_size,
89 "power off control", regs.which_io, 0);
91 /* Display a quick message on the console. */
92 if (auxio_power_register)
93 printk(KERN_INFO "Power off control detected.\n");