Module Name: src
Committed By: rkujawa
Date: Sun Dec 22 23:02:38 UTC 2013
Modified Files:
src/sys/arch/amiga/clockport: files.clockport
src/sys/arch/amiga/conf: GENERIC.in
src/sys/arch/amiga/dev: acafh.c acafhreg.h acafhvar.h wdc_acafh.c
Added Files:
src/sys/arch/amiga/clockport: gencp_acafh.c
Log Message:
Changes to ACA500 support:
- Add support for second (aux) CF slot.
- Rework wdc attachment to be more sane.
- Add support for clockport on ACA500.
- Fix style where appropriate.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/clockport/files.clockport
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/clockport/gencp_acafh.c
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/dev/acafh.c \
src/sys/arch/amiga/dev/acafhreg.h src/sys/arch/amiga/dev/acafhvar.h \
src/sys/arch/amiga/dev/wdc_acafh.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amiga/clockport/files.clockport
diff -u src/sys/arch/amiga/clockport/files.clockport:1.4 src/sys/arch/amiga/clockport/files.clockport:1.5
--- src/sys/arch/amiga/clockport/files.clockport:1.4 Thu Nov 8 18:30:21 2012
+++ src/sys/arch/amiga/clockport/files.clockport Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-# $NetBSD: files.clockport,v 1.4 2012/11/08 18:30:21 rkujawa Exp $
+# $NetBSD: files.clockport,v 1.5 2013/12/22 23:02:38 rkujawa Exp $
define clockportbus {}
@@ -18,6 +18,10 @@ file arch/amiga/clockport/a1k2cp.c a1k2
attach gencp at xsurfbus with gencp_xsurf
file arch/amiga/clockport/gencp_xsurf.c gencp_xsurf needs-flag
+# ACA500 clockport
+attach gencp at acafhbus with gencp_acafh
+file arch/amiga/clockport/gencp_acafh.c gencp_acafh needs-flag
+
# more zbus clockports should be added, like:
# Highway clockport
# attach gencp at highwaybus with gencp_highway
Index: src/sys/arch/amiga/conf/GENERIC.in
diff -u src/sys/arch/amiga/conf/GENERIC.in:1.121 src/sys/arch/amiga/conf/GENERIC.in:1.122
--- src/sys/arch/amiga/conf/GENERIC.in:1.121 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/conf/GENERIC.in Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.121 2013/12/22 02:21:51 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.122 2013/12/22 23:02:38 rkujawa Exp $
#
##
# GENERIC machine description file
@@ -52,7 +52,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.121 $"
+#ident "GENERIC-$Revision: 1.122 $"
m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
makeoptions COPTS="-Os"
@@ -462,6 +462,7 @@ xsurf* at zbus0 # X-Surf
ne* at xsurfbus? # NE2000 chip on X-Surf
gencp* at xsurfbus? # clockports on X-Surf
wdc* at xsurfbus? # IDE on X-Surf
+
clockport* at gencp?
# Arcnet
@@ -517,7 +518,8 @@ scsibus* at empsc0
#acafh0 at mainbus0 # Individual Computers ACA500
#options ACA500_SUPPORT
-#wdc* at acafhbus?
+#wdc* at acafhbus? # CF slots on ACA500
+#gencp* at acafhbus? # clockport on ACA500
wdc0 at mainbus0 # A4000 & A1200 IDE bus
wdc* at zbus0 # Buddha / Catweasel
Index: src/sys/arch/amiga/dev/acafh.c
diff -u src/sys/arch/amiga/dev/acafh.c:1.1 src/sys/arch/amiga/dev/acafh.c:1.2
--- src/sys/arch/amiga/dev/acafh.c:1.1 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/dev/acafh.c Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+/* $NetBSD: acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $");
/*
* Individual Computers ACA500 driver.
@@ -78,6 +78,7 @@ acafh_attach(device_t parent, device_t s
vaddr_t aca_vbase;
int i;
struct acafhbus_attach_args aaa_wdc;
+ struct acafhbus_attach_args aaa_cp;
sc = device_private(self);
sc->sc_dev = self;
@@ -127,9 +128,13 @@ acafh_attach(device_t parent, device_t s
}
aprint_normal("\n");
- aaa_wdc.aaa_base = (bus_addr_t) 0xDA0000 + 2;
+ aaa_wdc.aaa_pbase = (bus_addr_t) GAYLE_IDE_BASE + 2;
strcpy(aaa_wdc.aaa_name, "wdc_acafh");
config_found_ia(sc->sc_dev, "acafhbus", &aaa_wdc, acafh_print);
+
+ aaa_cp.aaa_pbase = (bus_addr_t) ACAFH_CLOCKPORT_BASE;
+ strcpy(aaa_cp.aaa_name, "gencp_acafh");
+ config_found_ia(sc->sc_dev, "acafhbus", &aaa_cp, acafh_print);
}
uint8_t
Index: src/sys/arch/amiga/dev/acafhreg.h
diff -u src/sys/arch/amiga/dev/acafhreg.h:1.1 src/sys/arch/amiga/dev/acafhreg.h:1.2
--- src/sys/arch/amiga/dev/acafhreg.h:1.1 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/dev/acafhreg.h Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: acafhreg.h,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+/* $NetBSD: acafhreg.h,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#ifndef _AMIGA_ACAFHREG_H_
#define GAYLE_IDE_BASE 0xDA0000 /* ACA500 has Gayle-compatible IDE */
+#define ACAFH_CLOCKPORT_BASE 0xD80001
#define ACAFH_MSB_SHIFT 0xF
#define ACAFH_MSB_MASK 0x8000
Index: src/sys/arch/amiga/dev/acafhvar.h
diff -u src/sys/arch/amiga/dev/acafhvar.h:1.1 src/sys/arch/amiga/dev/acafhvar.h:1.2
--- src/sys/arch/amiga/dev/acafhvar.h:1.1 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/dev/acafhvar.h Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: acafhvar.h,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+/* $NetBSD: acafhvar.h,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ struct acafh_softc {
struct acafhbus_attach_args {
char aaa_name[32];
- bus_addr_t aaa_base;
+ bus_addr_t aaa_pbase; /* physical base address */
};
uint8_t acafh_cf_intr_status(struct acafh_softc *, uint8_t);
Index: src/sys/arch/amiga/dev/wdc_acafh.c
diff -u src/sys/arch/amiga/dev/wdc_acafh.c:1.1 src/sys/arch/amiga/dev/wdc_acafh.c:1.2
--- src/sys/arch/amiga/dev/wdc_acafh.c:1.1 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/dev/wdc_acafh.c Sun Dec 22 23:02:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc_acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+/* $NetBSD: wdc_acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
/*-
* Copyright (c) 2000, 2003, 2013 The NetBSD Foundation, Inc.
@@ -32,8 +32,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * ACA500 CF (IDE) controller driver.
+ *
+ * The hardware emulates original A600/A1200 Gayle interface. However, it has
+ * two channels, second channel placed instead of ctl registers (so software
+ * reset of the bus is not possible, duh). There are no slave devices.
+ */
+
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc_acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -52,26 +60,39 @@ __KERNEL_RCSID(0, "$NetBSD: wdc_acafh.c,
#include <amiga/amiga/gayle.h>
#include <amiga/dev/zbusvar.h>
#include <amiga/dev/acafhvar.h>
+#include <amiga/dev/acafhreg.h>
#include <dev/ata/atavar.h>
#include <dev/ic/wdcvar.h>
+#define WDC_ACAFH_SLOTS 2
+
+struct wdc_acafh_slot {
+ struct ata_channel channel;
+ struct ata_queue chqueue;
+ struct wdc_regs wdr;
+};
+
struct wdc_acafh_softc {
- struct wdc_softc sc_wdcdev;
- struct ata_channel *sc_chanlist[1];
- struct ata_channel sc_channel;
- struct ata_queue sc_chqueue;
- struct wdc_regs sc_wdc_regs;
- struct isr sc_isr;
- volatile u_char *sc_intreg;
- struct bus_space_tag cmd_iot;
- struct bus_space_tag ctl_iot;
- struct acafh_softc *aca_sc;
+ device_t sc_dev;
+
+ struct wdc_softc sc_wdcdev;
+ struct ata_channel *sc_chanlist[WDC_ACAFH_SLOTS];
+ struct wdc_acafh_slot sc_slots[WDC_ACAFH_SLOTS];
+
+ struct isr sc_isr;
+ volatile u_char *sc_intreg;
+
+ struct bus_space_tag cmd_iot;
+
+ struct acafh_softc *aca_sc;
};
-int wdc_acafh_match(device_t, cfdata_t, void *);
-void wdc_acafh_attach(device_t, device_t, void *);
-int wdc_acafh_intr(void *);
+int wdc_acafh_match(device_t, cfdata_t, void *);
+void wdc_acafh_attach(device_t, device_t, void *);
+int wdc_acafh_intr(void *);
+static void wdc_acafh_attach_channel(struct wdc_acafh_softc *, int);
+static void wdc_acafh_map_channel(struct wdc_acafh_softc *, int);
CFATTACH_DECL_NEW(wdc_acafh, sizeof(struct wdc_acafh_softc),
wdc_acafh_match, wdc_acafh_attach, NULL, NULL);
@@ -90,28 +111,80 @@ void
wdc_acafh_attach(device_t parent, device_t self, void *aux)
{
struct wdc_acafh_softc *sc = device_private(self);
- struct wdc_regs *wdr;
int i;
- aprint_normal("\n");
- gayle_init();
+ aprint_normal(": ACA500 CompactFlash interface\n");
+ sc->sc_dev = device_private(self);
sc->aca_sc = device_private(parent);
- sc->sc_wdcdev.sc_atac.atac_dev = self;
- sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;
-
- sc->cmd_iot.base = (u_long) ztwomap(0xda0000 + 2);
gayle_init();
sc->sc_intreg = &gayle.intreq;
- sc->cmd_iot.absm = sc->ctl_iot.absm = &amiga_bus_stride_4swap;
+ /* XXX: take addr from attach args? */
+ sc->cmd_iot.base = (u_long) ztwomap(GAYLE_IDE_BASE + 2);
+ sc->cmd_iot.absm = &amiga_bus_stride_4swap;
+
+ sc->sc_wdcdev.sc_atac.atac_dev = self;
+ sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16;
+ sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
+ sc->sc_wdcdev.sc_atac.atac_channels = sc->sc_chanlist;
+ sc->sc_wdcdev.sc_atac.atac_nchannels = WDC_ACAFH_SLOTS;
+ sc->sc_wdcdev.wdc_maxdrives = 2;
+ sc->sc_wdcdev.cap = WDC_CAPABILITY_NO_AUXCTL;
+
+ wdc_allocate_regs(&sc->sc_wdcdev);
+ for (i = 0; i < WDC_ACAFH_SLOTS; i++) {
+ wdc_acafh_attach_channel(sc, i);
+ }
+
+ sc->sc_isr.isr_intr = wdc_acafh_intr;
+ sc->sc_isr.isr_arg = sc;
+ sc->sc_isr.isr_ipl = 2;
+ add_isr (&sc->sc_isr);
+
+ gayle.intena |= GAYLE_INT_IDE;
+
+}
+
+void
+wdc_acafh_attach_channel(struct wdc_acafh_softc *sc, int chnum)
+{
+ sc->sc_chanlist[chnum] = &sc->sc_slots[chnum].channel;
+ memset(&sc->sc_slots[chnum],0,sizeof(struct wdc_acafh_slot));
+ sc->sc_slots[chnum].channel.ch_channel = chnum;
+ sc->sc_slots[chnum].channel.ch_atac = &sc->sc_wdcdev.sc_atac;
+ sc->sc_slots[chnum].channel.ch_queue = &sc->sc_slots[chnum].chqueue;
+
+ wdc_acafh_map_channel(sc, chnum);
+
+ wdc_init_shadow_regs(&sc->sc_slots[chnum].channel);
+ wdcattach(&sc->sc_slots[chnum].channel);
+
+#ifdef WDC_ACAFH_DEBUG
+ aprint_normal_dev(sc->sc_dev, "done init for channel %d\n", chnum);
+#endif /* WDC_ACAFH_DEBUG */
+
+}
+
+void
+wdc_acafh_map_channel(struct wdc_acafh_softc *sc, int chnum)
+{
+ struct wdc_regs *wdr;
+ int i;
+ bus_addr_t off;
+
+ wdr = CHAN_TO_WDC_REGS(&sc->sc_slots[chnum].channel);
wdr->cmd_iot = &sc->cmd_iot;
- wdr->ctl_iot = &sc->ctl_iot;
- if (bus_space_map(wdr->cmd_iot, 0, 0x40, 0,
+ if (chnum == 0)
+ off = 0;
+ else
+ off = 0x400;
+
+ if (bus_space_map(wdr->cmd_iot, off, 0x40, 0,
&wdr->cmd_baseioh)) {
- aprint_error_dev(self, "couldn't map registers\n");
+ aprint_error_dev(sc->sc_dev, "couldn't map regs\n");
return;
}
@@ -122,35 +195,11 @@ wdc_acafh_attach(device_t parent, device
bus_space_unmap(wdr->cmd_iot,
wdr->cmd_baseioh, 0x40);
- aprint_error_dev(self, "couldn't map registers\n");
+ aprint_error_dev(sc->sc_dev, "couldn't map regs\n");
return;
}
}
- if (bus_space_subregion(wdr->cmd_iot,
- wdr->cmd_baseioh, 0x406, 1, &wdr->ctl_ioh))
- return;
-
- sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16;
- sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
- sc->sc_chanlist[0] = &sc->sc_channel;
- sc->sc_wdcdev.sc_atac.atac_channels = sc->sc_chanlist;
- sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
- sc->sc_wdcdev.wdc_maxdrives = 2;
- sc->sc_channel.ch_channel = 0;
- sc->sc_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
- sc->sc_channel.ch_queue = &sc->sc_chqueue;
-
- wdc_init_shadow_regs(&sc->sc_channel);
-
- sc->sc_isr.isr_intr = wdc_acafh_intr;
- sc->sc_isr.isr_arg = sc;
- sc->sc_isr.isr_ipl = 2;
- add_isr (&sc->sc_isr);
-
- gayle.intena |= GAYLE_INT_IDE;
-
- wdcattach(&sc->sc_channel);
}
int
@@ -161,13 +210,12 @@ wdc_acafh_intr(void *arg)
u_char intreq = *sc->sc_intreg;
if (intreq & GAYLE_INT_IDE) {
-/*
- if (acafh_cf_intr_status(sc->aca_sc, 1) == 1)
- aprint_normal_dev(sc->aca_sc->sc_dev, "intr at slot 1\n");
- if (acafh_cf_intr_status(sc->aca_sc, 0) == 1)
- aprint_normal_dev(sc->aca_sc->sc_dev, "intr at slot 0\n");
-*/
- ret = wdcintr(&sc->sc_channel);
+ if (acafh_cf_intr_status(sc->aca_sc, 1) == 1) {
+ ret = wdcintr(&sc->sc_slots[1].channel);
+ }
+ if (acafh_cf_intr_status(sc->aca_sc, 0) == 1) {
+ ret = wdcintr(&sc->sc_slots[0].channel);
+ }
gayle.intreq = 0x7c | (intreq & 0x03);
}
Added files:
Index: src/sys/arch/amiga/clockport/gencp_acafh.c
diff -u /dev/null src/sys/arch/amiga/clockport/gencp_acafh.c:1.1
--- /dev/null Sun Dec 22 23:02:38 2013
+++ src/sys/arch/amiga/clockport/gencp_acafh.c Sun Dec 22 23:02:38 2013
@@ -0,0 +1,98 @@
+/* $NetBSD: gencp_acafh.c,v 1.1 2013/12/22 23:02:38 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Clockport on ACA500. */
+
+#include <sys/cdefs.h>
+
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kmem.h>
+
+#include <machine/cpu.h>
+
+#include <amiga/amiga/device.h>
+
+#include <amiga/dev/acafhvar.h>
+#include <amiga/dev/zbusvar.h>
+
+#include <amiga/clockport/clockportvar.h>
+
+static int gencp_acafh_match(device_t, cfdata_t, void *);
+static void gencp_acafh_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(gencp_acafh, sizeof(struct gencp_softc),
+ gencp_acafh_match, gencp_acafh_attach, NULL, NULL);
+
+static int
+gencp_acafh_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct acafhbus_attach_args *aaa_aa;
+ static int attach_count = 0;
+
+ aaa_aa = aux;
+
+ if (strcmp(aaa_aa->aaa_name, "gencp_acafh") != 0)
+ return 0;
+
+ if (attach_count >= 1)
+ return 0;
+
+ attach_count++;
+
+ return 1;
+}
+
+static void
+gencp_acafh_attach(device_t parent, device_t self, void *aux)
+{
+ struct gencp_softc *sc;
+ struct bus_space_tag cpb_bst;
+ struct clockportbus_attach_args cpb_aa;
+ struct acafhbus_attach_args *aaa_aa;
+
+ aaa_aa = aux;
+ sc = device_private(self);
+ sc->sc_dev = self;
+ sc->cpb_aa = &cpb_aa;
+
+ /* Set the address and bus access methods. */
+ cpb_bst.base = (bus_addr_t) __UNVOLATILE(ztwomap(aaa_aa->aaa_pbase));
+ cpb_bst.absm = &amiga_bus_stride_4;
+
+ sc->cpb_aa->cp_iot = &cpb_bst;
+
+ gencp_attach(sc);
+}
+