mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kaustabh Chakraborty" <kauschluss@disroot.org>
To: "Kaustabh Chakraborty" <kauschluss@disroot.org>,
	"André Draszik" <andre.draszik@linaro.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>,
	"Shuah Khan" <skhan@linuxfoundation.org>
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 v2 07/12] mfd: sec: store hardware revision in sec_pmic_dev and add S2MU005 support
Date: Thu, 05 Feb 2026 21:56:07 +0530	[thread overview]
Message-ID: <DG7630P5V7QZ.1FLAW5QKEV4BZ@disroot.org> (raw)
In-Reply-To: <DG69QZBG97G3.1458CJYT0YG9C@disroot.org>

On 2026-02-04 20:35 +05:30, Kaustabh Chakraborty wrote:
> On 2026-02-04 14:17 +00:00, André Draszik wrote:
>> Hi Kaustabh,
>>
>> On Mon, 2026-01-26 at 00:37 +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
>>
>> s/very/vary
>>
>>> printing the value, store it in the driver data struct.
>>
>> Please mention that you're not doing that for s2mpg1x, though.
>>
>>> 
>>> 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         | 41 ++++++++++++++++++++++++++++++----------
>>>  include/linux/mfd/samsung/core.h |  1 +
>>>  2 files changed, 32 insertions(+), 10 deletions(-)
>>> 
>>> diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
>>> index bc2a1f2c6dc7a..069a1ba9aa1f1 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>
>>> @@ -111,17 +112,38 @@ 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 int sec_pmic_store_rev(struct sec_pmic_dev *sec_pmic)
>>>  {
>>> -	unsigned int val;
>>> +	unsigned int reg, mask, shift;
>>> +	int ret;
>>>  
>>> -	/* For s2mpg1x, the revision is in a different regmap */
>>> -	if (sec_pmic->device_type == S2MPG10)
>>> -		return;
>>> +	switch (sec_pmic->device_type) {
>>> +	case S2MPG10:
>>> +		/* For s2mpg1x, the revision is in a different regmap */
>>> +		return 0;
>>> +	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;
>>> +	}
>>> +
>>> +	ret = regmap_read(sec_pmic->regmap_pmic, reg, &sec_pmic->revision);
>>> +	if (ret) {
>>> +		dev_err(sec_pmic->dev, "Failed to read PMIC revision (%d)\n", ret);
>>> +		return ret;
>>> +	}
>>> +
>>> +	sec_pmic->revision &= mask;
>>> +	sec_pmic->revision >>= shift;
>>>  
>>> -	/* 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);
>>> +	dev_dbg(sec_pmic->dev, "Revision: 0x%x\n", sec_pmic->revision);
>>> +	return 0;
>>>  }
>>>  
>>>  static void sec_pmic_configure(struct sec_pmic_dev *sec_pmic)
>>> @@ -262,9 +284,8 @@ 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);
>>>  
>>> -	return ret;
>>> +	return sec_pmic_store_rev(sec_pmic);
>>>  }
>>>  EXPORT_SYMBOL_GPL(sec_pmic_probe);
>>>  
>>> diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
>>> index 43e0c5e55f5d3..56aa33d7e3d60 100644
>>> --- a/include/linux/mfd/samsung/core.h
>>> +++ b/include/linux/mfd/samsung/core.h
>>> @@ -70,6 +70,7 @@ struct sec_pmic_dev {
>>>  
>>>  	int device_type;
>>>  	int irq;
>>> +	unsigned int revision;
>>
>> kerneldoc needs to be updated.
>
> Seems like it needs cleanup anyway, I will send a patch for that
> separately (if this patch gets dropped in the next rev, see below).
>
>>
>> Given the LED driver is the only driver & device so far which needs the
>> PMIC revision, maybe for now that driver could determine the revision
>> itself instead of adding this new member for everybody?
>
> Hmm, implementing that would make this patch redundant. I'll do so.

It however seems weird to not handle it here; we're already reading the
revision value; it also makes sense to store it in the MFD driver
itself.

Either way, the patch won't be redundant, because the reading part at
least needs to be implemented here.

>
>>
>> Cheers,
>> Andre'
>>
>>>  };
>>>  
>>>  struct sec_platform_data {


  reply	other threads:[~2026-02-05 16:26 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-25 19:07 [PATCH v2 00/12] Support for Samsung S2MU005 PMIC and its sub-devices Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 01/12] dt-bindings: leds: document Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 02/12] dt-bindings: leds: document Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2026-02-06 13:38   ` Rob Herring
2026-02-06 13:56     ` Kaustabh Chakraborty
2026-02-06 14:03       ` Kaustabh Chakraborty
2026-02-08 13:05       ` Jacek Anaszewski
2026-01-25 19:07 ` [PATCH v2 03/12] dt-bindings: extcon: document Samsung S2M series PMIC extcon device Kaustabh Chakraborty
2026-02-06 13:49   ` Rob Herring
2026-02-06 13:52     ` Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 04/12] dt-bindings: power: supply: document Samsung S2M series PMIC charger device Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 05/12] dt-bindings: mfd: s2mps11: add documentation for S2MU005 PMIC Kaustabh Chakraborty
2026-01-25 20:59   ` Rob Herring (Arm)
2026-01-25 19:07 ` [PATCH v2 06/12] mfd: sec: add support " Kaustabh Chakraborty
2026-01-26 19:41   ` kernel test robot
2026-02-04 15:23   ` André Draszik
2026-02-05 15:32     ` Kaustabh Chakraborty
2026-02-10  9:55       ` André Draszik
2026-02-20 16:56       ` Sander Vanheule
2026-02-23 13:56         ` Kaustabh Chakraborty
2026-02-09  4:03   ` [PATCH FIX] mfd: sec-irq: fix non-constant case labels in s2mu005_irq_get_reg Łukasz Lebiedziński
2026-02-09  9:56     ` David Laight
2026-02-09 13:12     ` Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 07/12] mfd: sec: store hardware revision in sec_pmic_dev and add S2MU005 support Kaustabh Chakraborty
2026-02-04 14:17   ` André Draszik
2026-02-04 15:05     ` Kaustabh Chakraborty
2026-02-05 16:26       ` Kaustabh Chakraborty [this message]
2026-01-25 19:07 ` [PATCH v2 08/12] leds: flash: add support for Samsung S2M series PMIC flash LED device Kaustabh Chakraborty
2026-02-04 16:55   ` André Draszik
2026-02-05 16:16     ` Kaustabh Chakraborty
2026-02-10 10:03       ` André Draszik
2026-02-10 18:37         ` Kaustabh Chakraborty
2026-02-05 10:54   ` André Draszik
2026-01-25 19:07 ` [PATCH v2 09/12] leds: rgb: add support for Samsung S2M series PMIC RGB " Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 10/12] Documentation: leds: document pattern behavior of Samsung S2M series PMIC RGB LEDs Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 11/12] extcon: add support for Samsung S2M series PMIC extcon devices Kaustabh Chakraborty
2026-01-25 19:07 ` [PATCH v2 12/12] 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=DG7630P5V7QZ.1FLAW5QKEV4BZ@disroot.org \
    --to=kauschluss@disroot.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andre.draszik@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.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=skhan@linuxfoundation.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

all inboxes | Powered by JetHome®