involves turning sxiahci(4) into a real driver that dynamically attaches.
ehci(4) now also attaches dynamically.
ok jsg@, patrick@
-# $OpenBSD: GENERIC,v 1.32 2016/08/04 15:52:52 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.33 2016/08/05 19:00:25 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
sunxi0 at mainbus?
# Sunxi on-chip devices
-a1xintc* at sunxi? # A1x interrupt controller
+a1xintc* at fdt? # A1x interrupt controller
sxipio* at sunxi? # GPIO pins for leds & PHYs
gpio* at sxipio?
sxiccmu* at sunxi? # Clock Control Module/Unit
sxirtc* at sunxi? # Real Time Clock
sxiuart* at fdt? # onboard UARTs
sxie* at fdt?
-ahci* at sunxi? # AHCI/SATA (shim)
-ehci* at sunxi? # EHCI (shim)
+sxiahci* at fdt? # AHCI/SATA
+ehci* at fdt? # EHCI (shim)
usb* at ehci? #flags 0x1
#ohci* at sunxi?
#usb* at ohci?
-# $OpenBSD: RAMDISK,v 1.29 2016/08/04 15:52:52 kettenis Exp $
+# $OpenBSD: RAMDISK,v 1.30 2016/08/05 19:00:25 kettenis Exp $
machine armv7 arm
sunxi0 at mainbus?
# Sunxi on-chip devices
-a1xintc* at sunxi? # A1x interrupt controller
+a1xintc* at fdt? # A1x interrupt controller
sxipio* at sunxi? # GPIO pins for leds & PHYs
gpio* at sxipio?
sxiccmu* at sunxi? # Clock Control Module/Unit
sxirtc* at sunxi? # Real Time Clock
sxiuart* at fdt? # onboard UARTs
sxie* at fdt?
-ahci* at sunxi? # AHCI/SATA (shim)
-ehci* at sunxi? # EHCI (shim)
+sxiahci* at fdt? # AHCI/SATA
+ehci* at fdt? # EHCI (shim)
usb* at ehci? #flags 0x1
#ohci* at sunxi?
#usb* at ohci?
-/* $OpenBSD: a1xintc.c,v 1.7 2016/01/31 00:14:50 jsg Exp $ */
+/* $OpenBSD: a1xintc.c,v 1.8 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2013 Artturi Alm
#include <sys/evcount.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <armv7/armv7/armv7var.h>
#include <armv7/sunxi/sunxireg.h>
#include <armv7/sunxi/a1xintc.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
#ifdef DEBUG_INTC
#define DPRINTF(x) do { if (a1xintcdebug) printf x; } while (0)
#define DPRINTFN(n,x) do { if (a1xintcdebug>(n)) printf x; } while (0)
struct intrq a1xintc_handler[NIRQ];
u_int32_t a1xintc_smask[NIPL];
u_int32_t a1xintc_imask[NBANKS][NIPL];
+struct interrupt_controller a1xintc_ic;
bus_space_tag_t a1xintc_iot;
bus_space_handle_t a1xintc_ioh;
int a1xintc_nirq;
+int a1xintc_match(struct device *, void *, void *);
void a1xintc_attach(struct device *, struct device *, void *);
int a1xintc_spllower(int);
int a1xintc_splraise(int);
void a1xintc_setipl(int);
void a1xintc_calc_masks(void);
+void *a1xintc_intr_establish_fdt(void *, int *, int, int (*)(void *),
+ void *, char *);
struct cfattach a1xintc_ca = {
- sizeof (struct device), NULL, a1xintc_attach
+ sizeof (struct device), a1xintc_match, a1xintc_attach
};
struct cfdriver a1xintc_cd = {
int a1xintc_attached = 0;
+int
+a1xintc_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "allwinner,sun4i-a10-ic");
+}
+
void
-a1xintc_attach(struct device *parent, struct device *self, void *args)
+a1xintc_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
+ struct fdt_attach_args *faa = aux;
int i, j;
- a1xintc_iot = aa->aa_iot;
- if (bus_space_map(a1xintc_iot, aa->aa_dev->mem[0].addr,
- aa->aa_dev->mem[0].size, 0, &a1xintc_ioh))
+ a1xintc_iot = faa->fa_iot;
+ if (bus_space_map(a1xintc_iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size, 0, &a1xintc_ioh))
panic("a1xintc_attach: bus_space_map failed!");
/* disable/mask/clear all interrupts */
a1xintc_setipl(IPL_HIGH); /* XXX ??? */
enable_interrupts(PSR_I);
printf("\n");
+
+ a1xintc_ic.ic_node = faa->fa_node;
+ a1xintc_ic.ic_establish = a1xintc_intr_establish_fdt;
+ arm_intr_register_fdt(&a1xintc_ic);
}
void
}
void *
-a1xintc_intr_establish(int irq, int lvl, int (*f)(void *), void *arg, char *name)
+a1xintc_intr_establish(int irq, int level, int (*func)(void *),
+ void *arg, char *name)
{
int psw;
struct intrhand *ih;
if (irq <= 0 || irq >= NIRQ)
panic("intr_establish: bogus irq %d %s\n", irq, name);
- DPRINTF(("intr_establish: irq %d level %d [%s]\n", irq, lvl,
+ DPRINTF(("intr_establish: irq %d level %d [%s]\n", irq, level,
name != NULL ? name : "NULL"));
psw = disable_interrupts(PSR_I);
cold ? M_NOWAIT : M_WAITOK);
if (ih == NULL)
panic("intr_establish: can't malloc handler info\n");
- ih->ih_func = f;
+ ih->ih_func = func;
ih->ih_arg = arg;
- ih->ih_ipl = lvl;
+ ih->ih_ipl = level;
ih->ih_irq = irq;
ih->ih_name = name;
return (ih);
}
+void *
+a1xintc_intr_establish_fdt(void *cookie, int *cell, int level,
+ int (*func)(void *), void *arg, char *name)
+{
+ return a1xintc_intr_establish(cell[0], level, func, arg, name);
+}
+
void
a1xintc_intr_disestablish(void *cookie)
{
-# $OpenBSD: files.sunxi,v 1.6 2016/06/11 07:07:59 jsg Exp $
+# $OpenBSD: files.sunxi,v 1.7 2016/08/05 19:00:25 kettenis Exp $
define sunxi {}
device sunxi: sunxi
file arch/armv7/sunxi/sxipio.c sxipio
device a1xintc
-attach a1xintc at sunxi
+attach a1xintc at fdt
file arch/armv7/sunxi/a1xintc.c a1xintc
device sxitimer
attach sxirtc at sunxi
file arch/armv7/sunxi/sxirtc.c sxirtc
-attach ahci at sunxi with sxiahci
+device sxiahci: scsi, atascsi
+attach sxiahci at fdt
file arch/armv7/sunxi/sxiahci.c sxiahci
#attach ohci at sunxi with sxiohci
#file arch/armv7/sunxi/sxiohci.c sxiohci
-attach ehci at sunxi with sxiehci
+attach ehci at fdt with sxiehci
file arch/armv7/sunxi/sxiehci.c sxiehci
device sxiuart
-/* $OpenBSD: sunxi.c,v 1.14 2016/07/27 22:03:52 mglocker Exp $ */
+/* $OpenBSD: sunxi.c,v 1.15 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
*
struct board_dev sun4i_devs[] = {
{ "sxipio", 0 },
{ "sxiccmu", 0 },
- { "a1xintc", 0 },
{ "sxitimer", 0 },
{ "sxitimer", 1 },
{ "sxitimer", 2 },
{ "sxidog", 0 },
{ "sxirtc", 0 },
- { "ahci", 0 },
- { "ehci", 0 },
- { "ehci", 1 },
-#if 0
- { "ohci", 0 },
- { "ohci", 1 },
-#endif
{ NULL, 0 }
};
struct board_dev sun5i_devs[] = {
{ "sxipio", 0 },
{ "sxiccmu", 0 },
- { "a1xintc", 0 },
{ "sxitimer", 0 },
{ "sxitimer", 1 },
{ "sxitimer", 2 },
{ "sxidog", 0 },
- { "ehci", 0 },
-#if 0
- { "ohci", 0 },
-#endif
{ NULL, 0 }
};
{ "sxiccmu", 0 },
{ "sxidog", 0 },
{ "sxirtc", 0 },
- { "ahci", 0 },
- { "ehci", 0 },
- { "ehci", 1 },
-#if 0
- { "ohci", 0 },
- { "ohci", 1 },
-#endif
{ NULL, 0 }
};
-/* $OpenBSD: sxiahci.c,v 1.8 2015/01/22 14:33:01 krw Exp $ */
+/* $OpenBSD: sxiahci.c,v 1.9 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2013,2014 Artturi Alm
#include <sys/queue.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <dev/ic/ahcireg.h>
#include <dev/ic/ahcivar.h>
#include <armv7/sunxi/sxiccmuvar.h>
#include <armv7/sunxi/sxipiovar.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
#define SXIAHCI_CAP 0x0000
#define SXIAHCI_GHC 0x0004
#define SXIAHCI_PI 0x000c
#define SXIAHCI_PREG_DMA_MASK (0xff<<8)
#define SXIAHCI_PREG_DMA_INIT (0x44<<8)
+int sxiahci_match(struct device *, void *, void *);
void sxiahci_attach(struct device *, struct device *, void *);
int sxiahci_detach(struct device *, int);
int sxiahci_activate(struct device *, int);
struct cfattach sxiahci_ca = {
sizeof(struct sxiahci_softc),
- NULL,
+ sxiahci_match,
sxiahci_attach,
sxiahci_detach,
sxiahci_activate
};
struct cfdriver sxiahci_cd = {
- NULL, "ahci", DV_DULL
+ NULL, "sxiahci", DV_DULL
};
+int
+sxiahci_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "allwinner,sun4i-a10-ahci");
+}
+
void
-sxiahci_attach(struct device *parent, struct device *self, void *args)
+sxiahci_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
struct sxiahci_softc *sxisc = (struct sxiahci_softc *)self;
struct ahci_softc *sc = &sxisc->sc;
+ struct fdt_attach_args *faa = aux;
uint32_t timo;
- sc->sc_iot = aa->aa_iot;
- sc->sc_ios = aa->aa_dev->mem[0].size;
- sc->sc_dmat = aa->aa_dmat;
+ if (faa->fa_nreg < 1)
+ return;
- if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
- sc->sc_ios, 0, &sc->sc_ioh))
+ sc->sc_iot = faa->fa_iot;
+ sc->sc_ios = faa->fa_reg[0].size;
+ sc->sc_dmat = faa->fa_dmat;
+
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size, 0, &sc->sc_ioh))
panic("sxiahci_attach: bus_space_map failed!");
/* enable clock */
sxipio_setcfg(SXIAHCI_PWRPIN, SXIPIO_OUTPUT);
sxipio_setpin(SXIAHCI_PWRPIN);
- sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_BIO,
+ sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_BIO,
ahci_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": unable to establish interrupt\n");
goto clrpwr;
}
+ printf(":");
+
SXIWRITE4(sc, SXIAHCI_PI, 1);
SXICLR4(sc, SXIAHCI_CAP, AHCI_REG_CAP_SPM);
sc->sc_flags |= AHCI_F_NO_PMP;
-/* $OpenBSD: sxie.c,v 1.17 2016/07/27 11:45:02 patrick Exp $ */
+/* $OpenBSD: sxie.c,v 1.18 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2013 Artturi Alm
struct fdt_attach_args *faa = aux;
struct mii_data *mii;
struct ifnet *ifp;
- int s, irq;
+ int s;
- if (faa->fa_nreg != 1 || (faa->fa_nintr != 1 && faa->fa_nintr != 3))
+ if (faa->fa_nreg < 1)
return;
- if (faa->fa_nintr == 1)
- irq = faa->fa_intr[0];
- else
- irq = faa->fa_intr[1];
-
sc->sc_iot = faa->fa_iot;
if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
sxie_socware_init(sc);
sc->txf_inuse = 0;
- sc->sc_ih = arm_intr_establish(irq, IPL_NET,
+ sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_NET,
sxie_intr, sc, sc->sc_dev.dv_xname);
s = splnet();
-/* $OpenBSD: sxiehci.c,v 1.4 2014/05/19 13:11:31 mpi Exp $ */
+/* $OpenBSD: sxiehci.c,v 1.5 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
#include <machine/intr.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <armv7/sunxi/sxiccmuvar.h>
#include <armv7/sunxi/sxipiovar.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
#include <dev/usb/ehcireg.h>
#include <dev/usb/ehcivar.h>
#define AHB_INCR4 (1 << 9)
#define AHB_INCR8 (1 << 10)
+int sxiehci_match(struct device *, void *, void *);
void sxiehci_attach(struct device *, struct device *, void *);
int sxiehci_detach(struct device *, int);
int sxiehci_activate(struct device *, int);
int sxiehci_init(struct sxiehci_softc *, int);
struct cfattach sxiehci_ca = {
- sizeof (struct sxiehci_softc), NULL, sxiehci_attach,
+ sizeof(struct sxiehci_softc), sxiehci_match, sxiehci_attach,
sxiehci_detach, sxiehci_activate
};
-/* XXX
- * given the nature of SoCs, i think this should just panic on failure,
- * instead of disestablishing interrupt and unmapping space etc..
- */
+int
+sxiehci_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ if (OF_is_compatible(faa->fa_node, "allwinner,sun4i-a10-ehci"))
+ return 1;
+ if (OF_is_compatible(faa->fa_node, "allwinner,sun5i-a13-ehci"))
+ return 1;
+ if (OF_is_compatible(faa->fa_node, "allwinner,sun7i-a20-ehci"))
+ return 1;
+
+ return 0;
+}
+
void
sxiehci_attach(struct device *parent, struct device *self, void *aux)
{
struct sxiehci_softc *sc = (struct sxiehci_softc *)self;
- struct armv7_attach_args *aa = aux;
+ struct fdt_attach_args *faa = aux;
usbd_status r;
char *devname = sc->sc.sc_bus.bdev.dv_xname;
- sc->sc.iot = aa->aa_iot;
- sc->sc.sc_bus.dmatag = aa->aa_dmat;
- sc->sc.sc_size = aa->aa_dev->mem[0].size;
+ sc->sc.iot = faa->fa_iot;
+ sc->sc.sc_bus.dmatag = faa->fa_dmat;
+ sc->sc.sc_size = faa->fa_reg[0].size;
- if (bus_space_map(sc->sc.iot, aa->aa_dev->mem[0].addr,
- aa->aa_dev->mem[0].size, 0, &sc->sc.ioh)) {
+ if (bus_space_map(sc->sc.iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size, 0, &sc->sc.ioh)) {
printf(": cannot map mem space\n");
goto out;
}
sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
- sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_USB,
+ sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_USB,
ehci_intr, &sc->sc, devname);
if (sc->sc_ih == NULL) {
printf(": unable to establish interrupt\n");
-/* $OpenBSD: sxiuart.c,v 1.9 2016/07/27 11:45:02 patrick Exp $ */
+/* $OpenBSD: sxiuart.c,v 1.10 2016/08/05 19:00:25 kettenis Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
* Copyright (c) 2013 Artturi Alm
struct fdt_attach_args *faa = aux;
bus_space_tag_t iot;
bus_space_handle_t ioh;
- int s, irq;
+ int s;
- if (faa->fa_nreg != 1 || (faa->fa_nintr != 1 && faa->fa_nintr != 3))
+ if (faa->fa_nreg < 1)
return;
- if (faa->fa_nintr == 1)
- irq = faa->fa_intr[0];
- else
- irq = faa->fa_intr[1];
-
sc->sc_iot = iot = faa->fa_iot;
if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
faa->fa_reg[0].size, 0, &sc->sc_ioh))
bus_space_write_1(sc->sc_iot, sc->sc_ioh, SXIUART_MCR, sc->sc_mcr);
splx(s);
- arm_intr_establish(irq, IPL_TTY,
+ arm_intr_establish_fdt(faa->fa_node, IPL_TTY,
sxiuart_intr, sc, sc->sc_dev.dv_xname);
printf("\n");
-# $OpenBSD: files,v 1.621 2016/08/05 11:40:22 kettenis Exp $
+# $OpenBSD: files,v 1.622 2016/08/05 19:00:25 kettenis Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
# Advanced Host Controller Interface for Serial ATA
device ahci: scsi, atascsi
file dev/ic/ahci.c ahci | (ahci_pci | ahci_jmb |
- imxahci) needs-flag
+ imxahci | sxiahci) needs-flag
# NVM Express Controller
device nvme: scsi