All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] x86: baytrail: Add SIO HS-UART clock setup
@ 2016-07-19  5:41 Stefan Roese
  2016-08-01  0:45 ` Bin Meng
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Roese @ 2016-07-19  5:41 UTC (permalink / raw)
  To: u-boot

To support the BayTrail internal SIO HS UART, the internal UART clock
needs to get configured. This patch adds support for this clock
configuration which will be done, if the PCI device(s) are found.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
v2:
- Add loop over 2 UARTs

 arch/x86/cpu/baytrail/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/arch/x86/cpu/baytrail/cpu.c b/arch/x86/cpu/baytrail/cpu.c
index b1faf8c..2837709 100644
--- a/arch/x86/cpu/baytrail/cpu.c
+++ b/arch/x86/cpu/baytrail/cpu.c
@@ -9,12 +9,60 @@
 #include <common.h>
 #include <cpu.h>
 #include <dm.h>
+#include <pci.h>
 #include <asm/cpu.h>
 #include <asm/cpu_x86.h>
+#include <asm/io.h>
 #include <asm/lapic.h>
 #include <asm/msr.h>
 #include <asm/turbo.h>
 
+#define BYT_PRV_CLK			0x800
+#define BYT_PRV_CLK_EN			(1 << 0)
+#define BYT_PRV_CLK_M_VAL_SHIFT		1
+#define BYT_PRV_CLK_N_VAL_SHIFT		16
+#define BYT_PRV_CLK_UPDATE		(1 << 31)
+
+static void hsuart_clock_set(void *base)
+{
+	u32 m, n, reg;
+
+	/*
+	 * Configure the BayTrail UART clock for the internal HS UARTs
+	 * (PCI devices) to 58982400 Hz
+	 */
+	m = 0x2400;
+	n = 0x3d09;
+	reg = (m << BYT_PRV_CLK_M_VAL_SHIFT) | (n << BYT_PRV_CLK_N_VAL_SHIFT);
+	writel(reg, base + BYT_PRV_CLK);
+	reg |= BYT_PRV_CLK_EN | BYT_PRV_CLK_UPDATE;
+	writel(reg, base + BYT_PRV_CLK);
+}
+
+/*
+ * Configure the internal clock of both SIO HS-UARTs, if they are enabled
+ * via FSP
+ */
+int arch_cpu_init_dm(void)
+{
+	struct udevice *dev;
+	void *base;
+	int ret;
+	int i;
+
+	/* Loop over the 2 HS-UARTs */
+	for (i = 0; i < 2; i++) {
+		ret = dm_pci_bus_find_bdf(PCI_BDF(0, 0x1e, 3 + i), &dev);
+		if (!ret) {
+			base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
+					      PCI_REGION_MEM);
+			hsuart_clock_set(base);
+		}
+	}
+
+	return 0;
+}
+
 static void set_max_freq(void)
 {
 	msr_t perf_ctl;
-- 
2.9.2

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

* [U-Boot] [PATCH v2] x86: baytrail: Add SIO HS-UART clock setup
  2016-07-19  5:41 [U-Boot] [PATCH v2] x86: baytrail: Add SIO HS-UART clock setup Stefan Roese
@ 2016-08-01  0:45 ` Bin Meng
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Meng @ 2016-08-01  0:45 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 19, 2016 at 1:41 PM, Stefan Roese <sr@denx.de> wrote:
> To support the BayTrail internal SIO HS UART, the internal UART clock
> needs to get configured. This patch adds support for this clock
> configuration which will be done, if the PCI device(s) are found.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
> v2:
> - Add loop over 2 UARTs
>
>  arch/x86/cpu/baytrail/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>

applied to u-boot-x86, thanks!

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

end of thread, other threads:[~2016-08-01  0:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-19  5:41 [U-Boot] [PATCH v2] x86: baytrail: Add SIO HS-UART clock setup Stefan Roese
2016-08-01  0:45 ` Bin Meng

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.