mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Marius.Cristea@microchip.com
Cc: corbet@lwn.net, linux-hwmon@vger.kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org,
	linux-kernel@vger.kernel.org, krzk+dt@kernel.org,
	linux-doc@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 2/2] hwmon: temperature: add support for EMC1812
Date: Fri, 27 Mar 2026 10:29:55 -0700	[thread overview]
Message-ID: <55c96f65-d462-4507-a1ef-c36df6d3b4d9@roeck-us.net> (raw)
In-Reply-To: <350d1d2bf73c11c2c311c4ae6bf1b8b423151113.camel@microchip.com>

On 3/27/26 09:30, Marius.Cristea@microchip.com wrote:
> Hi Guenther,
> 
>     Thanks for the review, please see my comments below:
> 
> ...
> 
>>
>>
>>
>>
>>> +static int emc1812_init(struct emc1812_data *priv)
>>> +{
>>> +     int ret;
>>> +     u8 val;
>>> +
>>> +     /*
>>> +      * Set default values in registers. APDD, RECD12 and RECD34
>>> are active
>>> +      * on 0. Set ALERT pin to be in comparator mode.
>>> +      * Set the device to be in Run (Active) state and converting
>>> on all
>>> +      * channels.
>>> +      * Don't change conversion rate. After reset, default is 4
>>> conversions/seconds.
>>> +      * The temperature measurement range is -64°C to +191.875°C.
>>> +      */
>>> +     val = FIELD_PREP(EMC1812_CFG_MSKAL, 1) |
>>> +           FIELD_PREP(EMC1812_CFG_RS, 0) |
>>> +           FIELD_PREP(EMC1812_CFG_ATTHM, 1) |
>>> +           FIELD_PREP(EMC1812_CFG_RECD12, !priv->recd12_en) |
>>> +           FIELD_PREP(EMC1812_CFG_RECD34, !priv->recd34_en) |
>>> +           FIELD_PREP(EMC1812_CFG_RANGE, 1) |
>>> +           FIELD_PREP(EMC1812_CFG_DA_ENA, 0) |
>>> +           FIELD_PREP(EMC1812_CFG_APDD, !priv->apdd_en);
>>> +
>>
>> I assume it is on purpose that the defaults for EMC1812_CFG_RECD12
>> and
>> EMC1812_CFG_RECD34 deviate from the chip default (chip: enabled;
>> driver:
>> disabled).
>>
> 
> Yes, EMC1812_CFG_ATTHM was set in order for the alerts to be clear
> automaticaly when the limits goes back to normal.
> 
> The EMC1812_CFG_RANGE is set to extended range in order to be able to
> measure from the -64 to 191,875 degree Celsius.
> 
> The EMC1812_CFG_MSKAL could be left at the "reset", so I will change it
> to 0.
> 
> The EMC1812_CFG_RECD12 and EMC1812_CFG_RECD34 will be set based on the
> device tree setting and is related to the hardware and if the system
> designer wants to enable or disable the resistance error correction.
> 
> 
>>> +     ret = regmap_write(priv->regmap, EMC1812_CFG_ADDR, val);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     ret = regmap_write(priv->regmap, EMC1812_THRM_HYS_ADDR,
>>> 0x0A);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     ret = regmap_write(priv->regmap, EMC1812_CONSEC_ALERT_ADDR,
>>> 0x70);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     ret = regmap_write(priv->regmap, EMC1812_FILTER_SEL_ADDR, 0);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     ret = regmap_write(priv->regmap, EMC1812_HOTTEST_CFG_ADDR,
>>> 0);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     /* Enables the beta compensation factor auto-detection
>>> function for beta1 and beta2 */
>>> +     ret = regmap_write(priv->regmap,
>>> EMC1812_EXT1_BETA_CONFIG_ADDR,
>>> +                        EMC1812_BETA_LOCK_VAL);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     ret = regmap_write(priv->regmap,
>>> EMC1812_EXT2_BETA_CONFIG_ADDR,
>>
>> AI review thinks that this register only exists on EMC1812. I don't
>> find that detail in the datasheet, but it is odd that there are two
>> registers
>> with supposedly the same functionality.
>>
>>
> 
> All devices "have" the EMC1812_EXT2_BETA_CONFIG register (I mean if you
> are writing something to it, there will be no NAK on the i2c bus, but
> the value read back will be "0" for the devices that has the register
> not writable).
> EMC1812 having only one external channel, will not have the
> EMC1812_EXT2_BETA_CONFIG writable.
> 
Ah, so the second register is for the second external channel. Seems
obvious, thinking about it ;-). Still, would it make sense to only write
the register if the second external channel actually exists ?

Thanks,
Guenter


      reply	other threads:[~2026-03-27 17:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 14:50 [PATCH v8 0/2] Add support for Microchip EMC1812 Marius Cristea
2026-03-10 14:50 ` [PATCH v8 1/2] dt-bindings: hwmon: temperature: add support for EMC1812 Marius Cristea
2026-03-10 14:50 ` [PATCH v8 2/2] " Marius Cristea
2026-03-18  0:24   ` Guenter Roeck
2026-03-27 16:30     ` Marius.Cristea
2026-03-27 17:29       ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55c96f65-d462-4507-a1ef-c36df6d3b4d9@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Marius.Cristea@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®