Skip to content

Commit 3c63ba1

Browse files
Aleksandar Gerasimovskijic23
authored andcommitted
iio/adc/pac1934: fix channel disable configuration
There are two problems with the chip configuration in this driver: - First, is that writing 12 bytes (ARRAY_SIZE(regs)) would anyhow lead to a config overflow due to HW auto increment implementation in the chip. - Second, the i2c_smbus_write_block_data write ends up in writing unexpected value to the channel_dis register, this is because the smbus size that is 0x03 in this case gets written to the register. The PAC1931/2/3/4 data sheet does not really specify that block write is indeed supported. This problem is probably not visible on PAC1934 version where all channels are used as the chip is properly configured by luck, but in our case whenusing PAC1931 this leads to nonfunctional device. Fixes: 0fb528c (iio: adc: adding support for PAC193x) Suggested-by: Rene Straub <mailto:rene.straub@belden.com> Signed-off-by: Aleksandar Gerasimovski <aleksandar.gerasimovski@belden.com> Reviewed-by: Marius Cristea <marius.cristea@microchip.com> Link: https://patch.msgid.link/20250811130904.2481790-1-aleksandar.gerasimovski@belden.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 1b237f1 commit 3c63ba1

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

drivers/iio/adc/pac1934.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
#define PAC1934_VPOWER_3_ADDR 0x19
8989
#define PAC1934_VPOWER_4_ADDR 0x1A
9090
#define PAC1934_REFRESH_V_REG_ADDR 0x1F
91+
#define PAC1934_SLOW_REG_ADDR 0x20
9192
#define PAC1934_CTRL_STAT_REGS_ADDR 0x1C
9293
#define PAC1934_PID_REG_ADDR 0xFD
9394
#define PAC1934_MID_REG_ADDR 0xFE
@@ -1265,8 +1266,23 @@ static int pac1934_chip_configure(struct pac1934_chip_info *info)
12651266
/* no SLOW triggered REFRESH, clear POR */
12661267
regs[PAC1934_SLOW_REG_OFF] = 0;
12671268

1268-
ret = i2c_smbus_write_block_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
1269-
ARRAY_SIZE(regs), (u8 *)regs);
1269+
/*
1270+
* Write the three bytes sequentially, as the device does not support
1271+
* block write.
1272+
*/
1273+
ret = i2c_smbus_write_byte_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
1274+
regs[PAC1934_CHANNEL_DIS_REG_OFF]);
1275+
if (ret)
1276+
return ret;
1277+
1278+
ret = i2c_smbus_write_byte_data(client,
1279+
PAC1934_CTRL_STAT_REGS_ADDR + PAC1934_NEG_PWR_REG_OFF,
1280+
regs[PAC1934_NEG_PWR_REG_OFF]);
1281+
if (ret)
1282+
return ret;
1283+
1284+
ret = i2c_smbus_write_byte_data(client, PAC1934_SLOW_REG_ADDR,
1285+
regs[PAC1934_SLOW_REG_OFF]);
12701286
if (ret)
12711287
return ret;
12721288

0 commit comments

Comments
 (0)