Home | History | Annotate | Line # | Download | only in dev
auxio_ebus.c revision 1.1
      1 /*	$NetBSD: auxio_ebus.c,v 1.1 2000/04/05 07:52:48 mrg Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999 Matthew R. Green
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 /*
     32  * AUXIO registers support on the Ebus2.
     33  */
     34 
     35 #include <sys/param.h>
     36 #include <sys/systm.h>
     37 #include <sys/errno.h>
     38 #include <sys/device.h>
     39 #include <sys/malloc.h>
     40 
     41 #include <machine/autoconf.h>
     42 #include <machine/cpu.h>
     43 
     44 #include <sparc64/dev/ebusreg.h>
     45 #include <sparc64/dev/ebusvar.h>
     46 #include <sparc64/dev/auxioreg.h>
     47 #include <sparc64/dev/auxiovar.h>
     48 
     49 #define	AUXIO_ROM_NAME		"auxio"
     50 
     51 int	auxio_ebus_match __P((struct device *, struct cfdata *, void *));
     52 void	auxio_ebus_attach __P((struct device *, struct device *, void *));
     53 
     54 struct cfattach auxio_ebus_ca = {
     55 	sizeof(struct device), auxio_ebus_match, auxio_ebus_attach
     56 };
     57 
     58 struct auxio_registers auxio_registers;
     59 
     60 int
     61 auxio_ebus_match(parent, cf, aux)
     62 	struct device *parent;
     63 	struct cfdata *cf;
     64 	void *aux;
     65 {
     66 	struct ebus_attach_args *ea = aux;
     67 
     68 	return (strcmp(AUXIO_ROM_NAME, ea->ea_name) == 0);
     69 }
     70 
     71 void
     72 auxio_ebus_attach(parent, self, aux)
     73 	struct device *parent, *self;
     74 	void *aux;
     75 {
     76 	struct ebus_attach_args *ea = aux;
     77 	int i, first = 1;
     78 
     79 	/*
     80 	 * for each of the registers found, if we know the matching
     81 	 * AUXIO register, set it up.
     82 	 */
     83 	for (i = 0; i < ea->ea_nregs; i++) {
     84 
     85 #define	SHOWIT(s) do { \
     86 	if (first) { \
     87 		first = 0; \
     88 		printf(": mapping"); \
     89 	} \
     90 	printf(" %s", s); \
     91 } while (0)
     92 
     93 		if (ea->ea_regs[i].lo == AUXIO_FD) {
     94 			SHOWIT("fd");
     95 			auxio_registers.auxio_fd = (caddr_t)AUXIO_FD;
     96 		} else if (ea->ea_regs[i].lo == AUXIO_AUDIO) {
     97 			SHOWIT("audio");
     98 			auxio_registers.auxio_audio = (caddr_t)AUXIO_AUDIO;
     99 		} else if (ea->ea_regs[i].lo == AUXIO_POWER) {
    100 			SHOWIT("power");
    101 			auxio_registers.auxio_power = (caddr_t)AUXIO_POWER;
    102 		} else if (ea->ea_regs[i].lo == AUXIO_LED) {
    103 			SHOWIT("led");
    104 			auxio_registers.auxio_led = (caddr_t)AUXIO_LED;
    105 		} else if (ea->ea_regs[i].lo == AUXIO_PCI) {
    106 			SHOWIT("pci");
    107 			auxio_registers.auxio_pci = (caddr_t)AUXIO_PCI;
    108 		} else if (ea->ea_regs[i].lo == AUXIO_FREQ) {
    109 			SHOWIT("freq");
    110 			auxio_registers.auxio_freq = (caddr_t)AUXIO_FREQ;
    111 		} else if (ea->ea_regs[i].lo == AUXIO_SCSI) {
    112 			SHOWIT("scsi");
    113 			auxio_registers.auxio_scsi = (caddr_t)AUXIO_SCSI;
    114 		} else if (ea->ea_regs[i].lo == AUXIO_TEMP) {
    115 			SHOWIT("temp");
    116 			auxio_registers.auxio_temp = (caddr_t)AUXIO_TEMP;
    117 		} else {
    118 			printf(": unknown auxio register lo=%x", ea->ea_regs[i].lo);
    119 		}
    120 	}
    121 	printf("\n");
    122 }
    123