public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: <Shirley.Lin@infineon.com>
To: <robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<jdelvare@suse.com>, <linux@roeck-us.net>, <corbet@lwn.net>,
	<patrick.rudolph@9elements.com>, <bhelgaas@google.com>,
	<ninad@linux.ibm.com>, <festevam@denx.de>,
	<devicetree@vger.kernel.org>, <linux-hwmon@vger.kernel.org>,
	<linux-i2c@vger.kernel.org>
Cc: <Mills.Liu@infineon.com>, <Ashish.Yadav@infineon.com>,
	<Ian.Fang@infineon.com>
Subject: Update driver xdpe152c4.c
Date: Mon, 7 Apr 2025 03:52:29 +0000	[thread overview]
Message-ID: <3f7d0644a1f844b8b3ee9b3139b85339@infineon.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1156 bytes --]

Dear Linux Kernel administrators, Good Day.

We have urgent requirement to update driver link, https://github.com/torvalds/linux/blob/master/drivers/hwmon/pmbus/xdpe152c4.c<https://github.com/torvalds/linux/blob/master/drivers/hwmon/pmbus/xdpe152c4.c#L72>

Please help to review the attached Linux Kernel patch for xdpe152xx driver.

PEC Retry Functionality added for both read_word_data() & read_byte_data() cases of PMBUS.

Updated by : Yadav Ashish (PSS PCS RD FW HD) Ashish.Yadav@infineon.com<mailto:Ashish.Yadav@infineon.com>

Kindly leave your comment or give us approval for upstream.

Thanks a lot.
Best Regards,
Shirley Lin

Infineon Technologies Taiwan Co. Ltd.
Field Application Engineer
IFTW PSS SMD GC TM DCO
Office: +886 2 2652 6866
Mobile: +886 9 7822 9671
Shirley.Lin@infineon.com<mailto:Shirley.Lin@infineon.com>

17F, No. 335, Ruiguang Road
Neihu District, Taipei 114063
Taiwan

www.infineon.com<http://www.infineon.com/>  Discoveries<http://www.infineon.com/discoveries>  Facebook<http://www.facebook.com/infineon>  X<https://x.com/Infineon>  LinkedIn<http://www.linkedin.com/company/infineon-technologies>


[-- Attachment #1.2: Type: text/html, Size: 7549 bytes --]

[-- Attachment #2: XDPE152xx-PMBUS-Driver-PEC-RETRY.patch --]
[-- Type: application/octet-stream, Size: 2329 bytes --]

From 16fd1cd36bc890604355ddee0a5753559292f932 Mon Sep 17 00:00:00 2001
From: Ashish Yadav <ashish.yadav@infineon.com>
Date: Sat, 29 Mar 2025 12:25:39 +0530
Subject: [PATCH] XDPE152xx PMBUS Driver: PEC RETRY

xdpe152xx driver retry to read data in case of PEC Error or Nack on PMBUS.

Signed-off-by: Ashish Yadav <ashish.yadav@infineon.com>
---
 drivers/hwmon/pmbus/xdpe152c4.c | 63 ++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/xdpe152c4.c b/drivers/hwmon/pmbus/xdpe152c4.c
index 235e6b41a..a61ba4a56 100644
--- a/drivers/hwmon/pmbus/xdpe152c4.c
+++ b/drivers/hwmon/pmbus/xdpe152c4.c
@@ -10,12 +10,73 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/delay.h>
 #include "pmbus.h"
 
-#define XDPE152_PAGE_NUM 2
+#define XDPE152_PAGE_NUM	2
+#define XDPE152_RETRY_BUS_READ	4
+
+static int xdpe152_read_word_data(struct i2c_client *client, int page,
+					int phase, int reg)
+{
+	int ret = 0;
+	int retry = 0;
+
+	/* Virtual PMBUS Command not supported */
+	if (reg >= PMBUS_VIRT_BASE) {
+		ret = -ENXIO;
+		return ret;
+	}
+
+	do {
+		ret = pmbus_read_word_data(client, page, phase, reg);
+		if (ret == -EBADMSG || ret == -ENXIO) {
+			/* PEC Error or NACK: try again */
+			retry++;
+			/* Sleep for an approximate time */
+			usleep_range(25, 50);
+			continue;
+		} else {
+			break;
+		}
+
+	} while (retry < XDPE152_RETRY_BUS_READ);
+
+	if (ret < 0)
+		pr_warn("PMBUS READ ERROR:%d\n", ret);
+
+	return ret;
+}
+
+static int xdpe152_read_byte_data(struct i2c_client *client, int page, int reg)
+{
+	int ret = 0;
+	int retry = 0;
+
+	do {
+		ret = pmbus_read_byte_data(client, page, reg);
+		if (ret == -EBADMSG || ret == -ENXIO) {
+			/* PEC Error or NACK: try again */
+			retry++;
+			/* Sleep for an approximate time */
+			usleep_range(25, 50);
+			continue;
+		} else {
+			break;
+		}
+
+	} while (retry < XDPE152_RETRY_BUS_READ);
+
+	if (ret < 0)
+		pr_warn("PMBUS READ ERROR:%d\n", ret);
+
+	return ret;
+}
 
 static struct pmbus_driver_info xdpe152_info = {
 	.pages = XDPE152_PAGE_NUM,
+	.read_word_data = xdpe152_read_word_data,
+	.read_byte_data = xdpe152_read_byte_data,
 	.format[PSC_VOLTAGE_IN] = linear,
 	.format[PSC_VOLTAGE_OUT] = linear,
 	.format[PSC_TEMPERATURE] = linear,
-- 
2.39.5


[-- Attachment #3: PEC Retries Proposal_202503255.pdf --]
[-- Type: application/pdf, Size: 545466 bytes --]

             reply	other threads:[~2025-04-07  3:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07  3:52 Shirley.Lin [this message]
2025-04-07  4:59 ` Update driver xdpe152c4.c Mukesh Kumar Savaliya
2025-04-07  6:12   ` Wolfram Sang
2025-04-07  6:58     ` Mukesh Kumar Savaliya
2025-04-07  7:23       ` Shirley.Lin
2025-04-07  6:15 ` Wolfram Sang
2025-04-07 14:01   ` Guenter Roeck
2025-04-07 14:36     ` Guenter Roeck
2025-04-08  3:28       ` Ashish.Yadav
2025-04-08  4:06         ` Guenter Roeck

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=3f7d0644a1f844b8b3ee9b3139b85339@infineon.com \
    --to=shirley.lin@infineon.com \
    --cc=Ashish.Yadav@infineon.com \
    --cc=Ian.Fang@infineon.com \
    --cc=Mills.Liu@infineon.com \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@denx.de \
    --cc=jdelvare@suse.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=ninad@linux.ibm.com \
    --cc=patrick.rudolph@9elements.com \
    --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