Re: [PATCH v4 3/4] Input: pinephone-keyboard - Support the proxied I2C bus

From: Andy Shevchenko
Date: Sun Jun 19 2022 - 07:34:54 EST


On Sat, Jun 18, 2022 at 7:12 PM Samuel Holland <samuel@xxxxxxxxxxxx> wrote:
>
> The PinePhone keyboard case contains a battery managed by an integrated
> power bank IC. The power bank IC communicates over I2C, and the keyboard
> MCU firmware provides an interface to read and write its registers.
> Let's use this interface to implement a SMBus adapter, so we can reuse
> the driver for the power bank IC.

...

> + /* Read back the command status until it passes or fails. */
> + do {
> + usleep_range(300, 500);
> + ret = i2c_smbus_read_byte_data(client, PPKB_SYS_COMMAND);
> + } while (ret == buf[2]);
> + if (ret < 0)
> + return ret;
> + /* Commands return 0x00 on success and 0xff on failure. */
> + if (ret)
> + return -EIO;

Something to use from iopoll.h ?


--
With Best Regards,
Andy Shevchenko