1 /* $NetBSD: flipper.c,v 1.1 2012/11/08 18:30:21 rkujawa Exp $ */
2
3 /*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Radoslaw Kujawa.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /* Driver for Individual Computers Delfina Flipper / Petsoff Delfina 1200.
33 *
34 * TODO:
35 * - linux-style /dev/dsp56k interface
36 * - audio
37 * - firmware
38 * - interrupts: caa->cp_intr_establish(dspintr, sc);
39 */
40
41 #include <sys/cdefs.h>
42
43 #include <sys/param.h>
44 #include <sys/device.h>
45
46 #include <sys/bus.h>
47
48 #include <amiga/clockport/clockportvar.h>
49
50 #include <amiga/clockport/flipperreg.h>
51 #include <amiga/clockport/flippervar.h>
52
53 #define FLIPPER_DEBUG 1
54
55 static int flipper_probe(device_t, cfdata_t , void *);
56 static void flipper_attach(device_t, device_t, void *);
57
58 CFATTACH_DECL_NEW(flipper, sizeof(struct flipper_softc),
59 flipper_probe, flipper_attach, NULL, NULL);
60
61 static int
flipper_probe(device_t parent,cfdata_t cf,void * aux)62 flipper_probe(device_t parent, cfdata_t cf, void *aux)
63 {
64 struct clockport_attach_args *caa = aux;
65 uint8_t delfinaver;
66 bus_space_handle_t ioh;
67
68 bus_space_map(caa->cp_iot, 0, FLIPPER_REGSIZE, 0, &ioh);
69
70 delfinaver = bus_space_read_1(caa->cp_iot, ioh, FLIPPER_HOSTCTL);
71 #ifdef FLIPPER_DEBUG
72 aprint_normal("flipper: hostctl probe read %x\n", delfinaver);
73 #endif /* FLIPPER_DEBUG */
74
75 bus_space_unmap(caa->cp_iot, ioh, FLIPPER_REGSIZE);
76
77 if ((delfinaver == 0xB5) || (delfinaver == 0xB6))
78 return 1;
79
80 return 0;
81 }
82
83 static void
flipper_attach(device_t parent,device_t self,void * aux)84 flipper_attach(device_t parent, device_t self, void *aux)
85 {
86 struct flipper_softc *sc = device_private(self);
87 struct clockport_attach_args *caa = aux;
88 sc->sc_dev = self;
89 sc->sc_iot = caa->cp_iot;
90
91 if (bus_space_map(sc->sc_iot, 0, FLIPPER_REGSIZE, 0, &sc->sc_ioh)) {
92 aprint_normal("can't map the bus space\n");
93 return;
94 }
95
96 sc->sc_delfinaver = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
97 FLIPPER_HOSTCTL);
98
99 switch (sc->sc_delfinaver) {
100 case DELFINA_FLIPPER:
101 aprint_normal(": Individual Computers Delfina Flipper\n");
102 break;
103 case DELFINA_1200:
104 aprint_normal(": Petsoff Delfina 1200\n");
105 break;
106 default:
107 aprint_normal(": unknown model\n");
108 return;
109 }
110
111 /* reset the board */
112 bus_space_write_1(sc->sc_iot, sc->sc_ioh, FLIPPER_HOSTCTL,
113 FLIPPER_HOSTCTL_RESET | FLIPPER_HOSTCTL_IRQDIS);
114 delay(10000);
115 bus_space_write_1(sc->sc_iot, sc->sc_ioh, FLIPPER_HOSTCTL,
116 FLIPPER_HOSTCTL_IRQDIS); /* leave interrupts disabled for now */
117
118 /* attach dsp56k, audio, etc. */
119 }
120
121