Annotation of sys/arch/hppa/dev/com_dino.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: com_dino.c,v 1.4 2007/07/15 19:25:49 kettenis 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: #include <sys/param.h>
30: #include <sys/systm.h>
31: #include <sys/device.h>
32: #include <sys/tty.h>
33:
34: #include <machine/bus.h>
35: #include <machine/intr.h>
36: #include <machine/iomod.h>
37: #include <machine/autoconf.h>
38:
39: #include <dev/ic/comreg.h>
40: #include <dev/ic/comvar.h>
41:
42: #include <hppa/dev/cpudevs.h>
43:
44: void *dino_intr_establish(void *sc, int irq, int pri,
45: int (*handler)(void *v), void *arg, const char *name);
46:
47: #define COM_DINO_FREQ 7272700
48:
49: struct com_dino_regs {
50: u_int8_t reset;
51: u_int8_t pad0[3];
52: u_int8_t test;
53: #define COM_DINO_PAR_LOOP 0x01
54: #define COM_DINO_CLK_SEL 0x02
55: u_int8_t pad1[3];
56: u_int32_t iodc;
57: u_int8_t pad2[0x54];
58: u_int8_t dither;
59: };
60:
61: int com_dino_match(struct device *, void *, void *);
62: void com_dino_attach(struct device *, struct device *, void *);
63:
64: struct cfattach com_dino_ca = {
65: sizeof(struct com_softc), com_dino_match, com_dino_attach
66: };
67:
68: int
69: com_dino_match(parent, match, aux)
70: struct device *parent;
71: void *match, *aux;
72: {
73: struct confargs *ca = aux;
74:
75: if (ca->ca_type.iodc_type != HPPA_TYPE_FIO ||
76: ca->ca_type.iodc_sv_model != HPPA_FIO_GRS232)
77: return (0);
78:
79: return (1);
80: /* HOZER comprobe1(ca->ca_iot, ca->ca_hpa + IOMOD_DEVOFFSET); */
81: }
82:
83: void
84: com_dino_attach(parent, self, aux)
85: struct device *parent, *self;
86: void *aux;
87: {
88: struct com_softc *sc = (void *)self;
89: struct confargs *ca = aux;
90: struct com_dino_regs *regs = (struct com_dino_regs *)ca->ca_hpa;
91:
92: sc->sc_iot = ca->ca_iot;
93: sc->sc_iobase = (bus_addr_t)ca->ca_hpa + IOMOD_DEVOFFSET;
94:
95: if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS,
96: 0, &sc->sc_ioh)) {
97: printf(": cannot map io space\n");
98: return;
99: }
100:
101: if (PAGE0->mem_cons.pz_class == PCL_DUPLEX &&
102: PAGE0->mem_cons.pz_hpa == ca->ca_hpa) {
103: bus_space_unmap(sc->sc_iot, sc->sc_ioh, COM_NPORTS);
104: comcnattach(sc->sc_iot, sc->sc_iobase, comdefaultrate,
105: COM_DINO_FREQ, comconscflag);
106: }
107:
108: /* select clock freq */
109: regs->test = COM_DINO_CLK_SEL;
110: sc->sc_frequency = COM_DINO_FREQ;
111:
112: com_attach_subr(sc);
113:
114: sc->sc_ih = dino_intr_establish(parent, ca->ca_irq, IPL_TTY,
115: comintr, sc, sc->sc_dev.dv_xname);
116: }
CVSweb