Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/samsung XU4 FDT WDT - convert driver to FDT



details:   https://anonhg.NetBSD.org/src/rev/6bfc446b3d45
branches:  trunk
changeset: 342304:6bfc446b3d45
user:      marty <marty%NetBSD.org@localhost>
date:      Tue Dec 15 23:15:53 2015 +0000

description:
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.

diffstat:

 sys/arch/arm/samsung/exynos_wdt.c |  36 +++++++++++++++++++++++++-----------
 sys/arch/arm/samsung/files.exynos |   8 ++++----
 2 files changed, 29 insertions(+), 15 deletions(-)

diffs (122 lines):

diff -r 58b734e271fb -r 6bfc446b3d45 sys/arch/arm/samsung/exynos_wdt.c
--- a/sys/arch/arm/samsung/exynos_wdt.c Tue Dec 15 23:13:51 2015 +0000
+++ b/sys/arch/arm/samsung/exynos_wdt.c Tue Dec 15 23:15:53 2015 +0000
@@ -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 @@
 #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 @@
 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 @@
 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 @@
        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,
diff -r 58b734e271fb -r 6bfc446b3d45 sys/arch/arm/samsung/files.exynos
--- a/sys/arch/arm/samsung/files.exynos Tue Dec 15 23:13:51 2015 +0000
+++ b/sys/arch/arm/samsung/files.exynos Tue Dec 15 23:15:53 2015 +0000
@@ -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_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 @@
 
 # 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



Home | Main Index | Thread Index | Old Index