Happy to report that I was able to root cause and fix the issue. Batocera compiles the Kernel using GCC 12. Maybe that is triggering the issues. Anyway here was my finding before the fix.
The i2c driver was sending incorrect value to i2c device
[ 1581.469825] meson-i2c fe076000.i2c: meson_i2c_set_clk_div_std: clk 166666664, freq 100000, div_h 819, div_l 417
[ 1581.469862] meson-i2c fe076000.i2c: meson_i2c_put_data: data ffffff8a
00000000 len 2
[ 1581.470199] meson-i2c fe076000.i2c: irq: state 2, pos 0, count 2, ctrl 06333050
As you can see the value ffffff8a
should have been 0000yy8a
where yy is fan value instead it was 0xff. This only happens if the MSB byte (0x8a) is any value above 0x7f. To confirm I enabled the WOL which correctly populated the word.
[ 2585.123104] meson-i2c fe076000.i2c: meson_i2c_set_clk_div_std: clk 166666664, freq 100000, div_h 819, div_l 417
[ 2585.123117] meson-i2c fe076000.i2c: meson_i2c_put_data: data 00000121
00000000 len 2
[ 2585.123442] meson-i2c fe076000.i2c: irq: state 2, pos 0, count 2, ctrl 06333050
Khadas Team, Please consider applying the following patch in your branches. This can manifest itself if not compiled with your toolchain. Either way the functions should not have converted original i2c u8 pointer to char pointer.
diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c
index 0133170f5..7b59ac86a 100644
--- a/drivers/i2c/busses/i2c-meson.c
+++ b/drivers/i2c/busses/i2c-meson.c
@@ -273,7 +273,7 @@ static void meson_i2c_set_clk_div(struct meson_i2c *i2c, unsigned int freq)
}
#endif
-static void meson_i2c_get_data(struct meson_i2c *i2c, char *buf, int len)
+static void meson_i2c_get_data(struct meson_i2c *i2c, u8 *buf, int len)
{
u32 rdata0, rdata1;
int i;
@@ -291,7 +291,7 @@ static void meson_i2c_get_data(struct meson_i2c *i2c, char *buf, int len)
*buf++ = (rdata1 >> (i - 4) * 8) & 0xff;
}
-static void meson_i2c_put_data(struct meson_i2c *i2c, char *buf, int len)
+static void meson_i2c_put_data(struct meson_i2c *i2c, u8 *buf, int len)
{
u32 wdata0 = 0, wdata1 = 0;
int i;
After the patch, Here is the result
[ 408.562688] meson-i2c fe076000.i2c: meson_i2c_set_clk_div_std: clk 166666664, freq 100000, div_h 819, div_l 417
[ 408.562716] meson-i2c fe076000.i2c: meson_i2c_put_data: data 0000008a
00000000 len 2
[ 408.563041] meson-i2c fe076000.i2c: irq: state 2, pos 0, count 2, ctrl 06333050
[ 439.283308] meson-i2c fe076000.i2c: meson_i2c_set_clk_div_std: clk 166666664, freq 100000, div_h 819, div_l 417
[ 439.283335] meson-i2c fe076000.i2c: meson_i2c_put_data: data 0000328a
00000000 len 2
[ 439.283659] meson-i2c fe076000.i2c: irq: state 2, pos 0, count 2, ctrl 06333050
Among other VIM4 optimizations for Batocera that I have been working hopefully this change will get merged in the upstream Batocera repo.