Patchwork [U-Boot] imx: Use MXC_I2C_CLK in imx i2c driver

login
register
mail settings
Submitter Matthias Weisser
Date Sept. 24, 2012, 12:46 p.m.
Message ID <1348490813-21749-1-git-send-email-weisserm@arcor.de>
Download mbox | patch
Permalink /patch/186393/
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Comments

Matthias Weisser - Sept. 24, 2012, 12:46 p.m.
i2c didn't work on imx25 due to missing MXC_IPG_PERCLK. Now using
MXC_I2C_CLK on all imx systems using i2c.

Signed-off-by: Matthias Weisser <weisserm@arcor.de>
---
 arch/arm/cpu/arm1136/mx31/generic.c    |    1 +
 arch/arm/cpu/arm1136/mx35/generic.c    |    1 +
 arch/arm/cpu/armv7/mx5/clock.c         |    1 +
 arch/arm/cpu/armv7/mx6/clock.c         |    1 +
 arch/arm/include/asm/arch-mx31/clock.h |    1 +
 arch/arm/include/asm/arch-mx35/clock.h |    1 +
 arch/arm/include/asm/arch-mx5/clock.h  |    1 +
 arch/arm/include/asm/arch-mx6/clock.h  |    1 +
 drivers/i2c/mxc_i2c.c                  |    4 ++--
 9 files changed, 10 insertions(+), 2 deletions(-)
