No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp700 / dev / uturn.c
blob95f8ff9fec7d008c6bb0e8272af1f13e64e4e43b
1 /* $NetBSD: uturn.c,v 1.5 2009/05/24 06:53:34 skrll Exp $ */
3 /* $OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $ */
5 /*
6 * Copyright (c) 2004 Michael Shalayeff
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
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 OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
31 /* TODO IOA programming */
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/device.h>
36 #include <sys/reboot.h>
38 #include <machine/iomod.h>
39 #include <machine/autoconf.h>
41 #include <hp700/dev/cpudevs.h>
43 struct uturn_regs {
44 uint64_t resv0[2];
45 uint64_t status; /* 0x10: */
46 uint64_t resv1[5];
47 uint64_t debug; /* 0x40: */
50 struct uturn_softc {
51 device_t sc_dv;
53 struct uturn_regs volatile *sc_regs;
56 int uturnmatch(device_t, cfdata_t, void *);
57 void uturnattach(device_t, device_t, void *);
58 static void uturn_callback(device_t self, struct confargs *ca);
60 CFATTACH_DECL_NEW(uturn, sizeof(struct uturn_softc),
61 uturnmatch, uturnattach, NULL, NULL);
63 extern struct cfdriver uturn_cd;
65 int
66 uturnmatch(device_t parent, cfdata_t cf, void *aux)
68 struct confargs *ca = aux;
70 /* there will be only one */
71 if (ca->ca_type.iodc_type != HPPA_TYPE_IOA ||
72 ca->ca_type.iodc_sv_model != HPPA_IOA_UTURN)
73 return 0;
75 if (ca->ca_type.iodc_model == 0x58 &&
76 ca->ca_type.iodc_revision >= 0x20)
77 return 0;
79 return 1;
82 void
83 uturnattach(device_t parent, device_t self, void *aux)
85 struct confargs *ca = aux, nca;
86 struct uturn_softc *sc = device_private(self);
87 bus_space_handle_t ioh;
89 if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
90 aprint_error(": can't map IO space\n");
91 return;
94 sc->sc_dv = self;
95 sc->sc_regs = (struct uturn_regs *)ca->ca_hpa;
97 aprint_normal(": %s rev %d\n",
98 ca->ca_type.iodc_revision < 0x10? "U2" : "UTurn",
99 ca->ca_type.iodc_revision & 0xf);
101 /* keep it real */
102 ((struct iomod *)ioh)->io_control = 0x80;
105 * U2/UTurn is actually a combination of an Upper Bus Converter (UBC)
106 * and a Lower Bus Converter (LBC). This driver attaches to the UBC;
107 * the LBC isn't very interesting, so we skip it. This is easy, since
108 * it always is module 63, hence the MAXMODBUS - 1 below.
110 nca = *ca;
111 nca.ca_hpabase = 0;
112 nca.ca_nmodules = MAXMODBUS - 1;
113 pdc_scanbus(self, &nca, uturn_callback);
115 /* XXX On some machines, PDC doesn't tell us about all devices. */
116 switch (cpu_hvers) {
117 case HPPA_BOARD_HP809:
118 case HPPA_BOARD_HP819:
119 case HPPA_BOARD_HP829:
120 case HPPA_BOARD_HP839:
121 case HPPA_BOARD_HP849:
122 case HPPA_BOARD_HP859:
123 case HPPA_BOARD_HP869:
125 case HPPA_BOARD_HP800D:
126 case HPPA_BOARD_HP821:
127 nca.ca_hpabase = ((struct iomod *)ioh)->io_io_low << 16;
128 pdc_scanbus(self, &nca, uturn_callback);
129 break;
130 default:
131 break;
135 static void
136 uturn_callback(device_t self, struct confargs *ca)
139 config_found_sm_loc(self, "gedoens", NULL, ca, mbprint, mbsubmatch);