mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] i2c: at91: fix coding style issue
@ 2014-09-24 12:57 Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Raphaël Poggi @ 2014-09-24 12:57 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 399f6a9..2ce3fa3 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -186,8 +186,8 @@ static int at91_twi_wait_completion(struct at91_twi_dev *dev)
 
 	dev->transfer_status |= status;
 
-	while(!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
-		if(is_timeout(start, AT91_I2C_TIMEOUT)) {
+	while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
+		if (is_timeout(start, AT91_I2C_TIMEOUT)) {
 			dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
 			return -ETIMEDOUT;
 		}
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] i2c: at91: add at91sam9x5 config
  2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
@ 2014-09-24 12:57 ` Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] i2c: at91: add support of device tree Raphaël Poggi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Raphaël Poggi @ 2014-09-24 12:57 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 2ce3fa3..9490822 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -346,23 +346,32 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.has_unre_flag = false,
 };
 
+static struct at91_twi_pdata at91sam9x5_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
 static struct platform_device_id at91_twi_devtypes[] = {
 	{
-		.name = "i2c-at91rm9200",
+		.name = "at91rm9200-i2c",
 		.driver_data = (unsigned long) &at91rm9200_config,
 	}, {
-		.name = "i2c-at91sam9261",
+		.name = "at91sam9261-i2c",
 		.driver_data = (unsigned long) &at91sam9261_config,
 	}, {
-		.name = "i2c-at91sam9260",
+		.name = "at91sam9260-i2c",
 		.driver_data = (unsigned long) &at91sam9260_config,
 	}, {
-		.name = "i2c-at91sam9g20",
+		.name = "at91sam9g20-i2c",
 		.driver_data = (unsigned long) &at91sam9g20_config,
 	}, {
-		.name = "i2c-at91sam9g10",
+		.name = "at91sam9g10-i2c",
 		.driver_data = (unsigned long) &at91sam9g10_config,
 	}, {
+		.name = "at91sam9x5-i2c",
+		.driver_data = (unsigned long) &at91sam9x5_config,
+	}, {
 		/* sentinel */
 	}
 };
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] i2c: at91: add support of device tree
  2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
@ 2014-09-24 12:57 ` Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] I2C: at91: fix the method for interrupt Raphaël Poggi
  2014-09-25  6:11 ` [PATCH] i2c: at91: fix coding style issue Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Raphaël Poggi @ 2014-09-24 12:57 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 9490822..a2236ed 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -376,18 +376,44 @@ static struct platform_device_id at91_twi_devtypes[] = {
 	}
 };
 
+static struct of_device_id at91_twi_dt_ids[] = {
+	{
+		.compatible = "atmel,at91rm9200-i2c",
+		.data = (unsigned long) &at91rm9200_config,
+	} , {
+		.compatible = "atmel,at91sam9260-i2c",
+		.data = (unsigned long) &at91sam9260_config,
+	} , {
+		.compatible = "atmel,at91sam9261-i2c",
+		.data = (unsigned long) &at91sam9261_config,
+	} , {
+		.compatible = "atmel,at91sam9g20-i2c",
+		.data = (unsigned long) &at91sam9g20_config,
+	} , {
+		.compatible = "atmel,at91sam9g10-i2c",
+		.data = (unsigned long) &at91sam9g10_config,
+	}, {
+		.compatible = "atmel,at91sam9x5-i2c",
+		.data = (unsigned long) &at91sam9x5_config,
+	}, {
+		/* sentinel */
+	}
+};
+
 static int at91_twi_probe(struct device_d *dev)
 {
 	struct at91_twi_dev *i2c_at91;
 	struct at91_twi_pdata *i2c_data;
-	int rc;
+	int rc = 0;
 	u32 bus_clk_rate;
 
 	i2c_at91 = xzalloc(sizeof(struct at91_twi_dev));
 
 	rc = dev_get_drvdata(dev, (unsigned long *)&i2c_data);
-	if (rc)
+	if (rc < 0) {
+		dev_err(dev, "failed to retrieve driver data\n");
 		goto out_free;
+	}
 
 	i2c_at91->pdata = i2c_data;
 
@@ -398,7 +424,7 @@ static int at91_twi_probe(struct device_d *dev)
 		goto out_free;
 	}
 
-	i2c_at91->clk = clk_get(dev, "twi_clk");
+	i2c_at91->clk = clk_get(dev, NULL);
 	if (IS_ERR(i2c_at91->clk)) {
 		dev_err(dev, "no clock defined\n");
 		rc = -ENODEV;
@@ -427,17 +453,18 @@ static int at91_twi_probe(struct device_d *dev)
 	return 0;
 
 out_adap_fail:
-    clk_disable(i2c_at91->clk);
-    clk_put(i2c_at91->clk);
+	clk_disable(i2c_at91->clk);
+	clk_put(i2c_at91->clk);
 out_free:
-    kfree(i2c_at91);
-    return rc;
+	kfree(i2c_at91);
+	return rc;
 }
 
 static struct driver_d at91_twi_driver = {
 	.name		= "at91-twi",
 	.probe		= at91_twi_probe,
 	.id_table	= at91_twi_devtypes,
+	.of_compatible	= DRV_OF_COMPAT(at91_twi_dt_ids),
 };
 device_platform_driver(at91_twi_driver);
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] I2C: at91: fix the method for interrupt
  2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
  2014-09-24 12:57 ` [PATCH] i2c: at91: add support of device tree Raphaël Poggi
