linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] hwmon (it87): Support all know ADC values
@ 2023-03-12  4:31 Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 1/3] hwmon (it87): Added support for 11mV ADC Frank Crawford
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Frank Crawford @ 2023-03-12  4:31 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Frank Crawford

Add support of all know ADC values currently identified for it87 chips.

Generalise definitions for handling of scaled internal voltages and
voltage labels.

Apply some other minor optimistations.

---

Frank Crawford (3):
  Added support for 11mV ADC
  Add scaling macro for recent ADC voltages
  Minor optimisation of return value

 drivers/hwmon/it87.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/3] hwmon (it87): Added support for 11mV ADC
  2023-03-12  4:31 [PATCH v1 0/3] hwmon (it87): Support all know ADC values Frank Crawford
@ 2023-03-12  4:31 ` Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 3/3] hwmon (it87): Minor optimisation of return value Frank Crawford
  2 siblings, 0 replies; 7+ messages in thread
From: Frank Crawford @ 2023-03-12  4:31 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Frank Crawford

Add support of all know ADC values currently identified for it87 chips.
Includes adding support for 11mV ADC reported on IT8613E and IT8625E.

Signed-off-by: Frank Crawford <frank@crawford.emu.id.au>
---
 drivers/hwmon/it87.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 66f7ceaa7c3f..fe1291d5be4b 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -312,6 +312,7 @@ struct it87_devices {
  * chips to avoid the problem.
  */
 #define FEAT_CONF_NOEXIT	BIT(19)	/* Chip should not exit conf mode */
+#define FEAT_11MV_ADC		BIT(20)
 
 static const struct it87_devices it87_devices[] = {
 	[it87] = {
@@ -515,6 +516,7 @@ static const struct it87_devices it87_devices[] = {
 #define has_six_temp(data)	((data)->features & FEAT_SIX_TEMP)
 #define has_vin3_5v(data)	((data)->features & FEAT_VIN3_5V)
 #define has_conf_noexit(data)	((data)->features & FEAT_CONF_NOEXIT)
+#define has_11mv_adc(data)	((data)->features & FEAT_11MV_ADC)
 
 struct it87_sio_data {
 	int sioaddr;
@@ -608,6 +610,8 @@ static int adc_lsb(const struct it87_data *data, int nr)
 		lsb = 120;
 	else if (has_10_9mv_adc(data))
 		lsb = 109;
+	else if (has_11mv_adc(data))
+		lsb = 110;
 	else
 		lsb = 160;
 	if (data->in_scaled & BIT(nr))
@@ -2002,7 +2006,8 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr,
 
 	if (has_vin3_5v(data) && nr == 0)
 		label = labels[0];
-	else if (has_12mv_adc(data) || has_10_9mv_adc(data))
+	else if (has_12mv_adc(data) || has_10_9mv_adc(data) ||
+			has_11mv_adc(data))
 		label = labels_it8721[nr];
 	else
 		label = labels[nr];
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages
  2023-03-12  4:31 [PATCH v1 0/3] hwmon (it87): Support all know ADC values Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 1/3] hwmon (it87): Added support for 11mV ADC Frank Crawford
@ 2023-03-12  4:31 ` Frank Crawford
  2023-03-12 14:49   ` Guenter Roeck
  2023-03-12  4:31 ` [PATCH v1 3/3] hwmon (it87): Minor optimisation of return value Frank Crawford
  2 siblings, 1 reply; 7+ messages in thread
From: Frank Crawford @ 2023-03-12  4:31 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Frank Crawford

Generalise scaling to include all recent ADC values and match the labels
for internal voltage sensor to match.

This includes correction of an existing error for voltage scaling for
chips that have 10.9mV ADCs, where scaling was not performed.

Signed-off-by: Frank Crawford <frank@crawford.emu.id.au>
---
 drivers/hwmon/it87.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index fe1291d5be4b..ca4b79839d98 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -517,6 +517,9 @@ static const struct it87_devices it87_devices[] = {
 #define has_vin3_5v(data)	((data)->features & FEAT_VIN3_5V)
 #define has_conf_noexit(data)	((data)->features & FEAT_CONF_NOEXIT)
 #define has_11mv_adc(data)	((data)->features & FEAT_11MV_ADC)
+#define has_scaling(data)	((data)->features & (FEAT_12MV_ADC | \
+						     FEAT_10_9MV_ADC | \
+						     FEAT_11MV_ADC))
 
 struct it87_sio_data {
 	int sioaddr;
@@ -2006,8 +2009,7 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr,
 
 	if (has_vin3_5v(data) && nr == 0)
 		label = labels[0];
-	else if (has_12mv_adc(data) || has_10_9mv_adc(data) ||
-			has_11mv_adc(data))
+	else if (has_scaling(data))
 		label = labels_it8721[nr];
 	else
 		label = labels[nr];
@@ -3139,7 +3141,7 @@ static int it87_probe(struct platform_device *pdev)
 			 "Detected broken BIOS defaults, disabling PWM interface\n");
 
 	/* Starting with IT8721F, we handle scaling of internal voltages */
