Linux Audio

Check our new training course

Loading...
v3.5.6
 
  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
  6#include <linux/stddef.h>
  7#include <linux/init.h>
  8#include <linux/spinlock.h>
  9#include <linux/of.h>
 10#include <linux/of_device.h>
 11#include <linux/export.h>
 
 12#include <asm/oplib.h>
 13#include <asm/io.h>
 14#include <asm/auxio.h>
 15#include <asm/string.h>		/* memset(), Linux has no bzero() */
 16#include <asm/cpu_type.h>
 17
 
 
 18/* Probe and map in the Auxiliary I/O register */
 19
 20/* auxio_register is not static because it is referenced 
 21 * in entry.S::floppy_tdone
 22 */
 23void __iomem *auxio_register = NULL;
 24static DEFINE_SPINLOCK(auxio_lock);
 25
 26void __init auxio_probe(void)
 27{
 28	phandle node, auxio_nd;
 29	struct linux_prom_registers auxregs[1];
 30	struct resource r;
 31
 32	switch (sparc_cpu_model) {
 33	case sparc_leon:
 34	case sun4d:
 35		return;
 36	default:
 37		break;
 38	}
 39	node = prom_getchild(prom_root_node);
 40	auxio_nd = prom_searchsiblings(node, "auxiliary-io");
 41	if(!auxio_nd) {
 42		node = prom_searchsiblings(node, "obio");
 43		node = prom_getchild(node);
 44		auxio_nd = prom_searchsiblings(node, "auxio");
 45		if(!auxio_nd) {
 46#ifdef CONFIG_PCI
 47			/* There may be auxio on Ebus */
 48			return;
 49#else
 50			if(prom_searchsiblings(node, "leds")) {
 51				/* VME chassis sun4m machine, no auxio exists. */
 52				return;
 53			}
 54			prom_printf("Cannot find auxio node, cannot continue...\n");
 55			prom_halt();
 56#endif
 57		}
 58	}
 59	if(prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs)) <= 0)
 60		return;
 61	prom_apply_obio_ranges(auxregs, 0x1);
 62	/* Map the register both read and write */
 63	r.flags = auxregs[0].which_io & 0xF;
 64	r.start = auxregs[0].phys_addr;
 65	r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1;
 66	auxio_register = of_ioremap(&r, 0, auxregs[0].reg_size, "auxio");
 67	/* Fix the address on sun4m. */
 68	if ((((unsigned long) auxregs[0].phys_addr) & 3) == 3)
 69		auxio_register += (3 - ((unsigned long)auxio_register & 3));
 70
 71	set_auxio(AUXIO_LED, 0);
 72}
 73
 74unsigned char get_auxio(void)
 75{
 76	if(auxio_register) 
 77		return sbus_readb(auxio_register);
 78	return 0;
 79}
 80EXPORT_SYMBOL(get_auxio);
 81
 82void set_auxio(unsigned char bits_on, unsigned char bits_off)
 83{
 84	unsigned char regval;
 85	unsigned long flags;
 86	spin_lock_irqsave(&auxio_lock, flags);
 87	switch (sparc_cpu_model) {
 88	case sun4m:
 89		if(!auxio_register)
 90			break;     /* VME chassis sun4m, no auxio. */
 91		regval = sbus_readb(auxio_register);
 92		sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M,
 93			auxio_register);
 94		break;
 95	case sun4d:
 96		break;
 97	default:
 98		panic("Can't set AUXIO register on this machine.");
 99	}
100	spin_unlock_irqrestore(&auxio_lock, flags);
101}
102EXPORT_SYMBOL(set_auxio);
103
104/* sun4m power control register (AUXIO2) */
105
106volatile unsigned char * auxio_power_register = NULL;
107
108void __init auxio_power_probe(void)
109{
110	struct linux_prom_registers regs;
111	phandle node;
112	struct resource r;
113
114	/* Attempt to find the sun4m power control node. */
115	node = prom_getchild(prom_root_node);
116	node = prom_searchsiblings(node, "obio");
117	node = prom_getchild(node);
118	node = prom_searchsiblings(node, "power");
119	if (node == 0 || (s32)node == -1)
120		return;
121
122	/* Map the power control register. */
123	if (prom_getproperty(node, "reg", (char *)&regs, sizeof(regs)) <= 0)
124		return;
125	prom_apply_obio_ranges(&regs, 1);
126	memset(&r, 0, sizeof(r));
127	r.flags = regs.which_io & 0xF;
128	r.start = regs.phys_addr;
129	r.end = regs.phys_addr + regs.reg_size - 1;
130	auxio_power_register = (unsigned char *) of_ioremap(&r, 0,
131	    regs.reg_size, "auxpower");
132
133	/* Display a quick message on the console. */
134	if (auxio_power_register)
135		printk(KERN_INFO "Power off control detected.\n");
136}
v6.2
  1// SPDX-License-Identifier: GPL-2.0
  2/* auxio.c: Probing for the Sparc AUXIO register at boot time.
  3 *
  4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5 */
  6
  7#include <linux/stddef.h>
  8#include <linux/init.h>
  9#include <linux/spinlock.h>
 10#include <linux/of.h>
 11#include <linux/of_device.h>
 12#include <linux/export.h>
 13
 14#include <asm/oplib.h>
 15#include <asm/io.h>
 16#include <asm/auxio.h>
 17#include <asm/string.h>		/* memset(), Linux has no bzero() */
 18#include <asm/cpu_type.h>
 19
 20#include "kernel.h"
 21
 22/* Probe and map in the Auxiliary I/O register */
 23
 24/* auxio_register is not static because it is referenced 
 25 * in entry.S::floppy_tdone
 26 */
 27void __iomem *auxio_register = NULL;
 28static DEFINE_SPINLOCK(auxio_lock);
 29
 30void __init auxio_probe(void)
 31{
 32	phandle node, auxio_nd;
 33	struct linux_prom_registers auxregs[1];
 34	struct resource r;
 35
 36	switch (sparc_cpu_model) {
 37	case sparc_leon:
 38	case sun4d:
 39		return;
 40	default:
 41		break;
 42	}
 43	node = prom_getchild(prom_root_node);
 44	auxio_nd = prom_searchsiblings(node, "auxiliary-io");
 45	if(!auxio_nd) {
 46		node = prom_searchsiblings(node, "obio");
 47		node = prom_getchild(node);
 48		auxio_nd = prom_searchsiblings(node, "auxio");
 49		if(!auxio_nd) {
 50#ifdef CONFIG_PCI
 51			/* There may be auxio on Ebus */
 52			return;
 53#else
 54			if(prom_searchsiblings(node, "leds")) {
 55				/* VME chassis sun4m machine, no auxio exists. */
 56				return;
 57			}
 58			prom_printf("Cannot find auxio node, cannot continue...\n");
 59			prom_halt();
 60#endif
 61		}
 62	}
 63	if(prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs)) <= 0)
 64		return;
 65	prom_apply_obio_ranges(auxregs, 0x1);
 66	/* Map the register both read and write */
 67	r.flags = auxregs[0].which_io & 0xF;
 68	r.start = auxregs[0].phys_addr;
 69	r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1;
 70	auxio_register = of_ioremap(&r, 0, auxregs[0].reg_size, "auxio");
 71	/* Fix the address on sun4m. */
 72	if ((((unsigned long) auxregs[0].phys_addr) & 3) == 3)
 73		auxio_register += (3 - ((unsigned long)auxio_register & 3));
 74
 75	set_auxio(AUXIO_LED, 0);
 76}
 77
 78unsigned char get_auxio(void)
 79{
 80	if(auxio_register) 
 81		return sbus_readb(auxio_register);
 82	return 0;
 83}
 84EXPORT_SYMBOL(get_auxio);
 85
 86void set_auxio(unsigned char bits_on, unsigned char bits_off)
 87{
 88	unsigned char regval;
 89	unsigned long flags;
 90	spin_lock_irqsave(&auxio_lock, flags);
 91	switch (sparc_cpu_model) {
 92	case sun4m:
 93		if(!auxio_register)
 94			break;     /* VME chassis sun4m, no auxio. */
 95		regval = sbus_readb(auxio_register);
 96		sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M,
 97			auxio_register);
 98		break;
 99	case sun4d:
100		break;
101	default:
102		panic("Can't set AUXIO register on this machine.");
103	}
104	spin_unlock_irqrestore(&auxio_lock, flags);
105}
106EXPORT_SYMBOL(set_auxio);
107
108/* sun4m power control register (AUXIO2) */
109
110volatile u8 __iomem *auxio_power_register = NULL;
111
112void __init auxio_power_probe(void)
113{
114	struct linux_prom_registers regs;
115	phandle node;
116	struct resource r;
117
118	/* Attempt to find the sun4m power control node. */
119	node = prom_getchild(prom_root_node);
120	node = prom_searchsiblings(node, "obio");
121	node = prom_getchild(node);
122	node = prom_searchsiblings(node, "power");
123	if (node == 0 || (s32)node == -1)
124		return;
125
126	/* Map the power control register. */
127	if (prom_getproperty(node, "reg", (char *)&regs, sizeof(regs)) <= 0)
128		return;
129	prom_apply_obio_ranges(&regs, 1);
130	memset(&r, 0, sizeof(r));
131	r.flags = regs.which_io & 0xF;
132	r.start = regs.phys_addr;
133	r.end = regs.phys_addr + regs.reg_size - 1;
134	auxio_power_register =
135		(u8 __iomem *)of_ioremap(&r, 0, regs.reg_size, "auxpower");
136
137	/* Display a quick message on the console. */
138	if (auxio_power_register)
139		printk(KERN_INFO "Power off control detected.\n");
140}