Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c No need to do the poll-during-autoconfiguration ...



details:   https://anonhg.NetBSD.org/src/rev/b622e96aa03b
branches:  trunk
changeset: 847443:b622e96aa03b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Dec 23 02:50:50 2019 +0000

description:
No need to do the poll-during-autoconfiguration dance; the i2c code
does the right thing for us.

diffstat:

 sys/dev/i2c/axp20x.c  |  24 ++++++++++++------------
 sys/dev/i2c/axppmic.c |  26 +++++++++++++-------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diffs (168 lines):

diff -r 4e019bab974e -r b622e96aa03b sys/dev/i2c/axp20x.c
--- a/sys/dev/i2c/axp20x.c      Mon Dec 23 02:39:47 2019 +0000
+++ b/sys/dev/i2c/axp20x.c      Mon Dec 23 02:50:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: axp20x.c,v 1.13 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: axp20x.c,v 1.14 2019/12/23 02:50:50 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.13 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axp20x.c,v 1.14 2019/12/23 02:50:50 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -248,13 +248,13 @@
        sc->sc_phandle = ia->ia_cookie;
 
        error = axp20x_read(sc, AXP_INPUT_STATUS,
-           &sc->sc_inputstatus, 1, I2C_F_POLL);
+           &sc->sc_inputstatus, 1, 0);
        if (error) {
                aprint_error(": can't read status: %d\n", error);
                return;
        }
        error = axp20x_read(sc, AXP_POWER_MODE,
-           &sc->sc_powermode, 1, I2C_F_POLL);
+           &sc->sc_powermode, 1, 0);
        if (error) {
                aprint_error(": can't read power mode: %d\n", error);
                return;
@@ -262,18 +262,18 @@
        value = AXP_ADC_EN1_ACV | AXP_ADC_EN1_ACI | AXP_ADC_EN1_VBUSV | AXP_ADC_EN1_VBUSI | AXP_ADC_EN1_APSV | AXP_ADC_EN1_TS;
        if (sc->sc_powermode & AXP_POWER_MODE_BATTOK)
                value |= AXP_ADC_EN1_BATTV | AXP_ADC_EN1_BATTI;
-       error = axp20x_write(sc, AXP_ADC_EN1, &value, 1, I2C_F_POLL);
+       error = axp20x_write(sc, AXP_ADC_EN1, &value, 1, 0);
        if (error) {
                aprint_error(": can't set AXP_ADC_EN1\n");
                return;
        }
-       error = axp20x_read(sc, AXP_ADC_EN2, &value, 1, I2C_F_POLL);
+       error = axp20x_read(sc, AXP_ADC_EN2, &value, 1, 0);
        if (error) {
                aprint_error(": can't read AXP_ADC_EN2\n");
                return;
        }
        value |= AXP_ADC_EN2_TEMP;
-       error = axp20x_write(sc, AXP_ADC_EN2, &value, 1, I2C_F_POLL);
+       error = axp20x_write(sc, AXP_ADC_EN2, &value, 1, 0);
        if (error) {
                aprint_error(": can't set AXP_ADC_EN2\n");
                return;
@@ -381,22 +381,22 @@
 
        sysmon_envsys_register(sc->sc_sme);
 
-       if (axp20x_read(sc, AXP_DCDC2, &value, 1, I2C_F_POLL) == 0) {
+       if (axp20x_read(sc, AXP_DCDC2, &value, 1, 0) == 0) {
                aprint_verbose_dev(sc->sc_dev, "DCDC2 %dmV\n",
                    (int)(700 + (value & AXP_DCDC2_VOLT_MASK) * 25));
        }
-       if (axp20x_read(sc, AXP_DCDC3, &value, 1, I2C_F_POLL) == 0) {
+       if (axp20x_read(sc, AXP_DCDC3, &value, 1, 0) == 0) {
                aprint_verbose_dev(sc->sc_dev, "DCDC3 %dmV\n",
                    (int)(700 + (value & AXP_DCDC3_VOLT_MASK) * 25));
        }
-       if (axp20x_read(sc, AXP_LDO2_4, &value, 1, I2C_F_POLL) == 0) {
+       if (axp20x_read(sc, AXP_LDO2_4, &value, 1, 0) == 0) {
                aprint_verbose_dev(sc->sc_dev, "LDO2 %dmV, LDO4 %dmV\n",
                    (int)(1800 +
                    ((value & AXP_LDO2_VOLT_MASK) >> AXP_LDO2_VOLT_SHIFT) * 100
                    ),
                    ldo4_mvV[(value & AXP_LDO4_VOLT_MASK) >> AXP_LDO4_VOLT_SHIFT]);
        }
-       if (axp20x_read(sc, AXP_LDO3, &value, 1, I2C_F_POLL) == 0) {
+       if (axp20x_read(sc, AXP_LDO3, &value, 1, 0) == 0) {
                if (value & AXP_LDO3_TRACK) {
                        aprint_verbose_dev(sc->sc_dev, "LDO3: tracking\n");
                } else {
@@ -405,7 +405,7 @@
                }
        }
 
-       if (axp20x_read(sc, AXP_BKUP_CTRL, &value, 1, I2C_F_POLL) == 0) {
+       if (axp20x_read(sc, AXP_BKUP_CTRL, &value, 1, 0) == 0) {
                if (value & AXP_BKUP_CTRL_ENABLE) {
                        aprint_verbose_dev(sc->sc_dev,
                            "RTC supercap charger enabled: %dmV at %duA\n",
diff -r 4e019bab974e -r b622e96aa03b sys/dev/i2c/axppmic.c
--- a/sys/dev/i2c/axppmic.c     Mon Dec 23 02:39:47 2019 +0000
+++ b/sys/dev/i2c/axppmic.c     Mon Dec 23 02:50:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.26 2019/10/01 23:32:52 jmcneill Exp $ */
+/* $NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.26 2019/10/01 23:32:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -779,12 +779,12 @@
        envsys_data_t *e;
        uint8_t val;
 
-       iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+       iic_acquire_bus(sc->sc_i2c, 0);
        if (axppmic_read(sc->sc_i2c, sc->sc_addr, AXP_BATT_CAP_WARN_REG, &val, I2C_F_POLL) == 0) {
                sc->sc_warn_thres = __SHIFTOUT(val, AXP_BATT_CAP_WARN_LV1) + 5;
                sc->sc_shut_thres = __SHIFTOUT(val, AXP_BATT_CAP_WARN_LV2);
        }
-       iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+       iic_release_bus(sc->sc_i2c, 0);
 
        e = &sc->sc_sensor[AXP_SENSOR_BATT_PRESENT];
        e->private = AXP_SENSOR_BATT_PRESENT;
@@ -928,15 +928,15 @@
                const bool master_mode = of_hasprop(sc->sc_phandle, "x-powers,self-working-mode") ||
                    of_hasprop(sc->sc_phandle, "x-powers,master-mode");
 
-               iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+               iic_acquire_bus(sc->sc_i2c, 0);
                axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_ADDR_EXT_REG,
-                   master_mode ? AXP_ADDR_EXT_MASTER : AXP_ADDR_EXT_SLAVE, I2C_F_POLL);
-               iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+                   master_mode ? AXP_ADDR_EXT_MASTER : AXP_ADDR_EXT_SLAVE, 0);
+               iic_release_bus(sc->sc_i2c, 0);
        }
 
-       iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
-       error = axppmic_read(sc->sc_i2c, sc->sc_addr, AXP_CHIP_ID_REG, &val, I2C_F_POLL);
-       iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+       iic_acquire_bus(sc->sc_i2c, 0);
+       error = axppmic_read(sc->sc_i2c, sc->sc_addr, AXP_CHIP_ID_REG, &val, 0);
+       iic_release_bus(sc->sc_i2c, 0);
        if (error != 0) {
                aprint_error_dev(self, "couldn't read chipid\n");
                return;
@@ -948,7 +948,7 @@
        sysmon_pswitch_register(&sc->sc_smpsw);
 
        if (c->irq_regs > 0) {
-               iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+               iic_acquire_bus(sc->sc_i2c, 0);
                for (i = 1; i <= c->irq_regs; i++) {
                        irq_mask = 0;
                        if (i == c->poklirq.reg)
@@ -963,9 +963,9 @@
                                irq_mask |= c->chargeirq.mask;
                        if (i == c->chargestirq.reg)
                                irq_mask |= c->chargestirq.mask;
-                       axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_IRQ_ENABLE_REG(i), irq_mask, I2C_F_POLL);
+                       axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_IRQ_ENABLE_REG(i), irq_mask, 0);
                }
-               iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+               iic_release_bus(sc->sc_i2c, 0);
 
                ih = fdtbus_intr_establish(sc->sc_phandle, 0, IPL_VM, FDT_INTR_MPSAFE,
                    axppmic_intr, sc);



Home | Main Index | Thread Index | Old Index