[U-Boot] [EXT] Re: [PATCH v2 1/3] dm: i2c: Add a flag that needs to generate a stop bit
Chuanhua Han
chuanhua.han at nxp.com
Mon Jun 24 04:45:51 UTC 2019
> -----Original Message-----
> From: Simon Glass <sjg at chromium.org>
> Sent: 2019年6月23日 3:10
> To: Chuanhua Han <chuanhua.han at nxp.com>
> Cc: Heiko Schocher <hs at denx.de>; U-Boot Mailing List <u-boot at lists.denx.de>;
> Biwen Li <biwen.li at nxp.com>; Lukasz Majewski <lukma at denx.de>
> Subject: [EXT] Re: [PATCH v2 1/3] dm: i2c: Add a flag that needs to generate a
> stop bit
>
> Caution: EXT Email
>
> Hi,
>
> On Fri, 24 May 2019 at 03:23, Chuanhua Han <chuanhua.han at nxp.com> wrote:
> >
> > Usually the i2c bus needs to write the address of the register before
> > reading the internal register data of the device (ignoring the
> > transmission of the slave address).
> >
> > Generally, the stop signal is not needed before the register is read,
> > but there is a special chip that needs this stop signal (such as
> > pcf2127), this patch adds a flag that needs to generate a stop bit to
> > determine whether the i2c host needs to generate a stop signal before
> > reading the register data.
>
> Does this mean that the chip does not comply with the i2c protocol?
>
> Is it possible instead to so a write and then a read?
>
> See dm_i2c_xfer().
Please see the fourth version of the patch, use the dm_i2c_xfer () function to do and I use a flag to limit the dm_i2c_read function
It is the same to transmit only one msg. Since the core layer already provides the dm_i2c_read function, it is appropriate to use this function.
Only condition flag is required to limit
>
>
> >
> > Signed-off-by: Biwen Li <biwen.li at nxp.com>
> > Signed-off-by: Chuanhua Han <chuanhua.han at nxp.com>
> > ---
> > Changes in v2:
> > - Split the original patch into 3 patches
> > - Add detailed description information for each patch
> >
> > drivers/i2c/i2c-uclass.c | 2 ++
> > include/i2c.h | 2 ++
> > 2 files changed, 4 insertions(+)
> >
> > diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index
> > e47abf1833..18f7364d72 100644
> > --- a/drivers/i2c/i2c-uclass.c
> > +++ b/drivers/i2c/i2c-uclass.c
> > @@ -141,6 +141,8 @@ int dm_i2c_read(struct udevice *dev, uint offset,
> uint8_t *buffer, int len)
> > if (len) {
> > ptr->addr = chip->chip_addr;
> > ptr->flags = chip->flags & DM_I2C_CHIP_10BIT ?
> > I2C_M_TEN : 0;
> > + ptr->flags |= chip->flags &
> DM_I2C_CHIP_RD_NEED_STOP_BIT ?
> > + I2C_M_RD_NEED_STOP_BIT : 0;
> > ptr->flags |= I2C_M_RD;
> > ptr->len = len;
> > ptr->buf = buffer;
> > diff --git a/include/i2c.h b/include/i2c.h index
> > a5c760c711..beaa028349 100644
> > --- a/include/i2c.h
> > +++ b/include/i2c.h
> > @@ -28,6 +28,7 @@ enum dm_i2c_chip_flags {
> > DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */
> > DM_I2C_CHIP_RD_ADDRESS = 1 << 1, /* Send address for each
> read byte */
> > DM_I2C_CHIP_WR_ADDRESS = 1 << 2, /* Send address for each
> > write byte */
> > + DM_I2C_CHIP_RD_NEED_STOP_BIT = 1 << 3, /* Need generate
> stop bit */
> > };
> >
> > struct udevice;
> > @@ -87,6 +88,7 @@ enum dm_i2c_msg_flags {
> > I2C_M_IGNORE_NAK = 0x1000, /* continue after NAK */
> > I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on
> reads */
> > I2C_M_RECV_LEN = 0x0400, /* length is first received
> byte */
> > + I2C_M_RD_NEED_STOP_BIT = 0x0002, /* need generate stop bit
> */
> > };
> >
> > /**
> > --
> > 2.17.1
> >
More information about the U-Boot
mailing list