Annotation of sys/arch/hppa/dev/uturn.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: uturn.c,v 1.3 2005/04/07 00:21:51 mickey Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 2004 Michael Shalayeff
! 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: *
! 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 19: * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
! 20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 22: * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
! 24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
! 25: * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
! 26: * THE POSSIBILITY OF SUCH DAMAGE.
! 27: */
! 28:
! 29: /* TODO IOA programming */
! 30:
! 31: #include <sys/param.h>
! 32: #include <sys/systm.h>
! 33: #include <sys/device.h>
! 34: #include <sys/reboot.h>
! 35:
! 36: #include <machine/iomod.h>
! 37: #include <machine/autoconf.h>
! 38:
! 39: #include <hppa/dev/cpudevs.h>
! 40:
! 41: struct uturn_regs {
! 42: u_int64_t resv0[2];
! 43: u_int64_t status; /* 0x10: */
! 44: u_int64_t resv1[5];
! 45: u_int64_t debug; /* 0x40: */
! 46: };
! 47:
! 48: struct uturn_softc {
! 49: struct device sc_dv;
! 50:
! 51: struct uturn_regs volatile *sc_regs;
! 52: };
! 53:
! 54: int uturnmatch(struct device *, void *, void *);
! 55: void uturnattach(struct device *, struct device *, void *);
! 56:
! 57: struct cfattach uturn_ca = {
! 58: sizeof(struct uturn_softc), uturnmatch, uturnattach
! 59: };
! 60:
! 61: struct cfdriver uturn_cd = {
! 62: NULL, "uturn", DV_DULL
! 63: };
! 64:
! 65: int
! 66: uturnmatch(parent, cfdata, aux)
! 67: struct device *parent;
! 68: void *cfdata;
! 69: void *aux;
! 70: {
! 71: struct confargs *ca = aux;
! 72: /* struct cfdata *cf = cfdata; */
! 73:
! 74: /* there will be only one */
! 75: if (ca->ca_type.iodc_type != HPPA_TYPE_IOA ||
! 76: ca->ca_type.iodc_sv_model != HPPA_IOA_UTURN)
! 77: return 0;
! 78:
! 79: if (ca->ca_type.iodc_model == 0x58 &&
! 80: ca->ca_type.iodc_revision >= 0x20)
! 81: return 0;
! 82:
! 83: return 1;
! 84: }
! 85:
! 86: void
! 87: uturnattach(parent, self, aux)
! 88: struct device *parent;
! 89: struct device *self;
! 90: void *aux;
! 91: {
! 92: struct confargs *ca = aux, nca;
! 93: struct uturn_softc *sc = (struct uturn_softc *)self;
! 94: bus_space_handle_t ioh;
! 95:
! 96: if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
! 97: printf(": can't map IO space\n");
! 98: return;
! 99: }
! 100: sc->sc_regs = (struct uturn_regs *)ca->ca_hpa;
! 101:
! 102: printf(": %s rev %d\n",
! 103: ca->ca_type.iodc_revision < 0x10? "U2" : "UTurn",
! 104: ca->ca_type.iodc_revision & 0xf);
! 105:
! 106: /* keep it real */
! 107: ((struct iomod *)ioh)->io_control = 0x80;
! 108:
! 109: nca = *ca; /* clone from us */
! 110: nca.ca_hpamask = HPPA_IOBEGIN;
! 111: pdc_scanbus(self, &nca, MAXMODBUS, 0);
! 112: }
CVSweb