Author: ganbold
Date: Thu May 21 07:01:08 2015
New Revision: 283181
URL: https://svnweb.freebsd.org/changeset/base/283181

Log:
  The RTC initialization values are based on the SoC which can be
  determined at runtime so there's no need to set the values in
  each DTS.
  Tested on YYHD18 (aml8726-m3), VSATV102 (aml8726-m6), and
  ODROIDC1 (aml8726-m8b).
  
  Differential Revision:        https://reviews.freebsd.org/D2588
  Submitted by:         John Wehle

Modified:
  head/sys/arm/amlogic/aml8726/aml8726_rtc.c
  head/sys/boot/fdt/dts/arm/odroidc1.dts
  head/sys/boot/fdt/dts/arm/vsatv102-m6.dts

Modified: head/sys/arm/amlogic/aml8726/aml8726_rtc.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_rtc.c  Thu May 21 06:58:50 2015        
(r283180)
+++ head/sys/arm/amlogic/aml8726/aml8726_rtc.c  Thu May 21 07:01:08 2015        
(r283181)
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
+#include <arm/amlogic/aml8726/aml8726_soc.h>
+
 #include "clock_if.h"
 
 /*
@@ -372,44 +374,27 @@ static int
 aml8726_rtc_attach(device_t dev)
 {
        struct aml8726_rtc_softc *sc = device_get_softc(dev);
-       boolean_t init_always_valid;
-       char *init_always;
-       pcell_t prop;
-       phandle_t node;
-       ssize_t len;
 
        sc->dev = dev;
 
-       node = ofw_bus_get_node(dev);
-
-       len = OF_getprop_alloc(node, "init-always",
-           sizeof(char), (void **)&init_always);
-       sc->init.always = FALSE;
-       init_always_valid = FALSE;
-       if (len > 0) {
-               if (strncmp(init_always, "true", len) == 0) {
-                       sc->init.always = TRUE;
-                       init_always_valid = TRUE;
-               } else if (strncmp(init_always, "false", len) == 0)
-                       init_always_valid = TRUE;
-               free(init_always, M_OFWPROP);
-       }
-       if (init_always_valid == FALSE) {
-               device_printf(dev, "missing init-always attribute in FDT\n");
-               return (ENXIO);
-       }
-
-       if (OF_getencprop(node, "xo-init", &prop, sizeof(prop)) <= 0) {
-               device_printf(dev, "missing xo-init attribute in FDT\n");
-               return (ENXIO);
-       }
-       sc->init.xo = prop;
-
-       if (OF_getencprop(node, "gpo-init", &prop, sizeof(prop)) <= 0) {
-               device_printf(dev, "missing gpo-init attribute in FDT\n");
+       switch (aml8726_soc_hw_rev) {
+       case AML_SOC_HW_REV_M3:
+               sc->init.always = true;
+               sc->init.xo = 0x3c0a;
+               sc->init.gpo = 0x100000;
+               break;
+       case AML_SOC_HW_REV_M6:
+       case AML_SOC_HW_REV_M8:
+       case AML_SOC_HW_REV_M8B:
+               sc->init.always = false;
+               sc->init.xo = 0x180a;
+               sc->init.gpo = 0x500000;
+               break;
+       default:
+               device_printf(dev, "unsupported SoC\n");
                return (ENXIO);
+               /* NOTREACHED */
        }
-       sc->init.gpo = prop;
 
        if (bus_alloc_resources(dev, aml8726_rtc_spec, sc->res)) {
                device_printf(dev, "can not allocate resources for device\n");

Modified: head/sys/boot/fdt/dts/arm/odroidc1.dts
==============================================================================
--- head/sys/boot/fdt/dts/arm/odroidc1.dts      Thu May 21 06:58:50 2015        
(r283180)
+++ head/sys/boot/fdt/dts/arm/odroidc1.dts      Thu May 21 07:01:08 2015        
(r283181)
@@ -194,10 +194,6 @@
                        compatible = "amlogic,aml8726-rtc";
                        reg = <0xc8100740 20>;  /* aobus 0x1d0 */
                        interrupts = <0 72 1>;
-
-                       init-always = "false";
-                       xo-init = <0x180a>;
-                       gpo-init = <0x500000>;
                };
 
                clkmsr: clkmsr@c1108758 {

Modified: head/sys/boot/fdt/dts/arm/vsatv102-m6.dts
==============================================================================
--- head/sys/boot/fdt/dts/arm/vsatv102-m6.dts   Thu May 21 06:58:50 2015        
(r283180)
+++ head/sys/boot/fdt/dts/arm/vsatv102-m6.dts   Thu May 21 07:01:08 2015        
(r283181)
@@ -153,10 +153,6 @@
                        compatible = "amlogic,aml8726-rtc";
                        reg = <0xda004340 20>;  /* secbus2 0xd0 */
                        interrupts = <0 72 1>;  /* AM_IRQ2(8) */
-
-                       init-always = "false";
-                       xo-init = <0x180a>;
-                       gpo-init = <0x500000>;
                };
 
                clkmsr: clkmsr@c1108758 {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to