svn commit: r358649 - stable/12/sys/arm64/rockchip
Emmanuel Vadot
manu at FreeBSD.org
Wed Mar 4 21:25:50 UTC 2020
Author: manu
Date: Wed Mar 4 21:25:48 2020
New Revision: 358649
URL: https://svnweb.freebsd.org/changeset/base/358649
Log:
MFC r356485-r356486, r356893, r358278-r358279
r356485:
rk808: Add min/max for the switch regulators
The two switch regulator are always 3.0V.
Add a special case in get_voltage that if min=max we directly
return the value without calculating it.
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D23004
r356486:
rk805: Add regnode_status method
This allow consumers to check if the regulator is enable or not.
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D23005
r356893:
rk805: Add a regnode_init method
This method will set the desired voltaged based on values in the DTS.
It will not enable the regulator, this is the job of either a consumer
or regnode_set_constraint SYSINIT if the regulator is boot_on or always_on.
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D23216
r358278:
arm64: rockchip: rk_i2c: Bump to DELAY to 1000
In polling mode with use DELAY to wait for interrupts. The value was
too low for RK3328.
r358279:
arm64: rockchip: rk808: Only init regulator not enabled
If a regulator is already enabled, do not set its value to the minimum
supported on the board.
This fixes booting on rock64 where we set some regulator to the minimal value
while the IPs needs more based on what the bootloader configured.
Modified:
stable/12/sys/arm64/rockchip/rk805.c
stable/12/sys/arm64/rockchip/rk_i2c.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/arm64/rockchip/rk805.c
==============================================================================
--- stable/12/sys/arm64/rockchip/rk805.c Wed Mar 4 21:20:15 2020 (r358648)
+++ stable/12/sys/arm64/rockchip/rk805.c Wed Mar 4 21:25:48 2020 (r358649)
@@ -98,6 +98,10 @@ struct rk805_softc {
int nregs;
};
+static int rk805_regnode_status(struct regnode *regnode, int *status);
+static int rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
+ int max_uvolt, int *udelay);
+
static struct rk805_regdef rk805_regdefs[] = {
{
.id = RK805_DCDC1,
@@ -205,6 +209,7 @@ static struct rk805_regdef rk808_regdefs[] = {
.voltage_nstep = 64,
},
{
+ /* BUCK3 voltage is calculated based on external resistor */
.id = RK805_DCDC3,
.name = "DCDC_REG3",
.enable_reg = RK805_DCDC_EN,
@@ -323,12 +328,16 @@ static struct rk805_regdef rk808_regdefs[] = {
.name = "SWITCH_REG1",
.enable_reg = RK805_DCDC_EN,
.enable_mask = 0x20,
+ .voltage_min = 3000000,
+ .voltage_max = 3000000,
},
{
.id = RK808_SWITCH2,
.name = "SWITCH_REG2",
.enable_reg = RK805_DCDC_EN,
.enable_mask = 0x40,
+ .voltage_min = 3000000,
+ .voltage_max = 3000000,
},
};
@@ -344,13 +353,37 @@ rk805_read(device_t dev, uint8_t reg, uint8_t *data, u
static int
rk805_write(device_t dev, uint8_t reg, uint8_t data)
{
+
return (iicdev_writeto(dev, reg, &data, 1, IIC_INTRWAIT));
}
static int
rk805_regnode_init(struct regnode *regnode)
{
- return (0);
+ struct rk805_reg_sc *sc;
+ struct regnode_std_param *param;
+ int rv, udelay, status;
+
+ sc = regnode_get_softc(regnode);
+ param = regnode_get_stdparam(regnode);
+ if (param->min_uvolt == 0)
+ return (0);
+
+ /*
+ * Set the regulator at the correct voltage if it is not enabled.
+ * Do not enable it, this is will be done either by a
+ * consumer or by regnode_set_constraint if boot_on is true
+ */
+ rv = rk805_regnode_status(regnode, &status);
+ if (rv != 0 || status == REGULATOR_STATUS_ENABLED)
+ return (rv);
+
+ rv = rk805_regnode_set_voltage(regnode, param->min_uvolt,
+ param->max_uvolt, &udelay);
+ if (udelay != 0)
+ DELAY(udelay);
+
+ return (rv);
}
static int
@@ -409,6 +442,22 @@ rk805_regnode_voltage_to_reg(struct rk805_reg_sc *sc,
}
static int
+rk805_regnode_status(struct regnode *regnode, int *status)
+{
+ struct rk805_reg_sc *sc;
+ uint8_t val;
+
+ sc = regnode_get_softc(regnode);
+
+ *status = 0;
+ rk805_read(sc->base_dev, sc->def->enable_reg, &val, 1);
+ if (val & sc->def->enable_mask)
+ *status = REGULATOR_STATUS_ENABLED;
+
+ return (0);
+}
+
+static int
rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
int max_uvolt, int *udelay)
{
@@ -451,6 +500,11 @@ rk805_regnode_get_voltage(struct regnode *regnode, int
sc = regnode_get_softc(regnode);
+ if (sc->def->voltage_min == sc->def->voltage_max) {
+ *uvolt = sc->def->voltage_min;
+ return (0);
+ }
+
if (!sc->def->voltage_step)
return (ENXIO);
@@ -468,6 +522,7 @@ static regnode_method_t rk805_regnode_methods[] = {
/* Regulator interface */
REGNODEMETHOD(regnode_init, rk805_regnode_init),
REGNODEMETHOD(regnode_enable, rk805_regnode_enable),
+ REGNODEMETHOD(regnode_status, rk805_regnode_status),
REGNODEMETHOD(regnode_set_voltage, rk805_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage, rk805_regnode_get_voltage),
REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
Modified: stable/12/sys/arm64/rockchip/rk_i2c.c
==============================================================================
--- stable/12/sys/arm64/rockchip/rk_i2c.c Wed Mar 4 21:20:15 2020 (r358648)
+++ stable/12/sys/arm64/rockchip/rk_i2c.c Wed Mar 4 21:25:48 2020 (r358649)
@@ -530,7 +530,7 @@ rk_i2c_transfer(device_t dev, struct iic_msg *msgs, ui
rk_i2c_intr_locked(sc);
if (sc->transfer_done != 0)
break;
- DELAY(100);
+ DELAY(1000);
}
if (timeout <= 0)
err = ETIMEDOUT;
@@ -609,8 +609,8 @@ rk_i2c_attach(device_t dev)
device_printf(dev, "cannot get pclk clock\n");
goto fail;
}
- if (sc->sclk != NULL) {
- error = clk_enable(sc->sclk);
+ if (sc->pclk != NULL) {
+ error = clk_enable(sc->pclk);
if (error != 0) {
device_printf(dev, "cannot enable pclk clock\n");
goto fail;
More information about the svn-src-all
mailing list