sy7636a: power the panel only during updates
Subsystems (3)
v4 cover sy7636a: power the panel only during updates
The SY7636A hwmon driver keeps VCOM on from probe, so a display driver can not power the panel only during updates.
Read the temperature only while the rails are on instead.
This is based on regulator for-7.5, which has the rest of the series. Patch 1 depends on "regulator: sy7636a: bind to the I2C device directly" there.
Tested on a PocketBook Verse (B288).
v4:
- drop the patches applied by Mark and Guenter
- patch 1: keep the hwmon name (Guenter)
v3:
- drop the applied patches 1-3
- new patch: no wait when power good is already high (Mark)
- move the I2C binding before the hwmon read change, so the hwmon driver only probes once vin is on (Andreas)
- explain in a comment why power good gates the read, and its limitation (Guenter, Andreas)
v2:
- drop the DT patch keeping VCOM always-on (Andreas)
- only wait for power good, VCOM_EN stays as it was (Andreas)
- new patch: fix negative temperatures
- keep the temperature in drivers/hwmon as an auxiliary driver of the regulator, instead of moving it into the regulator driver (Guenter, Andreas)
- no VCOM enable at probe, which also removes the probe race
- read power good and the temperature in one transfer (Andreas)
Pablo Mazzini (2):
hwmon: sy7636a: read the temperature only while the rails are on
ARM: imx_v6_v7_defconfig: drop the SY7636A MFD option
arch/arm/configs/imx_v6_v7_defconfig | 1 - drivers/hwmon/sy7636a-hwmon.c | 35 +++++++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-)
base-commit: 89b552ff49551960b9e270feee888a0298a12d94
Signature · 1 line
2.52.0
PATCH v4 1/2 hwmon: sy7636a: read the temperature only while the rails are on
The driver enables VCOM at probe, which keeps the panel's high voltage rails on for good. Read the temperature only while the rails are on, when the chip samples it, and return -ENODATA otherwise. Read power good with it in one transfer, so the value can not be from before the first sample or after the rails went off.
--- drivers/hwmon/sy7636a-hwmon.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/hwmon/sy7636a-hwmon.c +24 -11
@@ -9,26 +9,43 @@*/ #include <linux/auxiliary_bus.h> +#include <linux/bits.h> #include <linux/err.h> #include <linux/hwmon.h> #include <linux/module.h> #include <linux/regmap.h> -#include <linux/regulator/machine.h> -#define SY7636A_REG_TERMISTOR_READOUT 0x08 +#define SY7636A_REG_FAULT_FLAG 0x07 +#define SY7636A_FAULT_FLAG_PG BIT(0)static int sy7636a_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long *temp) {struct regmap *regmap =dev_get_drvdata (dev); -int ret, reg_val; - - ret =regmap_read (regmap, -SY7636A_REG_TERMISTOR_READOUT , ®_val); +u8 buf[2 ]; +int ret; + +/* +* The thermistor is sampled while ON_OFF is set, but the first sample +* is only ready after the ADC sampling and conversion time (ADC_SPL + +* ADC_DEL in the datasheet); until then it holds its reset value, 0. +* PG is only set once all rails are up, after the first sample, so +* read it in the same transfer and report the temperature only while +* it is set. +* +* With ON_OFF set but PG low (rails still ramping up, or a fault), no +* temperature is reported even if one may be available. That is +* accepted: the display driver reads the temperature only while it +* holds the rails on, after power good. +*/ + ret =regmap_bulk_read (regmap,SY7636A_REG_FAULT_FLAG , buf,sizeof (buf));if (ret)return ret; - *temp = reg_val *1000 ; +if (!(buf[0 ] &SY7636A_FAULT_FLAG_PG )) +return -ENODATA ; + + *temp = (s8 )buf[1 ] *1000 ;return 0 ; }
@@ -72,10 +89,6 @@ static int sy7636a_sensor_probe(struct auxiliary_device *adev,if (!regmap)return -ENODEV ; - err =devm_regulator_get_enable (&adev->dev,"vcom" ); -if (err) -return err; - hwmon_dev =devm_hwmon_device_register_with_info (&adev->dev,"sy7636a_temperature" , regmap, &sy7636a_chip_info,NULL );
Signature · 1 line
2.52.0
PATCH v4 2/2 ARM: imx_v6_v7_defconfig: drop the SY7636A MFD option
In reply to Pablo MazziniThe SY7636A is no longer bound through an MFD.
--- arch/arm/configs/imx_v6_v7_defconfig | 1 - 1 file changed, 1 deletion(-)
arch/arm/configs/imx_v6_v7_defconfig +0 -1
@@ -239,7 +239,6 @@ CONFIG_MFD_DA9062=y CONFIG_MFD_DA9063=y CONFIG_MFD_MC13XXX_SPI=y CONFIG_MFD_MC13XXX_I2C=y -CONFIG_MFD_SY7636A=y CONFIG_MFD_RN5T618=y CONFIG_MFD_STMPE=y CONFIG_MFD_ROHM_BD71828=y
Signature · 1 line
2.52.0
[email protected]
AI reviewRe: [PATCH v4 1/2] hwmon: sy7636a: read the temperature only while the rails are on
In reply to Pablo MazziniSashiko has reviewed this patch and found no issues.
Quoted 7 lines
The driver enables VCOM at probe, which keeps the panel's high voltage rails on for good. Read the temperature only while the rails are on, when the chip samples it, and return
-ENODATAotherwise. Read power good with it in one transfer, so the value can not be from before the first sample or after the rails went off.Signed-off-by Pablo Mazzini <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v4 1/2] hwmon: sy7636a: read the temperature only while the rails are on
In reply to Pablo MazziniQuoted 7 lines · Pablo Mazzini
The driver enables VCOM at probe, which keeps the panel's high voltage rails on for good. Read the temperature only while the rails are on, when the chip samples it, and return
-ENODATAotherwise. Read power good with it in one transfer, so the value can not be from before the first sample or after the rails went off.Signed-off-by Pablo Mazzini <[email protected]>
This patch depends on the rest of the patch series, so I can not apply it to a hwmon branch. Assuming it will be applied to some other branch,
Thanks,
Guenter
Quoted 70 lines
--- drivers/hwmon/sy7636a-hwmon.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)drivers/hwmon/sy7636a-hwmon.c +24
-11@@ -9,26 +9,43 @@*/ #include <linux/auxiliary_bus.h> +#include <linux/bits.h> #include <linux/err.h> #include <linux/hwmon.h> #include <linux/module.h> #include <linux/regmap.h> -#include <linux/regulator/machine.h> -#define SY7636A_REG_TERMISTOR_READOUT 0x08 +#define SY7636A_REG_FAULT_FLAG 0x07 +#define SY7636A_FAULT_FLAG_PG BIT(0)static int sy7636a_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long *temp) {struct regmap *regmap =dev_get_drvdata (dev); -int ret, reg_val; - - ret =regmap_read (regmap, -SY7636A_REG_TERMISTOR_READOUT , ®_val); +u8 buf[2 ]; +int ret; + +/* +* The thermistor is sampled while ON_OFF is set, but the first sample +* is only ready after the ADC sampling and conversion time (ADC_SPL + +* ADC_DEL in the datasheet); until then it holds its reset value, 0. +* PG is only set once all rails are up, after the first sample, so +* read it in the same transfer and report the temperature only while +* it is set. +* +* With ON_OFF set but PG low (rails still ramping up, or a fault), no +* temperature is reported even if one may be available. That is +* accepted: the display driver reads the temperature only while it +* holds the rails on, after power good. +*/ + ret =regmap_bulk_read (regmap,SY7636A_REG_FAULT_FLAG , buf,sizeof (buf));if (ret)return ret; - *temp = reg_val *1000 ; +if (!(buf[0 ] &SY7636A_FAULT_FLAG_PG )) +return -ENODATA ; + + *temp = (s8 )buf[1 ] *1000 ;return 0 ; }@@ -72,10 +89,6 @@ static int sy7636a_sensor_probe(struct auxiliary_device *adev,if (!regmap)return -ENODEV ; - err =devm_regulator_get_enable (&adev->dev,"vcom" ); -if (err) -return err; - hwmon_dev =devm_hwmon_device_register_with_info (&adev->dev,"sy7636a_temperature" , regmap, &sy7636a_chip_info,NULL );