~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sparc/kernel/auxio_64.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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  * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
  6  */
  7 
  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>
 13 
 14 #include <asm/prom.h>
 15 #include <asm/io.h>
 16 #include <asm/auxio.h>
 17 
 18 void __iomem *auxio_register = NULL;
 19 EXPORT_SYMBOL(auxio_register);
 20 
 21 enum auxio_type {
 22         AUXIO_TYPE_NODEV,
 23         AUXIO_TYPE_SBUS,
 24         AUXIO_TYPE_EBUS
 25 };
 26 
 27 static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
 28 static DEFINE_SPINLOCK(auxio_lock);
 29 
 30 static void __auxio_rmw(u8 bits_on, u8 bits_off, int ebus)
 31 {
 32         if (auxio_register) {
 33                 unsigned long flags;
 34                 u8 regval, newval;
 35 
 36                 spin_lock_irqsave(&auxio_lock, flags);
 37 
 38                 regval = (ebus ?
 39                           (u8) readl(auxio_register) :
 40                           sbus_readb(auxio_register));
 41                 newval =  regval | bits_on;
 42                 newval &= ~bits_off;
 43                 if (!ebus)
 44                         newval &= ~AUXIO_AUX1_MASK;
 45                 if (ebus)
 46                         writel((u32) newval, auxio_register);
 47                 else
 48                         sbus_writeb(newval, auxio_register);
 49                 
 50                 spin_unlock_irqrestore(&auxio_lock, flags);
 51         }
 52 }
 53 
 54 static void __auxio_set_bit(u8 bit, int on, int ebus)
 55 {
 56         u8 bits_on = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
 57         u8 bits_off = 0;
 58 
 59         if (!on) {
 60                 u8 tmp = bits_off;
 61                 bits_off = bits_on;
 62                 bits_on = tmp;
 63         }
 64         __auxio_rmw(bits_on, bits_off, ebus);
 65 }
 66 
 67 void auxio_set_led(int on)
 68 {
 69         int ebus = auxio_devtype == AUXIO_TYPE_EBUS;
 70         u8 bit;
 71 
 72         bit = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
 73         __auxio_set_bit(bit, on, ebus);
 74 }
 75 EXPORT_SYMBOL(auxio_set_led);
 76 
 77 static void __auxio_sbus_set_lte(int on)
 78 {
 79         __auxio_set_bit(AUXIO_AUX1_LTE, on, 0);
 80 }
 81 
 82 void auxio_set_lte(int on)
 83 {
 84         switch(auxio_devtype) {
 85         case AUXIO_TYPE_SBUS:
 86                 __auxio_sbus_set_lte(on);
 87                 break;
 88         case AUXIO_TYPE_EBUS:
 89                 /* FALL-THROUGH */
 90         default:
 91                 break;
 92         }
 93 }
 94 EXPORT_SYMBOL(auxio_set_lte);
 95 
 96 static const struct of_device_id auxio_match[] = {
 97         {
 98                 .name = "auxio",
 99         },
100         {},
101 };
102 
103 MODULE_DEVICE_TABLE(of, auxio_match);
104 
105 static int auxio_probe(struct platform_device *dev)
106 {
107         struct device_node *dp = dev->dev.of_node;
108         unsigned long size;
109 
110         if (!strcmp(dp->parent->name, "ebus")) {
111                 auxio_devtype = AUXIO_TYPE_EBUS;
112                 size = sizeof(u32);
113         } else if (!strcmp(dp->parent->name, "sbus")) {
114                 auxio_devtype = AUXIO_TYPE_SBUS;
115                 size = 1;
116         } else {
117                 printk("auxio: Unknown parent bus type [%s]\n",
118                        dp->parent->name);
119                 return -ENODEV;
120         }
121         auxio_register = of_ioremap(&dev->resource[0], 0, size, "auxio");
122         if (!auxio_register)
123                 return -ENODEV;
124 
125         printk(KERN_INFO "AUXIO: Found device at %s\n",
126                dp->full_name);
127 
128         if (auxio_devtype == AUXIO_TYPE_EBUS)
129                 auxio_set_led(AUXIO_LED_ON);
130 
131         return 0;
132 }
133 
134 static struct platform_driver auxio_driver = {
135         .probe          = auxio_probe,
136         .driver = {
137                 .name = "auxio",
138                 .of_match_table = auxio_match,
139         },
140 };
141 
142 static int __init auxio_init(void)
143 {
144         return platform_driver_register(&auxio_driver);
145 }
146 
147 /* Must be after subsys_initcall() so that busses are probed.  Must
148  * be before device_initcall() because things like the floppy driver
149  * need to use the AUXIO register.
150  */
151 fs_initcall(auxio_init);
152 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp