Re: [PATCH] iio: light: stk3310: Deal with the ps interrupt issue in PM
From: Jonathan Cameron
Date: Tue Apr 28 2026 - 14:22:31 EST
On Mon, 27 Apr 2026 17:43:13 +0800
Miao Li <limiao870622@xxxxxxx> wrote:
> From: Miao Li <limiao@xxxxxxxxxx>
Hi Miao Li
A few (possibly additional) things inline.
>
> On the Huawei hisi platform, if the STK3311-X chip's PS interrupt
I'm curious. What HiSilicon platform is this?
Good to have that recorded as part of the description for anyone
else who encounters this bug.
> is configured in "Recommended interrupt mode", the interrupt cannot
> be triggered normally after waking from suspend or hibernation.
>
> In this case, neither disabling and re-enabling the interrupt nor
> resetting the PS threshold register can restore the interrupt to
> normal operation.
>
> if we disable the interrupt in suspend(), then reset the PS threshold
> register and enable the interrupt in resume(), this issue can be fixed.
Switch text to imperative.
If the interrupt is disabled in suspend() then rest the PS threshold
register and enable the interrupt in resume(). This resolves the issue.
Or something like that.
>
> Signed-off-by: Miao Li <limiao@xxxxxxxxxx>
> @@ -504,8 +523,13 @@ static int stk3310_init(struct iio_dev *indio_dev)
>
> /* Enable PS interrupts */
> ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
> - if (ret < 0)
> + if (ret < 0) {
> dev_err(&client->dev, "failed to enable interrupts!\n");
> + return ret;
> + }
> +
> + data->ps_int_enabled = true;
> + data->ps_thdh = STK3310_PS_MAX_VAL;
>
> return ret;
return 0;
...
> @@ -681,6 +714,8 @@ static int stk3310_resume(struct device *dev)
> {
> u8 state = 0;
> struct stk3310_data *data;
> + __be16 buf;
> + int ret;
>
> data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> if (data->ps_enabled)
> @@ -688,7 +723,35 @@ static int stk3310_resume(struct device *dev)
> if (data->als_enabled)
> state |= STK3310_STATE_EN_ALS;
>
> - return stk3310_set_state(data, state);
> + ret = stk3310_set_state(data, state);
> + if (ret < 0)
> + return ret;
> +
> + if (data->ps_thdl != 0x0) {
> + buf = cpu_to_be16(data->ps_thdl);
> + ret = regmap_bulk_write(data->regmap, STK3310_REG_THDL_PS, &buf, 2);
sizeof(buf) rather than 2. here and below.
> + if (ret < 0) {
> + dev_err(dev, "failed to set reg THDL_PS at resume.\n");
> + return ret;
> + }
> + }
> +
> + if (data->ps_thdh != STK3310_PS_MAX_VAL) {
> + buf = cpu_to_be16(data->ps_thdh);
> + ret = regmap_bulk_write(data->regmap, STK3310_REG_THDH_PS, &buf, 2);
> + if (ret < 0) {
> + dev_err(dev, "failed to set reg THDH_PS at resume.\n");
> + return ret;
> + }
> + }
> +
> + if (data->ps_int_enabled) {
> + ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
> + if (ret < 0)
> + dev_err(dev, "failed to enable ps int at resume.\n");
Keep return ret in here so we have consistent pattern with the above .
> + }
> +
> + return ret;
Then
return 0;
> }
>
> static DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend,