HWMON LM90 interrupt fixes and improvements
v2 cover HWMON LM90 interrupt fixes and improvements
Hi,
This series makes interrupt usable on NVIDIA Tegra devices, it also switches LM90 driver to use hwmon_notify_event().
Dmitry Osipenko (4):
hwmon: (lm90) Don't override interrupt trigger type
hwmon: (lm90) Use hwmon_notify_event()
hwmon: (lm90) Unmask hardware interrupt
hwmon: (lm90) Disable interrupt on suspend
drivers/hwmon/lm90.c | 79 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 13 deletions(-)
Signature · 1 line
2.30.2
PATCH v2 1/4 hwmon: (lm90) Don't override interrupt trigger type
The lm90 driver sets interrupt trigger type to level-low. This type is not suitable for sensors like NCT1008 that don't deassert interrupt line until temperature is back to normal, resulting in interrupt storm. The appropriate trigger type should come from OF device description and currently it's overridden by the driver's trigger type. Don't specify the trigger type in the driver code, letting interrupt core to use the device-specific trigger type.
--- drivers/hwmon/lm90.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/lm90.c +1 -2
@@ -1908,8 +1908,7 @@ static int lm90_probe(struct i2c_client *client)dev_dbg (dev,"IRQ: %d\n" , client->irq); err =devm_request_threaded_irq (dev, client->irq,NULL , lm90_irq_thread, -IRQF_TRIGGER_LOW |IRQF_ONESHOT , -"lm90" , client); +IRQF_ONESHOT ,"lm90" , client);if (err <0 ) {dev_err (dev,"cannot request IRQ %d\n" , client->irq);return err;
Signature · 1 line
2.30.2
PATCH v2 2/4 hwmon: (lm90) Use hwmon_notify_event()
In reply to Dmitry OsipenkoUse hwmon_notify_event() to notify userspace and thermal core about temperature changes.
--- drivers/hwmon/lm90.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-)
drivers/hwmon/lm90.c +33 -11
@@ -465,6 +465,7 @@ enum lm90_temp11_reg_index {struct lm90_data {struct i2c_client *client; +struct device *hwmon_dev;u32 channel_config[4 ];struct hwmon_channel_info temp_info;const struct hwmon_channel_info *info[3 ];
@@ -1731,22 +1732,41 @@ static bool lm90_is_tripped(struct i2c_client *client, u16 *status)if ((st & (LM90_STATUS_LLOW |LM90_STATUS_LHIGH |LM90_STATUS_LTHRM )) || (st2 &MAX6696_STATUS2_LOT2 )) -dev_warn (&client->dev, -"temp%d out of range, please check!\n" ,1 ); +dev_dbg (&client->dev, +"temp%d out of range, please check!\n" ,1 );if ((st & (LM90_STATUS_RLOW |LM90_STATUS_RHIGH |LM90_STATUS_RTHRM )) || (st2 &MAX6696_STATUS2_ROT2 )) -dev_warn (&client->dev, -"temp%d out of range, please check!\n" ,2 ); +dev_dbg (&client->dev, +"temp%d out of range, please check!\n" ,2 );if (st &LM90_STATUS_ROPEN ) -dev_warn (&client->dev, -"temp%d diode open, please check!\n" ,2 ); +dev_dbg (&client->dev, +"temp%d diode open, please check!\n" ,2 );if (st2 & (MAX6696_STATUS2_R2LOW |MAX6696_STATUS2_R2HIGH |MAX6696_STATUS2_R2THRM |MAX6696_STATUS2_R2OT2 )) -dev_warn (&client->dev, -"temp%d out of range, please check!\n" ,3 ); +dev_dbg (&client->dev, +"temp%d out of range, please check!\n" ,3 );if (st2 &MAX6696_STATUS2_R2OPEN ) -dev_warn (&client->dev, -"temp%d diode open, please check!\n" ,3 ); +dev_dbg (&client->dev, +"temp%d diode open, please check!\n" ,3 ); + +if (st &LM90_STATUS_LLOW ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_min,0 ); +if (st &LM90_STATUS_RLOW ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_min,1 ); +if (st2 &MAX6696_STATUS2_R2LOW ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_min,2 ); +if (st &LM90_STATUS_LHIGH ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_max,0 ); +if (st &LM90_STATUS_RHIGH ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_max,1 ); +if (st2 &MAX6696_STATUS2_R2HIGH ) +hwmon_notify_event (data->hwmon_dev, hwmon_temp, + hwmon_temp_max,2 );return true; }
@@ -1904,6 +1924,8 @@ static int lm90_probe(struct i2c_client *client)if (IS_ERR (hwmon_dev))return PTR_ERR (hwmon_dev); + data->hwmon_dev = hwmon_dev; +if (client->irq) {dev_dbg (dev,"IRQ: %d\n" , client->irq); err = devm_request_threaded_irq(dev, client->irq,
@@ -1940,7 +1962,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,lm90_update_confreg (data, data->config |0x80 ); } }else { -dev_info (&client->dev,"Everything OK\n" ); +dev_dbg (&client->dev,"Everything OK\n" ); } }
Signature · 1 line
2.30.2
PATCH v2 3/4 hwmon: (lm90) Unmask hardware interrupt
In reply to Dmitry OsipenkoThe ALERT interrupt is enabled by default after power-on, but it could be masked by bootloader. For example this is the case on Acer A500 tablet device. Unmask the hardware interrupt if interrupt is provided.
--- drivers/hwmon/lm90.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hwmon/lm90.c +7 -0
@@ -1704,6 +1704,13 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)if (data->kind == max6696) config &= ~0x08 ; +/* +* Interrupt is enabled by default on reset, but it may be disabled +* by bootloader, unmask it. +*/ +if (client->irq) + config &= ~0x80 ; + config &=0xBF ;/* run */ lm90_update_confreg (data, config);
Signature · 1 line
2.30.2
PATCH v2 4/4 hwmon: (lm90) Disable interrupt on suspend
In reply to Dmitry OsipenkoI2C accesses are prohibited and will error out after suspending of the I2C controller, hence we need to ensure that interrupt won't fire on suspend when it's too late. Disable interrupt across suspend/resume.
--- drivers/hwmon/lm90.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/hwmon/lm90.c +25 -0
@@ -1973,11 +1973,36 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type, } } +static int __maybe_unused lm90_suspend (struct device *dev) +{ +struct lm90_data *data =dev_get_drvdata (dev); +struct i2c_client *client = data->client; + +if (client->irq) +disable_irq (client->irq); + +return 0 ; +} + +static int __maybe_unused lm90_resume (struct device *dev) +{ +struct lm90_data *data =dev_get_drvdata (dev); +struct i2c_client *client = data->client; + +if (client->irq) +enable_irq (client->irq); + +return 0 ; +} + +static SIMPLE_DEV_PM_OPS(lm90_pm_ops, lm90_suspend, lm90_resume); +static struct i2c_driver lm90_driver = { .class =I2C_CLASS_HWMON , .driver = { .name ="lm90" , .of_match_table =of_match_ptr (lm90_of_match), + .pm = &lm90_pm_ops, }, .probe_new = lm90_probe, .alert = lm90_alert,
Signature · 1 line
2.30.2
Guenter Roeck
maintainerQuoted 5 lines · Dmitry Osipenko
Hi,
This series makes interrupt usable on NVIDIA Tegra devices, it also switches LM90 driver to use
hwmon_notify_event().
Quoted 9 lines
Dmitry Osipenko (4):
hwmon: (lm90) Don't override interrupt trigger type
hwmon: (lm90) Usehwmon_notify_event()
hwmon: (lm90) Unmask hardware interrupt
hwmon: (lm90) Disable interrupt on suspenddrivers/hwmon/lm90.c | 79 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 13 deletions(-)
Please resubmit with change log.
Guenter