Skip to content

Commit 5a2fb71

Browse files
mlauss2ralfbaechle
authored andcommitted
MIPS: Alchemy: platform: use clk framework for uarts
Use the clock framework to get the rate of the peripheral clock. Remove the now obsolete get_uart_baud_base function. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Patchwork: https://patchwork.linux-mips.org/patch/7468/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 4744022 commit 5a2fb71

3 files changed

Lines changed: 12 additions & 22 deletions

File tree

‎arch/mips/alchemy/common/clocks.c‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#define AU1000_SRC_CLK 12000000
3939

4040
static unsigned int au1x00_clock; /* Hz */
41-
static unsigned long uart_baud_base;
4241

4342
/*
4443
* Set the au1000_clock
@@ -54,21 +53,6 @@ unsigned int get_au1x00_speed(void)
5453
}
5554
EXPORT_SYMBOL(get_au1x00_speed);
5655

57-
/*
58-
* The UART baud base is not known at compile time ... if
59-
* we want to be able to use the same code on different
60-
* speed CPUs.
61-
*/
62-
unsigned long get_au1x00_uart_baud_base(void)
63-
{
64-
return uart_baud_base;
65-
}
66-
67-
void set_au1x00_uart_baud_base(unsigned long new_baud_base)
68-
{
69-
uart_baud_base = new_baud_base;
70-
}
71-
7256
/*
7357
* We read the real processor speed from the PLL. This is important
7458
* because it is more accurate than computing it from the 32 KHz
@@ -95,9 +79,6 @@ unsigned long au1xxx_calc_clock(void)
9579

9680
/* On Alchemy CPU:counter ratio is 1:1 */
9781
mips_hpt_frequency = cpu_speed;
98-
/* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */
99-
set_au1x00_uart_baud_base(cpu_speed / (2 *
100-
((alchemy_rdsys(AU1000_SYS_POWERCTRL) & 0x03) + 2) * 16));
10182

10283
set_au1x00_speed(cpu_speed);
10384

‎arch/mips/alchemy/common/platform.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* warranty of any kind, whether express or implied.
1212
*/
1313

14+
#include <linux/clk.h>
1415
#include <linux/dma-mapping.h>
1516
#include <linux/etherdevice.h>
1617
#include <linux/init.h>
@@ -99,10 +100,20 @@ static struct platform_device au1xx0_uart_device = {
99100

100101
static void __init alchemy_setup_uarts(int ctype)
101102
{
102-
unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
103+
long uartclk;
103104
int s = sizeof(struct plat_serial8250_port);
104105
int c = alchemy_get_uarts(ctype);
105106
struct plat_serial8250_port *ports;
107+
struct clk *clk = clk_get(NULL, ALCHEMY_PERIPH_CLK);
108+
109+
if (IS_ERR(clk))
110+
return;
111+
if (clk_prepare_enable(clk)) {
112+
clk_put(clk);
113+
return;
114+
}
115+
uartclk = clk_get_rate(clk);
116+
clk_put(clk);
106117

107118
ports = kzalloc(s * (c + 1), GFP_KERNEL);
108119
if (!ports) {

‎arch/mips/include/asm/mach-au1x00/au1000.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,6 @@ static inline int alchemy_get_macs(int type)
844844
/* arch/mips/au1000/common/clocks.c */
845845
extern void set_au1x00_speed(unsigned int new_freq);
846846
extern unsigned int get_au1x00_speed(void);
847-
extern void set_au1x00_uart_baud_base(unsigned long new_baud_base);
848-
extern unsigned long get_au1x00_uart_baud_base(void);
849847
extern unsigned long au1xxx_calc_clock(void);
850848

851849
/* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */

0 commit comments

Comments
 (0)