public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/8] ti: common: board_detect: Set alen to expected value before i2c read
Date: Fri, 28 Apr 2017 06:00:02 +0200	[thread overview]
Message-ID: <5902BE42.3020407@denx.de> (raw)
In-Reply-To: <20170420152549.28031-5-fcooper@ti.com>

Hello Franklin,

Am 20.04.2017 um 17:25 schrieb Franklin S Cooper Jr:
> In non DM I2C read operations the address length passed in during a read
> operation will be used automatically. However, in DM I2C the address length
> is set to a default value of one which causes problems when trying to
> perform a read with a differing alen. Therefore, before the first read in a
> series of read operations set the alen to the correct value.
>
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
>   board/ti/common/board_detect.c | 24 ++++++++++++++++++++++--
>   1 file changed, 22 insertions(+), 2 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot-i2c/next

bye,
Heiko
>
> diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
> index 1e695f4..6fdcb61 100644
> --- a/board/ti/common/board_detect.c
> +++ b/board/ti/common/board_detect.c
> @@ -83,7 +83,17 @@ static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
>   static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset,
>   					     uchar *ep, int epsize)
>   {
> -	return i2c_read(dev_addr, offset, 2, ep, epsize);
> +	int bus_num, rc, alen;
> +
> +	bus_num = i2c_get_bus_num();
> +
> +	alen = 2;
> +
> +	rc = ti_i2c_set_alen(bus_num, dev_addr, alen);
> +	if (rc)
> +		return rc;
> +
> +	return i2c_read(dev_addr, offset, alen, ep, epsize);
>   }
>
>   /**
> @@ -125,6 +135,11 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
>   	 * Read the header first then only read the other contents.
>   	 */
>   	byte = 2;
> +
> +	rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
> +	if (rc)
> +		return rc;
> +
>   	rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4);
>   	if (rc)
>   		return rc;
> @@ -137,9 +152,14 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
>   		 * 1 byte address (some legacy boards need this..)
>   		 */
>   		byte = 1;
> -		if (rc)
> +		if (rc) {
> +			rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
> +			if (rc)
> +				return rc;
> +
>   			rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read,
>   				      4);
> +		}
>   		if (rc)
>   			return rc;
>   	}
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2017-04-28  4:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 15:25 [U-Boot] [PATCH v2 0/8] drivers: i2c: davinci_i2c: Convert driver to DM Franklin S Cooper Jr
2017-04-20 15:25 ` [U-Boot] [PATCH v2 1/8] i2c: davinci: Split functions into two parts for future DM support Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  3:54   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 2/8] drivers: i2c: davinci_i2c: Update davinci i2c driver to driver model Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  3:55   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 3/8] ti: common: board_detect: Introduce function to set the address length Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  3:58   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 4/8] ti: common: board_detect: Set alen to expected value before i2c read Franklin S Cooper Jr
2017-04-28  4:00   ` Heiko Schocher [this message]
2017-04-20 15:25 ` [U-Boot] [PATCH v2 5/8] ARM: dts: k2g: Add I2C nodes to 66AK2Gx Franklin S Cooper Jr
2017-04-28  4:01   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 6/8] ARM: dts: keystone2: add I2C aliases for davinci I2C nodes Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  4:03   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 7/8] ARM: dts: keystone-k2g-evm: Enable I2C0 and I2C1 Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  4:05   ` Heiko Schocher
2017-04-20 15:25 ` [U-Boot] [PATCH v2 8/8] ARM: keystone: Enable DM_I2C by default Franklin S Cooper Jr
2017-04-26 19:16   ` Tom Rini
2017-04-28  4:07   ` Heiko Schocher
2017-04-21  4:08 ` [U-Boot] [PATCH v2 0/8] drivers: i2c: davinci_i2c: Convert driver to DM Vignesh R
2017-04-21  9:13   ` Vignesh R
2017-06-08  5:13 ` Lokesh Vutla

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=5902BE42.3020407@denx.de \
    --to=hs@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