public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] dm: i2c: Add a flag that need generate stop bit
Date: Tue, 18 Jun 2019 10:06:38 +0200	[thread overview]
Message-ID: <20190618100638.22003bec@jawa> (raw)
In-Reply-To: <20190617131241.47124-1-chuanhua.han@nxp.com>

On Mon, 17 Jun 2019 21:12:40 +0800
Chuanhua Han <chuanhua.han@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). However, in the current i2c general code, the dm_i2c_read
> api encapsulates two messages, the first time is to set the register
> address message, the second time is a message to read the register
> data, so that no stop signal is generated.
> 
> This patch uses the DM_I2C_CHIP_ADDR_STOP flag for specific
> i2c chips, so if the i2c slave requires a stop signal, chips driver
> can set this flag, then call the dm_i2c_write to set the register
> address (a stop signal is generated after this API call), then call
> dm_i2c_read to read the register data.
> 
> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
> Changes in v4:
> 	- Replace DM_I2C_CHIP_RD_NO_I2C_SETUP_OFFSET with
> DM_I2C_CHIP_ADDR_STOP.
> 
> Changes in v3:
> 	- Use the new flag DM_I2C_CHIP_RD_NO_I2C_SETUP_OFFSET	
> 
> Changes in v2: 
>         - Split the original patch into 3 patches
>         - Add detailed description information for each patch
> 
>  drivers/i2c/i2c-uclass.c | 6 ++++--
>  include/i2c.h            | 1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
> index e47abf1833..9804b5e8c7 100644
> --- a/drivers/i2c/i2c-uclass.c
> +++ b/drivers/i2c/i2c-uclass.c
> @@ -135,8 +135,10 @@ int dm_i2c_read(struct udevice *dev, uint
> offset, uint8_t *buffer, int len) if (chip->flags &
> DM_I2C_CHIP_RD_ADDRESS) return i2c_read_bytewise(dev, offset, buffer,
> len); ptr = msg;
> -	if (!i2c_setup_offset(chip, offset, offset_buf, ptr))
> -		ptr++;
> +	if (!(chip->flags & DM_I2C_CHIP_ADDR_STOP)) {
> +		if (!i2c_setup_offset(chip, offset, offset_buf, ptr))
> +			ptr++;
> +	}
>  
>  	if (len) {
>  		ptr->addr = chip->chip_addr;
> diff --git a/include/i2c.h b/include/i2c.h
> index a5c760c711..3123cbf280 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_ADDR_STOP  = 1 << 3, /* Need generate stop bit */
>  };
>  
>  struct udevice;




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190618/5b8b95c3/attachment.sig>

  parent reply	other threads:[~2019-06-18  8:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 13:12 [U-Boot] [PATCH 1/2] dm: i2c: Add a flag that need generate stop bit Chuanhua Han
2019-06-17 13:12 ` [U-Boot] [PATCH 2/2] rtc: pcf2127: Fixed bug with rtc settings and getting error time Chuanhua Han
2019-06-18  8:06   ` Lukasz Majewski
2019-06-18  8:18     ` Heiko Schocher
2019-06-24  4:48     ` [U-Boot] [EXT] " Chuanhua Han
2019-06-18  8:06 ` Lukasz Majewski [this message]
2019-06-24  4:48   ` [U-Boot] [EXT] Re: [PATCH 1/2] dm: i2c: Add a flag that need generate stop bit Chuanhua Han
2019-07-06 17:16     ` Simon Glass
2019-07-07 14:09       ` Chuanhua Han

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190618100638.22003bec@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox