hwmon: max34451: Workaround for lost page
PATCH 1/1 hwmon: max34451: Workaround for lost page
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hwmon/pmbus/max34440.c +7 -0
@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };
@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the +* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 ); + rv =i2c_smbus_read_word_data (client,MAX34451_MFR_CHANNEL_CONFIG );if (rv <0 )
Signature · 1 line
2.49.0.472.ge94155a9ec-goog
Guenter Roeck
maintainerQuoted 26 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hwmon/pmbus/max34440.c +1
-0@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 245
Quoted 4 lines
drivers/hwmon/pmbus/max34440.c +1
-0@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the
This is not the networking subsystem. Standard multi-line comments, please.
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 249
Quoted 4 lines
drivers/hwmon/pmbus/max34440.c +4
-0+* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 );
I would suggest to wait 100uS to be safe. The function is only called during probe, so that should be ok.
Is this a generic problem with this chip when changing pages ?
Thanks,
Guenter
Quoted 26 lines · Guenter Roeck
Quoted 24 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hwmon/pmbus/max34440.c +1
-0@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h"
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 245
Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the This is not the networking subsystem. Standard multi-line comments, please.
Okay, let me fix that.
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 249
Quoted 5 lines
drivers/hwmon/pmbus/max34440.c +4
-0+* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 );I would suggest to wait 100uS to be safe. The function is only called during probe, so that should be ok.
Yeah, I don't think they did strenuous measurement of these values on their end. We have been using this patch for 4-5 years now with seemingly good robustness on the 50us value. I just pulled up an old email from the vendor that gives this context.
Quoted 2 lines
Is this a generic problem with this chip when changing pages ?
I believe that is the case, but this patch is pretty old at this point. Is there somewhere to add in quirks for such chips that would allow us to build in such a delay?
Quoted 4 lines
Thanks,
Guenter
Guenter Roeck
maintainerQuoted 53 lines · William Kennington
Quoted 26 lines · Guenter Roeck
Quoted 24 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hwmon/pmbus/max34440.c +1
-0@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 245
Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the This is not the networking subsystem. Standard multi-line comments, please.
Okay, let me fix that.
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 249
Quoted 5 lines
drivers/hwmon/pmbus/max34440.c +4
-0+* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 );I would suggest to wait 100uS to be safe. The function is only called during probe, so that should be ok.
Yeah, I don't think they did strenuous measurement of these values on their end. We have been using this patch for 4-5 years now with seemingly good robustness on the 50us value. I just pulled up an old email from the vendor that gives this context.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
Is this a generic problem with this chip when changing pages ?
I believe that is the case, but this patch is pretty old at this point. Is there somewhere to add in quirks for such chips that would allow us to build in such a delay?
So far we only have delays for all accesses and for write operations. See access_delay and write_delay in struct pmbus_data. If the problem only affects page changes, we might have to add page_change_delay or something similar. Alternatively, maybe we could just set write_delay. If the chip has trouble with page changes, it might well be that it has trouble with write operations in general.
Thanks,
Guenter
Quoted 62 lines · Guenter Roeck
Quoted 53 lines · William Kennington
Quoted 26 lines · Guenter Roeck
Quoted 24 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hwmon/pmbus/max34440.c +1
-0@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 245
Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the This is not the networking subsystem. Standard multi-line comments, please.
Okay, let me fix that.
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 249
Quoted 5 lines
drivers/hwmon/pmbus/max34440.c +4
-0+* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 );I would suggest to wait 100uS to be safe. The function is only called during probe, so that should be ok.
Yeah, I don't think they did strenuous measurement of these values on their end. We have been using this patch for 4-5 years now with seemingly good robustness on the 50us value. I just pulled up an old email from the vendor that gives this context.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
Is this a generic problem with this chip when changing pages ?
I believe that is the case, but this patch is pretty old at this point. Is there somewhere to add in quirks for such chips that would allow us to build in such a delay?
Quoted 7 lines
So far we only have delays for all accesses and for write operations. See
access_delayandwrite_delayin structpmbus_data. If the problem only affects page changes, we might have to addpage_change_delayor something similar. Alternatively, maybe we could just setwrite_delay. If the chip has trouble with page changes, it might well be that it has trouble with write operations in general.
So I did some digging and asked the original contributors to the patch. It would appear that it's specifically an issue with this IC around page switches and not any arbitrary write command. There is an issue where it does not correctly respond to the second command issued after a PAGE switch occurs, if the commands come in too quickly. They believe it's an issue with max34451 (and other derivative ICs) not correctly clock stretching while the PAGE command is processed.
Let me know what approach you would prefer to take here. It seems like it would be most optimal to have a quirk specifically to delay commands after a PAGE.
Quoted 3 lines
Thanks,
Guenter
Guenter Roeck
maintainerQuoted 79 lines · William Kennington
Quoted 62 lines · Guenter Roeck
Quoted 53 lines · William Kennington
Quoted 26 lines · Guenter Roeck
Quoted 24 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware doesn't update the page on the max34451 side fast enough. This results in the kernel receiving data for a different page than what it expects.
To remedy this, the manufacturer recommends we wait 50-100us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>--- drivers/hwmon/pmbus/max34440.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hwmon/pmbus/max34440.c +1
-0@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 245
Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0enum chips { max34440, max34441, max34446, max34451, max34460, max34461 };@@ -241,6 +242,12 @@ static int max34451_set_supported_funcs(struct i2c_client *client,if (rv <0 )return rv; +/* Firmware is sometimes not ready if we try and read the This is not the networking subsystem. Standard multi-line comments, please.
Okay, let me fix that.
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static int max34451_set_supported_funcs(struct i2c_client *client, · line 249
Quoted 5 lines
drivers/hwmon/pmbus/max34440.c +4
-0+* data from the page immediately after setting. Maxim +* recommends 50-100us delay. +*/ +fsleep (50 );I would suggest to wait 100uS to be safe. The function is only called during probe, so that should be ok.
Yeah, I don't think they did strenuous measurement of these values on their end. We have been using this patch for 4-5 years now with seemingly good robustness on the 50us value. I just pulled up an old email from the vendor that gives this context.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
Is this a generic problem with this chip when changing pages ?
I believe that is the case, but this patch is pretty old at this point. Is there somewhere to add in quirks for such chips that would allow us to build in such a delay?
Quoted 7 lines
So far we only have delays for all accesses and for write operations. See
access_delayandwrite_delayin structpmbus_data. If the problem only affects page changes, we might have to addpage_change_delayor something similar. Alternatively, maybe we could just setwrite_delay. If the chip has trouble with page changes, it might well be that it has trouble with write operations in general.So I did some digging and asked the original contributors to the patch. It would appear that it's specifically an issue with this IC around page switches and not any arbitrary write command. There is an issue where it does not correctly respond to the second command issued after a PAGE switch occurs, if the commands come in too quickly. They believe it's an issue with max34451 (and other derivative ICs) not correctly clock stretching while the PAGE command is processed.
Quoted 4 lines
Let me know what approach you would prefer to take here. It seems like it would be most optimal to have a quirk specifically to delay commands after a PAGE.
I think we should add page_change_delay to struct pmbus_data, plus its handling in the pmbus core.
Thanks,
Guenter
PATCH v2 1/1 hwmon: max34451: Work around lost page
In reply to William A. Kennington IIIWhen requesting new pages from the max34451 we sometimes see that the firmware responds with stale or bad data to reads that happen immediately after a page change. This is due to a lack of clock stretching after page changing on the device side when it needs more time to complete the operation.
To remedy this, the manufacturer recommends we wait 50us until the firmware should be ready with the new page.
---
V1 -> V2: Make all page changes delay the required 50us
drivers/hwmon/pmbus/max34440.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/hwmon/pmbus/max34440.c +16 -0
@@ -12,10 +12,19 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 }; +/* +* Firmware is sometimes not ready if we try and read the +* data from the page immediately after setting. Maxim +* recommends 50us delay due to the chip failing to clock +* stretch long enough here. +*/ +#define MAX34440_PAGE_CHANGE_DELAY 50 +#define MAX34440_MFR_VOUT_PEAK 0xd4#define MAX34440_MFR_IOUT_PEAK 0xd5#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6
@@ -238,6 +247,7 @@ static int max34451_set_supported_funcs(struct i2c_client *client,for (page =0 ; page <16 ; page++) { rv =i2c_smbus_write_byte_data (client,PMBUS_PAGE , page); +fsleep (MAX34440_PAGE_CHANGE_DELAY );if (rv <0 )return rv;
@@ -312,6 +322,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34441] = { .pages = 12,
@@ -355,6 +366,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34446] = { .pages = 7,
@@ -392,6 +404,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34451] = { .pages = 21,
@@ -415,6 +428,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34460] = { .pages = 18,
@@ -445,6 +459,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[17] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34461] = { .pages = 23,
@@ -480,6 +495,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[21] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, };
Signature · 1 line
2.49.0.504.g3bcea36a83-goog
Re: [PATCH v2] hwmon: max34451: Work around lost page
Quoted 10 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware responds with stale or bad data to reads that happen immediately after a page change. This is due to a lack of clock stretching after page changing on the device side when it needs more time to complete the operation.
To remedy this, the manufacturer recommends we wait 50us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>
Applied to hwmon-next.
Alexis: Do you happen to know if the new revision of MAX34451 still has this problem ? Also, it would be nice to get some feedback if the patch covers all affected devices.
Thanks,
Guenter
Quoted 86 lines
---
V1 -> V2: Make all page changes delay the required 50usdrivers/hwmon/pmbus/max34440.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/hwmon/pmbus/max34440.c +16
-0@@ -12,10 +12,19 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 }; +/* +* Firmware is sometimes not ready if we try and read the +* data from the page immediately after setting. Maxim +* recommends 50us delay due to the chip failing to clock +* stretch long enough here. +*/ +#define MAX34440_PAGE_CHANGE_DELAY 50 +#define MAX34440_MFR_VOUT_PEAK 0xd4#define MAX34440_MFR_IOUT_PEAK 0xd5#define MAX34440_MFR_TEMPERATURE_PEAK 0xd6@@ -238,6 +247,7 @@ static int max34451_set_supported_funcs(struct i2c_client *client,for (page =0 ; page <16 ; page++) { rv =i2c_smbus_write_byte_data (client,PMBUS_PAGE , page); +fsleep (MAX34440_PAGE_CHANGE_DELAY );if (rv <0 )return rv;@@ -312,6 +322,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34441] = { .pages = 12,@@ -355,6 +366,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34446] = { .pages = 7,@@ -392,6 +404,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34451] = { .pages = 21,@@ -415,6 +428,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[20] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34460] = { .pages = 18,@@ -445,6 +459,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[17] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34461] = { .pages = 23,@@ -480,6 +495,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[21] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, };
RE: [PATCH v2] hwmon: max34451: Work around lost page
Quoted 23 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Tuesday, April 8, 2025 10:06 AM
To: William A. Kennington III <[email protected]>
Cc: Jean Delvare <[email protected]>; [email protected]; linux- [email protected]; Torreno, Alexis Czezar <[email protected]>
Subject: Re: [PATCH v2] hwmon: max34451: Work around lost page[External]
Quoted 9 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware responds with stale or bad data to reads that happen immediately after a page change. This is due to a lack of clock stretching after page changing on the device side when it needs more time to complete the operation.
To remedy this, the manufacturer recommends we wait 50us until the firmware should be ready with the new page.
Quoted 8 lines
Quoted 1 line
Signed-off-by William A. Kennington III <[email protected]>Applied to hwmon-next.
Alexis: Do you happen to know if the new revision of MAX34451 still has this problem ? Also, it would be nice to get some feedback if the patch covers all affected devices.
I unfortunately am not aware of this. Let me see if can get an answer from the engr of the part.
Quoted 93 lines
Quoted 67 lines
---
V1 -> V2: Make all page changes delay the required 50usdrivers/hwmon/pmbus/max34440.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)(quoted diff) +0
-0
b/drivers/hwmon/pmbus/max34440.cindexc9dda33831ff..0d9cb39a9cc6100644drivers/hwmon/pmbus/max34440.c +9
-0@@ -12,10 +12,19 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 }; +/* +* Firmware is sometimes not ready if we try and read the +* data from the page immediately after setting. Maxim +* recommends 50us delay due to the chip failing to clock +* stretch long enough here. +*/ +#define MAX34440_PAGE_CHANGE_DELAY 50 +#define MAX34440_MFR_VOUT_PEAK 0xd4#define MAX34440_MFR_IOUT_PEAK 0xd5#define
MAX34440_MFR_TEMPERATURE_PEAK0xd6drivers/hwmon/pmbus/max34440.c +4
-0@@ -238,6 +247,7 @@ static int max34451_set_supported_funcs(struct i2c_client *client, for (page = 0; page < 16; page++) { rv =i2c_smbus_write_byte_data (client,PMBUS_PAGE , page); +fsleep (MAX34440_PAGE_CHANGE_DELAY );if (rv <0 )return rv;@@ -312,6 +322,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34441] = { .pages = 12,@@ -355,6 +366,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34446] = { .pages = 7,@@ -392,6 +404,7 @@ static struct pmbus_driver_info max34440_info[] = { .read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34451] = { .pages = 21,drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = { · line 428
Quoted 1 line
drivers/hwmon/pmbus/max34440.c +0
-0@@ -415,6 +428,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[20] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = { · line 459
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34460] = { .pages = 18,@@ -445,6 +459,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[17] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = { · line 495
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34461] = { .pages = 23,@@ -480,6 +495,7 @@ static struct pmbus_driver_info max34440_info[] = { .func[21] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, };
RE: [PATCH v2] hwmon: max34451: Work around lost page
Quoted 16 lines
Quoted 16 lines
[External]
Quoted 10 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware responds with stale or bad data to reads that happen immediately after a page change. This is due to a lack of clock stretching after page changing on the device side when it needs more time to complete the operation.
To remedy this, the manufacturer recommends we wait 50us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>Applied to hwmon-next.
Quoted 7 lines
Quoted 4 lines
Alexis: Do you happen to know if the new revision of MAX34451 still has this problem ? Also, it would be nice to get some feedback if the patch covers all affected devices.
I unfortunately am not aware of this. Let me see if can get an answer from the engr of the part.
To follow up, here's the exact response I got.
- This is not an issue with the part. As the fix mentions, "the manufacturer recommends we wait 50us until the firmware should be ready with the new page". Compliant with I2C/SMBus spec, some parts require a longer idle time for the bus to be free before receiving the next command, in this situation it is normal to recommend a longer idle time in between commands. It's more related to the part's inner timing and architecture.
So I guess no specific changes related to this was made for later versions so the patch here should cover all.
Thanks,
Quoted 100 lines
Quoted 37 lines
Quoted 37 lines
---
V1 -> V2: Make all page changes delay the required 50usdrivers/hwmon/pmbus/max34440.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)(quoted diff) +0
-0
b/drivers/hwmon/pmbus/max34440.cindexc9dda33831ff..0d9cb39a9cc6100644drivers/hwmon/pmbus/max34440.c +9
-0@@ -12,10 +12,19 @@#include <linux/init.h> #include <linux/err.h> #include <linux/i2c.h> +#include <linux/delay.h> #include "pmbus.h" enum chips { max34440, max34441, max34446, max34451, max34460, max34461 }; +/* +* Firmware is sometimes not ready if we try and read the +* data from the page immediately after setting. Maxim +* recommends 50us delay due to the chip failing to clock +* stretch long enough here. +*/ +#define MAX34440_PAGE_CHANGE_DELAY 50 +#define MAX34440_MFR_VOUT_PEAK 0xd4#define MAX34440_MFR_IOUT_PEAK 0xd5#define
MAX34440_MFR_TEMPERATURE_PEAK0xd6drivers/hwmon/pmbus/max34440.c +0
-0@@ -238,6 +247,7 @@ static int max34451_set_supported_funcs(struct i2c_client *client,Quoted 7 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 7 lines
drivers/hwmon/pmbus/max34440.c +1
-0for (page =0 ; page <16 ; page++) { rv =i2c_smbus_write_byte_data (client,PMBUS_PAGE , page); +fsleep (MAX34440_PAGE_CHANGE_DELAY );if (rv <0 )return rv;@@ -312,6 +322,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34441] = { .pages = 12,@@ -355,6 +366,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34446] = { .pages = 7,@@ -392,6 +404,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_byte_data = max34440_read_byte_data, .read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34451] = { .pages = 21,@@ -415,6 +428,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 9 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = · line 428
Quoted 1 line
drivers/hwmon/pmbus/max34440.c +0
-0.func[20] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 7 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34460] = { .pages = 18,@@ -445,6 +459,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 9 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = · line 459
Quoted 1 line
drivers/hwmon/pmbus/max34440.c +0
-0.func[17] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] =
Quoted 7 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, [max34461] = { .pages = 23,@@ -480,6 +495,7 @@ static struct pmbus_driver_info max34440_info[] ={
Quoted 8 lines
drivers/hwmon/pmbus/max34440.c static struct pmbus_driver_info max34440_info[] = · line 495
Quoted 1 line
drivers/hwmon/pmbus/max34440.c +0
-0.func[21] = PMBUS_HAVE_TEMP |
PMBUS_HAVE_STATUS_TEMP,Quoted 6 lines
drivers/hwmon/pmbus/max34440.c +1
-0.read_word_data = max34440_read_word_data, .write_word_data = max34440_write_word_data, + .page_change_delay = MAX34440_PAGE_CHANGE_DELAY, }, };
Guenter Roeck
maintainerRe: [PATCH v2] hwmon: max34451: Work around lost page
Quoted 33 lines · Alexis Czezar
Quoted 16 lines
Quoted 16 lines
[External]
Quoted 10 lines · William A. Kennington III
When requesting new pages from the max34451 we sometimes see that the firmware responds with stale or bad data to reads that happen immediately after a page change. This is due to a lack of clock stretching after page changing on the device side when it needs more time to complete the operation.
To remedy this, the manufacturer recommends we wait 50us until the firmware should be ready with the new page.
Signed-off-by William A. Kennington III <[email protected]>Applied to hwmon-next.
Quoted 7 lines
Quoted 4 lines
Alexis: Do you happen to know if the new revision of MAX34451 still has this problem ? Also, it would be nice to get some feedback if the patch covers all affected devices.
I unfortunately am not aware of this. Let me see if can get an answer from the engr of the part.
To follow up, here's the exact response I got.
- This is not an issue with the part. As the fix mentions, "the manufacturer recommends we wait 50us until the firmware should be ready with the new page". Compliant with I2C/SMBus spec, some parts require a longer idle time for the bus to be free before receiving the next command, in this situation it is normal to recommend a longer idle time in between commands. It's more related to the part's inner timing and architecture.
Quoted 3 lines
So I guess no specific changes related to this was made for later versions so the patch here should cover all.
Ok. Thanks a lot for looking into this!
Guenter