Skip to contentSkip to conversation

stm32f7 clock improvements

PATCH New patrice.chotard at st.com 2 participants 19 messages Jul 18, 2017 – Jul 26, 2017

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover stm32f7 clock improvements

From: Patrice Chotard <[email protected]>

The objective of this series is to prepare the ground for future STM32H7 SoC introduction. As STM32F7 and STM32H7 SoCs shared several blocks (serial, qspi, gpio ....) some rework is needed to made some drivers more generic. Some of these driver are using proprietatry clock glue which need to be replace by clock framework one, which also implies stm32f7 clock driver rework.

Here are the steps:
_ align stm32f7 clock DT declaration with kernel one
_ retrieve RCC base address from DT
_ replace the stm32f7 clock_get() glue function by clock framework clk_get_rate()
inside several driver :
_ drivers/spi/stm32_qspi.c
_ drivers/serial/serial_stm32x7.c
_ remove proprietary clock glue

Patrice Chotard (9):
ARM: DTS: stm32: align DT clock declaration with kernel
clk: stm32f7: add static for configure_clocks()
clk: stm32f7: get RCC base address from DT
clk: stm32f7: add clock .get_rate() callback
clk: stm32f7: cleanup clocks unused definitions
serial: stm32x7: migrate serial struct to driver
serial: stm32x7: add clk_get_rate() support
spi: stm32_qspi: add clk_get_rate() support
clk: stm32f7: remove clock_get()

 arch/arm/dts/stm32f746.dtsi                      |  30 +++---
 arch/arm/include/asm/arch-stm32f7/rcc.h          |  24 +----
 arch/arm/include/asm/arch-stm32f7/stm32.h        |  13 ---
 arch/arm/include/asm/arch-stm32f7/stm32_periph.h |  15 ---
 board/st/stm32f746-disco/stm32f746-disco.c       |   1 -
 drivers/clk/clk_stm32f7.c                        | 100 +++++++++++++-------
 drivers/serial/serial_stm32x7.c                  |  18 ++--
 drivers/serial/serial_stm32x7.h                  |   5 +
 drivers/spi/stm32_qspi.c                         |  10 +-
 include/dm/platform_data/serial_stm32x7.h        |  17 ----
 include/dt-bindings/clock/stm32fx-clock.h        |  59 ++++++++++++
 include/dt-bindings/mfd/stm32f7-rcc.h            | 112 +++++++++++++++++++++++
 12 files changed, 276 insertions(+), 128 deletions(-)
 delete mode 100644 include/dm/platform_data/serial_stm32x7.h
 create mode 100644 include/dt-bindings/clock/stm32fx-clock.h
 create mode 100644 include/dt-bindings/mfd/stm32f7-rcc.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/9 ARM: DTS: stm32: align DT clock declaration with kernel

From: Patrice Chotard <[email protected]>

Use the same clocks macro than the one used by kernel DT.

---
 arch/arm/dts/stm32f746.dtsi               |  30 ++++----
 include/dt-bindings/clock/stm32fx-clock.h |  59 ++++++++++++++++
 include/dt-bindings/mfd/stm32f7-rcc.h     | 112 ++++++++++++++++++++++++++++++
 3 files changed, 187 insertions(+), 14 deletions(-)
 create mode 100644 include/dt-bindings/clock/stm32fx-clock.h
 create mode 100644 include/dt-bindings/mfd/stm32f7-rcc.h
arch/arm/dts/stm32f746.dtsi +16 -14
index 54f5bc7..783d4e7 100644
@@ -47,6 +47,8 @@
 
 #include "armv7-m.dtsi"
 #include <dt-bindings/pinctrl/stm32f746-pinfunc.h>
+#include <dt-bindings/clock/stm32fx-clock.h>
+#include <dt-bindings/mfd/stm32f7-rcc.h>
 
 / {
 	clocks {
@@ -74,7 +76,7 @@
 		fmc: fmc at A0000000 {
 			compatible = "st,stm32-fmc";
 			reg = <0xA0000000 0x1000>;
-			clocks = <&rcc 0 64>;
+			clocks = <&rcc 0 STM32F7_AHB3_CLOCK(FMC)>;
 			u-boot,dm-pre-reloc;
 		};
 
@@ -86,14 +88,14 @@
 			reg-names = "QuadSPI", "QuadSPI-memory";
 			interrupts = <92>;
 			spi-max-frequency = <108000000>;
-			clocks = <&rcc 0 65>;
+			clocks = <&rcc 0 STM32F7_AHB3_CLOCK(QSPI)>;
 			status = "disabled";
 		};
 		usart1: serial at 40011000 {
 			compatible = "st,stm32f7-usart", "st,stm32f7-uart";
 			reg = <0x40011000 0x400>;
 			interrupts = <37>;
-			clocks = <&rcc 0 164>;
+			clocks = <&rcc 0 STM32F7_APB2_CLOCK(USART1)>;
 			status = "disabled";
 			u-boot,dm-pre-reloc;
 		};
@@ -119,7 +121,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x0 0x400>;
-				clocks = <&rcc 0 0>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOA)>;
 				st,bank-name = "GPIOA";
 				u-boot,dm-pre-reloc;
 			};
@@ -129,7 +131,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x400 0x400>;
-				clocks = <&rcc 0 1>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOB)>;
 				st,bank-name = "GPIOB";
 				u-boot,dm-pre-reloc;
 			};
@@ -140,7 +142,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x800 0x400>;
-				clocks = <&rcc 0 2>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOC)>;
 				st,bank-name = "GPIOC";
 				u-boot,dm-pre-reloc;
 			};
@@ -150,7 +152,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0xc00 0x400>;
-				clocks = <&rcc 0 3>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOD)>;
 				st,bank-name = "GPIOD";
 				u-boot,dm-pre-reloc;
 			};
@@ -160,7 +162,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x1000 0x400>;
-				clocks = <&rcc 0 4>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOE)>;
 				st,bank-name = "GPIOE";
 				u-boot,dm-pre-reloc;
 			};
@@ -170,7 +172,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x1400 0x400>;
-				clocks = <&rcc 0 5>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOF)>;
 				st,bank-name = "GPIOF";
 				u-boot,dm-pre-reloc;
 			};
@@ -180,7 +182,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x1800 0x400>;
-				clocks = <&rcc 0 6>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOG)>;
 				st,bank-name = "GPIOG";
 				u-boot,dm-pre-reloc;
 			};
@@ -190,7 +192,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x1c00 0x400>;
-				clocks = <&rcc 0 7>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOH)>;
 				st,bank-name = "GPIOH";
 				u-boot,dm-pre-reloc;
 			};
@@ -200,7 +202,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x2000 0x400>;
-				clocks = <&rcc 0 8>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOI)>;
 				st,bank-name = "GPIOI";
 				u-boot,dm-pre-reloc;
 			};
@@ -210,7 +212,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x2400 0x400>;
-				clocks = <&rcc 0 9>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOJ)>;
 				st,bank-name = "GPIOJ";
 				u-boot,dm-pre-reloc;
 			};
@@ -220,7 +222,7 @@
 				#gpio-cells = <2>;
 				compatible = "st,stm32-gpio";
 				reg = <0x2800 0x400>;
-				clocks = <&rcc 0 10>;
+				clocks = <&rcc 0 STM32F7_AHB1_CLOCK(GPIOK)>;
 				st,bank-name = "GPIOK";
 				u-boot,dm-pre-reloc;
 			};
include/dt-bindings/clock/stm32fx-clock.h new file +59 -0

59 lines not on this page · raw message

include/dt-bindings/mfd/stm32f7-rcc.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/9 ARM: DTS: stm32: align DT clock declaration with kernel

Quoted 6 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Use the same clocks macro than the one used by kernel DT.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/581007ef/attachment.sig>
#3 lore raw

PATCH 2/9 clk: stm32f7: add static for configure_clocks()

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Also remove its declaration from stm32.h which
is no more needed.

