All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board
@ 2016-01-27  2:12 Vikas Manocha
  2016-01-27 22:53 ` Simon Glass
  2016-02-08 20:46 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Vikas Manocha @ 2016-01-27  2:12 UTC (permalink / raw)
  To: u-boot

This patch removes the uart clock enable from serial driver & move it in the
board code.

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
---
 arch/arm/include/asm/arch-stm32f4/stm32_defs.h     | 15 ++++++++
 arch/arm/include/asm/arch-stm32f4/stm32_periph.h   | 27 +++++++++++++++
 arch/arm/mach-stm32/stm32f4/clock.c                | 20 +++++++++++
 board/st/stm32f429-discovery/stm32f429-discovery.c |  3 ++
 drivers/serial/serial_stm32.c                      | 40 ----------------------
 5 files changed, 65 insertions(+), 40 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-stm32f4/stm32_defs.h
 create mode 100644 arch/arm/include/asm/arch-stm32f4/stm32_periph.h

diff --git a/arch/arm/include/asm/arch-stm32f4/stm32_defs.h b/arch/arm/include/asm/arch-stm32f4/stm32_defs.h
new file mode 100644
index 0000000..29b98ae
--- /dev/null
+++ b/arch/arm/include/asm/arch-stm32f4/stm32_defs.h
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2016
+ * Vikas Manocha, ST Micoelectronics, vikas.manocha at st.com.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __STM32_DEFS_H__
+#define __STM32_DEFS_H__
+#include <asm/arch/stm32_periph.h>
+
+int clock_setup(enum periph_clock);
+
+#endif
+
diff --git a/arch/arm/include/asm/arch-stm32f4/stm32_periph.h b/arch/arm/include/asm/arch-stm32f4/stm32_periph.h
new file mode 100644
index 0000000..a1af25c
--- /dev/null
+++ b/arch/arm/include/asm/arch-stm32f4/stm32_periph.h
@@ -0,0 +1,27 @@
+/*
+ * (C) Copyright 2016
+ * Vikas Manocha, ST Micoelectronics, vikas.manocha at st.com.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_ARM_ARCH_PERIPH_H
+#define __ASM_ARM_ARCH_PERIPH_H
+
+/*
+ * Peripherals required for pinmux configuration. List will
+ * grow with support for more devices getting added.
+ * Numbering based on interrupt table.
+ *
+ */
+enum periph_id {
+	UART1_GPIOA_9_10 = 0,
+	UART2_GPIOD_5_6,
+};
+
+enum periph_clock {
+	USART1_CLOCK_CFG = 0,
+	USART2_CLOCK_CFG,
+};
+
+#endif /* __ASM_ARM_ARCH_PERIPH_H */
diff --git a/arch/arm/mach-stm32/stm32f4/clock.c b/arch/arm/mach-stm32/stm32f4/clock.c
index 3deb17a..576d3e6 100644
--- a/arch/arm/mach-stm32/stm32f4/clock.c
+++ b/arch/arm/mach-stm32/stm32f4/clock.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/stm32.h>
+#include <asm/arch/stm32_periph.h>
 
 #define RCC_CR_HSION		(1 << 0)
 #define RCC_CR_HSEON		(1 << 16)
@@ -50,6 +51,14 @@
 
 #define RCC_APB1ENR_PWREN	(1 << 28)
 
+/*
+ * RCC USART specific definitions
+ */
+#define RCC_ENR_USART1EN		(1 << 4)
+#define RCC_ENR_USART2EN		(1 << 17)
+#define RCC_ENR_USART3EN		(1 << 18)
+#define RCC_ENR_USART6EN		(1 <<  5)
+
 #define PWR_CR_VOS0		(1 << 14)
 #define PWR_CR_VOS1		(1 << 15)
 #define PWR_CR_VOS_MASK		0xC000
@@ -221,3 +230,14 @@ unsigned long clock_get(enum clock clck)
 		break;
 	}
 }
+
+void clock_setup(int peripheral)
+{
+	switch (peripheral) {
+	case USART1_CLOCK_CFG:
+		setbits_le32(&STM32_RCC->apb2enr, RCC_ENR_USART1EN);
+		break;
+	default:
+		break;
+	}
+}
diff --git a/board/st/stm32f429-discovery/stm32f429-discovery.c b/board/st/stm32f429-discovery/stm32f429-discovery.c
index 8bc2d9e..fb8475f 100644
--- a/board/st/stm32f429-discovery/stm32f429-discovery.c
+++ b/board/st/stm32f429-discovery/stm32f429-discovery.c
@@ -19,6 +19,8 @@
 #include <asm/arch/fmc.h>
 #include <dm/platdata.h>
 #include <dm/platform_data/serial_stm32.h>
+#include <asm/arch/stm32_periph.h>
+#include <asm/arch/stm32_defs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -286,6 +288,7 @@ int board_early_init_f(void)
 	res = uart_setup_gpio();
 	if (res)
 		return res;
+	clock_setup(USART1_CLOCK_CFG);
 
 	return 0;
 }
diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index 91a5dde..c793ba6 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -35,24 +35,6 @@ struct stm32_usart {
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define MAX_SERIAL_PORTS		4
-
-/*
- * RCC USART specific definitions
- */
-#define RCC_ENR_USART1EN		(1 << 4)
-#define RCC_ENR_USART2EN		(1 << 17)
-#define RCC_ENR_USART3EN		(1 << 18)
-#define RCC_ENR_USART6EN		(1 <<  5)
-
-/* Array used to figure out which RCC bit needs to be set */
-static const unsigned long usart_port_rcc_pairs[MAX_SERIAL_PORTS][2] = {
-	{ STM32_USART1_BASE, RCC_ENR_USART1EN },
-	{ STM32_USART2_BASE, RCC_ENR_USART2EN },
-	{ STM32_USART3_BASE, RCC_ENR_USART3EN },
-	{ STM32_USART6_BASE, RCC_ENR_USART6EN }
-};
-
 static int stm32_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct stm32_serial_platdata *plat = dev->platdata;
@@ -114,28 +96,6 @@ static int stm32_serial_probe(struct udevice *dev)
 {
 	struct stm32_serial_platdata *plat = dev->platdata;
 	struct stm32_usart *const usart = plat->base;
-	int usart_port = -1;
-	int i;
-
-	for (i = 0; i < MAX_SERIAL_PORTS; i++) {
-		if ((u32)usart == usart_port_rcc_pairs[i][0]) {
-			usart_port = i;
-			break;
-		}
-	}
-
-	if (usart_port == -1)
-		return -EINVAL;
-
-	if (((u32)usart & STM32_BUS_MASK) == STM32_APB1PERIPH_BASE)
-		setbits_le32(&STM32_RCC->apb1enr,
-			     usart_port_rcc_pairs[usart_port][1]);
-	else if (((u32)usart & STM32_BUS_MASK) == STM32_APB2PERIPH_BASE)
-		setbits_le32(&STM32_RCC->apb2enr,
-			     usart_port_rcc_pairs[usart_port][1]);
-	else
-		return -EINVAL;
-
 	setbits_le32(&usart->cr1, USART_CR1_RE | USART_CR1_TE | USART_CR1_UE);
 
 	return 0;
-- 
1.9.1

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

* [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board
  2016-01-27  2:12 [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board Vikas Manocha
@ 2016-01-27 22:53 ` Simon Glass
  2016-01-27 22:57   ` Vikas MANOCHA
  2016-02-08 18:24   ` Vikas MANOCHA
  2016-02-08 20:46 ` [U-Boot] " Tom Rini
  1 sibling, 2 replies; 5+ messages in thread
From: Simon Glass @ 2016-01-27 22:53 UTC (permalink / raw)
  To: u-boot

On 26 January 2016 at 19:12, Vikas Manocha <vikas.manocha@st.com> wrote:
> This patch removes the uart clock enable from serial driver & move it in the
> board code.
>
> Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
> ---
>  arch/arm/include/asm/arch-stm32f4/stm32_defs.h     | 15 ++++++++
>  arch/arm/include/asm/arch-stm32f4/stm32_periph.h   | 27 +++++++++++++++
>  arch/arm/mach-stm32/stm32f4/clock.c                | 20 +++++++++++
>  board/st/stm32f429-discovery/stm32f429-discovery.c |  3 ++
>  drivers/serial/serial_stm32.c                      | 40 ----------------------
>  5 files changed, 65 insertions(+), 40 deletions(-)
>  create mode 100644 arch/arm/include/asm/arch-stm32f4/stm32_defs.h
>  create mode 100644 arch/arm/include/asm/arch-stm32f4/stm32_periph.h

Reviewed-by: Simon Glass <sjg@chromium.org>

You might consider adding a clock driver.

- Simon

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

* [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board
  2016-01-27 22:53 ` Simon Glass
