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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/sparc/kernel/auxio_64.c (Architecture ppc) and /arch/sparc/kernel/auxio_64.c (Architecture sparc)


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

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php