-	if (has_12mv_adc(data)) {
+	if (has_scaling(data)) {
 		if (sio_data->internal & BIT(0))
 			data->in_scaled |= BIT(3);	/* in3 is AVCC */
 		if (sio_data->internal & BIT(1))
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 3/3] hwmon (it87): Minor optimisation of return value
  2023-03-12  4:31 [PATCH v1 0/3] hwmon (it87): Support all know ADC values Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 1/3] hwmon (it87): Added support for 11mV ADC Frank Crawford
  2023-03-12  4:31 ` [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages Frank Crawford
@ 2023-03-12  4:31 ` Frank Crawford
  2 siblings, 0 replies; 7+ messages in thread
From: Frank Crawford @ 2023-03-12  4:31 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, Frank Crawford

Optimisation of return value from previously applied patch sets.

Signed-off-by: Frank Crawford <frank@crawford.emu.id.au>
---
 drivers/hwmon/it87.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index ca4b79839d98..7780a5cfd352 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -2865,7 +2865,7 @@ static int __init it87_find(int sioaddr, unsigned short *address,
 		sio_data->skip_pwm |= dmi_data->skip_pwm;
 
 exit:
-	superio_exit(sioaddr, config ? has_conf_noexit(config) : false);
+	superio_exit(sioaddr, config && has_conf_noexit(config));
 	return err;
 }
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages
  2023-03-12  4:31 ` [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages Frank Crawford
@ 2023-03-12 14:49   ` Guenter Roeck
  2023-03-13 11:06     ` Frank Crawford
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2023-03-12 14:49 UTC (permalink / raw)
  To: Frank Crawford, Jean Delvare; +Cc: linux-hwmon

On 3/11/23 20:31, Frank Crawford wrote:
> Generalise scaling to include all recent ADC values and match the labels
> for internal voltage sensor to match.
> 
> This includes correction of an existing error for voltage scaling for
> chips that have 10.9mV ADCs, where scaling was not performed.
> 

That is really two patches (one patch per logical change). The bug fix
should be the first patch of the series so it can be backported
to older kernels.

In general please only introduce new code like the 11mv scaling together
with code actually using it, or I can not apply it.

Thanks,
Guenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages
  2023-03-12 14:49   ` Guenter Roeck
@ 2023-03-13 11:06     ` Frank Crawford
  2023-03-13 14:09       ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Crawford @ 2023-03-13 11:06 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare; +Cc: linux-hwmon

On Sun, 2023-03-12 at 07:49 -0700, Guenter Roeck wrote:
> On 3/11/23 20:31, Frank Crawford wrote:
> > Generalise scaling to include all recent ADC values and match the
> > labels
> > for internal voltage sensor to match.
> > 
> > This includes correction of an existing error for voltage scaling
> > for
> > chips that have 10.9mV ADCs, where scaling was not performed.
> > 
> 
> That is really two patches (one patch per logical change). The bug
> fix
> should be the first patch of the series so it can be backported
> to older kernels.

Okay, ignore this patch set and I'll resubmit them a totally separate
patches.

> 
> In general please only introduce new code like the 11mv scaling
> together
> with code actually using it, or I can not apply it.

The minor problem with holding this off until it is actually used is
that the chipset that uses it also has a lot of other changes, related
to number of fans, etc, and I'm trying to introduce them all as small
increments.  Otherwise I will need to submit a big patch with lots of
unrelated pieces.

> 
> Thanks,
> Guenter

Regards
Frank
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages
  2023-03-13 11:06     ` Frank Crawford
@ 2023-03-13 14:09       ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2023-03-13 14:09 UTC (permalink / raw)
  To: Frank Crawford, Jean Delvare; +Cc: linux-hwmon

On 3/13/23 04:06, Frank Crawford wrote:
> On Sun, 2023-03-12 at 07:49 -0700, Guenter Roeck wrote:
>> On 3/11/23 20:31, Frank Crawford wrote:
>>> Generalise scaling to include all recent ADC values and match the
>>> labels
>>> for internal voltage sensor to match.
>>>
>>> This includes correction of an existing error for voltage scaling
>>> for
>>> chips that have 10.9mV ADCs, where scaling was not performed.
>>>
>>
>> That is really two patches (one patch per logical change). The bug
>> fix
>> should be the first patch of the series so it can be backported
>> to older kernels.
> 
> Okay, ignore this patch set and I'll resubmit them a totally separate
> patches.
> 
>>
>> In general please only introduce new code like the 11mv scaling
>> together
>> with code actually using it, or I can not apply it.
> 
> The minor problem with holding this off until it is actually used is
> that the chipset that uses it also has a lot of other changes, related
> to number of fans, etc, and I'm trying to introduce them all as small
> increments.  Otherwise I will need to submit a big patch with lots of
> unrelated pieces.
>

No, that would not be good either because it would be all but impossible
to review. Separate patches is perfect, it just has to be a single _series_
so that at the end it is all used.

Thanks,
Guenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-13 14:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-12  4:31 [PATCH v1 0/3] hwmon (it87): Support all know ADC values Frank Crawford
2023-03-12  4:31 ` [PATCH v1 1/3] hwmon (it87): Added support for 11mV ADC Frank Crawford
2023-03-12  4:31 ` [PATCH v1 2/3] hwmon (it87): Add scaling macro for recent ADC voltages Frank Crawford
2023-03-12 14:49   ` Guenter Roeck
2023-03-13 11:06     ` Frank Crawford
2023-03-13 14:09       ` Guenter Roeck
2023-03-12  4:31 ` [PATCH v1 3/3] hwmon (it87): Minor optimisation of return value Frank Crawford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).