@ 2014-09-24 12:57 ` Raphaël Poggi
  2014-09-25  6:11 ` [PATCH] i2c: at91: fix coding style issue Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Raphaël Poggi @ 2014-09-24 12:57 UTC (permalink / raw)
  To: barebox

From: Bo Shen <voice.shen@atmel.com>

As the i2c-at91 driver won't work in the interrupt mode,
so need to poll the interrupts.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 drivers/i2c/busses/i2c-at91.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index a2236ed..deb4ea4 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -174,24 +174,32 @@ static void at91_twi_read_next_byte(struct at91_twi_dev *dev)
 static int at91_twi_wait_completion(struct at91_twi_dev *dev)
 {
 	uint64_t start = get_time_ns();
-	unsigned int status = at91_twi_read(dev, AT91_TWI_SR);
-	unsigned int irqstatus = at91_twi_read(dev, AT91_TWI_IMR);
+	unsigned int status;
+	unsigned int irqstatus;
+
+	do {
+		status = at91_twi_read(dev, AT91_TWI_SR);
+		irqstatus = at91_twi_read(dev, AT91_TWI_IMR);
+
+		if (!(status & irqstatus)) {
+			if (is_timeout(start, AT91_I2C_TIMEOUT)) {
+				dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
+				return -ETIMEDOUT;
+			} else {
+				continue;
+			}
+		}
 
-	if (irqstatus & AT91_TWI_RXRDY)
-		at91_twi_read_next_byte(dev);
-	else if (irqstatus & AT91_TWI_TXRDY)
-		at91_twi_write_next_byte(dev);
-	else
-		dev_warn(&dev->adapter.dev, "neither rx and tx are ready\n");
+		if (irqstatus & AT91_TWI_RXRDY)
+			at91_twi_read_next_byte(dev);
+		else if (irqstatus & AT91_TWI_TXRDY)
+			at91_twi_write_next_byte(dev);
+		else
+			dev_warn(&dev->adapter.dev, "neither rx and tx are ready\n");
 
-	dev->transfer_status |= status;
+		dev->transfer_status |= status;
 
-	while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
-		if (is_timeout(start, AT91_I2C_TIMEOUT)) {
-			dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
-			return -ETIMEDOUT;
-		}
-	}
+	} while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP));
 
 	at91_disable_twi_interrupts(dev);
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] i2c: at91: fix coding style issue
  2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
                   ` (2 preceding siblings ...)
  2014-09-24 12:57 ` [PATCH] I2C: at91: fix the method for interrupt Raphaël Poggi
@ 2014-09-25  6:11 ` Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2014-09-25  6:11 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

Hi Raphaël,

On Wed, Sep 24, 2014 at 02:57:02PM +0200, Raphaël Poggi wrote:
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  drivers/i2c/busses/i2c-at91.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied all, thanks

Sascha

> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 399f6a9..2ce3fa3 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -186,8 +186,8 @@ static int at91_twi_wait_completion(struct at91_twi_dev *dev)
>  
>  	dev->transfer_status |= status;
>  
> -	while(!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
> -		if(is_timeout(start, AT91_I2C_TIMEOUT)) {
> +	while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
> +		if (is_timeout(start, AT91_I2C_TIMEOUT)) {
>  			dev_warn(&dev->adapter.dev, "timeout waiting for bus ready\n");
>  			return -ETIMEDOUT;
>  		}
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] i2c: at91: add at91sam9x5 config
  2014-08-04  7:34 ` Bo Shen
