Re: [RFC PATCH 1/3] mfd: upboard: Add UP2 platform controller driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 21, 2018 at 10:30 AM, Javier Arteaga <javier@xxxxxxxxxx> wrote:

This:

> +#define UPBOARD_ADDRESS_SIZE  7
> +#define UPBOARD_REGISTER_SIZE 16
>
> +#define UPBOARD_READ_FLAG     BIT(UPBOARD_ADDRESS_SIZE)
(...)

> +static int upboard_read(void *context, unsigned int reg, unsigned int *val)
> +{
> +       const struct upboard * const upboard = context;
> +       int i;
> +
> +       gpiod_set_value(upboard->clear_gpio, 0);
> +       gpiod_set_value(upboard->clear_gpio, 1);
> +
> +       reg |= UPBOARD_READ_FLAG;

Bit 7 read/write?

> +       for (i = UPBOARD_ADDRESS_SIZE; i >= 0; i--) {
> +               gpiod_set_value(upboard->strobe_gpio, 0);
> +               gpiod_set_value(upboard->datain_gpio, (reg >> i) & 0x1);
> +               gpiod_set_value(upboard->strobe_gpio, 1);
> +       }

Address 7 bits.

> +       gpiod_set_value(upboard->strobe_gpio, 0);
> +       *val = 0;
> +
> +       for (i = UPBOARD_REGISTER_SIZE - 1; i >= 0; i--) {
> +               gpiod_set_value(upboard->strobe_gpio, 1);
> +               gpiod_set_value(upboard->strobe_gpio, 0);
> +               *val |= gpiod_get_value(upboard->dataout_gpio) << i;
> +       }

16 bits register size.

> +       gpiod_set_value(upboard->strobe_gpio, 1);

Clockitclock.

To me this just looks like bit-banged I2C with 16bit register size.
Compare to the bitbanging algorithm in
drivers/i2c/algos/i2c-algo-bit.c

So it should be able to use drivers/i2c/busses/i2c-gpio.c

Can't you just instantiate this GPIO bit-banged host from whatever
platform description
you have (ACPI? I don't know). The driver may need some modification
so you can tell it that the registers are optionally 16bits wide.

In that case the regmap should also be able to use:
drivers/base/regmap/regmap-i2c.c

Maybe augmented a but to optionally use 16bit wide registers.

But Wolfram needs to have a say in this, I guess the difference to I2C
is that each
address signifies a set of 16 bits, two bytes instead of  8 bits one byte. Maybe
this is to unorthodox for the I2C subsystem to accomodate, and that would
be his pick.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux