Module Name: src Committed By: marty Date: Tue Dec 15 23:15:53 UTC 2015
Modified Files: src/sys/arch/arm/samsung: exynos_wdt.c files.exynos Log Message: XU4 FDT WDT - convert driver to FDT The watchdog timer is the most trivial driver in exynos, from the POV of converting to FDT, so go ahead and do it first. NOTE: There's a hack in the driver that needs to eventually be fixed -- the clock frequency is hardwired when it should be gotten from the clock in the device tree. I'll come back and fix this when I'm more comfortable with the api. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/samsung/exynos_wdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/samsung/files.exynos 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/arm/samsung/exynos_wdt.c diff -u src/sys/arch/arm/samsung/exynos_wdt.c:1.7 src/sys/arch/arm/samsung/exynos_wdt.c:1.8 --- src/sys/arch/arm/samsung/exynos_wdt.c:1.7 Sun Dec 13 22:28:09 2015 +++ src/sys/arch/arm/samsung/exynos_wdt.c Tue Dec 15 23:15:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_wdt.c,v 1.7 2015/12/13 22:28:09 marty Exp $ */ +/* $NetBSD: exynos_wdt.c,v 1.8 2015/12/15 23:15:53 marty Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "exynos_wdt.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exynos_wdt.c,v 1.7 2015/12/13 22:28:09 marty Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exynos_wdt.c,v 1.8 2015/12/15 23:15:53 marty Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: exynos_wdt.c #include <arm/samsung/exynos_reg.h> #include <arm/samsung/exynos_var.h> +#include <dev/fdt/fdtvar.h> #if NEXYNOS_WDT > 0 static int exynos_wdt_match(device_t, cfdata_t, void *); @@ -90,7 +91,10 @@ exynos_wdt_wdog_write(struct exynos_wdt_ static int exynos_wdt_match(device_t parent, cfdata_t cf, void *aux) { - return 1; + const char * const compatible[] = { "samsung,s3c2410-wdt", NULL }; + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); } static int @@ -173,22 +177,32 @@ static void exynos_wdt_attach(device_t parent, device_t self, void *aux) { struct exynos_wdt_softc * const sc = device_private(self); - struct exyo_attach_args * const exyo = aux; - prop_dictionary_t dict = device_properties(self); +// prop_dictionary_t dict = device_properties(self); + struct fdt_attach_args * const faa = aux; + bus_addr_t addr; + bus_size_t size; + int error; + + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } sc->sc_dev = self; - sc->sc_bst = exyo->exyo_core_bst; + sc->sc_bst = faa->faa_bst; - if (bus_space_subregion(sc->sc_bst, exyo->exyo_core_bsh, - exyo->exyo_loc.loc_offset, exyo->exyo_loc.loc_size, &sc->sc_wdog_bsh)) { - aprint_error(": failed to map registers\n"); + error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_wdog_bsh); + if (error) { + aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error); return; } /* * This runs at the Exynos Pclk. */ - prop_dictionary_get_uint32(dict, "frequency", &sc->sc_freq); +// prop_dictionary_get_uint32(dict, "frequency", &sc->sc_freq); + sc->sc_freq = 12000000; /* MJF: HACK hardwire for now */ + /* Need to figure out how to get freq from dtb */ sc->sc_wdog_wtcon = exynos_wdt_wdog_read(sc, EXYNOS_WDT_WTCON); sc->sc_wdog_armed = (sc->sc_wdog_wtcon & WTCON_ENABLE) && (sc->sc_wdog_wtcon & WTCON_RESET_ENABLE); @@ -255,7 +269,7 @@ exynos_wdt_attach(device_t parent, devic sc->sc_smw.smw_period = sc->sc_wdog_period; if (sc->sc_wdog_armed) { - int error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, + error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, sc->sc_wdog_period); if (error) aprint_error_dev(self, Index: src/sys/arch/arm/samsung/files.exynos diff -u src/sys/arch/arm/samsung/files.exynos:1.11 src/sys/arch/arm/samsung/files.exynos:1.12 --- src/sys/arch/arm/samsung/files.exynos:1.11 Mon Dec 14 22:06:57 2015 +++ src/sys/arch/arm/samsung/files.exynos Tue Dec 15 23:15:53 2015 @@ -1,4 +1,4 @@ -# $NetBSD: files.exynos,v 1.11 2015/12/14 22:06:57 marty Exp $ +# $NetBSD: files.exynos,v 1.12 2015/12/15 23:15:53 marty Exp $ # # Configuration info for Samsung Exynos SoC ARM Peripherals # @@ -12,14 +12,14 @@ file arch/arm/arm32/arm32_boot.c file arch/arm/arm32/arm32_kvminit.c file arch/arm/arm32/arm32_reboot.c file arch/arm/arm32/irq_dispatch.S +file arch/arm/arm32/armv7_generic_space.c +file arch/arm/arm/bus_space_a4x.S file arch/arm/samsung/exynos_soc.c file arch/arm/samsung/exynos_space.c #file arch/arm/samsung/exynos_dma.c file arch/arm/samsung/exynos_smc.S arm_trustzone_firmware -file arch/arm/arm/bus_space_a4x.S exyo - # Console parameters defparam opt_exynos.h CONADDR defparam opt_exynos.h CONSPEED @@ -63,7 +63,7 @@ file arch/arm/samsung/mct.c exyo_mct # Watchdog device exyowdt : sysmon_wdog -attach exyowdt at exyo with exynos_wdt +attach exyowdt at fdt with exynos_wdt file arch/arm/samsung/exynos_wdt.c exynos_wdt | exyo_io needs-flag # UARTs