@ 2016-01-27 22:57   ` Vikas MANOCHA
  2016-02-08 18:24   ` Vikas MANOCHA
  1 sibling, 0 replies; 5+ messages in thread
From: Vikas MANOCHA @ 2016-01-27 22:57 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
> Sent: Wednesday, January 27, 2016 2:54 PM
> To: Vikas MANOCHA
> Cc: Albert ARIBAUD; Kamil Lulko; U-Boot Mailing List; Peter Griffin; Antonio
> Borneo; rev13 at wp.pl; kunhuahuang
> Subject: Re: [PATCH] serial: serial_stm32: move clock config from driver to
> board
> 
> On 26 January 2016 at 19:12, Vikas Manocha <vikas.manocha@st.com>
> wrote:
> > This patch removes the uart clock enable from serial driver & move it
> > in the board code.
> >
> > Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
> > ---
> >  arch/arm/include/asm/arch-stm32f4/stm32_defs.h     | 15 ++++++++
> >  arch/arm/include/asm/arch-stm32f4/stm32_periph.h   | 27
> +++++++++++++++
> >  arch/arm/mach-stm32/stm32f4/clock.c                | 20 +++++++++++
> >  board/st/stm32f429-discovery/stm32f429-discovery.c |  3 ++
> >  drivers/serial/serial_stm32.c                      | 40 ----------------------
> >  5 files changed, 65 insertions(+), 40 deletions(-)  create mode
> > 100644 arch/arm/include/asm/arch-stm32f4/stm32_defs.h
> >  create mode 100644 arch/arm/include/asm/arch-stm32f4/stm32_periph.h
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks for reviewing.

> 
> You might consider adding a clock driver.

Yes, I agree. After some cleanup, I am planning to add support for clock and pinmux driver.

Rgds,
Vikas

> 
> - Simon

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

* [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board
  2016-01-27 22:53 ` Simon Glass
  2016-01-27 22:57   ` Vikas MANOCHA
@ 2016-02-08 18:24   ` Vikas MANOCHA
  1 sibling, 0 replies; 5+ messages in thread
From: Vikas MANOCHA @ 2016-02-08 18:24 UTC (permalink / raw)
  To: u-boot

Hi Tom/Kamil,

Can you please apply this patch.

Cheers,
Vikas

> -----Original Message-----
> From: Vikas MANOCHA
> Sent: Wednesday, January 27, 2016 2:58 PM
> To: 'Simon Glass'
> Cc: Albert ARIBAUD; Kamil Lulko; U-Boot Mailing List; Peter Griffin; Antonio
> Borneo; rev13 at wp.pl; kunhuahuang
> Subject: RE: [PATCH] serial: serial_stm32: move clock config from driver to
> board
> 
> Hi Simon,
> 
> > -----Original Message-----
> > From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
> > Sent: Wednesday, January 27, 2016 2:54 PM
> > To: Vikas MANOCHA
> > Cc: Albert ARIBAUD; Kamil Lulko; U-Boot Mailing List; Peter Griffin;
> > Antonio Borneo; rev13 at wp.pl; kunhuahuang
> > Subject: Re: [PATCH] serial: serial_stm32: move clock config from
> > driver to board
> >
> > On 26 January 2016 at 19:12, Vikas Manocha <vikas.manocha@st.com>
> > wrote:
> > > This patch removes the uart clock enable from serial driver & move
> > > it in the board code.
> > >
> > > Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
> > > ---
> > >  arch/arm/include/asm/arch-stm32f4/stm32_defs.h     | 15 ++++++++
> > >  arch/arm/include/asm/arch-stm32f4/stm32_periph.h   | 27
> > +++++++++++++++
> > >  arch/arm/mach-stm32/stm32f4/clock.c                | 20 +++++++++++
> > >  board/st/stm32f429-discovery/stm32f429-discovery.c |  3 ++
> > >  drivers/serial/serial_stm32.c                      | 40 ----------------------
> > >  5 files changed, 65 insertions(+), 40 deletions(-)  create mode
> > > 100644 arch/arm/include/asm/arch-stm32f4/stm32_defs.h
> > >  create mode 100644 arch/arm/include/asm/arch-
> stm32f4/stm32_periph.h
> >
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Thanks for reviewing.
> 
> >
> > You might consider adding a clock driver.
> 
> Yes, I agree. After some cleanup, I am planning to add support for clock and
> pinmux driver.
> 
> Rgds,
> Vikas
> 
> >
> > - Simon

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

* [U-Boot] serial: serial_stm32: move clock config from driver to board
  2016-01-27  2:12 [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board Vikas Manocha
  2016-01-27 22:53 ` Simon Glass
@ 2016-02-08 20:46 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2016-02-08 20:46 UTC (permalink / raw)
  To: u-boot

On Tue, Jan 26, 2016 at 06:12:20PM -0800, Vikas Manocha wrote:

> This patch removes the uart clock enable from serial driver & move it in the
> board code.
> 
> Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160208/ca8119c3/attachment.sig>

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

end of thread, other threads:[~2016-02-08 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27  2:12 [U-Boot] [PATCH] serial: serial_stm32: move clock config from driver to board Vikas Manocha
2016-01-27 22:53 ` Simon Glass
2016-01-27 22:57   ` Vikas MANOCHA
2016-02-08 18:24   ` Vikas MANOCHA
2016-02-08 20:46 ` [U-Boot] " Tom Rini

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.