---
 arch/arm/include/asm/arch-stm32f7/stm32.h | 1 -
 drivers/clk/clk_stm32f7.c                 | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
arch/arm/include/asm/arch-stm32f7/stm32.h +0 -1
index 14e3398..d4c834e 100644
@@ -114,7 +114,6 @@ struct stm32_pwr_regs {
 };
 #define STM32_PWR		((struct stm32_pwr_regs *)PWR_BASE)
 
-int configure_clocks(void);
 unsigned long clock_get(enum clock clck);
 void stm32_flash_latency_cfg(int latency);
 
drivers/clk/clk_stm32f7.c +1 -1
index fcdc3c0..aff8ad3 100644
@@ -104,7 +104,7 @@ struct pll_psc sys_pll_psc = {
 #endif
 #endif
 
-int configure_clocks(void)
+static int configure_clocks(void)
 {
 	/* Reset RCC configuration */
 	setbits_le32(&STM32_RCC->cr, RCC_CR_HSION);
Signature · 1 line
1.9.1
#4 lore raw

PATCH 2/9 clk: stm32f7: add static for configure_clocks()

Quoted 7 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Also remove its declaration from stm32.h which
is no more needed.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/61d12a23/attachment.sig>
#5 lore raw

PATCH 3/9 clk: stm32f7: get RCC base address from DT

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Retrieve RCC base address from DT, this will prepare the ground for future STM32 SoCs support.

---
 drivers/clk/clk_stm32f7.c | 57 +++++++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 19 deletions(-)
drivers/clk/clk_stm32f7.c +38 -19
index aff8ad3..7dd91b6 100644
@@ -83,6 +83,10 @@ struct pll_psc {
 #define APB_PSC_8			0x6
 #define APB_PSC_16			0x7
 
+struct stm32_clk {
+	struct stm32_rcc_regs *base;
+};
+
 #if !defined(CONFIG_STM32_HSE_HZ)
 #error "CONFIG_STM32_HSE_HZ not defined!"
 #else
@@ -104,23 +108,26 @@ struct pll_psc sys_pll_psc = {
 #endif
 #endif
 
-static int configure_clocks(void)
+static int configure_clocks(struct udevice *dev)
 {
+	struct stm32_clk *priv = dev_get_priv(dev);
+	struct stm32_rcc_regs *regs = priv->base;
+
 	/* Reset RCC configuration */
-	setbits_le32(&STM32_RCC->cr, RCC_CR_HSION);
-	writel(0, &STM32_RCC->cfgr); /* Reset CFGR */
-	clrbits_le32(&STM32_RCC->cr, (RCC_CR_HSEON | RCC_CR_CSSON
+	setbits_le32(&regs->cr, RCC_CR_HSION);
+	writel(0, &regs->cfgr); /* Reset CFGR */
+	clrbits_le32(&regs->cr, (RCC_CR_HSEON | RCC_CR_CSSON
 		| RCC_CR_PLLON));
-	writel(0x24003010, &STM32_RCC->pllcfgr); /* Reset value from RM */
-	clrbits_le32(&STM32_RCC->cr, RCC_CR_HSEBYP);
-	writel(0, &STM32_RCC->cir); /* Disable all interrupts */
+	writel(0x24003010, &regs->pllcfgr); /* Reset value from RM */
+	clrbits_le32(&regs->cr, RCC_CR_HSEBYP);
+	writel(0, &regs->cir); /* Disable all interrupts */
 
 	/* Configure for HSE+PLL operation */
-	setbits_le32(&STM32_RCC->cr, RCC_CR_HSEON);
-	while (!(readl(&STM32_RCC->cr) & RCC_CR_HSERDY))
+	setbits_le32(&regs->cr, RCC_CR_HSEON);
+	while (!(readl(&regs->cr) & RCC_CR_HSERDY))
 		;
 
-	setbits_le32(&STM32_RCC->cfgr, ((
+	setbits_le32(&regs->cfgr, ((
 		sys_pll_psc.ahb_psc << RCC_CFGR_HPRE_SHIFT)
 		| (sys_pll_psc.apb1_psc << RCC_CFGR_PPRE1_SHIFT)
 		| (sys_pll_psc.apb2_psc << RCC_CFGR_PPRE2_SHIFT)));
@@ -132,15 +139,15 @@ static int configure_clocks(void)
 	pllcfgr |= sys_pll_psc.pll_n << RCC_PLLCFGR_PLLN_SHIFT;
 	pllcfgr |= ((sys_pll_psc.pll_p >> 1) - 1) << RCC_PLLCFGR_PLLP_SHIFT;
 	pllcfgr |= sys_pll_psc.pll_q << RCC_PLLCFGR_PLLQ_SHIFT;
-	writel(pllcfgr, &STM32_RCC->pllcfgr);
+	writel(pllcfgr, &regs->pllcfgr);
 
 	/* Enable the main PLL */
-	setbits_le32(&STM32_RCC->cr, RCC_CR_PLLON);
-	while (!(readl(&STM32_RCC->cr) & RCC_CR_PLLRDY))
+	setbits_le32(&regs->cr, RCC_CR_PLLON);
+	while (!(readl(&regs->cr) & RCC_CR_PLLRDY))
 		;
 
 	/* Enable high performance mode, System frequency up to 200 MHz */
-	setbits_le32(&STM32_RCC->apb1enr, RCC_APB1ENR_PWREN);
+	setbits_le32(&regs->apb1enr, RCC_APB1ENR_PWREN);
 	setbits_le32(&STM32_PWR->cr1, PWR_CR1_ODEN);
 	/* Infinite wait! */
 	while (!(readl(&STM32_PWR->csr1) & PWR_CSR1_ODRDY))
@@ -152,10 +159,10 @@ static int configure_clocks(void)
 		;
 
 	stm32_flash_latency_cfg(5);
-	clrbits_le32(&STM32_RCC->cfgr, (RCC_CFGR_SW0 | RCC_CFGR_SW1));
-	setbits_le32(&STM32_RCC->cfgr, RCC_CFGR_SW_PLL);
+	clrbits_le32(&regs->cfgr, (RCC_CFGR_SW0 | RCC_CFGR_SW1));
+	setbits_le32(&regs->cfgr, RCC_CFGR_SW_PLL);
 
-	while ((readl(&STM32_RCC->cfgr) & RCC_CFGR_SWS_MASK) !=
+	while ((readl(&regs->cfgr) & RCC_CFGR_SWS_MASK) !=
 			RCC_CFGR_SWS_PLL)
 		;
 
@@ -215,12 +222,14 @@ unsigned long clock_get(enum clock clck)
 
 static int stm32_clk_enable(struct clk *clk)
 {
+	struct stm32_clk *priv = dev_get_priv(clk->dev);
+	struct stm32_rcc_regs *regs = priv->base;
 	u32 offset = clk->id / 32;
 	u32 bit_index = clk->id % 32;
 
 	debug("%s: clkid = %ld, offset from AHB1ENR is %d, bit_index = %d\n",
 	      __func__, clk->id, offset, bit_index);
-	setbits_le32(&STM32_RCC->ahb1enr + offset, BIT(bit_index));
+	setbits_le32(&regs->ahb1enr + offset, BIT(bit_index));
 
 	return 0;
 }
@@ -247,7 +256,17 @@ void clock_setup(int peripheral)
 static int stm32_clk_probe(struct udevice *dev)
 {
 	debug("%s: stm32_clk_probe\n", __func__);
-	configure_clocks();
+
+	struct stm32_clk *priv = dev_get_priv(dev);
+	fdt_addr_t addr;
+
+	addr = devfdt_get_addr(dev);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->base = (struct stm32_rcc_regs *)addr;
+
+	configure_clocks(dev);
 
 	return 0;
 }
Signature · 1 line
1.9.1
#6 lore raw

PATCH 3/9 clk: stm32f7: get RCC base address from DT

Quoted 7 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Retrieve RCC base address from DT, this will prepare the ground for future STM32 SoCs support.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/051a23e3/attachment.sig>
#7 lore raw

PATCH 4/9 clk: stm32f7: add clock .get_rate() callback

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Add clock framework .get_rate callback.
This step will allow to convert all drivers which was using proprietary clock_get() to use clock framework .get_rate().

---
 arch/arm/include/asm/arch-stm32f7/rcc.h |  2 ++
 drivers/clk/clk_stm32f7.c               | 62 +++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
arch/arm/include/asm/arch-stm32f7/rcc.h +2 -0
index 0f8d50b..cc9b57f 100644
@@ -8,6 +8,8 @@
 #ifndef _STM32_RCC_H
 #define _STM32_RCC_H
 
+#include <dt-bindings/mfd/stm32f7-rcc.h>
+
 /*
  * RCC AHB1ENR specific definitions
  */
drivers/clk/clk_stm32f7.c +62 -0

80 lines not on this page · raw message

Signature · 1 line
1.9.1
#8 lore raw

PATCH 4/9 clk: stm32f7: add clock .get_rate() callback

Quoted 8 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Add clock framework .get_rate callback.
This step will allow to convert all drivers which was using proprietary clock_get() to use clock framework .get_rate().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/e9f448df/attachment.sig>
#9 lore raw

PATCH 5/9 clk: stm32f7: cleanup clocks unused definitions

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

clean the code by removing unused enums, structs and defines related to clocks

---
 arch/arm/include/asm/arch-stm32f7/rcc.h          | 22 ----------------------
 arch/arm/include/asm/arch-stm32f7/stm32.h        |  6 ------
 arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 15 ---------------
 drivers/clk/clk_stm32f7.c                        |  3 ---
 4 files changed, 46 deletions(-)
arch/arm/include/asm/arch-stm32f7/rcc.h +0 -22
index cc9b57f..a33f8cf 100644
@@ -13,41 +13,19 @@
 /*
  * RCC AHB1ENR specific definitions
  */
-#define RCC_AHB1ENR_GPIO_A_EN		BIT(0)
-#define RCC_AHB1ENR_GPIO_B_EN		BIT(1)
-#define RCC_AHB1ENR_GPIO_C_EN		BIT(2)
-#define RCC_AHB1ENR_GPIO_D_EN		BIT(3)
-#define RCC_AHB1ENR_GPIO_E_EN		BIT(4)
-#define RCC_AHB1ENR_GPIO_F_EN		BIT(5)
-#define RCC_AHB1ENR_GPIO_G_EN		BIT(6)
-#define RCC_AHB1ENR_GPIO_H_EN		BIT(7)
-#define RCC_AHB1ENR_GPIO_I_EN		BIT(8)
-#define RCC_AHB1ENR_GPIO_J_EN		BIT(9)
-#define RCC_AHB1ENR_GPIO_K_EN		BIT(10)
 #define RCC_AHB1ENR_ETHMAC_EN		BIT(25)
 #define RCC_AHB1ENR_ETHMAC_TX_EN	BIT(26)
 #define RCC_AHB1ENR_ETHMAC_RX_EN	BIT(27)
-#define RCC_AHB1ENR_ETHMAC_PTP_EN	BIT(28)
-
-/*
- * RCC AHB3ENR specific definitions
- */
-#define RCC_AHB3ENR_FMC_EN		BIT(0)
-#define RCC_AHB3ENR_QSPI_EN             BIT(1)
 
 /*
  * RCC APB1ENR specific definitions
  */
 #define RCC_APB1ENR_TIM2EN		BIT(0)
-#define RCC_APB1ENR_USART2EN		BIT(17)
-#define RCC_APB1ENR_USART3EN		BIT(18)
 #define RCC_APB1ENR_PWREN		BIT(28)
 
 /*
  * RCC APB2ENR specific definitions
  */
-#define RCC_APB2ENR_USART1EN		BIT(4)
-#define RCC_APB2ENR_USART6EN		BIT(5)
 #define RCC_APB2ENR_SYSCFGEN		BIT(14)
 
 #endif
arch/arm/include/asm/arch-stm32f7/stm32.h +0 -6
index d4c834e..12efee5 100644
@@ -58,7 +58,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 };
 
 enum clock {
-	CLOCK_CORE,
 	CLOCK_AHB,
 	CLOCK_APB1,
 	CLOCK_APB2
@@ -101,11 +100,6 @@ struct stm32_rcc_regs {
 };
 #define STM32_RCC		((struct stm32_rcc_regs *)RCC_BASE)
 
-struct stm32_rcc_ext_f7_regs {
-	u32 dckcfgr2;	/* dedicated clocks configuration register */
-};
-#define STM32_RCC_EXT_F7	((struct stm32_rcc_ext_f7_regs *) (RCC_BASE + sizeof(struct stm32_rcc_regs)))
-
 struct stm32_pwr_regs {
 	u32 cr1;   /* power control register 1 */
 	u32 csr1;  /* power control/status register 2 */
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0 -15
index 3c5604a..9c1ec02 100644
@@ -21,24 +21,9 @@ enum periph_id {
 };
 
 enum periph_clock {
-	USART1_CLOCK_CFG = 0,
-	USART2_CLOCK_CFG,
-	GPIO_A_CLOCK_CFG,
-	GPIO_B_CLOCK_CFG,
-	GPIO_C_CLOCK_CFG,
-	GPIO_D_CLOCK_CFG,
-	GPIO_E_CLOCK_CFG,
-	GPIO_F_CLOCK_CFG,
-	GPIO_G_CLOCK_CFG,
-	GPIO_H_CLOCK_CFG,
-	GPIO_I_CLOCK_CFG,
-	GPIO_J_CLOCK_CFG,
-	GPIO_K_CLOCK_CFG,
 	SYSCFG_CLOCK_CFG,
 	TIMER2_CLOCK_CFG,
-	FMC_CLOCK_CFG,
 	STMMAC_CLOCK_CFG,
-	QSPI_CLOCK_CFG,
 };
 
 #endif /* __ASM_ARM_ARCH_PERIPH_H */
drivers/clk/clk_stm32f7.c +0 -3
index 5e20b0c..5bc650a 100644
@@ -195,9 +195,6 @@ unsigned long clock_get(enum clock clck)
 	}
 
 	switch (clck) {
-	case CLOCK_CORE:
-		return sysclk;
-		break;
 	case CLOCK_AHB:
 		shift = ahb_psc_table[(
 			(readl(&STM32_RCC->cfgr) & RCC_CFGR_AHB_PSC_MASK)
Signature · 1 line
1.9.1
#10 lore raw

PATCH 5/9 clk: stm32f7: cleanup clocks unused definitions

Quoted 7 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

clean the code by removing unused enums, structs and defines related to clocks

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/07f4fc46/attachment.sig>
#11 lore raw

PATCH 6/9 serial: stm32x7: migrate serial struct to driver

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This allow to remove include/dm/platform_data/serial_stm32x7.h which was included in the past by stm32x7 driver and by stm32f746-disco.c board file.
Since patch 42bf5e7c27 "serial: stm32f7: add device tree support" this file is no more needed in board file.

---
 board/st/stm32f746-disco/stm32f746-disco.c |  1 -
 drivers/serial/serial_stm32x7.c            |  1 -
 drivers/serial/serial_stm32x7.h            |  5 +++++
 include/dm/platform_data/serial_stm32x7.h  | 17 -----------------
 4 files changed, 5 insertions(+), 19 deletions(-)
 delete mode 100644 include/dm/platform_data/serial_stm32x7.h
board/st/stm32f746-disco/stm32f746-disco.c +0 -1
index fc4c60c..e3b662b 100644
@@ -14,7 +14,6 @@
 #include <asm/arch/stm32.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/fmc.h>
-#include <dm/platform_data/serial_stm32x7.h>
 #include <asm/arch/stm32_periph.h>
 #include <asm/arch/stm32_defs.h>
 #include <asm/arch/syscfg.h>
drivers/serial/serial_stm32x7.c +0 -1
index 61e8167..05c73da 100644
@@ -11,7 +11,6 @@
 #include <asm/io.h>
 #include <serial.h>
 #include <asm/arch/stm32.h>
-#include <dm/platform_data/serial_stm32x7.h>
 #include "serial_stm32x7.h"
 
 DECLARE_GLOBAL_DATA_PTR;
drivers/serial/serial_stm32x7.h +5 -0
index facfdba..42b05f1 100644
@@ -22,6 +22,11 @@ struct stm32_usart {
 	u32 tx_dr;
 };
 
+/* Information about a serial port */
+struct stm32x7_serial_platdata {
+	struct stm32_usart *base;  /* address of registers in physical memory */
+	unsigned int clock;
+};
 
 #define USART_CR1_OVER8			(1 << 15)
 #define USART_CR1_TE			(1 << 3)
include/dm/platform_data/serial_stm32x7.h deleted +0 -17
deleted file mode 100644
index 328a8a3..0000000
@@ -1,17 +0,0 @@
-/*
- * (C) Copyright 2016
- * Vikas Manocha, <[email protected]>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __SERIAL_STM32x7_H
-#define __SERIAL_STM32x7_H
-
-/* Information about a serial port */
-struct stm32x7_serial_platdata {
-	struct stm32_usart *base;  /* address of registers in physical memory */
-	unsigned int clock;
-};
-
-#endif /* __SERIAL_STM32x7_H */
Signature · 1 line
1.9.1
#12 lore raw

PATCH 6/9 serial: stm32x7: migrate serial struct to driver

Quoted 10 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

This allow to remove include/dm/platform_data/serial_stm32x7.h which was included in the past by stm32x7 driver and by stm32f746-disco.c board file.
Since patch 42bf5e7c27 "serial: stm32f7: add device tree support" this file is no more needed in board file.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/154b7f45/attachment.sig>
#13 lore raw

PATCH 7/9 serial: stm32x7: add clk_get_rate() support

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Replace proprietary clock_get() by clk_get_rate() The stm32x7 serial driver is now "generic" and can be used by other STM32 SoCs.

---
 drivers/serial/serial_stm32x7.c | 17 ++++++++---------
 drivers/serial/serial_stm32x7.h |  2 +-
 2 files changed, 9 insertions(+), 10 deletions(-)
drivers/serial/serial_stm32x7.c +8 -9
index 05c73da..bf118a7 100644
@@ -19,16 +19,9 @@ static int stm32_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct stm32x7_serial_platdata *plat = dev->platdata;
 	struct stm32_usart *const usart = plat->base;
-	u32  clock, int_div, mantissa, fraction, oversampling;
+	u32 int_div, mantissa, fraction, oversampling;
 
-	if (((u32)usart & STM32_BUS_MASK) == APB1_PERIPH_BASE)
-		clock = clock_get(CLOCK_APB1);
-	else if (((u32)usart & STM32_BUS_MASK) == APB2_PERIPH_BASE)
-		clock = clock_get(CLOCK_APB2);
-	else
-		return -EINVAL;
-
-	int_div = DIV_ROUND_CLOSEST(clock, baudrate);
+	int_div = DIV_ROUND_CLOSEST(plat->clock_rate, baudrate);
 
 	if (int_div < 16) {
 		oversampling = 8;
@@ -101,6 +94,12 @@ static int stm32_serial_probe(struct udevice *dev)
 	}
 #endif
 
+	plat->clock_rate = clk_get_rate(&clk);
+	if (plat->clock_rate < 0) {
+		clk_disable(&clk);
+		return plat->clock_rate;
+	};
+
 	/* Disable usart-> disable overrun-> enable usart */
 	clrbits_le32(&usart->cr1, USART_CR1_RE | USART_CR1_TE | USART_CR1_UE);
 	setbits_le32(&usart->cr3, USART_CR3_OVRDIS);
drivers/serial/serial_stm32x7.h +1 -1
index 42b05f1..9fe37af 100644
@@ -25,7 +25,7 @@ struct stm32_usart {
 /* Information about a serial port */
 struct stm32x7_serial_platdata {
 	struct stm32_usart *base;  /* address of registers in physical memory */
-	unsigned int clock;
+	unsigned long int clock_rate;
 };
 
 #define USART_CR1_OVER8			(1 << 15)
Signature · 1 line
1.9.1
#14 lore raw

PATCH 7/9 serial: stm32x7: add clk_get_rate() support

Quoted 8 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Replace proprietary clock_get() by clk_get_rate() The stm32x7 serial driver is now "generic" and can be used by other STM32 SoCs.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/12880cf2/attachment.sig>
#15 lore raw

PATCH 8/9 spi: stm32_qspi: add clk_get_rate() support

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Replace proprietary clock_get() by clk_get_rate() The stm32_qspi is now "generic" and can be used by other STM32 SoCs.

---
 drivers/spi/stm32_qspi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/spi/stm32_qspi.c +9 -1
index f0434a4..ef2b64e 100644
@@ -165,6 +165,7 @@ struct stm32_qspi_platdata {
 
 struct stm32_qspi_priv {
 	struct stm32_qspi_regs *regs;
+	ulong clock_rate;
 	u32 max_hz;
 	u32 mode;
 
@@ -471,6 +472,13 @@ static int stm32_qspi_probe(struct udevice *bus)
 		dev_err(bus, "failed to enable clock\n");
 		return ret;
 	}
+
+	priv->clock_rate = clk_get_rate(&clk);
+	if (priv->clock_rate < 0) {
+		clk_disable(&clk);
+		return priv->clock_rate;
+	}
+
 #endif
 
 	setbits_le32(&priv->regs->cr, STM32_QSPI_CR_SSHIFT);
@@ -536,7 +544,7 @@ static int stm32_qspi_set_speed(struct udevice *bus, uint speed)
 	if (speed > plat->max_hz)
 		speed = plat->max_hz;
 
-	u32 qspi_clk = clock_get(CLOCK_AHB);
+	u32 qspi_clk = priv->clock_rate;
 	u32 prescaler = 255;
 	if (speed > 0) {
 		prescaler = DIV_ROUND_UP(qspi_clk, speed) - 1;
Signature · 1 line
1.9.1
#16 lore raw

PATCH 8/9 spi: stm32_qspi: add clk_get_rate() support

Quoted 8 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

Replace proprietary clock_get() by clk_get_rate() The stm32_qspi is now "generic" and can be used by other STM32 SoCs.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/94e0a7a6/attachment.sig>
#17 lore raw

PATCH 9/9 clk: stm32f7: remove clock_get()

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

All drivers which was using clock_get() are now using clk_get_rate() from clock framework, now it's safe to remove clock_get().

---
 arch/arm/include/asm/arch-stm32f7/stm32.h |  6 ----
 drivers/clk/clk_stm32f7.c                 | 48 -------------------------------
 2 files changed, 54 deletions(-)
arch/arm/include/asm/arch-stm32f7/stm32.h +0 -6
index 12efee5..87aee60 100644
@@ -57,11 +57,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 	[5 ... 7] =	256 * 1024
 };
 
-enum clock {
-	CLOCK_AHB,
-	CLOCK_APB1,
-	CLOCK_APB2
-};
 #define STM32_BUS_MASK		GENMASK(31, 16)
 
 struct stm32_rcc_regs {
@@ -108,7 +103,6 @@ struct stm32_pwr_regs {
 };
 #define STM32_PWR		((struct stm32_pwr_regs *)PWR_BASE)
 
-unsigned long clock_get(enum clock clck);
 void stm32_flash_latency_cfg(int latency);
 
 #endif /* _ASM_ARCH_HARDWARE_H */
drivers/clk/clk_stm32f7.c +0 -48

54 lines not on this page · raw message

Signature · 1 line
1.9.1
#18 lore raw

PATCH 9/9 clk: stm32f7: remove clock_get()

Quoted 8 lines · Patrice Chotard

From: Patrice Chotard <[email protected]>

All drivers which was using clock_get() are now using clk_get_rate() from clock framework, now it's safe to remove clock_get().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/f94e0410/attachment.sig>