Stefano Babic - Sept. 24, 2012, 12:57 p.m.
On 24/09/2012 14:46, Matthias Weisser wrote:
> i2c didn't work on imx25 due to missing MXC_IPG_PERCLK. Now using
> MXC_I2C_CLK on all imx systems using i2c.
> 
> Signed-off-by: Matthias Weisser <weisserm@arcor.de>
> ---
>  arch/arm/cpu/arm1136/mx31/generic.c    |    1 +
>  arch/arm/cpu/arm1136/mx35/generic.c    |    1 +
>  arch/arm/cpu/armv7/mx5/clock.c         |    1 +
>  arch/arm/cpu/armv7/mx6/clock.c         |    1 +
>  arch/arm/include/asm/arch-mx31/clock.h |    1 +
>  arch/arm/include/asm/arch-mx35/clock.h |    1 +
>  arch/arm/include/asm/arch-mx5/clock.h  |    1 +
>  arch/arm/include/asm/arch-mx6/clock.h  |    1 +
>  drivers/i2c/mxc_i2c.c                  |    4 ++--
>  9 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
> index 93f429c..b9f9b43 100644
> --- a/arch/arm/cpu/arm1136/mx31/generic.c
> +++ b/arch/arm/cpu/arm1136/mx31/generic.c
> @@ -104,6 +104,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_CSPI_CLK:
>  	case MXC_UART_CLK:
>  	case MXC_ESDHC_CLK:
> +	case MXC_I2C_CLK:
>  		return mx31_get_ipg_clk();
>  	case MXC_IPU_CLK:
>  		return mx31_get_hsp_clk();
> diff --git a/arch/arm/cpu/arm1136/mx35/generic.c b/arch/arm/cpu/arm1136/mx35/generic.c
> index ef65176..7dc1a8e 100644
> --- a/arch/arm/cpu/arm1136/mx35/generic.c
> +++ b/arch/arm/cpu/arm1136/mx35/generic.c
> @@ -357,6 +357,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return imx_get_uartclk();
> diff --git a/arch/arm/cpu/armv7/mx5/clock.c b/arch/arm/cpu/armv7/mx5/clock.c
> index c67c3cf..8fa737a 100644
> --- a/arch/arm/cpu/armv7/mx5/clock.c
> +++ b/arch/arm/cpu/armv7/mx5/clock.c
> @@ -482,6 +482,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return get_uart_clk();
> diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
> index fddb373..44a81b2 100644
> --- a/arch/arm/cpu/armv7/mx6/clock.c
> +++ b/arch/arm/cpu/armv7/mx6/clock.c
> @@ -355,6 +355,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return get_uart_clk();
> diff --git a/arch/arm/include/asm/arch-mx31/clock.h b/arch/arm/include/asm/arch-mx31/clock.h
> index 9468b45..1dbb8da 100644
> --- a/arch/arm/include/asm/arch-mx31/clock.h
> +++ b/arch/arm/include/asm/arch-mx31/clock.h
> @@ -46,6 +46,7 @@ enum mxc_clock {
>  	MXC_UART_CLK,
>  	MXC_IPU_CLK,
>  	MXC_ESDHC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  unsigned int mxc_get_clock(enum mxc_clock clk);
> diff --git a/arch/arm/include/asm/arch-mx35/clock.h b/arch/arm/include/asm/arch-mx35/clock.h
> index eb7458a..2eff08d 100644
> --- a/arch/arm/include/asm/arch-mx35/clock.h
> +++ b/arch/arm/include/asm/arch-mx35/clock.h
> @@ -48,6 +48,7 @@ enum mxc_clock {
>  	MXC_USB_CLK,
>  	MXC_CSPI_CLK,
>  	MXC_FEC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  enum mxc_main_clock {
> diff --git a/arch/arm/include/asm/arch-mx5/clock.h b/arch/arm/include/asm/arch-mx5/clock.h
> index 8d8fa18..21febd8 100644
> --- a/arch/arm/include/asm/arch-mx5/clock.h
> +++ b/arch/arm/include/asm/arch-mx5/clock.h
> @@ -36,6 +36,7 @@ enum mxc_clock {
>  	MXC_DDR_CLK,
>  	MXC_NFC_CLK,
>  	MXC_PERIPH_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  u32 imx_get_uartclk(void);
> diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h
> index c55c18d..2af04f0 100644
> --- a/arch/arm/include/asm/arch-mx6/clock.h
> +++ b/arch/arm/include/asm/arch-mx6/clock.h
> @@ -41,6 +41,7 @@ enum mxc_clock {
>  	MXC_ESDHC4_CLK,
>  	MXC_SATA_CLK,
>  	MXC_NFC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  u32 imx_get_uartclk(void);
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 73d8958..18270b9 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -98,7 +98,7 @@ static uint8_t i2c_imx_get_clk(unsigned int rate)
>  #endif
>  
>  	/* Divider value calculation */
> -	i2c_clk_rate = mxc_get_clock(MXC_IPG_PERCLK);
> +	i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
>  	div = (i2c_clk_rate + rate - 1) / rate;
>  	if (div < i2c_clk_div[0][0])
>  		clk_div = 0;
> @@ -142,7 +142,7 @@ unsigned int bus_i2c_get_bus_speed(void *base)
>  	for (clk_div = 0; i2c_clk_div[clk_div][1] != clk_idx; clk_div++)
>  		;
>  
> -	return mxc_get_clock(MXC_IPG_PERCLK) / i2c_clk_div[clk_div][0];
> +	return mxc_get_clock(MXC_I2C_CLK) / i2c_clk_div[clk_div][0];
>  }
>  
>  #define ST_BUS_IDLE (0 | (I2SR_IBB << 8))
> 

This is exactly the changes I had in mind !

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Benoît Thébaudeau - Sept. 24, 2012, 1:08 p.m.
Hi Matthias,

On Monday, September 24, 2012 2:46:53 PM, Matthias Weisser wrote:
> i2c didn't work on imx25 due to missing MXC_IPG_PERCLK. Now using
> MXC_I2C_CLK on all imx systems using i2c.
> 
> Signed-off-by: Matthias Weisser <weisserm@arcor.de>
> ---
>  arch/arm/cpu/arm1136/mx31/generic.c    |    1 +
>  arch/arm/cpu/arm1136/mx35/generic.c    |    1 +
>  arch/arm/cpu/armv7/mx5/clock.c         |    1 +
>  arch/arm/cpu/armv7/mx6/clock.c         |    1 +
>  arch/arm/include/asm/arch-mx31/clock.h |    1 +
>  arch/arm/include/asm/arch-mx35/clock.h |    1 +
>  arch/arm/include/asm/arch-mx5/clock.h  |    1 +
>  arch/arm/include/asm/arch-mx6/clock.h  |    1 +
>  drivers/i2c/mxc_i2c.c                  |    4 ++--
>  9 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/cpu/arm1136/mx31/generic.c
> b/arch/arm/cpu/arm1136/mx31/generic.c
> index 93f429c..b9f9b43 100644
> --- a/arch/arm/cpu/arm1136/mx31/generic.c
> +++ b/arch/arm/cpu/arm1136/mx31/generic.c
> @@ -104,6 +104,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_CSPI_CLK:
>  	case MXC_UART_CLK:
>  	case MXC_ESDHC_CLK:
> +	case MXC_I2C_CLK:
>  		return mx31_get_ipg_clk();
>  	case MXC_IPU_CLK:
>  		return mx31_get_hsp_clk();
> diff --git a/arch/arm/cpu/arm1136/mx35/generic.c
> b/arch/arm/cpu/arm1136/mx35/generic.c
> index ef65176..7dc1a8e 100644
> --- a/arch/arm/cpu/arm1136/mx35/generic.c
> +++ b/arch/arm/cpu/arm1136/mx35/generic.c
> @@ -357,6 +357,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return imx_get_uartclk();
> diff --git a/arch/arm/cpu/armv7/mx5/clock.c
> b/arch/arm/cpu/armv7/mx5/clock.c
> index c67c3cf..8fa737a 100644
> --- a/arch/arm/cpu/armv7/mx5/clock.c
> +++ b/arch/arm/cpu/armv7/mx5/clock.c
> @@ -482,6 +482,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return get_uart_clk();
> diff --git a/arch/arm/cpu/armv7/mx6/clock.c
> b/arch/arm/cpu/armv7/mx6/clock.c
> index fddb373..44a81b2 100644
> --- a/arch/arm/cpu/armv7/mx6/clock.c
> +++ b/arch/arm/cpu/armv7/mx6/clock.c
> @@ -355,6 +355,7 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
>  	case MXC_IPG_CLK:
>  		return get_ipg_clk();
>  	case MXC_IPG_PERCLK:
> +	case MXC_I2C_CLK:
>  		return get_ipg_per_clk();
>  	case MXC_UART_CLK:
>  		return get_uart_clk();
> diff --git a/arch/arm/include/asm/arch-mx31/clock.h
> b/arch/arm/include/asm/arch-mx31/clock.h
> index 9468b45..1dbb8da 100644
> --- a/arch/arm/include/asm/arch-mx31/clock.h
> +++ b/arch/arm/include/asm/arch-mx31/clock.h
> @@ -46,6 +46,7 @@ enum mxc_clock {
>  	MXC_UART_CLK,
>  	MXC_IPU_CLK,
>  	MXC_ESDHC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  unsigned int mxc_get_clock(enum mxc_clock clk);
> diff --git a/arch/arm/include/asm/arch-mx35/clock.h
> b/arch/arm/include/asm/arch-mx35/clock.h
> index eb7458a..2eff08d 100644
> --- a/arch/arm/include/asm/arch-mx35/clock.h
> +++ b/arch/arm/include/asm/arch-mx35/clock.h
> @@ -48,6 +48,7 @@ enum mxc_clock {
>  	MXC_USB_CLK,
>  	MXC_CSPI_CLK,
>  	MXC_FEC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  enum mxc_main_clock {
> diff --git a/arch/arm/include/asm/arch-mx5/clock.h
> b/arch/arm/include/asm/arch-mx5/clock.h
> index 8d8fa18..21febd8 100644
> --- a/arch/arm/include/asm/arch-mx5/clock.h
> +++ b/arch/arm/include/asm/arch-mx5/clock.h
> @@ -36,6 +36,7 @@ enum mxc_clock {
>  	MXC_DDR_CLK,
>  	MXC_NFC_CLK,
>  	MXC_PERIPH_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  u32 imx_get_uartclk(void);
> diff --git a/arch/arm/include/asm/arch-mx6/clock.h
> b/arch/arm/include/asm/arch-mx6/clock.h
> index c55c18d..2af04f0 100644
> --- a/arch/arm/include/asm/arch-mx6/clock.h
> +++ b/arch/arm/include/asm/arch-mx6/clock.h
> @@ -41,6 +41,7 @@ enum mxc_clock {
>  	MXC_ESDHC4_CLK,
>  	MXC_SATA_CLK,
>  	MXC_NFC_CLK,
> +	MXC_I2C_CLK,
>  };
>  
>  u32 imx_get_uartclk(void);
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 73d8958..18270b9 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -98,7 +98,7 @@ static uint8_t i2c_imx_get_clk(unsigned int rate)
>  #endif
>  
>  	/* Divider value calculation */
> -	i2c_clk_rate = mxc_get_clock(MXC_IPG_PERCLK);
> +	i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
>  	div = (i2c_clk_rate + rate - 1) / rate;
>  	if (div < i2c_clk_div[0][0])
>  		clk_div = 0;
> @@ -142,7 +142,7 @@ unsigned int bus_i2c_get_bus_speed(void *base)
>  	for (clk_div = 0; i2c_clk_div[clk_div][1] != clk_idx; clk_div++)
>  		;
>  
> -	return mxc_get_clock(MXC_IPG_PERCLK) / i2c_clk_div[clk_div][0];
> +	return mxc_get_clock(MXC_I2C_CLK) / i2c_clk_div[clk_div][0];
>  }
>  
>  #define ST_BUS_IDLE (0 | (I2SR_IBB << 8))

I've reviewed your patch. It's perfect.

Best regards,
Benoît
Stefano Babic - Sept. 25, 2012, 1:04 p.m.
On 24/09/2012 14:46, Matthias Weisser wrote:
> i2c didn't work on imx25 due to missing MXC_IPG_PERCLK. Now using
> MXC_I2C_CLK on all imx systems using i2c.
> 
> Signed-off-by: Matthias Weisser <weisserm@arcor.de>
> ---

Applied to u-boot-imx, next branch, thanks.

Best regards,
Stefano Babic

Patch

diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
index 93f429c..b9f9b43 100644
--- a/arch/arm/cpu/arm1136/mx31/generic.c
+++ b/arch/arm/cpu/arm1136/mx31/generic.c
@@ -104,6 +104,7 @@  unsigned int mxc_get_clock(enum mxc_clock clk)
 	case MXC_CSPI_CLK:
 	case MXC_UART_CLK:
 	case MXC_ESDHC_CLK:
+	case MXC_I2C_CLK:
 		return mx31_get_ipg_clk();
 	case MXC_IPU_CLK:
 		return mx31_get_hsp_clk();
diff --git a/arch/arm/cpu/arm1136/mx35/generic.c b/arch/arm/cpu/arm1136/mx35/generic.c
index ef65176..7dc1a8e 100644
--- a/arch/arm/cpu/arm1136/mx35/generic.c
+++ b/arch/arm/cpu/arm1136/mx35/generic.c
@@ -357,6 +357,7 @@  unsigned int mxc_get_clock(enum mxc_clock clk)
 	case MXC_IPG_CLK:
 		return get_ipg_clk();
 	case MXC_IPG_PERCLK:
+	case MXC_I2C_CLK:
 		return get_ipg_per_clk();
 	case MXC_UART_CLK:
 		return imx_get_uartclk();
diff --git a/arch/arm/cpu/armv7/mx5/clock.c b/arch/arm/cpu/armv7/mx5/clock.c
index c67c3cf..8fa737a 100644
--- a/arch/arm/cpu/armv7/mx5/clock.c
+++ b/arch/arm/cpu/armv7/mx5/clock.c
@@ -482,6 +482,7 @@  unsigned int mxc_get_clock(enum mxc_clock clk)
 	case MXC_IPG_CLK:
 		return get_ipg_clk();
 	case MXC_IPG_PERCLK:
+	case MXC_I2C_CLK:
 		return get_ipg_per_clk();
 	case MXC_UART_CLK:
 		return get_uart_clk();
diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index fddb373..44a81b2 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -355,6 +355,7 @@  unsigned int mxc_get_clock(enum mxc_clock clk)
 	case MXC_IPG_CLK:
 		return get_ipg_clk();
 	case MXC_IPG_PERCLK:
+	case MXC_I2C_CLK:
 		return get_ipg_per_clk();
 	case MXC_UART_CLK:
 		return get_uart_clk();
diff --git a/arch/arm/include/asm/arch-mx31/clock.h b/arch/arm/include/asm/arch-mx31/clock.h
index 9468b45..1dbb8da 100644
--- a/arch/arm/include/asm/arch-mx31/clock.h
+++ b/arch/arm/include/asm/arch-mx31/clock.h
@@ -46,6 +46,7 @@  enum mxc_clock {
 	MXC_UART_CLK,
 	MXC_IPU_CLK,
 	MXC_ESDHC_CLK,
+	MXC_I2C_CLK,
 };
 
 unsigned int mxc_get_clock(enum mxc_clock clk);
diff --git a/arch/arm/include/asm/arch-mx35/clock.h b/arch/arm/include/asm/arch-mx35/clock.h
index eb7458a..2eff08d 100644
--- a/arch/arm/include/asm/arch-mx35/clock.h
+++ b/arch/arm/include/asm/arch-mx35/clock.h
@@ -48,6 +48,7 @@  enum mxc_clock {
 	MXC_USB_CLK,
 	MXC_CSPI_CLK,
 	MXC_FEC_CLK,
+	MXC_I2C_CLK,
 };
 
 enum mxc_main_clock {
diff --git a/arch/arm/include/asm/arch-mx5/clock.h b/arch/arm/include/asm/arch-mx5/clock.h
index 8d8fa18..21febd8 100644
--- a/arch/arm/include/asm/arch-mx5/clock.h
+++ b/arch/arm/include/asm/arch-mx5/clock.h
@@ -36,6 +36,7 @@  enum mxc_clock {
 	MXC_DDR_CLK,
 	MXC_NFC_CLK,
 	MXC_PERIPH_CLK,
+	MXC_I2C_CLK,
 };
 
 u32 imx_get_uartclk(void);
diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h
index c55c18d..2af04f0 100644
--- a/arch/arm/include/asm/arch-mx6/clock.h
+++ b/arch/arm/include/asm/arch-mx6/clock.h
@@ -41,6 +41,7 @@  enum mxc_clock {
 	MXC_ESDHC4_CLK,
 	MXC_SATA_CLK,
 	MXC_NFC_CLK,
+	MXC_I2C_CLK,
 };
 
 u32 imx_get_uartclk(void);
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 73d8958..18270b9 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -98,7 +98,7 @@  static uint8_t i2c_imx_get_clk(unsigned int rate)
 #endif
 
 	/* Divider value calculation */
-	i2c_clk_rate = mxc_get_clock(MXC_IPG_PERCLK);
+	i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
 	div = (i2c_clk_rate + rate - 1) / rate;
 	if (div < i2c_clk_div[0][0])
 		clk_div = 0;
@@ -142,7 +142,7 @@  unsigned int bus_i2c_get_bus_speed(void *base)
 	for (clk_div = 0; i2c_clk_div[clk_div][1] != clk_idx; clk_div++)
 		;
 
-	return mxc_get_clock(MXC_IPG_PERCLK) / i2c_clk_div[clk_div][0];
+	return mxc_get_clock(MXC_I2C_CLK) / i2c_clk_div[clk_div][0];
 }
 
 #define ST_BUS_IDLE (0 | (I2SR_IBB << 8))