diff options
author | Yang Ling <gnaygnil@gmail.com> | 2016-09-05 22:11:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2016-10-04 10:13:57 -0400 |
commit | 60219c563c9b62aac237631a7c9aa092e8396138 (patch) | |
tree | 128403687dec398acf1e4656c2030f9c180f6735 | |
parent | 9f3b8081a4763022ccfabaffc485094be0064fa4 (diff) |
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 <gnaygnil@gmail.com>
Cc: keguang.zhang@gmail.com
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14214/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/mach-loongson32/platform.h | 1 | ||||
-rw-r--r-- | arch/mips/loongson32/common/platform.c | 13 | ||||
-rw-r--r-- | arch/mips/loongson32/ls1c/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/loongson32/ls1c/board.c | 9 |
4 files changed, 19 insertions, 6 deletions
diff --git a/arch/mips/include/asm/mach-loongson32/platform.h b/arch/mips/include/asm/mach-loongson32/platform.h index 672531aa9bef..7adc31364939 100644 --- a/arch/mips/include/asm/mach-loongson32/platform.h +++ b/arch/mips/include/asm/mach-loongson32/platform.h | |||
@@ -30,5 +30,6 @@ void __init ls1x_clk_init(void); | |||
30 | void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata); | 30 | void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata); |
31 | void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata); | 31 | void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata); |
32 | void __init ls1x_serial_set_uartclk(struct platform_device *pdev); | 32 | void __init ls1x_serial_set_uartclk(struct platform_device *pdev); |
33 | void __init ls1x_rtc_set_extclk(struct platform_device *pdev); | ||
33 | 34 | ||
34 | #endif /* __ASM_MACH_LOONGSON32_PLATFORM_H */ | 35 | #endif /* __ASM_MACH_LOONGSON32_PLATFORM_H */ |
diff --git a/arch/mips/loongson32/common/platform.c b/arch/mips/loongson32/common/platform.c index 4d12e365dcb0..beff0852c6a4 100644 --- a/arch/mips/loongson32/common/platform.c +++ b/arch/mips/loongson32/common/platform.c | |||
@@ -23,6 +23,10 @@ | |||
23 | #include <dma.h> | 23 | #include <dma.h> |
24 | #include <nand.h> | 24 | #include <nand.h> |
25 | 25 | ||
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 | |||
26 | /* 8250/16550 compatible UART */ | 30 | /* 8250/16550 compatible UART */ |
27 | #define LS1X_UART(_id) \ | 31 | #define LS1X_UART(_id) \ |
28 | { \ | 32 | { \ |
@@ -66,6 +70,15 @@ void __init ls1x_serial_set_uartclk(struct platform_device *pdev) | |||
66 | p->uartclk = clk_get_rate(clk); | 70 | p->uartclk = clk_get_rate(clk); |
67 | } | 71 | } |
68 | 72 | ||
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 | |||
69 | /* CPUFreq */ | 82 | /* CPUFreq */ |
70 | static struct plat_ls1x_cpufreq ls1x_cpufreq_pdata = { | 83 | static struct plat_ls1x_cpufreq ls1x_cpufreq_pdata = { |
71 | .clk_name = "cpu_clk", | 84 | .clk_name = "cpu_clk", |
diff --git a/arch/mips/loongson32/ls1c/Makefile b/arch/mips/loongson32/ls1c/Makefile index 891eac482b82..a92c6cd3418d 100644 --- a/arch/mips/loongson32/ls1c/Makefile +++ b/arch/mips/loongson32/ls1c/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # Makefile for loongson1B based machines. | 2 | # Makefile for loongson1C based machines. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += board.o | 5 | obj-y += board.o |
diff --git a/arch/mips/loongson32/ls1c/board.c b/arch/mips/loongson32/ls1c/board.c index 3d69bd63ad56..a96bed5e3ea6 100644 --- a/arch/mips/loongson32/ls1c/board.c +++ b/arch/mips/loongson32/ls1c/board.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2016 Ling Yang <gnaygnil@gmail.com> | 2 | * Copyright (c) 2016 Yang Ling <gnaygnil@gmail.com> |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
@@ -12,17 +12,16 @@ | |||
12 | static struct platform_device *ls1c_platform_devices[] __initdata = { | 12 | static struct platform_device *ls1c_platform_devices[] __initdata = { |
13 | &ls1x_uart_pdev, | 13 | &ls1x_uart_pdev, |
14 | &ls1x_eth0_pdev, | 14 | &ls1x_eth0_pdev, |
15 | &ls1x_rtc_pdev, | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | static int __init ls1c_platform_init(void) | 18 | static int __init ls1c_platform_init(void) |
18 | { | 19 | { |
19 | int err; | ||
20 | |||
21 | ls1x_serial_set_uartclk(&ls1x_uart_pdev); | 20 | ls1x_serial_set_uartclk(&ls1x_uart_pdev); |
21 | ls1x_rtc_set_extclk(&ls1x_rtc_pdev); | ||
22 | 22 | ||
23 | err = platform_add_devices(ls1c_platform_devices, | 23 | return platform_add_devices(ls1c_platform_devices, |
24 | ARRAY_SIZE(ls1c_platform_devices)); | 24 | ARRAY_SIZE(ls1c_platform_devices)); |
25 | return err; | ||
26 | } | 25 | } |
27 | 26 | ||
28 | arch_initcall(ls1c_platform_init); | 27 | arch_initcall(ls1c_platform_init); |