STM32: Remove STMMAC clock setup from board
Subsystems (3)
cover STM32: Remove STMMAC clock setup from board
From: Patrice Chotard <[email protected]>
As STMMAC designware driver is now able to get and enable STMMAC clocks, we can remove code related to STMMAC clock setup in board and in clk_stm32f driver.
Set SYSCFG clock directly in configure_clocks()
Add missing STMMAC clocks in stm32f746 dts file.
Patrice Chotard (3):
ARM: dts: stm32: Add STMMAC clocks for stm32f746
clk: clk_stm32f: Remove STMMAC clock setup
clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()
arch/arm/dts/stm32f746.dtsi | 3 +++ arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 2 -- board/st/stm32f746-disco/stm32f746-disco.c | 20 ++++++-------------- drivers/clk/clk_stm32f.c | 16 ++++------------ 4 files changed, 13 insertions(+), 28 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 ARM: dts: stm32: Add STMMAC clocks for stm32f746
From: Patrice Chotard <[email protected]>
Add ETHMAC, ETHMACRX and ETHMACTX clocks for STMMAC.
--- arch/arm/dts/stm32f746.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/dts/stm32f746.dtsi +3 -0
@@ -65,6 +65,9 @@ compatible = "st,stm32-dwmac"; reg = <0x40028000 0x8000>; reg-names = "stmmaceth"; + clocks = <&rcc 0 STM32F7_AHB1_CLOCK(ETHMAC)>, + <&rcc 0 STM32F7_AHB1_CLOCK(ETHMACTX)>, + <&rcc 0 STM32F7_AHB1_CLOCK(ETHMACRX)>; interrupts = <61>, <62>; interrupt-names = "macirq", "eth_wake_irq"; snps,pbl = <8>;
Signature · 1 line
1.9.1
PATCH 1/3 ARM: dts: stm32: Add STMMAC clocks for stm32f746
Hi,
Quoted 5 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
Add ETHMAC, ETHMACRX and ETHMACTX clocks for STMMAC.
Signed-off-by Patrice Chotard <[email protected]>
Cheers,
Vikas
Quoted 19 lines
--- arch/arm/dts/stm32f746.dtsi | 3 +++ 1 file changed, 3 insertions(+)arch/arm/dts/stm32f746.dtsi +3
-0@@ -65,6 +65,9 @@ compatible = "st,stm32-dwmac"; reg = <0x40028000 0x8000>; reg-names = "stmmaceth"; + clocks = <&rcc 0 STM32F7_AHB1_CLOCK(ETHMAC)>, + <&rcc 0 STM32F7_AHB1_CLOCK(ETHMACTX)>, + <&rcc 0 STM32F7_AHB1_CLOCK(ETHMACRX)>; interrupts = <61>, <62>; interrupt-names = "macirq", "eth_wake_irq"; snps,pbl = <8>;
PATCH 2/3 clk: clk_stm32f: Remove STMMAC clock setup
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
Thanks to 'commit ba1f96672522 ("net: designware: add clock support")' we don't need anymore to setup the STMMAC clock in board.
--- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 - board/st/stm32f746-disco/stm32f746-disco.c | 1 - drivers/clk/clk_stm32f.c | 6 ------ 3 files changed, 8 deletions(-)
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0 -1
@@ -23,7 +23,6 @@ enum periph_id {enum periph_clock {SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , -STMMAC_CLOCK_CFG , };#endif /* __ASM_ARM_ARCH_PERIPH_H */
board/st/stm32f746-disco/stm32f746-disco.c +0 -1
@@ -75,7 +75,6 @@ static int stmmac_setup(void)clock_setup (SYSCFG_CLOCK_CFG );/* Set >RMII mode */ STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; -clock_setup (STMMAC_CLOCK_CFG );return 0 ; }
drivers/clk/clk_stm32f.c +0 -6
@@ -90,7 +90,6 @@enum periph_clock {SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , -STMMAC_CLOCK_CFG , };struct stm32_clk_info stm32f4_clk_info = {
@@ -359,11 +358,6 @@ void clock_setup(int peripheral)case TIMER2_CLOCK_CFG :setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_TIM2EN );break ; -case STMMAC_CLOCK_CFG : -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_EN ); -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_RX_EN ); -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_TX_EN ); -break ;default :break ; }
Signature · 1 line
1.9.1
PATCH 2/3 clk: clk_stm32f: Remove STMMAC clock setup
Hi,
Quoted 6 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
Thanks to 'commit
ba1f96672522("net: designware: add clock support")' we don't need anymore to setup the STMMAC clock in board.Signed-off-by Patrice Chotard <[email protected]>
Cheers,
Vikas
Quoted 55 lines
--- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 - board/st/stm32f746-disco/stm32f746-disco.c | 1 - drivers/clk/clk_stm32f.c | 6 ------ 3 files changed, 8 deletions(-)arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0
-1@@ -23,7 +23,6 @@ enum periph_id {enum periph_clock {SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , -STMMAC_CLOCK_CFG , };#endif /* __ASM_ARM_ARCH_PERIPH_H */ board/st/stm32f746-disco/stm32f746-disco.c +0
-1@@ -75,7 +75,6 @@ static int stmmac_setup(void)clock_setup (SYSCFG_CLOCK_CFG );/* Set >RMII mode */ STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; -clock_setup (STMMAC_CLOCK_CFG );return 0 ; }drivers/clk/clk_stm32f.c +0
-6@@ -90,7 +90,6 @@enum periph_clock {SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , -STMMAC_CLOCK_CFG , };struct stm32_clk_info stm32f4_clk_info = {@@ -359,11 +358,6 @@ void clock_setup(int peripheral)case TIMER2_CLOCK_CFG :setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_TIM2EN );break ; -case STMMAC_CLOCK_CFG : -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_EN ); -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_RX_EN ); -setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_TX_EN ); -break ;default :break ; }
PATCH 3/3 clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
Move SYSCFG clock setup into configure_clocks() instead of calling clock_setup() from drivers.
Move the RMII setup from board_early_init_f() to board_init() to insure that RMII bit is set only when clock driver is initialized.
--- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 - board/st/stm32f746-disco/stm32f746-disco.c | 19 ++++++------------- drivers/clk/clk_stm32f.c | 10 ++++------ 3 files changed, 10 insertions(+), 20 deletions(-)
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0 -1
@@ -21,7 +21,6 @@ enum periph_id { };enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };
board/st/stm32f746-disco/stm32f746-disco.c +6 -13
@@ -69,23 +69,10 @@ int dram_init_banksize(void)return 0 ; } -#ifdef CONFIG_ETH_DESIGNWARE -static int stmmac_setup (void ) -{ -clock_setup (SYSCFG_CLOCK_CFG ); -/* Set >RMII mode */ -STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; - -return 0 ; -} -int board_early_init_f (void ) { -stmmac_setup (); -return 0 ; } -#endif #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_OS_BOOT
@@ -162,5 +149,11 @@ int board_late_init(void)int board_init (void ) { gd->bd->bi_boot_params = gd->bd->bi_dram[0 ].start +0x100 ; + +#ifdef CONFIG_ETH_DESIGNWARE +/* Set >RMII mode */ +STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; +#endif +return 0 ; }
drivers/clk/clk_stm32f.c +4 -6
@@ -67,8 +67,6 @@#define RCC_DCKCFGRX_SDMMC1SEL BIT(28)#define RCC_DCKCFGR2_SDMMC2SEL BIT(29) -#define RCC_APB2ENR_SAI1EN BIT(22) -/* * RCC AHB1ENR specific definitions */
@@ -86,9 +84,9 @@* RCC APB2ENR specific definitions */ #define RCC_APB2ENR_SYSCFGEN BIT(14) +#define RCC_APB2ENR_SAI1EN BIT(22)enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };
@@ -227,6 +225,9 @@ static int configure_clocks(struct udevice *dev)/* gate the SAI clock, needed for MMC 1&2 clocks */ setbits_le32 (®s->apb2enr,RCC_APB2ENR_SAI1EN ); +/* gate the SYSCFG clock, needed to set RMII ethernet interface */ +setbits_le32 (®s->apb2enr,RCC_APB2ENR_SYSCFGEN ); +return 0 ; }
@@ -352,9 +353,6 @@ static int stm32_clk_enable(struct clk *clk)void clock_setup (int peripheral) {switch (peripheral) { -case SYSCFG_CLOCK_CFG : -setbits_le32 (&STM32_RCC ->apb2enr,RCC_APB2ENR_SYSCFGEN ); -break ;case TIMER2_CLOCK_CFG :setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_TIM2EN );break ;
Signature · 1 line
1.9.1
PATCH 3/3 clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()
Hi Patrice,
Quoted 4 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
Move SYSCFG clock setup into
configure_clocks()instead of callingclock_setup()from drivers.
It is in board configuration.
Quoted 87 lines
Move the RMII setup from
board_early_init_f()toboard_init()to insure that RMII bit is set only when clock driver is initialized.Signed-off-by Patrice Chotard <[email protected]>--- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 - board/st/stm32f746-disco/stm32f746-disco.c | 19 ++++++------------- drivers/clk/clk_stm32f.c | 10 ++++------ 3 files changed, 10 insertions(+), 20 deletions(-)arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0
-1@@ -21,7 +21,6 @@ enum periph_id { };enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };board/st/stm32f746-disco/stm32f746-disco.c +6
-13@@ -69,23 +69,10 @@ int dram_init_banksize(void)return 0 ; } -#ifdef CONFIG_ETH_DESIGNWARE -static int stmmac_setup (void ) -{ -clock_setup (SYSCFG_CLOCK_CFG ); -/* Set >RMII mode */ -STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; - -return 0 ; -} -int board_early_init_f (void ) { -stmmac_setup (); -return 0 ; } -#endif #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_OS_BOOT @@ -162,5 +149,11 @@ int board_late_init(void)int board_init (void ) { gd->bd->bi_boot_params = gd->bd->bi_dram[0 ].start +0x100 ; + +#ifdef CONFIG_ETH_DESIGNWARE +/* Set >RMII mode */ +STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; +#endif +return 0 ; }drivers/clk/clk_stm32f.c +1
-3@@ -67,8 +67,6 @@#define RCC_DCKCFGRX_SDMMC1SEL BIT(28)#define RCC_DCKCFGR2_SDMMC2SEL BIT(29) -#define RCC_APB2ENR_SAI1EN BIT(22) -/* * RCC AHB1ENR specific definitions */ @@ -86,9 +84,9 @@* RCC APB2ENR specific definitions */ #define RCC_APB2ENR_SYSCFGEN BIT(14) +#define RCC_APB2ENR_SAI1EN BIT(22)enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };
drivers/clk/clk_stm32f.c static int configure_clocks(struct udevice *dev) · line 228
Quoted 4 lines
drivers/clk/clk_stm32f.c +1
-0@@ -227,6 +225,9 @@ static int configure_clocks(struct udevice *dev)/* gate the SAI clock, needed for MMC 1&2 clocks */ setbits_le32 (®s->apb2enr,RCC_APB2ENR_SAI1EN ); +/* gate the SYSCFG clock, needed to set RMII ethernet interface */
RMII interface only required for f746 disco board.
drivers/clk/clk_stm32f.c static int configure_clocks(struct udevice *dev) · line 229
Quoted 1 line
drivers/clk/clk_stm32f.c +1
-0+setbits_le32 (®s->apb2enr,RCC_APB2ENR_SYSCFGEN );
RMII & Syscfg is board specific requirement, here it will configure it for all stm32f devices.
Cheers,
Vikas
Quoted 15 lines
drivers/clk/clk_stm32f.c +1
-3+return 0 ; }@@ -352,9 +353,6 @@ static int stm32_clk_enable(struct clk *clk)void clock_setup (int peripheral) {switch (peripheral) { -case SYSCFG_CLOCK_CFG : -setbits_le32 (&STM32_RCC ->apb2enr,RCC_APB2ENR_SYSCFGEN ); -break ;case TIMER2_CLOCK_CFG :setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_TIM2EN );break ;
PATCH 3/3 clk: clk_stm32f: Move SYSCFG clock setup into configure_clocks()
Hi Vikas
Quoted 9 lines · Vikas Manocha
Hi Patrice,
Quoted 4 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
Move SYSCFG clock setup into
configure_clocks()instead of callingclock_setup()from drivers.It is in board configuration.
Yes, my comment is badly formulated.
The idea is to remove clock_setup() from clock driver.
Quoted 91 lines
Quoted 91 lines
Move the RMII setup from
board_early_init_f()toboard_init()to insure that RMII bit is set only when clock driver is initialized.Signed-off-by Patrice Chotard <[email protected]>--- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 - board/st/stm32f746-disco/stm32f746-disco.c | 19 ++++++------------- drivers/clk/clk_stm32f.c | 10 ++++------ 3 files changed, 10 insertions(+), 20 deletions(-)arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0
-1@@ -21,7 +21,6 @@ enum periph_id { };enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };board/st/stm32f746-disco/stm32f746-disco.c +6
-13@@ -69,23 +69,10 @@ int dram_init_banksize(void)return 0 ; } -#ifdef CONFIG_ETH_DESIGNWARE -static int stmmac_setup (void ) -{ -clock_setup (SYSCFG_CLOCK_CFG ); -/* Set >RMII mode */ -STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; - -return 0 ; -} -int board_early_init_f (void ) { -stmmac_setup (); -return 0 ; } -#endif #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_OS_BOOT @@ -162,5 +149,11 @@ int board_late_init(void)int board_init (void ) { gd->bd->bi_boot_params = gd->bd->bi_dram[0 ].start +0x100 ; + +#ifdef CONFIG_ETH_DESIGNWARE +/* Set >RMII mode */ +STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; +#endif +return 0 ; }drivers/clk/clk_stm32f.c +1
-3@@ -67,8 +67,6 @@#define RCC_DCKCFGRX_SDMMC1SEL BIT(28)#define RCC_DCKCFGR2_SDMMC2SEL BIT(29) -#define RCC_APB2ENR_SAI1EN BIT(22) -/* * RCC AHB1ENR specific definitions */ @@ -86,9 +84,9 @@* RCC APB2ENR specific definitions */ #define RCC_APB2ENR_SYSCFGEN BIT(14) +#define RCC_APB2ENR_SAI1EN BIT(22)enum periph_clock { -SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG , };@@ -227,6 +225,9 @@ static int configure_clocks(struct udevice *dev)/* gate the SAI clock, needed for MMC 1&2 clocks */ setbits_le32 (®s->apb2enr,RCC_APB2ENR_SAI1EN );
Quoted 7 lines
drivers/clk/clk_stm32f.c static int configure_clocks(struct udevice *dev) · line 228
Quoted 1 line
drivers/clk/clk_stm32f.c +1
-0+/* gate the SYSCFG clock, needed to set RMII ethernet interface */ RMII interface only required for f746 disco board.
drivers/clk/clk_stm32f.c static int configure_clocks(struct udevice *dev) · line 229
Quoted 1 line
drivers/clk/clk_stm32f.c +1
-0+setbits_le32 (®s->apb2enr,RCC_APB2ENR_SYSCFGEN );RMII & Syscfg is board specific requirement, here it will configure it for all stm32f devices.
You are right, i will update this. As it is currently only needed for ethernet, i will add the CONFIG_ETH_DESIGNWARE flag around.
For information, i will add new stm32f429-evaluation board (already supported in kernel) which provide ethernet connection.
Thanks for reviewing
Patrice
Quoted 19 lines
Cheers,
VikasQuoted 15 lines
drivers/clk/clk_stm32f.c +1
-3+return 0 ; }@@ -352,9 +353,6 @@ static int stm32_clk_enable(struct clk *clk)void clock_setup (int peripheral) {switch (peripheral) { -case SYSCFG_CLOCK_CFG : -setbits_le32 (&STM32_RCC ->apb2enr,RCC_APB2ENR_SYSCFGEN ); -break ;case TIMER2_CLOCK_CFG :setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_TIM2EN );break ;