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/config.h>
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/ioport.h>
14 #include <asm/oplib.h>
18 #include <asm/auxio.h>
20 void __iomem *auxio_register = NULL;
21 EXPORT_SYMBOL(auxio_register);
29 static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
30 static DEFINE_SPINLOCK(auxio_lock);
32 static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
39 spin_lock_irqsave(&auxio_lock, flags);
41 regval = sbus_readb(auxio_register);
42 newval = regval | bits_on;
44 newval &= ~AUXIO_AUX1_MASK;
45 sbus_writeb(newval, auxio_register);
47 spin_unlock_irqrestore(&auxio_lock, flags);
51 static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
58 spin_lock_irqsave(&auxio_lock, flags);
60 regval = (u8)readl(auxio_register);
61 newval = regval | bits_on;
63 writel((u32)newval, auxio_register);
65 spin_unlock_irqrestore(&auxio_lock, flags);
69 static inline void __auxio_ebus_set_led(int on)
71 (on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
72 __auxio_ebus_set(0, AUXIO_PCIO_LED) ;
75 static inline void __auxio_sbus_set_led(int on)
77 (on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
78 __auxio_sbus_set(0, AUXIO_AUX1_LED) ;
81 void auxio_set_led(int on)
83 switch(auxio_devtype) {
85 __auxio_sbus_set_led(on);
88 __auxio_ebus_set_led(on);
95 static inline void __auxio_sbus_set_lte(int on)
97 (on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) :
98 __auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
101 void auxio_set_lte(int on)
103 switch(auxio_devtype) {
104 case AUXIO_TYPE_SBUS:
105 __auxio_sbus_set_lte(on);
107 case AUXIO_TYPE_EBUS:
114 static void __devinit auxio_report_dev(struct device_node *dp)
116 printk(KERN_INFO "AUXIO: Found device at %s\n",
120 static struct of_device_id auxio_match[] = {
127 MODULE_DEVICE_TABLE(of, auxio_match);
130 static int __devinit auxio_sbus_probe(struct of_device *dev, const struct of_device_id *match)
132 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
134 auxio_devtype = AUXIO_TYPE_SBUS;
135 auxio_register = sbus_ioremap(&sdev->resource[0], 0,
136 sdev->reg_addrs[0].reg_size,
141 auxio_report_dev(dev->node);
145 static struct of_platform_driver auxio_sbus_driver = {
147 .match_table = auxio_match,
148 .probe = auxio_sbus_probe,
153 static int __devinit auxio_ebus_probe(struct of_device *dev, const struct of_device_id *match)
155 struct linux_ebus_device *edev = to_ebus_device(&dev->dev);
157 auxio_devtype = AUXIO_TYPE_EBUS;
158 auxio_register = ioremap(edev->resource[0].start, sizeof(u32));
162 auxio_report_dev(dev->node);
164 auxio_set_led(AUXIO_LED_ON);
169 static struct of_platform_driver auxio_ebus_driver = {
171 .match_table = auxio_match,
172 .probe = auxio_ebus_probe,
176 static int __init auxio_probe(void)
179 of_register_driver(&auxio_sbus_driver, &sbus_bus_type);
182 of_register_driver(&auxio_ebus_driver, &ebus_bus_type);
188 /* Must be after subsys_initcall() so that busses are probed. Must
189 * be before device_initcall() because things like the floppy driver
190 * need to use the AUXIO register.
192 fs_initcall(auxio_probe);