From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Christian Marangi <ansuelsmth@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v3 2/5] thermal/drivers: airoha: Generalize probe function
Date: Tue, 25 Nov 2025 18:16:29 +0100 [thread overview]
Message-ID: <23a99187-0ca5-459e-8bf0-b3bf61dd12fe@linaro.org> (raw)
In-Reply-To: <20251106225929.1778398-3-ansuelsmth@gmail.com>
On 11/6/25 23:59, Christian Marangi wrote:
> In preparation for support of Airoha AN7583, generalize the probe
> function to address for the 2 SoC differece.
>
> Implement a match_data struct where it's possible to define a more
> specific probe and post_probe function and specific thermal ops and
> pllrg protect value.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> drivers/thermal/airoha_thermal.c | 102 +++++++++++++++++++++++--------
> 1 file changed, 75 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_thermal.c
> index 01ed49a4887e..864a01fd8fd8 100644
> --- a/drivers/thermal/airoha_thermal.c
> +++ b/drivers/thermal/airoha_thermal.c
> @@ -198,12 +198,23 @@ struct airoha_thermal_priv {
> struct regmap *chip_scu;
> struct resource scu_adc_res;
>
> + u32 pllrg_protect;
> +
> struct thermal_zone_device *tz;
> int init_temp;
> int default_slope;
> int default_offset;
> };
>
> +struct airoha_thermal_soc_data {
> + u32 pllrg_protect;
> +
> + const struct thermal_zone_device_ops *thdev_ops;
> + int (*probe)(struct platform_device *pdev,
> + struct airoha_thermal_priv *priv);
> + int (*post_probe)(struct platform_device *pdev);
What the post-probe provides compared to calling the corresponding code
in the probe function ?
> +};
> +
> static int airoha_get_thermal_ADC(struct airoha_thermal_priv *priv)
> {
> u32 val;
> @@ -220,7 +231,8 @@ static void airoha_init_thermal_ADC_mode(struct airoha_thermal_priv *priv)
> regmap_read(priv->chip_scu, EN7581_PLLRG_PROTECT, &pllrg);
>
> /* Give access to thermal regs */
> - regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, EN7581_SCU_THERMAL_PROTECT_KEY);
> + regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT,
> + priv->pllrg_protect);
> adc_mux = FIELD_PREP(EN7581_MUX_TADC, EN7581_SCU_THERMAL_MUX_DIODE1);
> regmap_write(priv->chip_scu, EN7581_PWD_TADC, adc_mux);
>
> @@ -228,7 +240,7 @@ static void airoha_init_thermal_ADC_mode(struct airoha_thermal_priv *priv)
> regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, pllrg);
> }
>
> -static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
> +static int en7581_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
Please provide a separate patch before where s/airoha/en7581/
[ ... ]
> +static int en7581_thermal_post_probe(struct platform_device *pdev)
> +{
> + struct airoha_thermal_priv *priv = platform_get_drvdata(pdev);
> +
> + /* Enable LOW and HIGH interrupt (if supported) */
Why "(if supported)" ?
> + regmap_write(priv->map, EN7581_TEMPMONINT,
> + EN7581_HOFSINTEN0 | EN7581_LOFSINTEN0);
> +
> + return 0;
> +}
> +
> +static int airoha_thermal_probe(struct platform_device *pdev)
> +{
> + const struct airoha_thermal_soc_data *soc_data;
> + struct airoha_thermal_priv *priv;
> + struct device *dev = &pdev->dev;
> + int ret;
> +
> + soc_data = device_get_match_data(dev);
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->pllrg_protect = soc_data->pllrg_protect;
> +
> + if (!soc_data->probe)
> + return -EINVAL;
Shall the driver check its own code ?
> + ret = soc_data->probe(pdev, priv);
> + if (ret)
[ ... ]
> +static const struct airoha_thermal_soc_data en7581_data = {
> + .pllrg_protect = EN7581_SCU_THERMAL_PROTECT_KEY,
> + .thdev_ops = &en7581_thdev_ops,
> + .probe = &en7581_thermal_probe,
> + .post_probe = &en7581_thermal_post_probe,
.probe = en7581_thermal_probe,
.post_probe = en7581_thermal_post_probe,
> +};
> +
> static const struct of_device_id airoha_thermal_match[] = {
> - { .compatible = "airoha,en7581-thermal" },
> + { .compatible = "airoha,en7581-thermal", .data = &en7581_data },
> {},
> };
> MODULE_DEVICE_TABLE(of, airoha_thermal_match);
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2025-11-25 17:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 22:59 [PATCH v3 0/5] thermal/drivers: airoha: Add support for AN7583 Christian Marangi
2025-11-06 22:59 ` [PATCH v3 1/5] thermal/drivers: airoha: Convert to regmap API Christian Marangi
2025-11-06 22:59 ` [PATCH v3 2/5] thermal/drivers: airoha: Generalize probe function Christian Marangi
2025-11-25 17:16 ` Daniel Lezcano [this message]
2025-11-25 17:24 ` Christian Marangi
2025-11-25 17:41 ` Daniel Lezcano
2025-11-06 22:59 ` [PATCH v3 3/5] thermal/drivers: airoha: Generalize get_thermal_ADC and set_mux function Christian Marangi
2025-11-25 21:20 ` Daniel Lezcano
2025-11-06 22:59 ` [PATCH v3 4/5] dt-bindings: arm: airoha: Add the chip-scu node for AN7583 SoC Christian Marangi
2025-11-07 7:45 ` Krzysztof Kozlowski
2025-11-07 8:53 ` Krzysztof Kozlowski
2025-11-06 22:59 ` [PATCH v3 5/5] thermal/drivers: airoha: Add support for AN7583 Thermal Sensor Christian Marangi
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=23a99187-0ca5-459e-8bf0-b3bf61dd12fe@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
/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®