@ 2014-08-04  7:40   ` Bo Shen
  0 siblings, 0 replies; 8+ messages in thread
From: Bo Shen @ 2014-08-04  7:40 UTC (permalink / raw)
  To: Raphaël Poggi, barebox

Hi Raphaël Poggi,

On 08/04/2014 03:34 PM, Bo Shen wrote:
> Hi Raphaël Poggi,
>    Actually, this is a build fix.
>
> On 08/01/2014 09:26 PM, Raphaël Poggi wrote:
>> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
>
> Acked-by: Bo Shen <voice.shen@atmel.com>

Sorry, can you squash this patch into "[PATCH 1/2] i2c: at91: add 
support of device tree"

>> ---
>>   drivers/i2c/busses/i2c-at91.c |    6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-at91.c
>> b/drivers/i2c/busses/i2c-at91.c
>> index 399f6a9..4aa4e4e 100644
>> --- a/drivers/i2c/busses/i2c-at91.c
>> +++ b/drivers/i2c/busses/i2c-at91.c
>> @@ -346,6 +346,12 @@ static struct at91_twi_pdata at91sam9g10_config = {
>>       .has_unre_flag = false,
>>   };
>>
>> +static struct at91_twi_pdata at91sam9x5_config = {
>> +    .clk_max_div = 7,
>> +    .clk_offset = 4,
>> +    .has_unre_flag = false,
>> +};
>> +
>>   static struct platform_device_id at91_twi_devtypes[] = {
>>       {
>>           .name = "i2c-at91rm9200",
>>
>
> Best Regards,
> Bo Shen

Best Regards,
Bo Shen

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] i2c: at91: add at91sam9x5 config
  2014-08-01 13:26 [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
@ 2014-08-04  7:34 ` Bo Shen
  2014-08-04  7:40   ` Bo Shen
  0 siblings, 1 reply; 8+ messages in thread
From: Bo Shen @ 2014-08-04  7:34 UTC (permalink / raw)
  To: Raphaël Poggi, barebox

Hi Raphaël Poggi,
   Actually, this is a build fix.

On 08/01/2014 09:26 PM, Raphaël Poggi wrote:
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>

Acked-by: Bo Shen <voice.shen@atmel.com>

> ---
>   drivers/i2c/busses/i2c-at91.c |    6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 399f6a9..4aa4e4e 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -346,6 +346,12 @@ static struct at91_twi_pdata at91sam9g10_config = {
>   	.has_unre_flag = false,
>   };
>
> +static struct at91_twi_pdata at91sam9x5_config = {
> +	.clk_max_div = 7,
> +	.clk_offset = 4,
> +	.has_unre_flag = false,
> +};
> +
>   static struct platform_device_id at91_twi_devtypes[] = {
>   	{
>   		.name = "i2c-at91rm9200",
>

Best Regards,
Bo Shen

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] i2c: at91: add at91sam9x5 config
@ 2014-08-01 13:26 Raphaël Poggi
  2014-08-04  7:34 ` Bo Shen
  0 siblings, 1 reply; 8+ messages in thread
From: Raphaël Poggi @ 2014-08-01 13:26 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 399f6a9..4aa4e4e 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -346,6 +346,12 @@ static struct at91_twi_pdata at91sam9g10_config = {
 	.has_unre_flag = false,
 };
 
+static struct at91_twi_pdata at91sam9x5_config = {
+	.clk_max_div = 7,
+	.clk_offset = 4,
+	.has_unre_flag = false,
+};
+
 static struct platform_device_id at91_twi_devtypes[] = {
 	{
 		.name = "i2c-at91rm9200",
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-09-25  6:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
2014-09-24 12:57 ` [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
2014-09-24 12:57 ` [PATCH] i2c: at91: add support of device tree Raphaël Poggi
2014-09-24 12:57 ` [PATCH] I2C: at91: fix the method for interrupt Raphaël Poggi
2014-09-25  6:11 ` [PATCH] i2c: at91: fix coding style issue Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2014-08-01 13:26 [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
2014-08-04  7:34 ` Bo Shen
2014-08-04  7:40   ` Bo Shen

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