Patchwork Oneiric SRU: UBUNTU: SAUCE: OMAP3 and 4 hwmod I2C units only allow 16 bit access

login
register
mail settings
Submitter Tim Gardner
Date Sept. 19, 2011, 1:53 p.m.
Message ID <20110919135342.18D37F9189@sepang.rtg.net>
Download mbox | patch
Permalink /patch/115345/
State New
Headers show

Comments

Tim Gardner - Sept. 19, 2011, 1:53 p.m.
From f8f23179a8c9d046d30f2cfec094e879bd8543b3 Mon Sep 17 00:00:00 2001
From: Andy Green <andy.green@linaro.org>
Date: Mon, 19 Sep 2011 07:49:10 -0600
Subject: [PATCH] UBUNTU: SAUCE: OMAP3 and 4 hwmod I2C units only allow 16 bit access

BugLink: http://bugs.launchpad.net/bugs/852225

Peter Maydell noticed when running under QEMU he was getting
errors reporting 32-bit access to I2C peripheral unit registers
that are documented to be 8 or 16-bit only[1][2]

The I2C driver is blameless as it wraps its accesses in a
function using __raw_writew and __raw_readw, it turned out it
is the hwmod stuff.

However the hwmod code already has a flag to force a
perhipheral unit to only be accessed using 16-bit operations.

This patch applies the 16-bit only flag to the OMAP3xxx and
OMAP44xx hwmod structs.

[1] OMAP4430 Technical reference manual section 23.1.6.2
[2] OMAP3530 Techincal reference manual section 18.6

Cc: patches@linaro.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andy Green <andy.green@linaro.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    3 +++
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
Tim Gardner - Sept. 19, 2011, 2:15 p.m.
As a follow-up note, this patch has already been merged upstream, but in 
a sufficiently different form that a cherry-pick is not feasible.

rtg
Seth Forshee - Sept. 19, 2011, 2:28 p.m.
On Mon, Sep 19, 2011 at 07:53:42AM -0600, Tim Gardner wrote:
> From f8f23179a8c9d046d30f2cfec094e879bd8543b3 Mon Sep 17 00:00:00 2001
> From: Andy Green <andy.green@linaro.org>
> Date: Mon, 19 Sep 2011 07:49:10 -0600
> Subject: [PATCH] UBUNTU: SAUCE: OMAP3 and 4 hwmod I2C units only allow 16 bit access
> 
> BugLink: http://bugs.launchpad.net/bugs/852225
> 
> Peter Maydell noticed when running under QEMU he was getting
> errors reporting 32-bit access to I2C peripheral unit registers
> that are documented to be 8 or 16-bit only[1][2]
> 
> The I2C driver is blameless as it wraps its accesses in a
> function using __raw_writew and __raw_readw, it turned out it
> is the hwmod stuff.
> 
> However the hwmod code already has a flag to force a
> perhipheral unit to only be accessed using 16-bit operations.
> 
> This patch applies the 16-bit only flag to the OMAP3xxx and
> OMAP44xx hwmod structs.
> 
> [1] OMAP4430 Technical reference manual section 23.1.6.2
> [2] OMAP3530 Techincal reference manual section 18.6
> 
> Cc: patches@linaro.org
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andy Green <andy.green@linaro.org>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Looks reasonable, and seems to be true to the upstream patch.

Acked-by: Seth Forshee <seth.forshee@canonical.com>
Stefan Bader - Sept. 19, 2011, 2:30 p.m.
On 19.09.2011 15:53, Tim Gardner wrote:
> From f8f23179a8c9d046d30f2cfec094e879bd8543b3 Mon Sep 17 00:00:00 2001
> From: Andy Green <andy.green@linaro.org>
> Date: Mon, 19 Sep 2011 07:49:10 -0600
> Subject: [PATCH] UBUNTU: SAUCE: OMAP3 and 4 hwmod I2C units only allow 16 bit access
> 
> BugLink: http://bugs.launchpad.net/bugs/852225
> 
> Peter Maydell noticed when running under QEMU he was getting
> errors reporting 32-bit access to I2C peripheral unit registers
> that are documented to be 8 or 16-bit only[1][2]
> 
> The I2C driver is blameless as it wraps its accesses in a
> function using __raw_writew and __raw_readw, it turned out it
> is the hwmod stuff.
> 
> However the hwmod code already has a flag to force a
> perhipheral unit to only be accessed using 16-bit operations.
> 
> This patch applies the 16-bit only flag to the OMAP3xxx and
> OMAP44xx hwmod structs.
> 
> [1] OMAP4430 Technical reference manual section 23.1.6.2
> [2] OMAP3530 Techincal reference manual section 18.6
> 
> Cc: patches@linaro.org
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andy Green <andy.green@linaro.org>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    3 +++
>  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    8 ++++----
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> index 909a84d..78efb59 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> @@ -1891,6 +1891,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c1_slaves[] = {
>  
>  static struct omap_hwmod omap3xxx_i2c1_hwmod = {
>  	.name		= "i2c1",
> +	.flags		= HWMOD_16BIT_REG,
>  	.mpu_irqs	= i2c1_mpu_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(i2c1_mpu_irqs),
>  	.sdma_reqs	= i2c1_sdma_reqs,
> @@ -1933,6 +1934,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c2_slaves[] = {
>  
>  static struct omap_hwmod omap3xxx_i2c2_hwmod = {
>  	.name		= "i2c2",
> +	.flags		= HWMOD_16BIT_REG,
>  	.mpu_irqs	= i2c2_mpu_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(i2c2_mpu_irqs),
>  	.sdma_reqs	= i2c2_sdma_reqs,
> @@ -1975,6 +1977,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c3_slaves[] = {
>  
>  static struct omap_hwmod omap3xxx_i2c3_hwmod = {
>  	.name		= "i2c3",
> +	.flags		= HWMOD_16BIT_REG,
>  	.mpu_irqs	= i2c3_mpu_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(i2c3_mpu_irqs),
>  	.sdma_reqs	= i2c3_sdma_reqs,
> diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> index e1c69ff..67d2f9b 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> @@ -2164,7 +2164,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c1_slaves[] = {
>  static struct omap_hwmod omap44xx_i2c1_hwmod = {
>  	.name		= "i2c1",
>  	.class		= &omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>  	.mpu_irqs	= omap44xx_i2c1_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c1_irqs),
>  	.sdma_reqs	= omap44xx_i2c1_sdma_reqs,
> @@ -2217,7 +2217,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c2_slaves[] = {
>  static struct omap_hwmod omap44xx_i2c2_hwmod = {
>  	.name		= "i2c2",
>  	.class		= &omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>  	.mpu_irqs	= omap44xx_i2c2_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c2_irqs),
>  	.sdma_reqs	= omap44xx_i2c2_sdma_reqs,
> @@ -2270,7 +2270,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c3_slaves[] = {
>  static struct omap_hwmod omap44xx_i2c3_hwmod = {
>  	.name		= "i2c3",
>  	.class		= &omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>  	.mpu_irqs	= omap44xx_i2c3_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c3_irqs),
>  	.sdma_reqs	= omap44xx_i2c3_sdma_reqs,
> @@ -2323,7 +2323,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c4_slaves[] = {
>  static struct omap_hwmod omap44xx_i2c4_hwmod = {
>  	.name		= "i2c4",
>  	.class		= &omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>  	.mpu_irqs	= omap44xx_i2c4_irqs,
>  	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c4_irqs),
>  	.sdma_reqs	= omap44xx_i2c4_sdma_reqs,

Seems to be doing what it claims and is limited to the arm regions. Cannot make
much comments on completeness.

Acked-by: Stefan Bader <smb@canonical.com>
Tim Gardner - Sept. 19, 2011, 3:06 p.m.
On 09/19/2011 07:53 AM, Tim Gardner wrote:
>  From f8f23179a8c9d046d30f2cfec094e879bd8543b3 Mon Sep 17 00:00:00 2001
> From: Andy Green<andy.green@linaro.org>
> Date: Mon, 19 Sep 2011 07:49:10 -0600
> Subject: [PATCH] UBUNTU: SAUCE: OMAP3 and 4 hwmod I2C units only allow 16 bit access
>
> BugLink: http://bugs.launchpad.net/bugs/852225
>
> Peter Maydell noticed when running under QEMU he was getting
> errors reporting 32-bit access to I2C peripheral unit registers
> that are documented to be 8 or 16-bit only[1][2]
>
> The I2C driver is blameless as it wraps its accesses in a
> function using __raw_writew and __raw_readw, it turned out it
> is the hwmod stuff.
>
> However the hwmod code already has a flag to force a
> perhipheral unit to only be accessed using 16-bit operations.
>
> This patch applies the 16-bit only flag to the OMAP3xxx and
> OMAP44xx hwmod structs.
>
> [1] OMAP4430 Technical reference manual section 23.1.6.2
> [2] OMAP3530 Techincal reference manual section 18.6
>
> Cc: patches@linaro.org
> Reported-by: Peter Maydell<peter.maydell@linaro.org>
> Signed-off-by: Andy Green<andy.green@linaro.org>
> Signed-off-by: Tim Gardner<tim.gardner@canonical.com>
> ---
>   arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    3 +++
>   arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    8 ++++----
>   2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> index 909a84d..78efb59 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
> @@ -1891,6 +1891,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c1_slaves[] = {
>
>   static struct omap_hwmod omap3xxx_i2c1_hwmod = {
>   	.name		= "i2c1",
> +	.flags		= HWMOD_16BIT_REG,
>   	.mpu_irqs	= i2c1_mpu_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(i2c1_mpu_irqs),
>   	.sdma_reqs	= i2c1_sdma_reqs,
> @@ -1933,6 +1934,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c2_slaves[] = {
>
>   static struct omap_hwmod omap3xxx_i2c2_hwmod = {
>   	.name		= "i2c2",
> +	.flags		= HWMOD_16BIT_REG,
>   	.mpu_irqs	= i2c2_mpu_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(i2c2_mpu_irqs),
>   	.sdma_reqs	= i2c2_sdma_reqs,
> @@ -1975,6 +1977,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_i2c3_slaves[] = {
>
>   static struct omap_hwmod omap3xxx_i2c3_hwmod = {
>   	.name		= "i2c3",
> +	.flags		= HWMOD_16BIT_REG,
>   	.mpu_irqs	= i2c3_mpu_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(i2c3_mpu_irqs),
>   	.sdma_reqs	= i2c3_sdma_reqs,
> diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> index e1c69ff..67d2f9b 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
> @@ -2164,7 +2164,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c1_slaves[] = {
>   static struct omap_hwmod omap44xx_i2c1_hwmod = {
>   	.name		= "i2c1",
>   	.class		=&omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>   	.mpu_irqs	= omap44xx_i2c1_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c1_irqs),
>   	.sdma_reqs	= omap44xx_i2c1_sdma_reqs,
> @@ -2217,7 +2217,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c2_slaves[] = {
>   static struct omap_hwmod omap44xx_i2c2_hwmod = {
>   	.name		= "i2c2",
>   	.class		=&omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>   	.mpu_irqs	= omap44xx_i2c2_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c2_irqs),
>   	.sdma_reqs	= omap44xx_i2c2_sdma_reqs,
> @@ -2270,7 +2270,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c3_slaves[] = {
>   static struct omap_hwmod omap44xx_i2c3_hwmod = {
>   	.name		= "i2c3",
>   	.class		=&omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>   	.mpu_irqs	= omap44xx_i2c3_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c3_irqs),
>   	.sdma_reqs	= omap44xx_i2c3_sdma_reqs,
> @@ -2323,7 +2323,7 @@ static struct omap_hwmod_ocp_if *omap44xx_i2c4_slaves[] = {
>   static struct omap_hwmod omap44xx_i2c4_hwmod = {
>   	.name		= "i2c4",
>   	.class		=&omap44xx_i2c_hwmod_class,
> -	.flags		= HWMOD_INIT_NO_RESET,
> +	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
>   	.mpu_irqs	= omap44xx_i2c4_irqs,
>   	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c4_irqs),
>   	.sdma_reqs	= omap44xx_i2c4_sdma_reqs,

Patch

diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 909a84d..78efb59 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1891,6 +1891,7 @@  static struct omap_hwmod_ocp_if *omap3xxx_i2c1_slaves[] = {
 
 static struct omap_hwmod omap3xxx_i2c1_hwmod = {
 	.name		= "i2c1",
+	.flags		= HWMOD_16BIT_REG,
 	.mpu_irqs	= i2c1_mpu_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(i2c1_mpu_irqs),
 	.sdma_reqs	= i2c1_sdma_reqs,
@@ -1933,6 +1934,7 @@  static struct omap_hwmod_ocp_if *omap3xxx_i2c2_slaves[] = {
 
 static struct omap_hwmod omap3xxx_i2c2_hwmod = {
 	.name		= "i2c2",
+	.flags		= HWMOD_16BIT_REG,
 	.mpu_irqs	= i2c2_mpu_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(i2c2_mpu_irqs),
 	.sdma_reqs	= i2c2_sdma_reqs,
@@ -1975,6 +1977,7 @@  static struct omap_hwmod_ocp_if *omap3xxx_i2c3_slaves[] = {
 
 static struct omap_hwmod omap3xxx_i2c3_hwmod = {
 	.name		= "i2c3",
+	.flags		= HWMOD_16BIT_REG,
 	.mpu_irqs	= i2c3_mpu_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(i2c3_mpu_irqs),
 	.sdma_reqs	= i2c3_sdma_reqs,
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index e1c69ff..67d2f9b 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2164,7 +2164,7 @@  static struct omap_hwmod_ocp_if *omap44xx_i2c1_slaves[] = {
 static struct omap_hwmod omap44xx_i2c1_hwmod = {
 	.name		= "i2c1",
 	.class		= &omap44xx_i2c_hwmod_class,
-	.flags		= HWMOD_INIT_NO_RESET,
+	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
 	.mpu_irqs	= omap44xx_i2c1_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c1_irqs),
 	.sdma_reqs	= omap44xx_i2c1_sdma_reqs,
@@ -2217,7 +2217,7 @@  static struct omap_hwmod_ocp_if *omap44xx_i2c2_slaves[] = {
 static struct omap_hwmod omap44xx_i2c2_hwmod = {
 	.name		= "i2c2",
 	.class		= &omap44xx_i2c_hwmod_class,
-	.flags		= HWMOD_INIT_NO_RESET,
+	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
 	.mpu_irqs	= omap44xx_i2c2_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c2_irqs),
 	.sdma_reqs	= omap44xx_i2c2_sdma_reqs,
@@ -2270,7 +2270,7 @@  static struct omap_hwmod_ocp_if *omap44xx_i2c3_slaves[] = {
 static struct omap_hwmod omap44xx_i2c3_hwmod = {
 	.name		= "i2c3",
 	.class		= &omap44xx_i2c_hwmod_class,
-	.flags		= HWMOD_INIT_NO_RESET,
+	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
 	.mpu_irqs	= omap44xx_i2c3_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c3_irqs),
 	.sdma_reqs	= omap44xx_i2c3_sdma_reqs,
@@ -2323,7 +2323,7 @@  static struct omap_hwmod_ocp_if *omap44xx_i2c4_slaves[] = {
 static struct omap_hwmod omap44xx_i2c4_hwmod = {
 	.name		= "i2c4",
 	.class		= &omap44xx_i2c_hwmod_class,
-	.flags		= HWMOD_INIT_NO_RESET,
+	.flags		= HWMOD_INIT_NO_RESET | HWMOD_16BIT_REG,
 	.mpu_irqs	= omap44xx_i2c4_irqs,
 	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_i2c4_irqs),
 	.sdma_reqs	= omap44xx_i2c4_sdma_reqs,