From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15DAA20DD51 for ; Tue, 25 Nov 2025 17:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764090994; cv=none; b=kkKe0f41Jk6alXD+mVziTC8bPEJ5pSBugl1UxPwdUSDoautqK8PUHISvd9dDoo0umgzUHipFI4acKTv9o+DFahk0Bk18cAGKkGxzp0q/8JAgyONWoVWrcOjCTxOb+l2kH+9JrQApSmhgs8dXb6g3AwNDs1mq+nJhLEE33usPR6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764090994; c=relaxed/simple; bh=w/sfDkRtzu4hJVrbpiOQ/RxM1u70C1+28Ln9IBW7wdg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=W1LYiDwjBHU/tuf8UlWqgPcgCNmbya6FQ6w4HxPY7jJqBaq7DNhvGSJl3numvKhdNTu7lJzJKsiaQgEq8pmJmpbYTrOgUSn37K/VZbv/wM8+i2WkDcRYldEmaBaFF8EA2g6yFcAZM2OyW3MOwVkZynqu5AFsx75P80FPITnGd9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KuoZaYsz; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KuoZaYsz" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so38423255e9.0 for ; Tue, 25 Nov 2025 09:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764090991; x=1764695791; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=FK8tpY1vO1WQebcFHT53ELWTdlM+gqsVcXdE0gNSnHI=; b=KuoZaYszGRquDzhNZWQ1cxPlumcbkaoseDYFZzKHJBTjM28j2pIhpO/LZHnb9t4uYj V5B9D+I1baT+EZPcMeclQXpyizJABXeyg1sKnDhRJ3Hp/CAntys6oQNnfR+ONC+c+PGr 72Bh9QUGfoHXsjla2yF6PKBJAiNjTdEpDbPMEuF3rk8OdGDjGJ9LTFUdocV9iBZMGnlL VtnwP2KFQ2u630QXVFA3duYAVX+PjHXx7EhAA8qi/PZsBy0EM5p7V3j2QIiSIEO6Ak4I m5dLflfYCCcH8xBhbNY+NXJneUmiKSes+b1M3auzv7iD2tvHDdGFvZqpyUPCsN5XdtqJ wXBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764090991; x=1764695791; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FK8tpY1vO1WQebcFHT53ELWTdlM+gqsVcXdE0gNSnHI=; b=hOCVWcAIW1XvV2EysGhcy9ssiT62ZRtE4XcA9McyUv8wP7fMsfq8U6An6cMLK3D35j flzwlj2bwTrNYcoCMPEZB0gQRyBumCWLu+5jnZSuvyFSt1WjfKo99a4ul/fkiTUA5ifY sbUtqY7AM4DKxowXZE2+zruKquzrmFUPFXY8XRnEEkGHTKuDgDpKJmMMn1LZe9hbx3ef W7u0v0AIz8wL/wKzfjkysjg4z/l5lZSsAw4r7ahHCeANbiitZNihfVqNllSW9NCNz+1Z rD36WLxxkiCy7p2UJ/pfhQrech0v3lbfajWDm2U/SQPTi+f/b+9/3SUHBKa1csfjAs9O BCqw== X-Forwarded-Encrypted: i=1; AJvYcCXhJy4JsWaFPuegMl+Hyig6ztSXg1klGlLkqZuKSI5AfjXaup/UkVb4NcSm+7sDyRo0xh4F9CinUzdFeOM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxm1Xrr0vhEtrrmd1vXUj4yZsueHttssabmrjwHknG5pJadsWvL LGE1uAgbYpiQPoQwSGJXiEQfJjdgcLZkwW4LIloMIi2S8/Q8GTjY8ADeDdzSkaMPkpM= X-Gm-Gg: ASbGncsH9Q3COYGbBjB1Wq16UtA8d/AhZkl7NKGQx1Xb9RZ43TplCz8/ged6+07AYKE psXtQhdI0F+2ywuWXmVN/6nTPnVAHvpRnUP2KRGe3nvAbkU/5bsKpFpDrKaRwhw9LiG3NlUsAhK SIItAtuKEoqsPIWOGCXRl4J6NK77dH7LHxFfnvcTjVOfSFqFbT7BmFxQISzE8pU1xOXDjO+ci0D D4UtpfT7ead7S1YIDBM+73U4+YfBdS34hgA7gTBBCo1nG0nAR4PEK5sZDCvO1EXoQ4kVg+tTzrt ASKdkdHFDnUBAyPR/cpdvISxfoRFaGDV9jnk4iLbdf1aiVkEaMFuE4Bv06Q5QbnelPXOnSWOoY4 sYANGGOrtZ/6W3IqOLpdTYkA7rk9vanKckKYGpQcqpk4wnAy4BPNSvMrz/Us0oazSZb32LF6jbb +b2uUZYVgqYUAI1UbfyZXAVMKu43rynwmdrV2aNYEp3BHL7XT4s7w= X-Google-Smtp-Source: AGHT+IGgairekF1MJuLNaXid1oGa5EygE8Hk29JHXoMtw3VRdPrHyLASn563oUHVRUEckwECm+Iucw== X-Received: by 2002:a05:600c:19d4:b0:477:63b5:6f3a with SMTP id 5b1f17b1804b1-477c112635amr147250255e9.27.1764090991246; Tue, 25 Nov 2025 09:16:31 -0800 (PST) Received: from ?IPV6:2a05:6e02:1041:c10:1d9d:2362:4539:c68d? ([2a05:6e02:1041:c10:1d9d:2362:4539:c68d]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4790ab8bb21sm404395e9.0.2025.11.25.09.16.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Nov 2025 09:16:30 -0800 (PST) Message-ID: <23a99187-0ca5-459e-8bf0-b3bf61dd12fe@linaro.org> Date: Tue, 25 Nov 2025 18:16:29 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/5] thermal/drivers: airoha: Generalize probe function To: Christian Marangi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Zhang Rui , Lukasz Luba , Lorenzo Bianconi , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org References: <20251106225929.1778398-1-ansuelsmth@gmail.com> <20251106225929.1778398-3-ansuelsmth@gmail.com> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <20251106225929.1778398-3-ansuelsmth@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > --- > 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); -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog