Update driver xdpe152c4.c

Shirley.Lin
2025-04-07T03:53:42Z

[-- 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 --]