diff --git a/sys/arch/arm/broadcom/bcm2835_fdt.c b/sys/arch/arm/broadcom/bcm2835_fdt.c index 5f6bcff..536347b 100644 --- a/sys/arch/arm/broadcom/bcm2835_fdt.c +++ b/sys/arch/arm/broadcom/bcm2835_fdt.c @@ -62,6 +62,7 @@ bcmfdt_attach(device_t parent, device_t self, void *aux) { const char *bcmfdt_init[] = { "interrupt-controller", + "timer", "gpio", "clocks", "mailbox", diff --git a/sys/arch/arm/broadcom/bcm2835_tmr.c b/sys/arch/arm/broadcom/bcm2835_tmr.c index c426d6b..0901092 100644 --- a/sys/arch/arm/broadcom/bcm2835_tmr.c +++ b/sys/arch/arm/broadcom/bcm2835_tmr.c @@ -39,10 +39,11 @@ __KERNEL_RCSID(0, "$NetBSD: bcm2835_tmr.c,v 1.7 2015/07/29 14:22:49 skrll Exp $" #include #include -#include #include #include +#include + #define BCM2835_STIMER_CS 0x00 #define BCM2835_STIMER_M0 __BIT(0) #define BCM2835_STIMER_M1 __BIT(1) @@ -65,6 +66,8 @@ struct bcm2835tmr_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; + + void *sc_ih; }; static int bcmtmr_match(device_t, cfdata_t, void *); @@ -94,19 +97,27 @@ CFATTACH_DECL_NEW(bcmtmr_amba, sizeof(struct bcm2835tmr_softc), static int bcmtmr_match(device_t parent, cfdata_t match, void *aux) { - struct amba_attach_args *aaa = aux; - - if (strcmp(aaa->aaa_name, "bcmtmr") != 0) - return 0; + const char * const compatible[] = { + "brcm,bcm2835-system-timer", + NULL + }; + struct fdt_attach_args * const faa = aux; - return 1; + return of_match_compatible(faa->faa_phandle, compatible); } static void bcmtmr_attach(device_t parent, device_t self, void *aux) { struct bcm2835tmr_softc *sc = device_private(self); - struct amba_attach_args *aaa = aux; +// struct fdtbus_interrupt_controller_func *ifuncs; + struct fdt_attach_args * const faa = aux; + bus_addr_t addr; + bus_size_t size; + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } aprint_naive("\n"); aprint_normal(": VC System Timer\n"); @@ -115,11 +126,25 @@ bcmtmr_attach(device_t parent, device_t self, void *aux) bcm2835tmr_sc = sc; sc->sc_dev = self; - sc->sc_iot = aaa->aaa_iot; + sc->sc_iot = faa->faa_bst; + const int phandle = faa->faa_phandle; - if (bus_space_map(aaa->aaa_iot, aaa->aaa_addr, BCM2835_STIMER_SIZE, 0, - &sc->sc_ioh)) { - aprint_error_dev(sc->sc_dev, "unable to map device\n"); + if (bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_ioh) != 0) { + aprint_error(": couldn't map device\n"); + return; + } + + char intrstr[128]; + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { + aprint_error(": failed to decode interrupt\n"); + return; + } + + sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_CLOCK, FDT_INTR_MPSAFE, + clockhandler, NULL); + if (sc->sc_ih == NULL) { + aprint_error(": failed to establish interrupt on %s\n", + intrstr); return; } @@ -130,7 +155,6 @@ void cpu_initclocks(void) { struct bcm2835tmr_softc *sc = bcm2835tmr_sc; - void *clock_ih; uint32_t stcl; KASSERT(sc != NULL); @@ -143,10 +167,6 @@ cpu_initclocks(void) stcl += counts_per_hz; bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_STIMER_C3, stcl); - clock_ih = intr_establish(BCM2835_INT_TIMER3, IPL_CLOCK, IST_LEVEL, - clockhandler, NULL); - if (clock_ih == NULL) - panic("%s: unable to register timer interrupt", __func__); tc_init(&bcm2835tmr_timecounter); } diff --git a/sys/arch/evbarm/conf/RPI b/sys/arch/evbarm/conf/RPI index b899222..bceb537 100644 --- a/sys/arch/evbarm/conf/RPI +++ b/sys/arch/evbarm/conf/RPI @@ -7,6 +7,8 @@ include "arch/evbarm/conf/std.rpi" include "arch/evbarm/conf/GENERIC.common" +options VERBOSE_INIT_ARM + # CPU options options CPU_ARM1176 diff --git a/sys/arch/evbarm/rpi/rpi_start.S b/sys/arch/evbarm/rpi/rpi_start.S index 3210273..79a8328 100644 --- a/sys/arch/evbarm/rpi/rpi_start.S +++ b/sys/arch/evbarm/rpi/rpi_start.S @@ -339,7 +339,7 @@ Lctl_ID_dis: mmu_init_table: /* Add 1MB of VA==PA at 0x00000000 so we can keep the kernel going */ MMU_INIT(0x0, 0x0, - (_end - KERNEL_BASE + 2 * L1_S_SIZE - 1), + (192 * 1024 * 1024), L1_S_PROTO | L1_S_APv6_KRW) MMU_INIT(KERNEL_BASE, 0x0,