Skip to content

Commit 60219c5

Browse files
gnaygnilralfbaechle
authored andcommitted
MIPS: Add RTC support for Loongson1C board
The patch adds RTC support for Loongson1C board, and enable the external crystal when the RTC is first powered up. Signed-off-by: Yang Ling <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/14214/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent 9f3b808 commit 60219c5

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

arch/mips/include/asm/mach-loongson32/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ void __init ls1x_clk_init(void);
3030
void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata);
3131
void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata);
3232
void __init ls1x_serial_set_uartclk(struct platform_device *pdev);
33+
void __init ls1x_rtc_set_extclk(struct platform_device *pdev);
3334

3435
#endif /* __ASM_MACH_LOONGSON32_PLATFORM_H */

arch/mips/loongson32/common/platform.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include <dma.h>
2424
#include <nand.h>
2525

26+
#define LS1X_RTC_CTRL ((void __iomem *)KSEG1ADDR(LS1X_RTC_BASE + 0x40))
27+
#define RTC_EXTCLK_OK (BIT(5) | BIT(8))
28+
#define RTC_EXTCLK_EN BIT(8)
29+
2630
/* 8250/16550 compatible UART */
2731
#define LS1X_UART(_id) \
2832
{ \
@@ -66,6 +70,15 @@ void __init ls1x_serial_set_uartclk(struct platform_device *pdev)
6670
p->uartclk = clk_get_rate(clk);
6771
}
6872

73+
void __init ls1x_rtc_set_extclk(struct platform_device *pdev)
74+
{
75+
u32 val;
76+
77+
val = __raw_readl(LS1X_RTC_CTRL);
78+
if (!(val & RTC_EXTCLK_OK))
79+
__raw_writel(val | RTC_EXTCLK_EN, LS1X_RTC_CTRL);
80+
}
81+
6982
/* CPUFreq */
7083
static struct plat_ls1x_cpufreq ls1x_cpufreq_pdata = {
7184
.clk_name = "cpu_clk",

arch/mips/loongson32/ls1c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Makefile for loongson1B based machines.
2+
# Makefile for loongson1C based machines.
33
#
44

55
obj-y += board.o

arch/mips/loongson32/ls1c/board.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016 Ling Yang <[email protected]>
2+
* Copyright (c) 2016 Yang Ling <[email protected]>
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the
@@ -12,17 +12,16 @@
1212
static struct platform_device *ls1c_platform_devices[] __initdata = {
1313
&ls1x_uart_pdev,
1414
&ls1x_eth0_pdev,
15+
&ls1x_rtc_pdev,
1516
};
1617

1718
static int __init ls1c_platform_init(void)
1819
{
19-
int err;
20-
2120
ls1x_serial_set_uartclk(&ls1x_uart_pdev);
21+
ls1x_rtc_set_extclk(&ls1x_rtc_pdev);
2222

23-
err = platform_add_devices(ls1c_platform_devices,
23+
return platform_add_devices(ls1c_platform_devices,
2424
ARRAY_SIZE(ls1c_platform_devices));
25-
return err;
2625
}
2726

2827
arch_initcall(ls1c_platform_init);

0 commit comments

Comments
 (0)