1 /* auxio.c: Probing for the Sparc AUXIO register at boot time.
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/ioport.h>
12 #include <linux/of_device.h>
16 #include <asm/auxio.h>
18 void __iomem *auxio_register = NULL;
19 EXPORT_SYMBOL(auxio_register);
27 static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
28 static DEFINE_SPINLOCK(auxio_lock);
30 static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
37 spin_lock_irqsave(&auxio_lock, flags);
39 regval = sbus_readb(auxio_register);
40 newval = regval | bits_on;
42 newval &= ~AUXIO_AUX1_MASK;
43 sbus_writeb(newval, auxio_register);
45 spin_unlock_irqrestore(&auxio_lock, flags);
49 static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
56 spin_lock_irqsave(&auxio_lock, flags);
58 regval = (u8)readl(auxio_register);
59 newval = regval | bits_on;
61 writel((u32)newval, auxio_register);
63 spin_unlock_irqrestore(&auxio_lock, flags);
67 static inline void __auxio_ebus_set_led(int on)
69 (on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
70 __auxio_ebus_set(0, AUXIO_PCIO_LED) ;
73 static inline void __auxio_sbus_set_led(int on)
75 (on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
76 __auxio_sbus_set(0, AUXIO_AUX1_LED) ;
79 void auxio_set_led(int on)
81 switch(auxio_devtype) {
83 __auxio_sbus_set_led(on);
86 __auxio_ebus_set_led(on);
93 static inline void __auxio_sbus_set_lte(int on)
95 (on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) :
96 __auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
99 void auxio_set_lte(int on)
101 switch(auxio_devtype) {
102 case AUXIO_TYPE_SBUS:
103 __auxio_sbus_set_lte(on);
105 case AUXIO_TYPE_EBUS:
112 static struct of_device_id auxio_match[] = {
119 MODULE_DEVICE_TABLE(of, auxio_match);
121 static int __devinit auxio_probe(struct of_device *dev, const struct of_device_id *match)
123 struct device_node *dp = dev->node;
126 if (!strcmp(dp->parent->name, "ebus")) {
127 auxio_devtype = AUXIO_TYPE_EBUS;
129 } else if (!strcmp(dp->parent->name, "sbus")) {
130 auxio_devtype = AUXIO_TYPE_SBUS;
133 printk("auxio: Unknown parent bus type [%s]\n",
137 auxio_register = of_ioremap(&dev->resource[0], 0, size, "auxio");
141 printk(KERN_INFO "AUXIO: Found device at %s\n",
144 if (auxio_devtype == AUXIO_TYPE_EBUS)
145 auxio_set_led(AUXIO_LED_ON);
150 static struct of_platform_driver auxio_driver = {
151 .match_table = auxio_match,
152 .probe = auxio_probe,
158 static int __init auxio_init(void)
160 return of_register_driver(&auxio_driver, &of_platform_bus_type);
163 /* Must be after subsys_initcall() so that busses are probed. Must
164 * be before device_initcall() because things like the floppy driver
165 * need to use the AUXIO register.
167 fs_initcall(auxio_init);