File: /usr/src/linux/arch/sparc/kernel/auxio.c

1     /* auxio.c: Probing for the Sparc AUXIO register at boot time.
2      *
3      * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4      */
5     
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>
12     #include <asm/string.h>		/* memset(), Linux has no bzero() */
13     
14     /* Probe and map in the Auxiliary I/O register */
15     unsigned char *auxio_register;
16     
17     void __init auxio_probe(void)
18     {
19     	int node, auxio_nd;
20     	struct linux_prom_registers auxregs[1];
21     	struct resource r;
22     
23     	switch (sparc_cpu_model) {
24     	case sun4d:
25     	case sun4:
26     		auxio_register = 0;
27     		return;
28     	default:
29     		break;
30     	}
31     	node = prom_getchild(prom_root_node);
32     	auxio_nd = prom_searchsiblings(node, "auxiliary-io");
33     	if(!auxio_nd) {
34     		node = prom_searchsiblings(node, "obio");
35     		node = prom_getchild(node);
36     		auxio_nd = prom_searchsiblings(node, "auxio");
37     		if(!auxio_nd) {
38     #ifdef CONFIG_PCI
39     			/* There may be auxio on Ebus */
40     			auxio_register = 0;
41     			return;
42     #else
43     			if(prom_searchsiblings(node, "leds")) {
44     				/* VME chassis sun4m machine, no auxio exists. */
45     				auxio_register = 0;
46     				return;
47     			}
48     			prom_printf("Cannot find auxio node, cannot continue...\n");
49     			prom_halt();
50     #endif
51     		}
52     	}
53     	prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs));
54     	prom_apply_obio_ranges(auxregs, 0x1);
55     	/* Map the register both read and write */
56     	r.flags = auxregs[0].which_io & 0xF;
57     	r.start = auxregs[0].phys_addr;
58     	r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1;
59     	auxio_register = (unsigned char *) sbus_ioremap(&r, 0,
60     	    auxregs[0].reg_size, "auxio");
61     	/* Fix the address on sun4m and sun4c. */
62     	if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 ||
63     	   sparc_cpu_model == sun4c)
64     		auxio_register = (unsigned char *) ((int)auxio_register | 3);
65     
66     	TURN_ON_LED;
67     }
68     
69     
70     /* sun4m power control register (AUXIO2) */
71     
72     volatile unsigned char * auxio_power_register = NULL;
73     
74     void __init auxio_power_probe(void)
75     {
76     	struct linux_prom_registers regs;
77     	int node;
78     	struct resource r;
79     
80     	/* Attempt to find the sun4m power control node. */
81     	node = prom_getchild(prom_root_node);
82     	node = prom_searchsiblings(node, "obio");
83     	node = prom_getchild(node);
84     	node = prom_searchsiblings(node, "power");
85     	if (node == 0 || node == -1)
86     		return;
87     
88     	/* Map the power control register. */
89     	prom_getproperty(node, "reg", (char *)&regs, sizeof(regs));
90     	prom_apply_obio_ranges(&regs, 1);
91     	memset(&r, 0, sizeof(r));
92     	r.flags = regs.which_io & 0xF;
93     	r.start = regs.phys_addr;
94     	r.end = regs.phys_addr + regs.reg_size - 1;
95     	auxio_power_register = (unsigned char *) sbus_ioremap(&r, 0,
96     	    regs.reg_size, "auxpower");
97     
98     	/* Display a quick message on the console. */
99     	if (auxio_power_register)
100     		printk(KERN_INFO "Power off control detected.\n");
101     }
102