Author: mmel
Date: Wed Apr 29 13:43:15 2020
New Revision: 360461
URL: https://svnweb.freebsd.org/changeset/base/360461

Log:
  Multiple fixes for rockchip iodomain driver:
  - always initialize selector of voltage signaling standard.
    Various versions of U-boot leaves voltage signaling standard settings
    for PMUIO2 domain in different state.  Always initialize it
    into expected state.
  - start the driver as early as possible, the IO domains should be
    initialized before other drivers are attached.
  - rename RK3399 register to its name founds in TRM.
  
  This is the second part of fixes for serial port corruption observed after
  DT 5.6 import.
  
  Reviewed by:  manu
  MFC after:    1 week

Modified:
  head/sys/arm64/rockchip/rk_iodomain.c

Modified: head/sys/arm64/rockchip/rk_iodomain.c
==============================================================================
--- head/sys/arm64/rockchip/rk_iodomain.c       Wed Apr 29 13:41:32 2020        
(r360460)
+++ head/sys/arm64/rockchip/rk_iodomain.c       Wed Apr 29 13:43:15 2020        
(r360461)
@@ -45,17 +45,20 @@ __FBSDID("$FreeBSD$");
 
 #define        RK3288_GRF_IO_VSEL              0x380
 #define        RK3399_GRF_IO_VSEL              0xe640
-#define        RK3399_PMUGRF_IO_VSEL           0x180
+#define        RK3399_PMUGRF_SOC_CON0          0x180
 
 struct rk_iodomain_supply {
        char            *name;
        uint32_t        bit;
 };
 
+struct rk_iodomain_softc;
+
 struct rk_iodomain_conf {
        struct rk_iodomain_supply       *supply;
        int                             nsupply;
        uint32_t                        grf_reg;
+       void                            (*init)(struct rk_iodomain_softc *sc);
 };
 
 struct rk_iodomain_softc {
@@ -101,10 +104,12 @@ static struct rk_iodomain_supply rk3399_pmu_supply[] =
        {"pmu1830-supply", 9},
 };
 
+static void rk3399_pmu_init(struct rk_iodomain_softc *sc);
 static struct rk_iodomain_conf rk3399_pmu_conf = {
        .supply = rk3399_pmu_supply,
        .nsupply = nitems(rk3399_pmu_supply),
-       .grf_reg = RK3399_PMUGRF_IO_VSEL,
+       .grf_reg = RK3399_PMUGRF_SOC_CON0,
+       .init = rk3399_pmu_init,
 };
 
 static struct ofw_compat_data compat_data[] = {
@@ -115,6 +120,14 @@ static struct ofw_compat_data compat_data[] = {
 };
 
 static void
+rk3399_pmu_init(struct rk_iodomain_softc *sc)
+{
+
+       SYSCON_WRITE_4(sc->grf, RK3399_PMUGRF_SOC_CON0,
+           (1 << 8) | (1 << (8 + 16)));        /* set pmu1830_volsel */
+}
+
+static void
 rk_iodomain_set(struct rk_iodomain_softc *sc)
 {
        regulator_t supply;
@@ -141,6 +154,8 @@ rk_iodomain_set(struct rk_iodomain_softc *sc)
        }
 
        SYSCON_WRITE_4(sc->grf, sc->conf->grf_reg, reg | mask);
+       if (sc->conf->init != NULL)
+                sc->conf->init(sc);
 }
 
 static int
@@ -204,4 +219,4 @@ static driver_t rk_iodomain_driver = {
 static devclass_t rk_iodomain_devclass;
 
 EARLY_DRIVER_MODULE(rk_iodomain, simplebus, rk_iodomain_driver,
-  rk_iodomain_devclass, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE);
+  rk_iodomain_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to