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_rmw(u8 bits_on, u8 bits_off, int ebus)
36 spin_lock_irqsave(&auxio_lock, flags);
39 (u8) readl(auxio_register) :
40 sbus_readb(auxio_register));
41 newval = regval | bits_on;
44 newval &= ~AUXIO_AUX1_MASK;
46 writel((u32) newval, auxio_register);
48 sbus_writeb(newval, auxio_register);
50 spin_unlock_irqrestore(&auxio_lock, flags);
54 static void __auxio_set_bit(u8 bit, int on, int ebus)
56 u8 bits_on = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
64 __auxio_rmw(bits_on, bits_off, ebus);
67 void auxio_set_led(int on)
69 int ebus = auxio_devtype == AUXIO_TYPE_EBUS;
72 bit = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
73 __auxio_set_bit(bit, on, ebus);
76 static void __auxio_sbus_set_lte(int on)
78 __auxio_set_bit(AUXIO_AUX1_LTE, on, 0);
81 void auxio_set_lte(int on)
83 switch(auxio_devtype) {
85 __auxio_sbus_set_lte(on);
94 static struct of_device_id __initdata auxio_match[] = {
101 MODULE_DEVICE_TABLE(of, auxio_match);
103 static int __devinit auxio_probe(struct of_device *dev, const struct of_device_id *match)
105 struct device_node *dp = dev->node;
108 if (!strcmp(dp->parent->name, "ebus")) {
109 auxio_devtype = AUXIO_TYPE_EBUS;
111 } else if (!strcmp(dp->parent->name, "sbus")) {
112 auxio_devtype = AUXIO_TYPE_SBUS;
115 printk("auxio: Unknown parent bus type [%s]\n",
119 auxio_register = of_ioremap(&dev->resource[0], 0, size, "auxio");
123 printk(KERN_INFO "AUXIO: Found device at %s\n",
126 if (auxio_devtype == AUXIO_TYPE_EBUS)
127 auxio_set_led(AUXIO_LED_ON);
132 static struct of_platform_driver auxio_driver = {
133 .match_table = auxio_match,
134 .probe = auxio_probe,
140 static int __init auxio_init(void)
142 return of_register_driver(&auxio_driver, &of_platform_bus_type);
145 /* Must be after subsys_initcall() so that busses are probed. Must
146 * be before device_initcall() because things like the floppy driver
147 * need to use the AUXIO register.
149 fs_initcall(auxio_init);