devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "André Draszik" <andre.draszik@linaro.org>
To: Kaustabh Chakraborty <kauschluss@disroot.org>,
	Lee Jones <lee@kernel.org>,  Pavel Machek <pavel@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi	 <cw00.choi@samsung.com>,
	Sebastian Reichel <sre@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Jonathan Corbet	 <corbet@lwn.net>
Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	 linux-samsung-soc@vger.kernel.org, linux-rtc@vger.kernel.org,
	 linux-doc@vger.kernel.org
Subject: Re: [PATCH 08/13] mfd: sec: store hardware revision in sec_pmic_dev and add S2MU005 support
Date: Fri, 14 Nov 2025 13:14:19 +0000	[thread overview]
Message-ID: <982158427bae79e15c92ad0198b398258e262ef6.camel@linaro.org> (raw)
In-Reply-To: <20251114-s2mu005-pmic-v1-8-9e3184d3a0c9@disroot.org>

On Fri, 2025-11-14 at 00:35 +0530, Kaustabh Chakraborty wrote:
> The device revision matters in cases when in some PMICs, the correct
> register offsets very in different revisions. Instead of just debug
> printing the value, store it in the driver data struct.
> 
> Unlike other devices, S2MU005 has its hardware revision ID in register
> offset 0x73. Allow handling different devices and add support for S2MU005.
> 
> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
> ---
>  drivers/mfd/sec-common.c         | 30 ++++++++++++++++++++++++------
>  include/linux/mfd/samsung/core.h |  3 +++
>  2 files changed, 27 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
> index 4c5f4dc2905b..f51c53e7a164 100644
> --- a/drivers/mfd/sec-common.c
> +++ b/drivers/mfd/sec-common.c
> @@ -16,6 +16,7 @@
>  #include <linux/mfd/samsung/irq.h>
>  #include <linux/mfd/samsung/s2mps11.h>
>  #include <linux/mfd/samsung/s2mps13.h>
> +#include <linux/mfd/samsung/s2mu005.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/pm.h>
> @@ -86,17 +87,34 @@ static const struct mfd_cell s2mu005_devs[] = {
>  	MFD_CELL_OF("s2mu005-rgb", NULL, NULL, 0, 0, "samsung,s2mu005-rgb"),
>  };
>  
> -static void sec_pmic_dump_rev(struct sec_pmic_dev *sec_pmic)
> +static void sec_pmic_store_rev(struct sec_pmic_dev *sec_pmic)
>  {
> -	unsigned int val;
> +	unsigned int reg, mask, shift;
>  
>  	/* For s2mpg1x, the revision is in a different regmap */
>  	if (sec_pmic->device_type == S2MPG10)
>  		return;
>  
> -	/* For each device type, the REG_ID is always the first register */
> -	if (!regmap_read(sec_pmic->regmap_pmic, S2MPS11_REG_ID, &val))
> -		dev_dbg(sec_pmic->dev, "Revision: 0x%x\n", val);
> +	switch (sec_pmic->device_type) {
> +	case S2MU005:
> +		reg = S2MU005_REG_ID;
> +		mask = S2MU005_ID_MASK;
> +		shift = S2MU005_ID_SHIFT;
> +		break;
> +	default:
> +		/* For other device types, the REG_ID is always the first register. */
> +		reg = S2MPS11_REG_ID;
> +		mask = ~0;
> +		shift = 0;
> +	}
> +
> +	if (!regmap_read(sec_pmic->regmap_pmic, reg, &sec_pmic->revision))
> +		return;

You should probably propagate the error up to the caller here.

Cheers,
Andre'

> +
> +	sec_pmic->revision &= mask;
> +	sec_pmic->revision >>= shift;
> +
> +	dev_dbg(sec_pmic->dev, "Revision: 0x%x\n", sec_pmic->revision);
>  }
>  
>  static void sec_pmic_configure(struct sec_pmic_dev *sec_pmic)
> @@ -236,7 +254,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  		return ret;
>  
>  	sec_pmic_configure(sec_pmic);
> -	sec_pmic_dump_rev(sec_pmic);
> +	sec_pmic_store_rev(sec_pmic);
>  
>  	return ret;
>  }
> diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
> index fc07f7944dcd..ccd1bfa15b85 100644
> --- a/include/linux/mfd/samsung/core.h
> +++ b/include/linux/mfd/samsung/core.h
> @@ -63,6 +63,7 @@ enum sec_device_type {
>   * @irq_base:		Base IRQ number for device, required for IRQs
>   * @irq:		Generic IRQ number for device
>   * @irq_data:		Runtime data structure for IRQ controller
> + * @revision:		Revision number of the device
>   * @wakeup:		Whether or not this is a wakeup device
>   */
>  struct sec_pmic_dev {
> @@ -74,6 +75,8 @@ struct sec_pmic_dev {
>  	int device_type;
>  	int irq;
>  	struct regmap_irq_chip_data *irq_data[MAX_IRQ_CHIPS];
> +
> +	unsigned int revision;
>  };
>  
>  struct sec_platform_data {

  reply	other threads:[~2025-11-14 13:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 19:05 [PATCH 00/13] Support for Samsung S2MU005 PMIC and its sub-devices Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 01/13] dt-bindings: leds: document Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2025-11-13 19:52   ` Conor Dooley
2025-11-13 19:05 ` [PATCH 02/13] dt-bindings: leds: document Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2025-11-13 19:53   ` Conor Dooley
2025-11-13 19:05 ` [PATCH 03/13] dt-bindings: extcon: document Samsung S2M series PMIC extcon device Kaustabh Chakraborty
2025-11-13 19:54   ` Conor Dooley
2025-11-13 19:05 ` [PATCH 04/13] dt-bindings: power: supply: document Samsung S2M series PMIC charger device Kaustabh Chakraborty
2025-11-13 19:57   ` Conor Dooley
2025-11-13 19:05 ` [PATCH 05/13] dt-bindings: mfd: s2mps11: add documentation for S2MU005 PMIC Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 06/13] mfd: sec-irq: add support for creating multiple IRQ chips Kaustabh Chakraborty
2025-11-14  7:50   ` Alexandre Belloni
2025-11-14 11:55     ` André Draszik
2025-11-15 15:45       ` Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 07/13] mfd: sec: add support for S2MU005 PMIC Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 08/13] mfd: sec: store hardware revision in sec_pmic_dev and add S2MU005 support Kaustabh Chakraborty
2025-11-14 13:14   ` André Draszik [this message]
2025-11-13 19:05 ` [PATCH 09/13] leds: flash: add support for Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 10/13] leds: rgb: add support for Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 11/13] Documentation: leds: document pattern behavior of Samsung S2M series PMIC RGB LEDs Kaustabh Chakraborty
2025-11-13 19:57   ` Randy Dunlap
2025-11-13 19:05 ` [PATCH 12/13] extcon: add support for Samsung S2M series PMIC extcon devices Kaustabh Chakraborty
2025-11-13 19:05 ` [PATCH 13/13] power: supply: add support for Samsung S2M series PMIC charger device Kaustabh Chakraborty

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=982158427bae79e15c92ad0198b398258e262ef6.camel@linaro.org \
    --to=andre.draszik@linaro.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kauschluss@disroot.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@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;
as well as URLs for NNTP newsgroup(s).