All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock
@ 2015-06-25  1:33 Peng Fan
  2015-06-25  1:33 ` [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX Peng Fan
  2015-06-28  8:53 ` [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Stefano Babic
  0 siblings, 2 replies; 9+ messages in thread
From: Peng Fan @ 2015-06-25  1:33 UTC (permalink / raw)
  To: u-boot

enable_spi_clock does the same thing with enable_cspi_clock, so
remove enable_cspi_clock.
Remove enable_cspi_clock prototype in header file
convert cm_fx6/spl.c to use enable_spi_clk

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
---
 arch/arm/cpu/armv7/mx6/clock.c        | 19 -------------------
 arch/arm/include/asm/arch-mx6/clock.h |  1 -
 board/compulab/cm_fx6/spl.c           |  2 +-
 3 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index ae99945..1134770 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -102,25 +102,6 @@ void enable_uart_clk(unsigned char enable)
 }
 #endif
 
-#ifdef CONFIG_SPI
-/* spi_num can be from 0 - 4 */
-int enable_cspi_clock(unsigned char enable, unsigned spi_num)
-{
-	u32 mask;
-
-	if (spi_num > 4)
-		return -EINVAL;
-
-	mask = MXC_CCM_CCGR_CG_MASK << (spi_num * 2);
-	if (enable)
-		setbits_le32(&imx_ccm->CCGR1, mask);
-	else
-		clrbits_le32(&imx_ccm->CCGR1, mask);
-
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_MMC
 int enable_usdhc_clk(unsigned char enable, unsigned bus_num)
 {
diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h
index a6de5ee..7b3bbb8 100644
--- a/arch/arm/include/asm/arch-mx6/clock.h
+++ b/arch/arm/include/asm/arch-mx6/clock.h
@@ -57,7 +57,6 @@ void hab_caam_clock_enable(unsigned char enable);
 void enable_ocotp_clk(unsigned char enable);
 void enable_usboh3_clk(unsigned char enable);
 void enable_uart_clk(unsigned char enable);
-int enable_cspi_clock(unsigned char enable, unsigned spi_num);
 int enable_usdhc_clk(unsigned char enable, unsigned bus_num);
 int enable_sata_clock(void);
 void disable_sata_clock(void);
diff --git a/board/compulab/cm_fx6/spl.c b/board/compulab/cm_fx6/spl.c
index 5b4b76f..d94ced9 100644
--- a/board/compulab/cm_fx6/spl.c
+++ b/board/compulab/cm_fx6/spl.c
@@ -303,7 +303,7 @@ static void cm_fx6_setup_uart(void)
 static void cm_fx6_setup_ecspi(void)
 {
 	cm_fx6_set_ecspi_iomux();
-	enable_cspi_clock(1, 0);
+	enable_spi_clk(1, 0);
 }
 #else
 static void cm_fx6_setup_ecspi(void) { }
-- 
1.8.4

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

* [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX
  2015-06-25  1:33 [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Peng Fan
@ 2015-06-25  1:33 ` Peng Fan
  2015-06-28  8:52   ` Stefano Babic
  2015-06-28  8:53 ` [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Stefano Babic
  1 sibling, 1 reply; 9+ messages in thread
From: Peng Fan @ 2015-06-25  1:33 UTC (permalink / raw)
  To: u-boot

Add I2C4 clock support for i.MX6SX. Since we use runtime check,
but not macro, we need to remove `#ifdef ..` in crm_regs.h, or
we will get compliation failure for other platforms.

Making the macros only for i.MX6SX open to other i.MX6x maybe not
a good choice, but we have runtime check.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
---
 arch/arm/cpu/armv7/mx6/clock.c           | 14 ++++++++++----
 arch/arm/include/asm/arch-mx6/crm_regs.h |  9 ++++-----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 1134770..b461898 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -126,6 +126,7 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
 {
 	u32 reg;
 	u32 mask;
+	u32 *addr;
 
 	if (i2c_num > 3)
 		return -EINVAL;
@@ -140,14 +141,19 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
 			reg &= ~mask;
 		__raw_writel(reg, &imx_ccm->CCGR2);
 	} else {
-		mask = MXC_CCM_CCGR_CG_MASK
-			<< (MXC_CCM_CCGR1_I2C4_SERIAL_OFFSET);
-		reg = __raw_readl(&imx_ccm->CCGR1);
+		if (is_cpu_type(MXC_CPU_MX6SX)) {
+			mask = MXC_CCM_CCGR6_I2C4_MASK;
+			addr = &imx_ccm->CCGR6;
+		} else {
+			mask = MXC_CCM_CCGR1_I2C4_SERIAL_MASK;
+			addr = &imx_ccm->CCGR1;
+		}
+		reg = __raw_readl(addr);
 		if (enable)
 			reg |= mask;
 		else
 			reg &= ~mask;
-		__raw_writel(reg, &imx_ccm->CCGR1);
+		__raw_writel(reg, addr);
 	}
 	return 0;
 }
diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h b/arch/arm/include/asm/arch-mx6/crm_regs.h
index 887d048..4c743b6 100644
--- a/arch/arm/include/asm/arch-mx6/crm_regs.h
+++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
@@ -740,7 +740,10 @@ struct mxc_ccm_reg {
 #define MXC_CCM_CCGR6_USDHC4_MASK		(3 << MXC_CCM_CCGR6_USDHC4_OFFSET)
 #define MXC_CCM_CCGR6_EMI_SLOW_OFFSET		10
 #define MXC_CCM_CCGR6_EMI_SLOW_MASK		(3 << MXC_CCM_CCGR6_EMI_SLOW_OFFSET)
-#ifdef CONFIG_MX6SX
+/* The two does not exist on i.MX6SX */
+#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
+#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
+/* The following *CCGR6* exist only i.MX6SX */
 #define MXC_CCM_CCGR6_PWM8_OFFSET		16
 #define MXC_CCM_CCGR6_PWM8_MASK			(3 << MXC_CCM_CCGR6_PWM8_OFFSET)
 #define MXC_CCM_CCGR6_VADC_OFFSET		20
@@ -755,10 +758,6 @@ struct mxc_ccm_reg {
 #define MXC_CCM_CCGR6_PWM6_MASK			(3 << MXC_CCM_CCGR6_PWM6_OFFSET)
 #define MXC_CCM_CCGR6_PWM7_OFFSET		30
 #define MXC_CCM_CCGR6_PWM7_MASK			(3 << MXC_CCM_CCGR6_PWM7_OFFSET)
-#else
-#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
-#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
-#endif
 
 #define BM_ANADIG_PLL_SYS_LOCK 0x80000000
 #define BP_ANADIG_PLL_SYS_RSVD0      20
-- 
1.8.4

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

* [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX
  2015-06-25  1:33 ` [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX Peng Fan
@ 2015-06-28  8:52   ` Stefano Babic
  2015-06-29  1:33     ` Peng Fan
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano Babic @ 2015-06-28  8:52 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On 25/06/2015 03:33, Peng Fan wrote:
> Add I2C4 clock support for i.MX6SX. Since we use runtime check,
> but not macro, we need to remove `#ifdef ..` in crm_regs.h, or
> we will get compliation failure for other platforms.

               ^----- compliation ?

> 
> Making the macros only for i.MX6SX open to other i.MX6x maybe not
> a good choice, but we have runtime check.
> 
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> ---
>  arch/arm/cpu/armv7/mx6/clock.c           | 14 ++++++++++----
>  arch/arm/include/asm/arch-mx6/crm_regs.h |  9 ++++-----
>  2 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
> index 1134770..b461898 100644
> --- a/arch/arm/cpu/armv7/mx6/clock.c
> +++ b/arch/arm/cpu/armv7/mx6/clock.c
> @@ -126,6 +126,7 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
>  {
>  	u32 reg;
>  	u32 mask;
> +	u32 *addr;
>  
>  	if (i2c_num > 3)
>  		return -EINVAL;
> @@ -140,14 +141,19 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
>  			reg &= ~mask;
>  		__raw_writel(reg, &imx_ccm->CCGR2);
>  	} else {
> -		mask = MXC_CCM_CCGR_CG_MASK
> -			<< (MXC_CCM_CCGR1_I2C4_SERIAL_OFFSET);
> -		reg = __raw_readl(&imx_ccm->CCGR1);
> +		if (is_cpu_type(MXC_CPU_MX6SX)) {
> +			mask = MXC_CCM_CCGR6_I2C4_MASK;
> +			addr = &imx_ccm->CCGR6;
> +		} else {
> +			mask = MXC_CCM_CCGR1_I2C4_SERIAL_MASK;
> +			addr = &imx_ccm->CCGR1;
> +		}
> +		reg = __raw_readl(addr);
>  		if (enable)
>  			reg |= mask;
>  		else
>  			reg &= ~mask;
> -		__raw_writel(reg, &imx_ccm->CCGR1);
> +		__raw_writel(reg, addr);
>  	}
>  	return 0;
>  }
> diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h b/arch/arm/include/asm/arch-mx6/crm_regs.h
> index 887d048..4c743b6 100644
> --- a/arch/arm/include/asm/arch-mx6/crm_regs.h
> +++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
> @@ -740,7 +740,10 @@ struct mxc_ccm_reg {
>  #define MXC_CCM_CCGR6_USDHC4_MASK		(3 << MXC_CCM_CCGR6_USDHC4_OFFSET)
>  #define MXC_CCM_CCGR6_EMI_SLOW_OFFSET		10
>  #define MXC_CCM_CCGR6_EMI_SLOW_MASK		(3 << MXC_CCM_CCGR6_EMI_SLOW_OFFSET)
> -#ifdef CONFIG_MX6SX
> +/* The two does not exist on i.MX6SX */
> +#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
> +#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
> +/* The following *CCGR6* exist only i.MX6SX */

Agree to group together macros that belong only to a SOC variant, else
it is difficult to find them. But what has
MXC_CCM_CCGR6_VDOAXICLK_OFFSET to do with addings I2C4 clock to i.MX6SX
? It should be posted in a separate patch.

>  #define MXC_CCM_CCGR6_PWM8_OFFSET		16
>  #define MXC_CCM_CCGR6_PWM8_MASK			(3 << MXC_CCM_CCGR6_PWM8_OFFSET)
>  #define MXC_CCM_CCGR6_VADC_OFFSET		20
> @@ -755,10 +758,6 @@ struct mxc_ccm_reg {
>  #define MXC_CCM_CCGR6_PWM6_MASK			(3 << MXC_CCM_CCGR6_PWM6_OFFSET)
>  #define MXC_CCM_CCGR6_PWM7_OFFSET		30
>  #define MXC_CCM_CCGR6_PWM7_MASK			(3 << MXC_CCM_CCGR6_PWM7_OFFSET)
> -#else
> -#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
> -#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
> -#endif
>  
>  #define BM_ANADIG_PLL_SYS_LOCK 0x80000000
>  #define BP_ANADIG_PLL_SYS_RSVD0      20
> 

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock
  2015-06-25  1:33 [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Peng Fan
  2015-06-25  1:33 ` [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX Peng Fan
@ 2015-06-28  8:53 ` Stefano Babic
  1 sibling, 0 replies; 9+ messages in thread
From: Stefano Babic @ 2015-06-28  8:53 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On 25/06/2015 03:33, Peng Fan wrote:
> enable_spi_clock does the same thing with enable_cspi_clock, so
> remove enable_cspi_clock.
> Remove enable_cspi_clock prototype in header file
> convert cm_fx6/spl.c to use enable_spi_clk
> 
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> ---
>  arch/arm/cpu/armv7/mx6/clock.c        | 19 -------------------
>  arch/arm/include/asm/arch-mx6/clock.h |  1 -
>  board/compulab/cm_fx6/spl.c           |  2 +-
>  3 files changed, 1 insertion(+), 21 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
> index ae99945..1134770 100644
> --- a/arch/arm/cpu/armv7/mx6/clock.c
> +++ b/arch/arm/cpu/armv7/mx6/clock.c
> @@ -102,25 +102,6 @@ void enable_uart_clk(unsigned char enable)
>  }
>  #endif
>  
> -#ifdef CONFIG_SPI
> -/* spi_num can be from 0 - 4 */
> -int enable_cspi_clock(unsigned char enable, unsigned spi_num)
> -{
> -	u32 mask;
> -
> -	if (spi_num > 4)
> -		return -EINVAL;
> -
> -	mask = MXC_CCM_CCGR_CG_MASK << (spi_num * 2);
> -	if (enable)
> -		setbits_le32(&imx_ccm->CCGR1, mask);
> -	else
> -		clrbits_le32(&imx_ccm->CCGR1, mask);
> -
> -	return 0;
> -}
> -#endif
> -
>  #ifdef CONFIG_MMC
>  int enable_usdhc_clk(unsigned char enable, unsigned bus_num)
>  {
> diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h
> index a6de5ee..7b3bbb8 100644
> --- a/arch/arm/include/asm/arch-mx6/clock.h
> +++ b/arch/arm/include/asm/arch-mx6/clock.h
> @@ -57,7 +57,6 @@ void hab_caam_clock_enable(unsigned char enable);
>  void enable_ocotp_clk(unsigned char enable);
>  void enable_usboh3_clk(unsigned char enable);
>  void enable_uart_clk(unsigned char enable);
> -int enable_cspi_clock(unsigned char enable, unsigned spi_num);
>  int enable_usdhc_clk(unsigned char enable, unsigned bus_num);
>  int enable_sata_clock(void);
>  void disable_sata_clock(void);
> diff --git a/board/compulab/cm_fx6/spl.c b/board/compulab/cm_fx6/spl.c
> index 5b4b76f..d94ced9 100644
> --- a/board/compulab/cm_fx6/spl.c
> +++ b/board/compulab/cm_fx6/spl.c
> @@ -303,7 +303,7 @@ static void cm_fx6_setup_uart(void)
>  static void cm_fx6_setup_ecspi(void)
>  {
>  	cm_fx6_set_ecspi_iomux();
> -	enable_cspi_clock(1, 0);
> +	enable_spi_clk(1, 0);
>  }
>  #else
>  static void cm_fx6_setup_ecspi(void) { }
> 

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

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX
  2015-06-28  8:52   ` Stefano Babic
@ 2015-06-29  1:33     ` Peng Fan
  2015-06-29  7:13       ` Stefano Babic
  0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2015-06-29  1:33 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On Sun, Jun 28, 2015 at 10:52:50AM +0200, Stefano Babic wrote:
>Hi Peng,
>
>On 25/06/2015 03:33, Peng Fan wrote:
>> Add I2C4 clock support for i.MX6SX. Since we use runtime check,
>> but not macro, we need to remove `#ifdef ..` in crm_regs.h, or
>> we will get compliation failure for other platforms.
>
>               ^----- compliation ?
I mean gcc will complains about failing to compile the code.
>
>> 
>> Making the macros only for i.MX6SX open to other i.MX6x maybe not
>> a good choice, but we have runtime check.
>> 
>> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
>> ---
>>  arch/arm/cpu/armv7/mx6/clock.c           | 14 ++++++++++----
>>  arch/arm/include/asm/arch-mx6/crm_regs.h |  9 ++++-----
>>  2 files changed, 14 insertions(+), 9 deletions(-)
>> 
>> diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
>> index 1134770..b461898 100644
>> --- a/arch/arm/cpu/armv7/mx6/clock.c
>> +++ b/arch/arm/cpu/armv7/mx6/clock.c
>> @@ -126,6 +126,7 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
>>  {
>>  	u32 reg;
>>  	u32 mask;
>> +	u32 *addr;
>>  
>>  	if (i2c_num > 3)
>>  		return -EINVAL;
>> @@ -140,14 +141,19 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
>>  			reg &= ~mask;
>>  		__raw_writel(reg, &imx_ccm->CCGR2);
>>  	} else {
>> -		mask = MXC_CCM_CCGR_CG_MASK
>> -			<< (MXC_CCM_CCGR1_I2C4_SERIAL_OFFSET);
>> -		reg = __raw_readl(&imx_ccm->CCGR1);
>> +		if (is_cpu_type(MXC_CPU_MX6SX)) {
>> +			mask = MXC_CCM_CCGR6_I2C4_MASK;
>> +			addr = &imx_ccm->CCGR6;
>> +		} else {
>> +			mask = MXC_CCM_CCGR1_I2C4_SERIAL_MASK;
>> +			addr = &imx_ccm->CCGR1;
>> +		}
>> +		reg = __raw_readl(addr);
>>  		if (enable)
>>  			reg |= mask;
>>  		else
>>  			reg &= ~mask;
>> -		__raw_writel(reg, &imx_ccm->CCGR1);
>> +		__raw_writel(reg, addr);
>>  	}
>>  	return 0;
>>  }
>> diff --git a/arch/arm/include/asm/arch-mx6/crm_regs.h b/arch/arm/include/asm/arch-mx6/crm_regs.h
>> index 887d048..4c743b6 100644
>> --- a/arch/arm/include/asm/arch-mx6/crm_regs.h
>> +++ b/arch/arm/include/asm/arch-mx6/crm_regs.h
>> @@ -740,7 +740,10 @@ struct mxc_ccm_reg {
>>  #define MXC_CCM_CCGR6_USDHC4_MASK		(3 << MXC_CCM_CCGR6_USDHC4_OFFSET)
>>  #define MXC_CCM_CCGR6_EMI_SLOW_OFFSET		10
>>  #define MXC_CCM_CCGR6_EMI_SLOW_MASK		(3 << MXC_CCM_CCGR6_EMI_SLOW_OFFSET)
>> -#ifdef CONFIG_MX6SX
>> +/* The two does not exist on i.MX6SX */
>> +#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
>> +#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
>> +/* The following *CCGR6* exist only i.MX6SX */
>
>Agree to group together macros that belong only to a SOC variant, else
>it is difficult to find them. But what has
>MXC_CCM_CCGR6_VDOAXICLK_OFFSET to do with addings I2C4 clock to i.MX6SX
>? It should be posted in a separate patch.

I just move this piece of code from the back to the front, see the end
of the patch.
I removed the #ifdef in header file, because it is really not a good idea
to see so many #ifdefs in header file. The bad point here is some CCM macros
are exposed to other platforms, so we should take care to use the CCM macros.

Take the following as example:
In crm_regs.h
#ifdef CONFIG_MX6SX
#define MXC_CCM_CCGR6_PWM7_MASK 	(3 << 30)
#else
#define MXC_CCM_CCGR6_VDOAXICLK_MASK	(3 << 12)
#endif

u32 test()
{
	if (is_cpu_type(MXC_CPU_MX6SX))
		return MXC_CCM_CCGR6_PWM7_MASK;		
	else
		return MXC_CCM_CCGR6_VDOAXICLK_OFFSET;
}

Here gcc can not successfully compile the code if we want to build for i.mx6sx,
becuase MXC_CCM_CCGR6_VDOAXICLK_OFFSET is not defined for i.mx6sx.

So:
#define MXC_CCM_CCGR6_PWM7_MASK     (3 << 30)
/* This CCM Definition does not exist on i.MX6SX */
#define MXC_CCM_CCGR6_VDOAXICLK_MASK    (3 << 12)

>
>>  #define MXC_CCM_CCGR6_PWM8_OFFSET		16
>>  #define MXC_CCM_CCGR6_PWM8_MASK			(3 << MXC_CCM_CCGR6_PWM8_OFFSET)
>>  #define MXC_CCM_CCGR6_VADC_OFFSET		20
>> @@ -755,10 +758,6 @@ struct mxc_ccm_reg {
>>  #define MXC_CCM_CCGR6_PWM6_MASK			(3 << MXC_CCM_CCGR6_PWM6_OFFSET)
>>  #define MXC_CCM_CCGR6_PWM7_OFFSET		30
>>  #define MXC_CCM_CCGR6_PWM7_MASK			(3 << MXC_CCM_CCGR6_PWM7_OFFSET)
>> -#else
>> -#define MXC_CCM_CCGR6_VDOAXICLK_OFFSET		12
>> -#define MXC_CCM_CCGR6_VDOAXICLK_MASK		(3 << MXC_CCM_CCGR6_VDOAXICLK_OFFSET)
>> -#endif
>>  
>>  #define BM_ANADIG_PLL_SYS_LOCK 0x80000000
>>  #define BP_ANADIG_PLL_SYS_RSVD0      20
>> 
>
>Best regards,
>Stefano Babic
>
>-- 
>=====================================================================
>DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
>=====================================================================

Regards,
Peng.
-- 

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

* [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX
  2015-06-29  1:33     ` Peng Fan
@ 2015-06-29  7:13       ` Stefano Babic
  2015-06-29  7:29         ` Peng Fan
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano Babic @ 2015-06-29  7:13 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On 29/06/2015 03:33, Peng Fan wrote:
> Hi Stefano,
> 
> On Sun, Jun 28, 2015 at 10:52:50AM +0200, Stefano Babic wrote:
>> Hi Peng,
>>
>> On 25/06/2015 03:33, Peng Fan wrote:
>>> Add I2C4 clock support for i.MX6SX. Since we use runtime check,
>>> but not macro, we need to remove `#ifdef ..` in crm_regs.h, or
>>> we will get compliation failure for other platforms.
>>
>>               ^----- compliation ?
> I mean gcc will complains about failing to compile the code.

Right. Fix the commit message.


>> Agree to group together macros that belong only to a SOC variant, else
>> it is difficult to find them. But what has
>> MXC_CCM_CCGR6_VDOAXICLK_OFFSET to do with addings I2C4 clock to i.MX6SX
>> ? It should be posted in a separate patch.
> 
> I just move this piece of code from the back to the front, see the end
> of the patch.
> I removed the #ifdef in header file, because it is really not a good idea
> to see so many #ifdefs in header file. The bad point here is some CCM macros
> are exposed to other platforms, so we should take care to use the CCM macros.

That is correct. We have a lot of macro across all i.MXes, not only
i.MX6es. This allow to have consistent code, and we must take care of
not breaking other SOCs.

> 
> Take the following as example:
> In crm_regs.h
> #ifdef CONFIG_MX6SX
> #define MXC_CCM_CCGR6_PWM7_MASK 	(3 << 30)
> #else
> #define MXC_CCM_CCGR6_VDOAXICLK_MASK	(3 << 12)
> #endif
> 
> u32 test()
> {
> 	if (is_cpu_type(MXC_CPU_MX6SX))
> 		return MXC_CCM_CCGR6_PWM7_MASK;		
> 	else
> 		return MXC_CCM_CCGR6_VDOAXICLK_OFFSET;
> }

Here there is a bad use of these kind of macro. To use a define, we
should have the same name and not different names as in this case.

> 
> Here gcc can not successfully compile the code if we want to build for i.mx6sx,
> becuase MXC_CCM_CCGR6_VDOAXICLK_OFFSET is not defined for i.mx6sx.

Right,  but this is bad code and must be fixed.

> 
> So:
> #define MXC_CCM_CCGR6_PWM7_MASK     (3 << 30)
> /* This CCM Definition does not exist on i.MX6SX */
> #define MXC_CCM_CCGR6_VDOAXICLK_MASK    (3 << 12)

Better should be to add also a common name for both, that is then used
in the function.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

* [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX
  2015-06-29  7:13       ` Stefano Babic
@ 2015-06-29  7:29         ` Peng Fan
  0 siblings, 0 replies; 9+ messages in thread
From: Peng Fan @ 2015-06-29  7:29 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On Mon, Jun 29, 2015 at 09:13:01AM +0200, Stefano Babic wrote:
>Hi Peng,
>
>On 29/06/2015 03:33, Peng Fan wrote:
>> Hi Stefano,
>> 
>> On Sun, Jun 28, 2015 at 10:52:50AM +0200, Stefano Babic wrote:
>>> Hi Peng,
>>>
>>> On 25/06/2015 03:33, Peng Fan wrote:
>>>> Add I2C4 clock support for i.MX6SX. Since we use runtime check,
>>>> but not macro, we need to remove `#ifdef ..` in crm_regs.h, or
>>>> we will get compliation failure for other platforms.
>>>
>>>               ^----- compliation ?
>> I mean gcc will complains about failing to compile the code.
>
>Right. Fix the commit message.
>
>
>>> Agree to group together macros that belong only to a SOC variant, else
>>> it is difficult to find them. But what has
>>> MXC_CCM_CCGR6_VDOAXICLK_OFFSET to do with addings I2C4 clock to i.MX6SX
>>> ? It should be posted in a separate patch.
>> 
>> I just move this piece of code from the back to the front, see the end
>> of the patch.
>> I removed the #ifdef in header file, because it is really not a good idea
>> to see so many #ifdefs in header file. The bad point here is some CCM macros
>> are exposed to other platforms, so we should take care to use the CCM macros.
>
>That is correct. We have a lot of macro across all i.MXes, not only
>i.MX6es. This allow to have consistent code, and we must take care of
>not breaking other SOCs.
>
>> 
>> Take the following as example:
>> In crm_regs.h
>> #ifdef CONFIG_MX6SX
>> #define MXC_CCM_CCGR6_PWM7_MASK 	(3 << 30)
>> #else
>> #define MXC_CCM_CCGR6_VDOAXICLK_MASK	(3 << 12)
>> #endif
>> 
>> u32 test()
>> {
>> 	if (is_cpu_type(MXC_CPU_MX6SX))
>> 		return MXC_CCM_CCGR6_PWM7_MASK;		
>> 	else
>> 		return MXC_CCM_CCGR6_VDOAXICLK_OFFSET;
>> }
>
>Here there is a bad use of these kind of macro. To use a define, we
>should have the same name and not different names as in this case.
>
>> 
>> Here gcc can not successfully compile the code if we want to build for i.mx6sx,
>> becuase MXC_CCM_CCGR6_VDOAXICLK_OFFSET is not defined for i.mx6sx.
>
>Right,  but this is bad code and must be fixed.
>
>> 
>> So:
>> #define MXC_CCM_CCGR6_PWM7_MASK     (3 << 30)
>> /* This CCM Definition does not exist on i.MX6SX */
>> #define MXC_CCM_CCGR6_VDOAXICLK_MASK    (3 << 12)
>
>Better should be to add also a common name for both, that is then used
>in the function.

To those which have same offset and same bit width, we can have a common
name to cover for different SOCs. To those same offset, but different bit
width, we need the ifdefs.  Also some CCM definitions are not used by
U-Boot, maybe we can removed them, such as GPU and etc. Anyway, better not
to do big change to avoid breaking something, so when adding new definitions,
avoid adding ifdefs and doing small code refactor.

>
>Best regards,
>Stefano Babic
>
>-- 
>=====================================================================
>DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
>=====================================================================

Regards,
Peng
-- 

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

* [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock
  2015-07-01  9:01 Peng Fan
@ 2015-07-10  7:37 ` Stefano Babic
  0 siblings, 0 replies; 9+ messages in thread
From: Stefano Babic @ 2015-07-10  7:37 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On 01/07/2015 11:01, Peng Fan wrote:
> enable_spi_clock does the same thing with enable_cspi_clock, so
> remove enable_cspi_clock.
> Remove enable_cspi_clock prototype in header file
> convert cm_fx6/spl.c to use enable_spi_clk
> 
> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
> Acked-by: Stefano Babic <sbabic@denx.de>
> ---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock
@ 2015-07-01  9:01 Peng Fan
  2015-07-10  7:37 ` Stefano Babic
  0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2015-07-01  9:01 UTC (permalink / raw)
  To: u-boot

enable_spi_clock does the same thing with enable_cspi_clock, so
remove enable_cspi_clock.
Remove enable_cspi_clock prototype in header file
convert cm_fx6/spl.c to use enable_spi_clk

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Acked-by: Stefano Babic <sbabic@denx.de>
---

Changes v2:
 Add Stefano's Acked-by

 arch/arm/cpu/armv7/mx6/clock.c        | 19 -------------------
 arch/arm/include/asm/arch-mx6/clock.h |  1 -
 board/compulab/cm_fx6/spl.c           |  2 +-
 3 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index b7e714c..7bd78d7 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -102,25 +102,6 @@ void enable_uart_clk(unsigned char enable)
 }
 #endif
 
-#ifdef CONFIG_SPI
-/* spi_num can be from 0 - 4 */
-int enable_cspi_clock(unsigned char enable, unsigned spi_num)
-{
-	u32 mask;
-
-	if (spi_num > 4)
-		return -EINVAL;
-
-	mask = MXC_CCM_CCGR_CG_MASK << (spi_num * 2);
-	if (enable)
-		setbits_le32(&imx_ccm->CCGR1, mask);
-	else
-		clrbits_le32(&imx_ccm->CCGR1, mask);
-
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_MMC
 int enable_usdhc_clk(unsigned char enable, unsigned bus_num)
 {
diff --git a/arch/arm/include/asm/arch-mx6/clock.h b/arch/arm/include/asm/arch-mx6/clock.h
index a6de5ee..7b3bbb8 100644
--- a/arch/arm/include/asm/arch-mx6/clock.h
+++ b/arch/arm/include/asm/arch-mx6/clock.h
@@ -57,7 +57,6 @@ void hab_caam_clock_enable(unsigned char enable);
 void enable_ocotp_clk(unsigned char enable);
 void enable_usboh3_clk(unsigned char enable);
 void enable_uart_clk(unsigned char enable);
-int enable_cspi_clock(unsigned char enable, unsigned spi_num);
 int enable_usdhc_clk(unsigned char enable, unsigned bus_num);
 int enable_sata_clock(void);
 void disable_sata_clock(void);
diff --git a/board/compulab/cm_fx6/spl.c b/board/compulab/cm_fx6/spl.c
index 5b4b76f..d94ced9 100644
--- a/board/compulab/cm_fx6/spl.c
+++ b/board/compulab/cm_fx6/spl.c
@@ -303,7 +303,7 @@ static void cm_fx6_setup_uart(void)
 static void cm_fx6_setup_ecspi(void)
 {
 	cm_fx6_set_ecspi_iomux();
-	enable_cspi_clock(1, 0);
+	enable_spi_clk(1, 0);
 }
 #else
 static void cm_fx6_setup_ecspi(void) { }
-- 
1.8.4

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

end of thread, other threads:[~2015-07-10  7:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25  1:33 [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Peng Fan
2015-06-25  1:33 ` [U-Boot] [PATCH V2 2/2] imx: mx6 add i2c4 clock support for i.MX6SX Peng Fan
2015-06-28  8:52   ` Stefano Babic
2015-06-29  1:33     ` Peng Fan
2015-06-29  7:13       ` Stefano Babic
2015-06-29  7:29         ` Peng Fan
2015-06-28  8:53 ` [U-Boot] [PATCH V2 1/2] imx: mx6 remove duplicated enable_cspi_clock Stefano Babic
2015-07-01  9:01 Peng Fan
2015-07-10  7:37 ` Stefano Babic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.