• Hans de Goede's avatar
    iio: accel: mxc4005: Interrupt handling fixes · 57a15927
    Hans de Goede authored
    There are 2 issues with interrupt handling in the mxc4005 driver:
    
    1. mxc4005_set_trigger_state() writes MXC4005_REG_INT_MASK1_BIT_DRDYE
    (0x01) to INT_MASK1 to enable the interrupt, but to disable the interrupt
    it writes ~MXC4005_REG_INT_MASK1_BIT_DRDYE which is 0xfe, so it enables
    all other interrupt sources in the INT_SRC1 register. On the MXC4005 this
    is not an issue because only bit 0 of the register is used. On the MXC6655
    OTOH this is a problem since bit7 is used as TC (Temperature Compensation)
    disable bit and writing 1 to this disables Temperature Compensation which
    should only be done when running self-tests on the chip.
    
    Write 0 instead of ~MXC4005_REG_INT_MASK1_BIT_DRDYE to disable
    the interrupts to fix this.
    
    2. The datasheets for the MXC4005 / MXC6655 do not state what the reset
    value for the INT_MASK0 and INT_MASK1 registers is and since these are
    write only we also cannot learn this from the hw. Presumably the reset
    value for both is all 0, which means all interrupts disabled.
    
    Explicitly set both registers to 0 from mxc4005_chip_init() to ensure
    both masks are actually set to 0.
    
    Fixes: 79846e33 ("iio: accel: mxc4005: add support for mxc6655")
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20240326113700.56725-2-hdegoede@redhat.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    57a15927
mxc4005.c 11.6 KB