Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/ingenic - keep a list of devices, addresses an...
details: https://anonhg.NetBSD.org/src/rev/018d6b1b1f03
branches: trunk
changeset: 336749:018d6b1b1f03
user: macallan <macallan%NetBSD.org@localhost>
date: Tue Mar 17 07:25:07 2015 +0000
description:
- keep a list of devices, addresses and interrupts in apbus.c
- pass irq numbers to devices
- reduce magic numbers in device drivers
- allow multiple instances of device drivers
diffstat:
sys/arch/mips/ingenic/apbus.c | 54 ++++++++++++++++++++++-----------
sys/arch/mips/ingenic/ingenic_dwctwo.c | 8 ++--
sys/arch/mips/ingenic/ingenic_ehci.c | 8 ++--
sys/arch/mips/ingenic/ingenic_ohci.c | 8 ++--
sys/arch/mips/ingenic/ingenic_var.h | 3 +-
5 files changed, 50 insertions(+), 31 deletions(-)
diffs (204 lines):
diff -r baca16c87d79 -r 018d6b1b1f03 sys/arch/mips/ingenic/apbus.c
--- a/sys/arch/mips/ingenic/apbus.c Tue Mar 17 07:22:40 2015 +0000
+++ b/sys/arch/mips/ingenic/apbus.c Tue Mar 17 07:25:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apbus.c,v 1.7 2015/03/09 13:24:21 macallan Exp $ */
+/* $NetBSD: apbus.c,v 1.8 2015/03/17 07:25:07 macallan Exp $ */
/*-
* Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
/* catch-all for on-chip peripherals */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.7 2015/03/09 13:24:21 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.8 2015/03/17 07:25:07 macallan Exp $");
#include "locators.h"
#define _MIPS_BUS_DMA_PRIVATE
@@ -62,14 +62,30 @@
._dmatag_ops = _BUS_DMATAG_OPS_INITIALIZER,
};
-static const char *apbus_devs[] = {
- "dwctwo",
- "ohci",
- "ehci",
- "dme",
- "jzgpio",
- "jzfb",
- NULL
+typedef struct apbus_dev {
+ const char *name;
+ bus_addr_t addr;
+ uint32_t irq;
+} apbus_dev_t;
+
+static const apbus_dev_t apbus_devs[] = {
+ { "dwctwo", JZ_DWC2_BASE, 21},
+ { "ohci", JZ_OHCI_BASE, 5 },
+ { "ehci", JZ_EHCI_BASE, 20},
+ { "dme", JZ_DME_BASE, -1}, /* irq via gpio abuse */
+ { "jzgpio", JZ_GPIO_A_BASE, 17},
+ { "jzgpio", JZ_GPIO_B_BASE, 16},
+ { "jzgpio", JZ_GPIO_C_BASE, 15},
+ { "jzgpio", JZ_GPIO_D_BASE, 14},
+ { "jzgpio", JZ_GPIO_E_BASE, 13},
+ { "jzgpio", JZ_GPIO_F_BASE, 12},
+ { "jziic", JZ_SMB0_BASE, 60},
+ { "jziic", JZ_SMB1_BASE, 59},
+ { "jziic", JZ_SMB2_BASE, 58},
+ { "jziic", JZ_SMB3_BASE, 57},
+ { "jziic", JZ_SMB4_BASE, 56},
+ { "jzfb", -1, -1},
+ { NULL, -1, -1}
};
void
@@ -135,10 +151,11 @@
printf("JZ_UHCCDR %08x\n", readreg(JZ_UHCCDR));
#endif
- for (const char **adv = apbus_devs; *adv != NULL; adv++) {
+ for (const apbus_dev_t *adv = apbus_devs; adv->name != NULL; adv++) {
struct apbus_attach_args aa;
- aa.aa_name = *adv;
- aa.aa_addr = 0;
+ aa.aa_name = adv->name;
+ aa.aa_addr = adv->addr;
+ aa.aa_irq = adv->irq;
aa.aa_dmat = &apbus_dmat;
aa.aa_bst = apbus_memt;
@@ -151,12 +168,13 @@
{
struct apbus_attach_args *aa = aux;
- if (pnp)
+ if (pnp) {
aprint_normal("%s at %s", aa->aa_name, pnp);
-
- if (aa->aa_addr)
- aprint_normal(" addr 0x%" PRIxBUSADDR, aa->aa_addr);
-
+ if (aa->aa_addr != -1)
+ aprint_normal(" addr 0x%" PRIxBUSADDR, aa->aa_addr);
+ if (aa->aa_irq != -1)
+ aprint_normal(" irq %d", aa->aa_irq);
+ }
return (UNCONF);
}
diff -r baca16c87d79 -r 018d6b1b1f03 sys/arch/mips/ingenic/ingenic_dwctwo.c
--- a/sys/arch/mips/ingenic/ingenic_dwctwo.c Tue Mar 17 07:22:40 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_dwctwo.c Tue Mar 17 07:25:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_dwctwo.c,v 1.7 2015/03/10 18:03:17 macallan Exp $ */
+/* $NetBSD: ingenic_dwctwo.c,v 1.8 2015/03/17 07:25:07 macallan Exp $ */
/*-
* Copyright (c) 2014 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_dwctwo.c,v 1.7 2015/03/10 18:03:17 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_dwctwo.c,v 1.8 2015/03/17 07:25:07 macallan Exp $");
/*
* adapted from bcm2835_dwctwo.c
@@ -176,11 +176,11 @@
delay(10000);
- sc->sc_ih = evbmips_intr_establish(21, dwc2_intr, &sc->sc_dwc2);
+ sc->sc_ih = evbmips_intr_establish(aa->aa_irq, dwc2_intr, &sc->sc_dwc2);
if (sc->sc_ih == NULL) {
aprint_error_dev(self, "failed to establish interrupt %d\n",
- 21);
+ aa->aa_irq);
goto fail;
}
diff -r baca16c87d79 -r 018d6b1b1f03 sys/arch/mips/ingenic/ingenic_ehci.c
--- a/sys/arch/mips/ingenic/ingenic_ehci.c Tue Mar 17 07:22:40 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_ehci.c Tue Mar 17 07:25:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_ehci.c,v 1.1 2015/03/08 17:14:27 macallan Exp $ */
+/* $NetBSD: ingenic_ehci.c,v 1.2 2015/03/17 07:25:07 macallan Exp $ */
/*-
* Copyright (c) 2015 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_ehci.c,v 1.1 2015/03/08 17:14:27 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_ehci.c,v 1.2 2015/03/17 07:25:07 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -114,11 +114,11 @@
/* Disable EHCI interrupts */
bus_space_write_4(sc->iot, sc->ioh, EHCI_USBINTR, 0);
- ih = evbmips_intr_establish(20, ehci_intr, sc);
+ ih = evbmips_intr_establish(aa->aa_irq, ehci_intr, sc);
if (ih == NULL) {
aprint_error_dev(self, "failed to establish interrupt %d\n",
- 20);
+ aa->aa_irq);
goto fail;
}
diff -r baca16c87d79 -r 018d6b1b1f03 sys/arch/mips/ingenic/ingenic_ohci.c
--- a/sys/arch/mips/ingenic/ingenic_ohci.c Tue Mar 17 07:22:40 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_ohci.c Tue Mar 17 07:25:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_ohci.c,v 1.1 2015/03/08 17:14:27 macallan Exp $ */
+/* $NetBSD: ingenic_ohci.c,v 1.2 2015/03/17 07:25:07 macallan Exp $ */
/*-
* Copyright (c) 2015 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_ohci.c,v 1.1 2015/03/08 17:14:27 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_ohci.c,v 1.2 2015/03/17 07:25:07 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -102,11 +102,11 @@
bus_space_write_4(sc->iot, sc->ioh, OHCI_INTERRUPT_DISABLE,
OHCI_ALL_INTRS);
- ih = evbmips_intr_establish(5, ohci_intr, sc);
+ ih = evbmips_intr_establish(aa->aa_irq, ohci_intr, sc);
if (ih == NULL) {
aprint_error_dev(self, "failed to establish interrupt %d\n",
- 5);
+ aa->aa_irq);
goto fail;
}
diff -r baca16c87d79 -r 018d6b1b1f03 sys/arch/mips/ingenic/ingenic_var.h
--- a/sys/arch/mips/ingenic/ingenic_var.h Tue Mar 17 07:22:40 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_var.h Tue Mar 17 07:25:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_var.h,v 1.1 2014/12/06 14:34:56 macallan Exp $ */
+/* $NetBSD: ingenic_var.h,v 1.2 2015/03/17 07:25:07 macallan Exp $ */
/*-
* Copyright (c) 2014 Michael Lorenz
@@ -36,6 +36,7 @@
bus_space_tag_t aa_bst;
bus_dma_tag_t aa_dmat;
bus_addr_t aa_addr;
+ uint32_t aa_irq;
};
extern bus_space_tag_t ingenic_memt;
Home |
Main Index |
Thread Index |
Old Index