Basically ensure all RS780E stuff is enabled by DeviceTree.
So I can post LS7A support later on.
Hi Thomas, could you please pick them into MIPS tree?
Thanks.
Jiaxun Yang (5):
MIPS: Loongson64: Remove dead RTC code
MIPS: Loongson64: Make RS780E ACPI as a platform driver
dt-bindings: Document Loongson RS780E PCH ACPI Controller
MIPS: DTS: Loongson64: Add ACPI Controller Node
MIPS: Loongson64: Mark RS780 HPET as broken
.../bindings/mips/loongson/rs780e-acpi.yaml | 40 +++++++++++++
arch/mips/boot/dts/loongson/rs780e-pch.dtsi | 5 ++
.../include/asm/mach-loongson64/mc146818rtc.h | 36 ------------
arch/mips/loongson64/Kconfig | 12 +---
arch/mips/loongson64/Makefile | 3 +-
arch/mips/loongson64/rtc.c | 39 -------------
arch/mips/loongson64/time.c | 8 +--
drivers/platform/mips/Kconfig | 6 ++
drivers/platform/mips/Makefile | 1 +
.../platform/mips/rs780e-acpi.c | 58 ++++++++++++-------
10 files changed, 95 insertions(+), 113 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mips/loongson/rs780e-acpi.yaml
delete mode 100644 arch/mips/include/asm/mach-loongson64/mc146818rtc.h
delete mode 100644 arch/mips/loongson64/rtc.c
rename arch/mips/loongson64/acpi_init.c => drivers/platform/mips/rs780e-acpi.c (70%)
--
2.26.0.rc2
RTC is now enabled by devicetree. So platform code is
no longer needed.
Signed-off-by: Jiaxun Yang <[email protected]>
---
.../include/asm/mach-loongson64/mc146818rtc.h | 36 -----------------
arch/mips/loongson64/Kconfig | 4 --
arch/mips/loongson64/Makefile | 1 -
arch/mips/loongson64/rtc.c | 39 -------------------
arch/mips/loongson64/time.c | 8 +---
5 files changed, 1 insertion(+), 87 deletions(-)
delete mode 100644 arch/mips/include/asm/mach-loongson64/mc146818rtc.h
delete mode 100644 arch/mips/loongson64/rtc.c
diff --git a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h b/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
deleted file mode 100644
index ebdccfee50be..000000000000
--- a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1998, 2001, 03, 07 by Ralf Baechle ([email protected])
- *
- * RTC routines for PC style attached Dallas chip.
- */
-#ifndef __ASM_MACH_LOONGSON64_MC146818RTC_H
-#define __ASM_MACH_LOONGSON64_MC146818RTC_H
-
-#include <linux/io.h>
-
-#define RTC_PORT(x) (0x70 + (x))
-#define RTC_IRQ 8
-
-static inline unsigned char CMOS_READ(unsigned long addr)
-{
- outb_p(addr, RTC_PORT(0));
- return inb_p(RTC_PORT(1));
-}
-
-static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
-{
- outb_p(addr, RTC_PORT(0));
- outb_p(data, RTC_PORT(1));
-}
-
-#define RTC_ALWAYS_BCD 0
-
-#ifndef mc146818_decode_year
-#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
-#endif
-
-#endif /* __ASM_MACH_LOONGSON64_MC146818RTC_H */
diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
index 48b29c198acf..c386b8a3c753 100644
--- a/arch/mips/loongson64/Kconfig
+++ b/arch/mips/loongson64/Kconfig
@@ -14,8 +14,4 @@ config RS780_HPET
If unsure, say Yes.
-config LOONGSON_MC146818
- bool
- default n
-
endif # MACH_LOONGSON64
diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile
index f04461839540..102a19aa92aa 100644
--- a/arch/mips/loongson64/Makefile
+++ b/arch/mips/loongson64/Makefile
@@ -8,6 +8,5 @@ obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_NUMA) += numa.o
obj-$(CONFIG_RS780_HPET) += hpet.o
-obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
obj-$(CONFIG_SUSPEND) += pm.o
obj-$(CONFIG_PCI_QUIRKS) += vbios_quirk.o
diff --git a/arch/mips/loongson64/rtc.c b/arch/mips/loongson64/rtc.c
deleted file mode 100644
index 8d7628c0f513..000000000000
--- a/arch/mips/loongson64/rtc.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Lemote Fuloong platform support
- *
- * Copyright(c) 2010 Arnaud Patard <[email protected]>
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/mc146818rtc.h>
-
-static struct resource loongson_rtc_resources[] = {
- {
- .start = RTC_PORT(0),
- .end = RTC_PORT(1),
- .flags = IORESOURCE_IO,
- }, {
- .start = RTC_IRQ,
- .end = RTC_IRQ,
- .flags = IORESOURCE_IRQ,
- }
-};
-
-static struct platform_device loongson_rtc_device = {
- .name = "rtc_cmos",
- .id = -1,
- .resource = loongson_rtc_resources,
- .num_resources = ARRAY_SIZE(loongson_rtc_resources),
-};
-
-
-static int __init loongson_rtc_platform_init(void)
-{
- platform_device_register(&loongson_rtc_device);
- return 0;
-}
-
-device_initcall(loongson_rtc_platform_init);
diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
index 1245f22cec84..91e842b58365 100644
--- a/arch/mips/loongson64/time.c
+++ b/arch/mips/loongson64/time.c
@@ -6,7 +6,7 @@
* Copyright (C) 2009 Lemote Inc.
* Author: Wu Zhangjin, [email protected]
*/
-#include <asm/mc146818-time.h>
+
#include <asm/time.h>
#include <asm/hpet.h>
@@ -21,9 +21,3 @@ void __init plat_time_init(void)
setup_hpet_timer();
#endif
}
-
-void read_persistent_clock64(struct timespec64 *ts)
-{
- ts->tv_sec = mc146818_get_cmos_time();
- ts->tv_nsec = 0;
-}
--
2.26.0.rc2
Make RS780E ACPI as a platform driver so we can enable it
by DeviceTree selectively.
Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/loongson64/Makefile | 2 +-
drivers/platform/mips/Kconfig | 6 ++
drivers/platform/mips/Makefile | 1 +
.../platform/mips/rs780e-acpi.c | 58 ++++++++++++-------
4 files changed, 46 insertions(+), 21 deletions(-)
rename arch/mips/loongson64/acpi_init.c => drivers/platform/mips/rs780e-acpi.c (70%)
diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile
index 102a19aa92aa..6f81b822aeae 100644
--- a/arch/mips/loongson64/Makefile
+++ b/arch/mips/loongson64/Makefile
@@ -2,7 +2,7 @@
#
# Makefile for Loongson-3 family machines
#
-obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \
+obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o dma.o \
setup.o init.o env.o time.o reset.o \
obj-$(CONFIG_SMP) += smp.o
diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig
index 5e77b0dc5fd6..8ac149173c64 100644
--- a/drivers/platform/mips/Kconfig
+++ b/drivers/platform/mips/Kconfig
@@ -24,4 +24,10 @@ config CPU_HWMON
help
Loongson-3A/3B CPU Hwmon (temperature sensor) driver.
+config RS780E_ACPI
+ bool "Loongson RS780E ACPI Controller"
+ depends on MACH_LOONGSON64 || COMPILE_TEST
+ help
+ Loongson RS780E PCH ACPI Controller driver.
+
endif # MIPS_PLATFORM_DEVICES
diff --git a/drivers/platform/mips/Makefile b/drivers/platform/mips/Makefile
index be8146c20dc8..178149098777 100644
--- a/drivers/platform/mips/Makefile
+++ b/drivers/platform/mips/Makefile
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
+obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
diff --git a/arch/mips/loongson64/acpi_init.c b/drivers/platform/mips/rs780e-acpi.c
similarity index 70%
rename from arch/mips/loongson64/acpi_init.c
rename to drivers/platform/mips/rs780e-acpi.c
index 8d7c119ddf91..e5a643b78ac9 100644
--- a/arch/mips/loongson64/acpi_init.c
+++ b/drivers/platform/mips/rs780e-acpi.c
@@ -3,32 +3,23 @@
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/export.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
-#define SBX00_ACPI_IO_BASE 0x800
-#define SBX00_ACPI_IO_SIZE 0x100
+static unsigned long acpi_iobase;
-#define ACPI_PM_EVT_BLK (SBX00_ACPI_IO_BASE + 0x00) /* 4 bytes */
-#define ACPI_PM_CNT_BLK (SBX00_ACPI_IO_BASE + 0x04) /* 2 bytes */
-#define ACPI_PMA_CNT_BLK (SBX00_ACPI_IO_BASE + 0x0F) /* 1 byte */
-#define ACPI_PM_TMR_BLK (SBX00_ACPI_IO_BASE + 0x18) /* 4 bytes */
-#define ACPI_GPE0_BLK (SBX00_ACPI_IO_BASE + 0x10) /* 8 bytes */
-#define ACPI_END (SBX00_ACPI_IO_BASE + 0x80)
+#define ACPI_PM_EVT_BLK (acpi_iobase + 0x00) /* 4 bytes */
+#define ACPI_PM_CNT_BLK (acpi_iobase + 0x04) /* 2 bytes */
+#define ACPI_PMA_CNT_BLK (acpi_iobase + 0x0F) /* 1 byte */
+#define ACPI_PM_TMR_BLK (acpi_iobase + 0x18) /* 4 bytes */
+#define ACPI_GPE0_BLK (acpi_iobase + 0x10) /* 8 bytes */
+#define ACPI_END (acpi_iobase + 0x80)
#define PM_INDEX 0xCD6
#define PM_DATA 0xCD7
#define PM2_INDEX 0xCD0
#define PM2_DATA 0xCD1
-/*
- * SCI interrupt need acpi space, allocate here
- */
-
-static int __init register_acpi_resource(void)
-{
- request_region(SBX00_ACPI_IO_BASE, SBX00_ACPI_IO_SIZE, "acpi");
- return 0;
-}
-
static void pmio_write_index(u16 index, u8 reg, u8 value)
{
outb(reg, index);
@@ -141,11 +132,38 @@ void acpi_registers_setup(void)
pm2_iowrite(0xf8, value);
}
-int __init sbx00_acpi_init(void)
+static int rs780e_acpi_probe(struct platform_device *pdev)
{
- register_acpi_resource();
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -ENODEV;
+
+ /* SCI interrupt need acpi space, allocate here */
+ if (!request_region(res->start, resource_size(res), "acpi")) {
+ pr_err("RS780E-ACPI: Failed to request IO Region\n");
+ return -EBUSY;
+ }
+
+ acpi_iobase = res->start;
+
acpi_registers_setup();
acpi_hw_clear_status();
return 0;
}
+
+static const struct of_device_id rs780e_acpi_match[] = {
+ { .compatible = "loongson,rs780e-acpi" },
+ {},
+};
+
+static struct platform_driver rs780e_acpi_driver = {
+ .probe = rs780e_acpi_probe,
+ .driver = {
+ .name = "RS780E-ACPI",
+ .of_match_table = rs780e_acpi_match,
+ },
+};
+builtin_platform_driver(rs780e_acpi_driver);
--
2.26.0.rc2
This controller is attached under ISA Bus and can be found
in Loongson-3 systems with RS780E PCH.
Signed-off-by: Jiaxun Yang <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
---
.../bindings/mips/loongson/rs780e-acpi.yaml | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mips/loongson/rs780e-acpi.yaml
diff --git a/Documentation/devicetree/bindings/mips/loongson/rs780e-acpi.yaml b/Documentation/devicetree/bindings/mips/loongson/rs780e-acpi.yaml
new file mode 100644
index 000000000000..d317897e1115
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/loongson/rs780e-acpi.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/mips/loongson/rs780e-acpi.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Loongson RS780E PCH ACPI Controller
+
+maintainers:
+ - Jiaxun Yang <[email protected]>
+
+description: |
+ This controller can be found in Loongson-3 systems with RS780E PCH.
+
+properties:
+ compatible:
+ const: loongson,rs780e-acpi
+
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+examples:
+ - |
+ isa@0 {
+ compatible = "isa";
+ #address-cells = <2>;
+ #size-cells = <1>;
+ ranges = <1 0 0 0x1000>;
+
+ acpi@800 {
+ compatible = "loongson,rs780e-acpi";
+ reg = <1 0x800 0x100>;
+ };
+ };
+
+...
--
2.26.0.rc2
Add ACPI Controller Node for RS780E PCH to fit newly added driver.
Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/boot/dts/loongson/rs780e-pch.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/mips/boot/dts/loongson/rs780e-pch.dtsi b/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
index 8766f97306c6..5e68ceae20ca 100644
--- a/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
+++ b/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
@@ -36,6 +36,11 @@ rtc0: rtc@70 {
interrupts = <8>;
interrupt-parent = <&htpic>;
};
+
+ acpi@800 {
+ compatible = "loongson,rs780e-acpi";
+ reg = <1 0x800 0x100>;
+ };
};
};
};
--
2.26.0.rc2
This driver is using some dangerous hack to set MMIO address for HPET,
which might break systems with other kinds of PCH.
Also, as Loongson-3 cpufreq driver never appeared in mainline,
this driver rarely got used.
So we temporarily mark it as broken until we find a better solution.
Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/loongson64/Kconfig | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
index c386b8a3c753..16e6acab8cce 100644
--- a/arch/mips/loongson64/Kconfig
+++ b/arch/mips/loongson64/Kconfig
@@ -4,14 +4,12 @@ if MACH_LOONGSON64
config RS780_HPET
bool "RS780/SBX00 HPET Timer"
depends on MACH_LOONGSON64
+ depends on BROKEN
select MIPS_EXTERNAL_TIMER
help
This option enables the hpet timer of AMD RS780/SBX00.
- If you want to enable the Loongson3 CPUFreq Driver, Please enable
- this option at first, otherwise, You will get wrong system time.
-
- If unsure, say Yes.
-
+ Note: This driver is doing some dangerous hack. Please only enable
+ it on RS780E systems.
endif # MACH_LOONGSON64
--
2.26.0.rc2
On Mon, Apr 20, 2020 at 03:33:35PM +0800, Jiaxun Yang wrote:
> Basically ensure all RS780E stuff is enabled by DeviceTree.
> So I can post LS7A support later on.
>
> Hi Thomas, could you please pick them into MIPS tree?
well, first patch doesn't apply, because it relies on your PCI patch
series. I've fixed this while applying and then faced
arch/mips/loongson64/pci.o: In function `pcibios_init':
pci.c:(.init.text+0x44): undefined reference to `sbx00_acpi_init'
IMHO there is something to improve...
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
于 2020年4月20日 GMT+08:00 下午5:07:26, Thomas Bogendoerfer <[email protected]> 写到:
>On Mon, Apr 20, 2020 at 03:33:35PM +0800, Jiaxun Yang wrote:
>> Basically ensure all RS780E stuff is enabled by DeviceTree.
>> So I can post LS7A support later on.
>>
>> Hi Thomas, could you please pick them into MIPS tree?
>
>well, first patch doesn't apply, because it relies on your PCI patch
>series. I've fixed this while applying and then faced
>
>arch/mips/loongson64/pci.o: In function `pcibios_init':
>pci.c:(.init.text+0x44): undefined reference to `sbx00_acpi_init'
>
>IMHO there is something to improve...
Oops, sorry.
It should depends on PCI series.
I'll send v2 without this requirement soon.
Thanks.
>
>Thomas.
>
--
Jiaxun Yang
On 04/20/2020 03:33 PM, Jiaxun Yang wrote:
> RTC is now enabled by devicetree. So platform code is
> no longer needed.
>
> Signed-off-by: Jiaxun Yang <[email protected]>
> ---
> .../include/asm/mach-loongson64/mc146818rtc.h | 36 -----------------
> arch/mips/loongson64/Kconfig | 4 --
> arch/mips/loongson64/Makefile | 1 -
> arch/mips/loongson64/rtc.c | 39 -------------------
> arch/mips/loongson64/time.c | 8 +---
> 5 files changed, 1 insertion(+), 87 deletions(-)
> delete mode 100644 arch/mips/include/asm/mach-loongson64/mc146818rtc.h
> delete mode 100644 arch/mips/loongson64/rtc.c
>
> diff --git a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h b/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
> deleted file mode 100644
> index ebdccfee50be..000000000000
> --- a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -/*
> - * This file is subject to the terms and conditions of the GNU General Public
> - * License. See the file "COPYING" in the main directory of this archive
> - * for more details.
> - *
> - * Copyright (C) 1998, 2001, 03, 07 by Ralf Baechle ([email protected])
> - *
> - * RTC routines for PC style attached Dallas chip.
> - */
> -#ifndef __ASM_MACH_LOONGSON64_MC146818RTC_H
> -#define __ASM_MACH_LOONGSON64_MC146818RTC_H
> -
> -#include <linux/io.h>
> -
> -#define RTC_PORT(x) (0x70 + (x))
> -#define RTC_IRQ 8
> -
> -static inline unsigned char CMOS_READ(unsigned long addr)
> -{
> - outb_p(addr, RTC_PORT(0));
> - return inb_p(RTC_PORT(1));
> -}
> -
> -static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
> -{
> - outb_p(addr, RTC_PORT(0));
> - outb_p(data, RTC_PORT(1));
> -}
> -
> -#define RTC_ALWAYS_BCD 0
> -
> -#ifndef mc146818_decode_year
> -#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
> -#endif
> -
> -#endif /* __ASM_MACH_LOONGSON64_MC146818RTC_H */
> diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
> index 48b29c198acf..c386b8a3c753 100644
> --- a/arch/mips/loongson64/Kconfig
> +++ b/arch/mips/loongson64/Kconfig
> @@ -14,8 +14,4 @@ config RS780_HPET
> If unsure, say Yes.
>
>
> -config LOONGSON_MC146818
> - bool
> - default n
> -
> endif # MACH_LOONGSON64
> diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile
> index f04461839540..102a19aa92aa 100644
> --- a/arch/mips/loongson64/Makefile
> +++ b/arch/mips/loongson64/Makefile
> @@ -8,6 +8,5 @@ obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \
> obj-$(CONFIG_SMP) += smp.o
> obj-$(CONFIG_NUMA) += numa.o
> obj-$(CONFIG_RS780_HPET) += hpet.o
> -obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
> obj-$(CONFIG_SUSPEND) += pm.o
> obj-$(CONFIG_PCI_QUIRKS) += vbios_quirk.o
> diff --git a/arch/mips/loongson64/rtc.c b/arch/mips/loongson64/rtc.c
> deleted file mode 100644
> index 8d7628c0f513..000000000000
> --- a/arch/mips/loongson64/rtc.c
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * Lemote Fuloong platform support
> - *
> - * Copyright(c) 2010 Arnaud Patard <[email protected]>
> - */
> -
> -#include <linux/init.h>
> -#include <linux/kernel.h>
> -#include <linux/platform_device.h>
> -#include <linux/mc146818rtc.h>
> -
> -static struct resource loongson_rtc_resources[] = {
> - {
> - .start = RTC_PORT(0),
> - .end = RTC_PORT(1),
> - .flags = IORESOURCE_IO,
> - }, {
> - .start = RTC_IRQ,
> - .end = RTC_IRQ,
> - .flags = IORESOURCE_IRQ,
> - }
> -};
> -
> -static struct platform_device loongson_rtc_device = {
> - .name = "rtc_cmos",
> - .id = -1,
> - .resource = loongson_rtc_resources,
> - .num_resources = ARRAY_SIZE(loongson_rtc_resources),
> -};
> -
> -
> -static int __init loongson_rtc_platform_init(void)
> -{
> - platform_device_register(&loongson_rtc_device);
> - return 0;
> -}
> -
> -device_initcall(loongson_rtc_platform_init);
> diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
> index 1245f22cec84..91e842b58365 100644
> --- a/arch/mips/loongson64/time.c
> +++ b/arch/mips/loongson64/time.c
> @@ -6,7 +6,7 @@
> * Copyright (C) 2009 Lemote Inc.
> * Author: Wu Zhangjin, [email protected]
> */
> -#include <asm/mc146818-time.h>
> +
> #include <asm/time.h>
> #include <asm/hpet.h>
>
> @@ -21,9 +21,3 @@ void __init plat_time_init(void)
> setup_hpet_timer();
> #endif
> }
> -
> -void read_persistent_clock64(struct timespec64 *ts)
> -{
> - ts->tv_sec = mc146818_get_cmos_time();
> - ts->tv_nsec = 0;
> -}
>
Hi Jiaxun,
Are you sure to remove function read_persistent_clock64 ? which is called in kernel/time/timekeeping.c
regards
bibo,mao
On Mon, 20 Apr 2020 20:06:02 +0800
maobibo <[email protected]> wrote:
> On 04/20/2020 03:33 PM, Jiaxun Yang wrote:
> > RTC is now enabled by devicetree. So platform code is
> > no longer needed.
> >
> > Signed-off-by: Jiaxun Yang <[email protected]>
> > ---
> > .../include/asm/mach-loongson64/mc146818rtc.h | 36
> > ----------------- arch/mips/loongson64/Kconfig |
> > 4 -- arch/mips/loongson64/Makefile | 1 -
> > arch/mips/loongson64/rtc.c | 39
> > ------------------- arch/mips/loongson64/time.c |
> > 8 +--- 5 files changed, 1 insertion(+), 87 deletions(-)
> > delete mode 100644
> > arch/mips/include/asm/mach-loongson64/mc146818rtc.h delete mode
> > 100644 arch/mips/loongson64/rtc.c
> >
> > diff --git a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
> > b/arch/mips/include/asm/mach-loongson64/mc146818rtc.h deleted file
> > mode 100644 index ebdccfee50be..000000000000
> > --- a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
> > +++ /dev/null
> > @@ -1,36 +0,0 @@
> > -/*
> > - * This file is subject to the terms and conditions of the GNU
> > General Public
> > - * License. See the file "COPYING" in the main directory of this
> > archive
> > - * for more details.
> > - *
> > - * Copyright (C) 1998, 2001, 03, 07 by Ralf Baechle
> > ([email protected])
> > - *
> > - * RTC routines for PC style attached Dallas chip.
> > - */
> > -#ifndef __ASM_MACH_LOONGSON64_MC146818RTC_H
> > -#define __ASM_MACH_LOONGSON64_MC146818RTC_H
> > -
> > -#include <linux/io.h>
> > -
> > -#define RTC_PORT(x) (0x70 + (x))
> > -#define RTC_IRQ 8
> > -
> > -static inline unsigned char CMOS_READ(unsigned long addr)
> > -{
> > - outb_p(addr, RTC_PORT(0));
> > - return inb_p(RTC_PORT(1));
> > -}
> > -
> > -static inline void CMOS_WRITE(unsigned char data, unsigned long
> > addr) -{
> > - outb_p(addr, RTC_PORT(0));
> > - outb_p(data, RTC_PORT(1));
> > -}
> > -
> > -#define RTC_ALWAYS_BCD 0
> > -
> > -#ifndef mc146818_decode_year
> > -#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 :
> > (year) + 1970) -#endif
> > -
> > -#endif /* __ASM_MACH_LOONGSON64_MC146818RTC_H */
> > diff --git a/arch/mips/loongson64/Kconfig
> > b/arch/mips/loongson64/Kconfig index 48b29c198acf..c386b8a3c753
> > 100644 --- a/arch/mips/loongson64/Kconfig
> > +++ b/arch/mips/loongson64/Kconfig
> > @@ -14,8 +14,4 @@ config RS780_HPET
> > If unsure, say Yes.
> >
> >
> > -config LOONGSON_MC146818
> > - bool
> > - default n
> > -
> > endif # MACH_LOONGSON64
> > diff --git a/arch/mips/loongson64/Makefile
> > b/arch/mips/loongson64/Makefile index f04461839540..102a19aa92aa
> > 100644 --- a/arch/mips/loongson64/Makefile
> > +++ b/arch/mips/loongson64/Makefile
> > @@ -8,6 +8,5 @@ obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o
> > platform.o acpi_init.o dma.o \ obj-$(CONFIG_SMP) += smp.o
> > obj-$(CONFIG_NUMA) += numa.o
> > obj-$(CONFIG_RS780_HPET) += hpet.o
> > -obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
> > obj-$(CONFIG_SUSPEND) += pm.o
> > obj-$(CONFIG_PCI_QUIRKS) += vbios_quirk.o
> > diff --git a/arch/mips/loongson64/rtc.c b/arch/mips/loongson64/rtc.c
> > deleted file mode 100644
> > index 8d7628c0f513..000000000000
> > --- a/arch/mips/loongson64/rtc.c
> > +++ /dev/null
> > @@ -1,39 +0,0 @@
> > -// SPDX-License-Identifier: GPL-2.0-or-later
> > -/*
> > - * Lemote Fuloong platform support
> > - *
> > - * Copyright(c) 2010 Arnaud Patard <[email protected]>
> > - */
> > -
> > -#include <linux/init.h>
> > -#include <linux/kernel.h>
> > -#include <linux/platform_device.h>
> > -#include <linux/mc146818rtc.h>
> > -
> > -static struct resource loongson_rtc_resources[] = {
> > - {
> > - .start = RTC_PORT(0),
> > - .end = RTC_PORT(1),
> > - .flags = IORESOURCE_IO,
> > - }, {
> > - .start = RTC_IRQ,
> > - .end = RTC_IRQ,
> > - .flags = IORESOURCE_IRQ,
> > - }
> > -};
> > -
> > -static struct platform_device loongson_rtc_device = {
> > - .name = "rtc_cmos",
> > - .id = -1,
> > - .resource = loongson_rtc_resources,
> > - .num_resources = ARRAY_SIZE(loongson_rtc_resources),
> > -};
> > -
> > -
> > -static int __init loongson_rtc_platform_init(void)
> > -{
> > - platform_device_register(&loongson_rtc_device);
> > - return 0;
> > -}
> > -
> > -device_initcall(loongson_rtc_platform_init);
> > diff --git a/arch/mips/loongson64/time.c
> > b/arch/mips/loongson64/time.c index 1245f22cec84..91e842b58365
> > 100644 --- a/arch/mips/loongson64/time.c
> > +++ b/arch/mips/loongson64/time.c
> > @@ -6,7 +6,7 @@
> > * Copyright (C) 2009 Lemote Inc.
> > * Author: Wu Zhangjin, [email protected]
> > */
> > -#include <asm/mc146818-time.h>
> > +
> > #include <asm/time.h>
> > #include <asm/hpet.h>
> >
> > @@ -21,9 +21,3 @@ void __init plat_time_init(void)
> > setup_hpet_timer();
> > #endif
> > }
> > -
> > -void read_persistent_clock64(struct timespec64 *ts)
> > -{
> > - ts->tv_sec = mc146818_get_cmos_time();
> > - ts->tv_nsec = 0;
> > -}
> >
> Hi Jiaxun,
>
> Are you sure to remove function read_persistent_clock64 ? which is
> called in kernel/time/timekeeping.c
Hi Bibi,
Thanks for your review.
Pretty sure. It is mc146818 specified, it can never work on LS7A/LS2K
which have another RTC implementation.
I have performed boot test with this patch.
Kernel have safety fallback on platforms without this callback.
>
> regards
> bibo,mao
>
Thanks
--
Jiaxun Yang
On 04/20/2020 08:13 PM, Jiaxun Yang wrote:
> Hi Bibi,
>
> Thanks for your review.
>
> Pretty sure. It is mc146818 specified, it can never work on LS7A/LS2K
> which have another RTC implementation.
>
> I have performed boot test with this patch.
> Kernel have safety fallback on platforms without this callback.
Although it boots ok, the wall time will be 0 for every boot since it does not read from rtc
regards
bibo, mao
于 2020年4月20日 GMT+08:00 下午9:04:52, maobibo <[email protected]> 写到:
>
>
>On 04/20/2020 08:13 PM, Jiaxun Yang wrote:
>> Hi Bibi,
>>
>> Thanks for your review.
>>
>> Pretty sure. It is mc146818 specified, it can never work on LS7A/LS2K
>> which have another RTC implementation.
>>
>> I have performed boot test with this patch.
>> Kernel have safety fallback on platforms without this callback.
>Although it boots ok, the wall time will be 0 for every boot since it does not read from rtc
Not a big deal :-)
It must be removed unless we can come out a solution
fits both mc146818 and Loongson's in-house design RTC.
Thanks
>
>regards
>bibo, mao
>
--
Jiaxun Yang
RTC is now enabled by devicetree. So platform code is
no longer needed.
Signed-off-by: Jiaxun Yang <[email protected]>
---
v2: Rebase to mips-next
---
.../include/asm/mach-loongson64/mc146818rtc.h | 36 -----------------
arch/mips/loongson64/Kconfig | 4 --
arch/mips/loongson64/Makefile | 1 -
arch/mips/loongson64/rtc.c | 39 -------------------
arch/mips/loongson64/time.c | 8 +---
5 files changed, 1 insertion(+), 87 deletions(-)
delete mode 100644 arch/mips/include/asm/mach-loongson64/mc146818rtc.h
delete mode 100644 arch/mips/loongson64/rtc.c
diff --git a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h b/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
deleted file mode 100644
index ebdccfee50be..000000000000
--- a/arch/mips/include/asm/mach-loongson64/mc146818rtc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1998, 2001, 03, 07 by Ralf Baechle ([email protected])
- *
- * RTC routines for PC style attached Dallas chip.
- */
-#ifndef __ASM_MACH_LOONGSON64_MC146818RTC_H
-#define __ASM_MACH_LOONGSON64_MC146818RTC_H
-
-#include <linux/io.h>
-
-#define RTC_PORT(x) (0x70 + (x))
-#define RTC_IRQ 8
-
-static inline unsigned char CMOS_READ(unsigned long addr)
-{
- outb_p(addr, RTC_PORT(0));
- return inb_p(RTC_PORT(1));
-}
-
-static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
-{
- outb_p(addr, RTC_PORT(0));
- outb_p(data, RTC_PORT(1));
-}
-
-#define RTC_ALWAYS_BCD 0
-
-#ifndef mc146818_decode_year
-#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
-#endif
-
-#endif /* __ASM_MACH_LOONGSON64_MC146818RTC_H */
diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
index 48b29c198acf..c386b8a3c753 100644
--- a/arch/mips/loongson64/Kconfig
+++ b/arch/mips/loongson64/Kconfig
@@ -14,8 +14,4 @@ config RS780_HPET
If unsure, say Yes.
-config LOONGSON_MC146818
- bool
- default n
-
endif # MACH_LOONGSON64
diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile
index b7f40b179c71..32b8c224852f 100644
--- a/arch/mips/loongson64/Makefile
+++ b/arch/mips/loongson64/Makefile
@@ -9,5 +9,4 @@ obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_NUMA) += numa.o
obj-$(CONFIG_RS780_HPET) += hpet.o
obj-$(CONFIG_PCI) += pci.o
-obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
obj-$(CONFIG_SUSPEND) += pm.o
diff --git a/arch/mips/loongson64/rtc.c b/arch/mips/loongson64/rtc.c
deleted file mode 100644
index 8d7628c0f513..000000000000
--- a/arch/mips/loongson64/rtc.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Lemote Fuloong platform support
- *
- * Copyright(c) 2010 Arnaud Patard <[email protected]>
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/mc146818rtc.h>
-
-static struct resource loongson_rtc_resources[] = {
- {
- .start = RTC_PORT(0),
- .end = RTC_PORT(1),
- .flags = IORESOURCE_IO,
- }, {
- .start = RTC_IRQ,
- .end = RTC_IRQ,
- .flags = IORESOURCE_IRQ,
- }
-};
-
-static struct platform_device loongson_rtc_device = {
- .name = "rtc_cmos",
- .id = -1,
- .resource = loongson_rtc_resources,
- .num_resources = ARRAY_SIZE(loongson_rtc_resources),
-};
-
-
-static int __init loongson_rtc_platform_init(void)
-{
- platform_device_register(&loongson_rtc_device);
- return 0;
-}
-
-device_initcall(loongson_rtc_platform_init);
diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
index 1245f22cec84..91e842b58365 100644
--- a/arch/mips/loongson64/time.c
+++ b/arch/mips/loongson64/time.c
@@ -6,7 +6,7 @@
* Copyright (C) 2009 Lemote Inc.
* Author: Wu Zhangjin, [email protected]
*/
-#include <asm/mc146818-time.h>
+
#include <asm/time.h>
#include <asm/hpet.h>
@@ -21,9 +21,3 @@ void __init plat_time_init(void)
setup_hpet_timer();
#endif
}
-
-void read_persistent_clock64(struct timespec64 *ts)
-{
- ts->tv_sec = mc146818_get_cmos_time();
- ts->tv_nsec = 0;
-}
--
2.26.0.rc2
Make RS780E ACPI as a platform driver so we can enable it
by DeviceTree selectively.
Signed-off-by: Jiaxun Yang <[email protected]>
---
v2: Rebase to mips-next
---
arch/mips/loongson64/Makefile | 2 +-
arch/mips/loongson64/pci.c | 2 -
drivers/platform/mips/Kconfig | 6 ++
drivers/platform/mips/Makefile | 1 +
.../platform/mips/rs780e-acpi.c | 58 ++++++++++++-------
5 files changed, 46 insertions(+), 23 deletions(-)
rename arch/mips/loongson64/acpi_init.c => drivers/platform/mips/rs780e-acpi.c (70%)
diff --git a/arch/mips/loongson64/Makefile b/arch/mips/loongson64/Makefile
index 32b8c224852f..6f3c2b47f66f 100644
--- a/arch/mips/loongson64/Makefile
+++ b/arch/mips/loongson64/Makefile
@@ -2,7 +2,7 @@
#
# Makefile for Loongson-3 family machines
#
-obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \
+obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o dma.o \
setup.o init.o env.o time.o reset.o \
obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/mips/loongson64/pci.c b/arch/mips/loongson64/pci.c
index e84ae20c3290..a440a2725a20 100644
--- a/arch/mips/loongson64/pci.c
+++ b/arch/mips/loongson64/pci.c
@@ -43,8 +43,6 @@ static int __init pcibios_init(void)
register_pci_controller(&loongson_pci_controller);
- sbx00_acpi_init();
-
return 0;
}
diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig
index 5e77b0dc5fd6..8ac149173c64 100644
--- a/drivers/platform/mips/Kconfig
+++ b/drivers/platform/mips/Kconfig
@@ -24,4 +24,10 @@ config CPU_HWMON
help
Loongson-3A/3B CPU Hwmon (temperature sensor) driver.
+config RS780E_ACPI
+ bool "Loongson RS780E ACPI Controller"
+ depends on MACH_LOONGSON64 || COMPILE_TEST
+ help
+ Loongson RS780E PCH ACPI Controller driver.
+
endif # MIPS_PLATFORM_DEVICES
diff --git a/drivers/platform/mips/Makefile b/drivers/platform/mips/Makefile
index be8146c20dc8..178149098777 100644
--- a/drivers/platform/mips/Makefile
+++ b/drivers/platform/mips/Makefile
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
+obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
diff --git a/arch/mips/loongson64/acpi_init.c b/drivers/platform/mips/rs780e-acpi.c
similarity index 70%
rename from arch/mips/loongson64/acpi_init.c
rename to drivers/platform/mips/rs780e-acpi.c
index 8d7c119ddf91..e5a643b78ac9 100644
--- a/arch/mips/loongson64/acpi_init.c
+++ b/drivers/platform/mips/rs780e-acpi.c
@@ -3,32 +3,23 @@
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/export.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
-#define SBX00_ACPI_IO_BASE 0x800
-#define SBX00_ACPI_IO_SIZE 0x100
+static unsigned long acpi_iobase;
-#define ACPI_PM_EVT_BLK (SBX00_ACPI_IO_BASE + 0x00) /* 4 bytes */
-#define ACPI_PM_CNT_BLK (SBX00_ACPI_IO_BASE + 0x04) /* 2 bytes */
-#define ACPI_PMA_CNT_BLK (SBX00_ACPI_IO_BASE + 0x0F) /* 1 byte */
-#define ACPI_PM_TMR_BLK (SBX00_ACPI_IO_BASE + 0x18) /* 4 bytes */
-#define ACPI_GPE0_BLK (SBX00_ACPI_IO_BASE + 0x10) /* 8 bytes */
-#define ACPI_END (SBX00_ACPI_IO_BASE + 0x80)
+#define ACPI_PM_EVT_BLK (acpi_iobase + 0x00) /* 4 bytes */
+#define ACPI_PM_CNT_BLK (acpi_iobase + 0x04) /* 2 bytes */
+#define ACPI_PMA_CNT_BLK (acpi_iobase + 0x0F) /* 1 byte */
+#define ACPI_PM_TMR_BLK (acpi_iobase + 0x18) /* 4 bytes */
+#define ACPI_GPE0_BLK (acpi_iobase + 0x10) /* 8 bytes */
+#define ACPI_END (acpi_iobase + 0x80)
#define PM_INDEX 0xCD6
#define PM_DATA 0xCD7
#define PM2_INDEX 0xCD0
#define PM2_DATA 0xCD1
-/*
- * SCI interrupt need acpi space, allocate here
- */
-
-static int __init register_acpi_resource(void)
-{
- request_region(SBX00_ACPI_IO_BASE, SBX00_ACPI_IO_SIZE, "acpi");
- return 0;
-}
-
static void pmio_write_index(u16 index, u8 reg, u8 value)
{
outb(reg, index);
@@ -141,11 +132,38 @@ void acpi_registers_setup(void)
pm2_iowrite(0xf8, value);
}
-int __init sbx00_acpi_init(void)
+static int rs780e_acpi_probe(struct platform_device *pdev)
{
- register_acpi_resource();
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -ENODEV;
+
+ /* SCI interrupt need acpi space, allocate here */
+ if (!request_region(res->start, resource_size(res), "acpi")) {
+ pr_err("RS780E-ACPI: Failed to request IO Region\n");
+ return -EBUSY;
+ }
+
+ acpi_iobase = res->start;
+
acpi_registers_setup();
acpi_hw_clear_status();
return 0;
}
+
+static const struct of_device_id rs780e_acpi_match[] = {
+ { .compatible = "loongson,rs780e-acpi" },
+ {},
+};
+
+static struct platform_driver rs780e_acpi_driver = {
+ .probe = rs780e_acpi_probe,
+ .driver = {
+ .name = "RS780E-ACPI",
+ .of_match_table = rs780e_acpi_match,
+ },
+};
+builtin_platform_driver(rs780e_acpi_driver);
--
2.26.0.rc2
This driver is using some dangerous hack to set MMIO address for HPET,
which might break systems with other kinds of PCH.
Also, as Loongson-3 cpufreq driver never appeared in mainline,
this driver rarely got used.
So we temporarily mark it as broken until we find a better solution.
Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/loongson64/Kconfig | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig
index c386b8a3c753..517f1f8e81fb 100644
--- a/arch/mips/loongson64/Kconfig
+++ b/arch/mips/loongson64/Kconfig
@@ -4,14 +4,12 @@ if MACH_LOONGSON64
config RS780_HPET
bool "RS780/SBX00 HPET Timer"
depends on MACH_LOONGSON64
+ depends on BROKEN
select MIPS_EXTERNAL_TIMER
help
This option enables the hpet timer of AMD RS780/SBX00.
- If you want to enable the Loongson3 CPUFreq Driver, Please enable
- this option at first, otherwise, You will get wrong system time.
-
- If unsure, say Yes.
-
+ Note: This driver is doing some dangerous hack. Please only enable
+ it on RS780E systems.
endif # MACH_LOONGSON64
--
2.26.0.rc2
Add ACPI Controller Node for RS780E PCH to fit newly added driver.
Signed-off-by: Jiaxun Yang <[email protected]>
---
arch/mips/boot/dts/loongson/rs780e-pch.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/mips/boot/dts/loongson/rs780e-pch.dtsi b/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
index 45c54d555fa4..8687c4f7370a 100644
--- a/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
+++ b/arch/mips/boot/dts/loongson/rs780e-pch.dtsi
@@ -21,6 +21,11 @@ rtc0: rtc@70 {
interrupts = <8>;
interrupt-parent = <&htpic>;
};
+
+ acpi@800 {
+ compatible = "loongson,rs780e-acpi";
+ reg = <1 0x800 0x100>;
+ };
};
};
};
--
2.26.0.rc2
On Mon, Apr 20, 2020 at 09:45:25PM +0800, Jiaxun Yang wrote:
> RTC is now enabled by devicetree. So platform code is
> no longer needed.
>
> Signed-off-by: Jiaxun Yang <[email protected]>
> ---
> v2: Rebase to mips-next
series applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]