Source-Changes-HG archive

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

[src/trunk]: src/sys - Recognize the AS3722 sd0_v_minus_200mV bit, which is 1...



details:   https://anonhg.NetBSD.org/src/rev/6fd08c1b67dc
branches:  trunk
changeset: 353332:6fd08c1b67dc
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Apr 29 20:43:48 2017 +0000

description:
- Recognize the AS3722 sd0_v_minus_200mV bit, which is 1 on my Jetson TK1.
 - Reduce intended core voltage for Tegra K1 124 by 200mV to 1.2V.

The actual value programmed into the SD0 regulator remains the same (0x50),
a value corresponding to 1.20V.

diffstat:

 sys/arch/arm/nvidia/tegra124_cpu.c |  22 ++++++------
 sys/dev/i2c/as3722.c               |  64 ++++++++++++++++++++++++++++++-------
 2 files changed, 62 insertions(+), 24 deletions(-)

diffs (156 lines):

diff -r 8f10f9d3a8f4 -r 6fd08c1b67dc sys/arch/arm/nvidia/tegra124_cpu.c
--- a/sys/arch/arm/nvidia/tegra124_cpu.c        Sat Apr 29 19:56:59 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra124_cpu.c        Sat Apr 29 20:43:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra124_cpu.c,v 1.1 2017/04/23 12:31:38 jmcneill Exp $ */
+/* $NetBSD: tegra124_cpu.c,v 1.2 2017/04/29 20:43:48 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra124_cpu.c,v 1.1 2017/04/23 12:31:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra124_cpu.c,v 1.2 2017/04/29 20:43:48 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -88,15 +88,15 @@
        u_int divp;
        u_int uvol;
 } tegra124_cpufreq_rates[] = {
-       { 2316, 1, 193, 0, 1400000 },
-       { 2100, 1, 175, 0, 1400000 },
-       { 1896, 1, 158, 0, 1400000 },
-       { 1692, 1, 141, 0, 1400000 },
-       { 1500, 1, 125, 0, 1400000 },
-       { 1296, 1, 108, 0, 1400000 },
-       { 1092, 1, 91,  0, 1400000 },
-       { 900,  1, 75,  0, 1400000 },
-       { 696,  1, 58,  0, 1400000 }
+       { 2316, 1, 193, 0, 1200000 },
+       { 2100, 1, 175, 0, 1200000 },
+       { 1896, 1, 158, 0, 1200000 },
+       { 1692, 1, 141, 0, 1200000 },
+       { 1500, 1, 125, 0, 1200000 },
+       { 1296, 1, 108, 0, 1200000 },
+       { 1092, 1, 91,  0, 1200000 },
+       { 900,  1, 75,  0, 1200000 },
+       { 696,  1, 58,  0, 1200000 }
 };
 
 static const u_int tegra124_cpufreq_max[] = {
diff -r 8f10f9d3a8f4 -r 6fd08c1b67dc sys/dev/i2c/as3722.c
--- a/sys/dev/i2c/as3722.c      Sat Apr 29 19:56:59 2017 +0000
+++ b/sys/dev/i2c/as3722.c      Sat Apr 29 20:43:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.10 2017/04/29 19:56:59 jakllsch Exp $ */
+/* $NetBSD: as3722.c,v 1.11 2017/04/29 20:43:48 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.10 2017/04/29 19:56:59 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.11 2017/04/29 20:43:48 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,11 +101,16 @@
 #define AS3722_ASIC_ID1_REG            0x90
 #define AS3722_ASIC_ID2_REG            0x91
 
+#define AS3722_FUSE7_REG               0xa7
+#define AS3722_FUSE7_SD0_V_MINUS_200MV __BIT(4)
+
 struct as3722_softc {
        device_t        sc_dev;
        i2c_tag_t       sc_i2c;
        i2c_addr_t      sc_addr;
        int             sc_phandle;
+       int             sc_flags;
+#define AS3722_FLAG_SD0_V_MINUS_200MV 0x01
 
        struct sysmon_wdog sc_smw;
        struct todr_chip_handle sc_todr;
@@ -468,6 +473,20 @@
 {
        struct as3722reg_attach_args raa;
        int phandle, child;
+       int error;
+       const int flags = (cold ? I2C_F_POLL : 0);
+       uint8_t tmp;
+
+       iic_acquire_bus(sc->sc_i2c, flags);
+       error = as3722_read(sc, AS3722_FUSE7_REG, &tmp, flags);
+       iic_release_bus(sc->sc_i2c, flags);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev, "failed to read Fuse7: %d\n", error);
+               return;
+       }
+
+       if (tmp & AS3722_FUSE7_SD0_V_MINUS_200MV)
+               sc->sc_flags |= AS3722_FLAG_SD0_V_MINUS_200MV;
 
        phandle = of_find_firstchild_byname(sc->sc_phandle, "regulators");
        if (phandle <= 0)
@@ -634,11 +653,21 @@
        u_int uvol;
        int error;
 
-       for (uint8_t v = 0x01; v <= 0x5a; v++) {
-               uvol = 600000 + (v * 10000);
-               if (uvol >= min_uvol && uvol <= max_uvol) {
-                       set_v = v;
-                       goto done;
+       if (asc->sc_flags & AS3722_FLAG_SD0_V_MINUS_200MV) {
+               for (uint8_t v = 0x01; v <= 0x6e; v++) {
+                       uvol = 400000 + (v * 10000);
+                       if (uvol >= min_uvol && uvol <= max_uvol) {
+                               set_v = v;
+                               goto done;
+                       }
+               }
+       } else {
+               for (uint8_t v = 0x01; v <= 0x5a; v++) {
+                       uvol = 600000 + (v * 10000);
+                       if (uvol >= min_uvol && uvol <= max_uvol) {
+                               set_v = v;
+                               goto done;
+                       }
                }
        }
        if (set_v == 0)
@@ -671,14 +700,23 @@
 
        v &= regdef->vsel_mask;
 
-       if (v == 0)
+       if (v == 0) {
                *puvol = 0;     /* DC/DC powered down */
-       else if (v >= 0x01 && v <= 0x5a)
-               *puvol = 600000 + (v * 10000);
-       else
-               return EINVAL;
+               return 0;
+       }
+       if (asc->sc_flags & AS3722_FLAG_SD0_V_MINUS_200MV) {
+               if (v >= 0x01 && v <= 0x6e) {
+                       *puvol = 400000 + (v * 10000);
+                       return 0;
+               }
+       } else {
+               if (v >= 0x01 && v <= 0x5a) {
+                       *puvol = 600000 + (v * 10000);
+                       return 0;
+               }
+       }
 
-       return 0;
+       return EINVAL;
 }
 
 static int



Home | Main Index | Thread Index | Old Index