Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: sx9360: Add pre-charge resistor setting

Add ability to set the precharge internal resistance from the device
tree.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20220429220144.1476049-11-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Gwendal Grignou and committed by
Jonathan Cameron
bc76ea59 4f3b42b8

+14 -1
+14 -1
drivers/iio/proximity/sx9360.c
··· 51 51 #define SX9360_REG_GNRL_REG_2_FREQ(_r) (SX9360_FOSC_HZ / ((_r) * 8192)) 52 52 53 53 #define SX9360_REG_AFE_CTRL1 0x21 54 + #define SX9360_REG_AFE_CTRL1_RESFILTIN_MASK GENMASK(3, 0) 55 + #define SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS 0 54 56 #define SX9360_REG_AFE_PARAM0_PHR 0x22 55 57 #define SX9360_REG_AFE_PARAM1_PHR 0x23 56 58 #define SX9360_REG_AFE_PARAM0_PHM 0x24 ··· 673 671 { SX9360_REG_GNRL_CTRL1, 0x00 }, 674 672 { SX9360_REG_GNRL_CTRL2, SX9360_REG_GNRL_CTRL2_PERIOD_102MS }, 675 673 676 - { SX9360_REG_AFE_CTRL1, 0x00 }, 674 + { SX9360_REG_AFE_CTRL1, SX9360_REG_AFE_CTRL1_RESFILTIN_0OHMS }, 677 675 { SX9360_REG_AFE_PARAM0_PHR, SX9360_REG_AFE_PARAM0_RSVD | 678 676 SX9360_REG_AFE_PARAM0_RESOLUTION_128 }, 679 677 { SX9360_REG_AFE_PARAM1_PHR, SX9360_REG_AFE_PARAM1_AGAIN_PHM_6PF | ··· 724 722 725 723 memcpy(reg_def, &sx9360_default_regs[idx], sizeof(*reg_def)); 726 724 switch (reg_def->reg) { 725 + case SX9360_REG_AFE_CTRL1: 726 + ret = device_property_read_u32(dev, 727 + "semtech,input-precharge-resistor-ohms", 728 + &raw); 729 + if (ret) 730 + break; 731 + 732 + reg_def->def &= ~SX9360_REG_AFE_CTRL1_RESFILTIN_MASK; 733 + reg_def->def |= FIELD_PREP(SX9360_REG_AFE_CTRL1_RESFILTIN_MASK, 734 + raw / 2000); 735 + break; 727 736 case SX9360_REG_AFE_PARAM0_PHR: 728 737 case SX9360_REG_AFE_PARAM0_PHM: 729 738 ret = device_property_read_u32(dev, "semtech,resolution", &raw);