commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=e870d29242311df700415c08c8549308585f783f
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Steven Miao <[email protected]>
Signed-off-by: Bob Liu <[email protected]>
---
 arch/blackfin/kernel/setup.c   |   32 +++++++++++++++++---------------
 drivers/tty/serial/bfin_uart.c |   17 ++++++++++++-----
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 562c270..b0c1b54 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -25,6 +25,7 @@
 #include <asm/cacheflush.h>
 #include <asm/blackfin.h>
 #include <asm/cplbinit.h>
+#include <asm/clocks.h>
 #include <asm/div64.h>
 #include <asm/cpu.h>
 #include <asm/fixed_code.h>
@@ -870,6 +871,7 @@ void __init setup_arch(char **cmdline_p)
 {
 	u32 mmr;
 	unsigned long sclk, cclk;
+	struct clk *clk;
 
 	native_machine_early_platform_add_devices();
 
@@ -930,8 +932,20 @@ void __init setup_arch(char **cmdline_p)
 					~HYST_NONEGPIO_MASK) | HYST_NONEGPIO);
 #endif
 
-	cclk = get_cclk();
-	sclk = get_sclk();
+#ifdef CONFIG_BF60x
+	clk_init();
+#endif
+	clk = clk_get(NULL, "CCLK");
+	if (!IS_ERR(clk)) {
+		cclk = clk_get_rate(clk);
+		clk_put(clk);
+	}
+
+	clk = clk_get(NULL, "SCLK0");
+	if (!IS_ERR(clk)) {
+		sclk = clk_get_rate(clk);
+		clk_put(clk);
+	}
 
 	if ((ANOMALY_05000273 || ANOMALY_05000274) && (cclk >> 1) < sclk)
 		panic("ANOMALY 05000273 or 05000274: CCLK must be >= 2*SCLK");
@@ -1089,11 +1103,7 @@ static u_long get_vco(void)
 {
 	static u_long cached_vco;
 #ifdef CONFIG_BF60x
-# ifdef CONFIG_BF609_FPGA
 	return CONFIG_CLKIN_HZ;
-# else
-	return cached_vco;
-# endif
 #else
 	u_long msel, pll_ctl;
 
@@ -1120,11 +1130,7 @@ u_long get_cclk(void)
 {
 	static u_long cached_cclk_pll_div, cached_cclk;
 #ifdef CONFIG_BF60x
-# ifdef CONFIG_BF609_FPGA
-	return get_vco() / 6;
-# else
-	return cached_cclk;
-# endif
+	return get_vco() * 16;
 #else
 	u_long csel, ssel;
 
@@ -1153,11 +1159,7 @@ u_long get_sclk(void)
 {
 	static u_long cached_sclk;
 #ifdef CONFIG_BF60x
-# ifdef CONFIG_BF609_FPGA
 	return get_cclk() / 4;
-# else
-	return cached_sclk;
-# endif
 #else
 	u_long ssel;
 
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 87cb095..0a90ee2 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -15,6 +15,7 @@
 #define DRIVER_NAME "bfin-uart"
 #define pr_fmt(fmt) DRIVER_NAME ": " fmt
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/gfp.h>
@@ -865,7 +866,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
 			port->ignore_status_mask |= OE;
 	}
 
-#ifdef CONFIG_BF609_FPGA
+#if defined(CONFIG_BF60x)
 	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk);
 	quot = uart_get_divisor(port, baud/16);
 #else
@@ -886,7 +887,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
 	/* Set DLAB in LCR to Access CLK */
 	UART_SET_DLAB(uart);
 
-#ifdef CONFIG_BF609_FPGA
+#if defined(CONFIG_BF60x)
 	UART_PUT_CLK(uart, quot | EDBO);
 #else
 	UART_PUT_CLK(uart, quot);
@@ -1117,7 +1118,7 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
 		/* Clear DLAB in LCR to Access THR RBR IER */
 		UART_CLEAR_DLAB(uart);
 
-#ifdef CONFIG_BF609_FPGA
+#if defined(CONFIG_BF60x)
 		*baud = get_sclk() / clk;
 #else
 		*baud = get_sclk() / (16*clk);
@@ -1270,6 +1271,7 @@ static int bfin_serial_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct bfin_serial_port *uart = NULL;
 	int ret = 0;
+	struct clk *uart_clk;
 
 	if (pdev->id < 0 || pdev->id >= BFIN_UART_NR_PORTS) {
 		dev_err(&pdev->dev, "Wrong bfin uart platform device id.\n");
@@ -1304,9 +1306,12 @@ static int bfin_serial_probe(struct platform_device *pdev)
 #ifdef CONFIG_EARLY_PRINTK
 		}
 #endif
-
 		spin_lock_init(&uart->port.lock);
-		uart->port.uartclk   = get_sclk();
+		uart_clk = clk_get(NULL, "SCLK0");
+		if (!IS_ERR(uart_clk)) {
+			uart->port.uartclk   = clk_get_rate(uart_clk);
+			clk_put(uart_clk);
+		}
 		uart->port.fifosize  = BFIN_UART_TX_FIFO_SIZE;
 		uart->port.ops       = &bfin_serial_pops;
 		uart->port.line      = pdev->id;
@@ -1511,6 +1516,8 @@ static int bfin_earlyprintk_probe(struct platform_device *pdev)
 	bfin_earlyprintk_port.port.mapbase = res->start;
 	bfin_earlyprintk_port.port.line = pdev->id;
 	bfin_earlyprintk_port.port.uartclk = get_sclk();
+	bfin_write_UART0_CLK(0x800006c8);
+
 	bfin_earlyprintk_port.port.fifosize  = BFIN_UART_TX_FIFO_SIZE;
 	spin_lock_init(&bfin_earlyprintk_port.port.lock);
 
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to