public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support
@ 2014-01-15 15:45 Chin Liang See
  2014-01-15 15:51 ` Alexey Brodkin
  0 siblings, 1 reply; 5+ messages in thread
From: Chin Liang See @ 2014-01-15 15:45 UTC (permalink / raw)
  To: u-boot

Enhance the DesignWare I2C driver to support address length more
than 1 byte. This enhancement is required as some I2C slave
device such as EEPROM chip might have 16 bit address byte.

Signed-off-by: Chin Liang See <clsee@altera.com>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: Tom Rini <trini@ti.com>
cc: Armando Visconti <armando.visconti@st.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Heiko Schocher <hs@denx.de>
Cc: Vipin KUMAR <vipin.kumar@st.com>
Cc: Mischa Jonker <mjonker@synopsys.com>
---
Changes for v2
- Removed the function check_params()
---
 drivers/i2c/designware_i2c.c |   41 +++++++++--------------------------------
 1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index cb2ac04..5b8482a 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -197,35 +197,18 @@ static int i2c_wait_for_bb(void)
 	return 0;
 }
 
-/* check parameters for i2c_read and i2c_write */
-static int check_params(uint addr, int alen, uchar *buffer, int len)
-{
-	if (buffer == NULL) {
-		printf("Buffer is invalid\n");
-		return 1;
-	}
-
-	if (alen > 1) {
-		printf("addr len %d not supported\n", alen);
-		return 1;
-	}
-
-	if (addr + len > 256) {
-		printf("address out of range\n");
-		return 1;
-	}
-
-	return 0;
-}
-
-static int i2c_xfer_init(uchar chip, uint addr)
+static int i2c_xfer_init(uchar chip, uint addr, int alen)
 {
 	if (i2c_wait_for_bb())
 		return 1;
 
 	i2c_setaddress(chip);
-	writel(addr, &i2c_regs_p->ic_cmd_data);
-
+	while (alen) {
+		alen--;
+		/* high byte address going out first */
+		writel((addr >> (alen * 8)) & 0xff,
+			&i2c_regs_p->ic_cmd_data);
+	}
 	return 0;
 }
 
@@ -266,10 +249,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
 	unsigned long start_time_rx;
 
-	if (check_params(addr, alen, buffer, len))
-		return 1;
-
-	if (i2c_xfer_init(chip, addr))
+	if (i2c_xfer_init(chip, addr, alen))
 		return 1;
 
 	start_time_rx = get_timer(0);
@@ -307,10 +287,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 	int nb = len;
 	unsigned long start_time_tx;
 
-	if (check_params(addr, alen, buffer, len))
-		return 1;
-
-	if (i2c_xfer_init(chip, addr))
+	if (i2c_xfer_init(chip, addr, alen))
 		return 1;
 
 	start_time_tx = get_timer(0);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support
  2014-01-15 15:45 [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support Chin Liang See
@ 2014-01-15 15:51 ` Alexey Brodkin
  2014-01-22 15:37   ` Chin Liang See
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Brodkin @ 2014-01-15 15:51 UTC (permalink / raw)
  To: u-boot

On Wed, 2014-01-15 at 09:45 -0600, Chin Liang See wrote:
> Changes for v2
> - Removed the function check_params()

Ok, so you decided to not add "assert" check instead.
I think it's ok - it's not a requirement. Others don't do it as well so
let's leave it as it is.

Acked-by: Alexey Brodkin <abrodkin@synopsys.com>

Regards,
Alexey

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support
  2014-01-15 15:51 ` Alexey Brodkin
@ 2014-01-22 15:37   ` Chin Liang See
  2014-01-30  5:20     ` Heiko Schocher
  0 siblings, 1 reply; 5+ messages in thread
From: Chin Liang See @ 2014-01-22 15:37 UTC (permalink / raw)
  To: u-boot

Thanks Alexey.

Hi Heiko,

I believe this patch should be good for apply. Would need your help
then. :) Thanks

Chin Liang


On Wed, 2014-01-15 at 15:51 +0000, Alexey Brodkin wrote:
> On Wed, 2014-01-15 at 09:45 -0600, Chin Liang See wrote:
> > Changes for v2
> > - Removed the function check_params()
> 
> Ok, so you decided to not add "assert" check instead.
> I think it's ok - it's not a requirement. Others don't do it as well so
> let's leave it as it is.
> 
> Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
> 
> Regards,
> Alexey
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support
  2014-01-22 15:37   ` Chin Liang See
@ 2014-01-30  5:20     ` Heiko Schocher
  2014-02-04 17:51       ` Chin Liang See
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2014-01-30  5:20 UTC (permalink / raw)
  To: u-boot

Hello Chin,

Am 22.01.2014 16:37, schrieb Chin Liang See:
> Thanks Alexey.
>
> Hi Heiko,
>
> I believe this patch should be good for apply. Would need your help
> then. :) Thanks
>
> Chin Liang
>
>
> On Wed, 2014-01-15 at 15:51 +0000, Alexey Brodkin wrote:
>> On Wed, 2014-01-15 at 09:45 -0600, Chin Liang See wrote:
>>> Changes for v2
>>> - Removed the function check_params()
>>
>> Ok, so you decided to not add "assert" check instead.
>> I think it's ok - it's not a requirement. Others don't do it as well so
>> let's leave it as it is.
>>
>> Acked-by: Alexey Brodkin<abrodkin@synopsys.com>
>>
>> Regards,
>> Alexey

Your patch apply not clean to current head f889cc81c1572f4af0be950fd49bb6b67bc580fb
also checkpatch drops one warning:

CHECK: Alignment should match open parenthesis
#82: FILE: drivers/i2c/designware_i2c.c:210:
+               writel((addr >> (alen * 8)) & 0xff,
+                       &i2c_regs_p->ic_cmd_data);

total: 0 errors, 0 warnings, 1 checks, 64 lines checked

Could you please fix this, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support
  2014-01-30  5:20     ` Heiko Schocher
@ 2014-02-04 17:51       ` Chin Liang See
  0 siblings, 0 replies; 5+ messages in thread
From: Chin Liang See @ 2014-02-04 17:51 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Thu, 2014-01-30 at 06:20 +0100, Heiko Schocher wrote:
> Hello Chin,
> 
> Am 22.01.2014 16:37, schrieb Chin Liang See:
> > Thanks Alexey.
> >
> > Hi Heiko,
> >
> > I believe this patch should be good for apply. Would need your help
> > then. :) Thanks
> >
> > Chin Liang
> >
> >
> > On Wed, 2014-01-15 at 15:51 +0000, Alexey Brodkin wrote:
> >> On Wed, 2014-01-15 at 09:45 -0600, Chin Liang See wrote:
> >>> Changes for v2
> >>> - Removed the function check_params()
> >>
> >> Ok, so you decided to not add "assert" check instead.
> >> I think it's ok - it's not a requirement. Others don't do it as well so
> >> let's leave it as it is.
> >>
> >> Acked-by: Alexey Brodkin<abrodkin@synopsys.com>
> >>
> >> Regards,
> >> Alexey
> 
> Your patch apply not clean to current head f889cc81c1572f4af0be950fd49bb6b67bc580fb
> also checkpatch drops one warning:
> 

Yup, it caused by a later patch. Let me re-base my patch.

> CHECK: Alignment should match open parenthesis
> #82: FILE: drivers/i2c/designware_i2c.c:210:
> +               writel((addr >> (alen * 8)) & 0xff,
> +                       &i2c_regs_p->ic_cmd_data);
> 
> total: 0 errors, 0 warnings, 1 checks, 64 lines checked

I overlooked this as I saw no errors. Let me fix that too.
Thanks again for your helps.

Chin Liang

> 
> Could you please fix this, thanks!
> 
> bye,
> Heiko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-04 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15 15:45 [U-Boot] [PATCH v2] designware_i2c: Enhance DesignWare I2C driver address support Chin Liang See
2014-01-15 15:51 ` Alexey Brodkin
2014-01-22 15:37   ` Chin Liang See
2014-01-30  5:20     ` Heiko Schocher
2014-02-04 17:51       ` Chin Liang See

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox