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/kernel.h>
10 #include <linux/init.h>
11 #include <linux/ioport.h>
13 #include <asm/oplib.h>
17 #include <asm/auxio.h>
19 /* This cannot be static, as it is referenced in irq.c */
20 void __iomem *auxio_register = NULL;
28 static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
29 static DEFINE_SPINLOCK(auxio_lock);
31 static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
38 spin_lock_irqsave(&auxio_lock, flags);
40 regval = sbus_readb(auxio_register);
41 newval = regval | bits_on;
43 newval &= ~AUXIO_AUX1_MASK;
44 sbus_writeb(newval, auxio_register);
46 spin_unlock_irqrestore(&auxio_lock, flags);
50 static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
57 spin_lock_irqsave(&auxio_lock, flags);
59 regval = (u8)readl(auxio_register);
60 newval = regval | bits_on;
62 writel((u32)newval, auxio_register);
64 spin_unlock_irqrestore(&auxio_lock, flags);
68 static inline void __auxio_ebus_set_led(int on)
70 (on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
71 __auxio_ebus_set(0, AUXIO_PCIO_LED) ;
74 static inline void __auxio_sbus_set_led(int on)
76 (on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
77 __auxio_sbus_set(0, AUXIO_AUX1_LED) ;
80 void auxio_set_led(int on)
82 switch(auxio_devtype) {
84 __auxio_sbus_set_led(on);
87 __auxio_ebus_set_led(on);
94 static inline void __auxio_sbus_set_lte(int on)
96 (on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) :
97 __auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
100 void auxio_set_lte(int on)
102 switch(auxio_devtype) {
103 case AUXIO_TYPE_SBUS:
104 __auxio_sbus_set_lte(on);
106 case AUXIO_TYPE_EBUS:
113 static void __devinit auxio_report_dev(struct device_node *dp)
115 printk(KERN_INFO "AUXIO: Found device at %s\n",
119 static struct of_device_id auxio_match[] = {
126 MODULE_DEVICE_TABLE(of, auxio_match);
129 static int __devinit auxio_sbus_probe(struct of_device *dev, const struct of_device_id *match)
131 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
133 auxio_devtype = AUXIO_TYPE_SBUS;
134 auxio_register = sbus_ioremap(&sdev->resource[0], 0,
135 sdev->reg_addrs[0].reg_size,
140 auxio_report_dev(dev->node);
144 static struct of_platform_driver auxio_sbus_driver = {
146 .match_table = auxio_match,
147 .probe = auxio_sbus_probe,
152 static int __devinit auxio_ebus_probe(struct of_device *dev, const struct of_device_id *match)
154 struct linux_ebus_device *edev = to_ebus_device(&dev->dev);
156 auxio_devtype = AUXIO_TYPE_EBUS;
157 auxio_register = ioremap(edev->resource[0].start, sizeof(u32));
161 auxio_report_dev(dev->node);
163 auxio_set_led(AUXIO_LED_ON);
168 static struct of_platform_driver auxio_ebus_driver = {
170 .match_table = auxio_match,
171 .probe = auxio_ebus_probe,
175 static int __init auxio_probe(void)
178 of_register_driver(&auxio_sbus_driver, &sbus_bus_type);
181 of_register_driver(&auxio_ebus_driver, &ebus_bus_type);
187 /* Must be after subsys_initcall() so that busses are probed. Must
188 * be before device_initcall() because things like the floppy driver
189 * need to use the AUXIO register.
191 fs_initcall(auxio_probe);