* [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver
@ 2021-11-26 1:52 Qing Zhang
2021-11-26 1:52 ` [PATCH v9 2/3] MIPS: Loongson64: DTS: Add pm block node for Loongson-2K1000 Qing Zhang
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Qing Zhang @ 2021-11-26 1:52 UTC (permalink / raw)
To: Rob Herring, Thomas Bogendoerfer
Cc: Jiaxun Yang, devicetree, linux-mips, linux-kernel
Add power management register operations to support reboot and poweroff.
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
v8-v9:
No change
---
drivers/platform/mips/Kconfig | 6 ++++
drivers/platform/mips/Makefile | 1 +
drivers/platform/mips/ls2k-reset.c | 53 ++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 drivers/platform/mips/ls2k-reset.c
diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig
index 8ac149173c64b..d421e14823957 100644
--- a/drivers/platform/mips/Kconfig
+++ b/drivers/platform/mips/Kconfig
@@ -30,4 +30,10 @@ config RS780E_ACPI
help
Loongson RS780E PCH ACPI Controller driver.
+config LS2K_RESET
+ bool "Loongson-2K1000 Reset Controller"
+ depends on MACH_LOONGSON64 || COMPILE_TEST
+ help
+ Loongson-2K1000 Reset Controller driver.
+
endif # MIPS_PLATFORM_DEVICES
diff --git a/drivers/platform/mips/Makefile b/drivers/platform/mips/Makefile
index 1781490987773..4c71444e453a6 100644
--- a/drivers/platform/mips/Makefile
+++ b/drivers/platform/mips/Makefile
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
+obj-$(CONFIG_LS2K_RESET) += ls2k-reset.o
diff --git a/drivers/platform/mips/ls2k-reset.c b/drivers/platform/mips/ls2k-reset.c
new file mode 100644
index 0000000000000..b70e7b8a092c2
--- /dev/null
+++ b/drivers/platform/mips/ls2k-reset.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021, Qing Zhang <zhangqing@loongson.cn>
+ * Loongson-2K1000 reset support
+ */
+
+#include <linux/of_address.h>
+#include <linux/pm.h>
+#include <asm/reboot.h>
+
+#define PM1_STS 0x0c /* Power Management 1 Status Register */
+#define PM1_CNT 0x14 /* Power Management 1 Control Register */
+#define RST_CNT 0x30 /* Reset Control Register */
+
+static void __iomem *base;
+
+static void ls2k_restart(char *command)
+{
+ writel(0x1, base + RST_CNT);
+}
+
+static void ls2k_poweroff(void)
+{
+ /* Clear */
+ writel((readl(base + PM1_STS) & 0xffffffff), base + PM1_STS);
+ /* Sleep Enable | Soft Off*/
+ writel(GENMASK(12, 10) | BIT(13), base + PM1_CNT);
+}
+
+static int ls2k_reset_init(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "loongson,ls2k-pm");
+ if (!np) {
+ pr_info("Failed to get PM node\n");
+ return -ENODEV;
+ }
+
+ base = of_iomap(np, 0);
+ if (!base) {
+ pr_info("Failed to map PM register base address\n");
+ return -ENOMEM;
+ }
+
+ _machine_restart = ls2k_restart;
+ pm_power_off = ls2k_poweroff;
+
+ of_node_put(np);
+ return 0;
+}
+
+arch_initcall(ls2k_reset_init);
--
2.31.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v9 2/3] MIPS: Loongson64: DTS: Add pm block node for Loongson-2K1000
2021-11-26 1:52 [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Qing Zhang
@ 2021-11-26 1:52 ` Qing Zhang
2021-11-26 1:52 ` [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support Qing Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Qing Zhang @ 2021-11-26 1:52 UTC (permalink / raw)
To: Rob Herring, Thomas Bogendoerfer
Cc: Jiaxun Yang, devicetree, linux-mips, linux-kernel
The module is now supported, enable it.
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
v8-v9:
No change
---
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
index bfc3d3243ee7f..8143a61111e33 100644
--- a/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
+++ b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
@@ -52,6 +52,11 @@ package0: bus@10000000 {
0 0x40000000 0 0x40000000 0 0x40000000
0xfe 0x00000000 0xfe 0x00000000 0 0x40000000>;
+ pm: reset-controller@1fe07000 {
+ compatible = "loongson,ls2k-pm";
+ reg = <0 0x1fe07000 0 0x422>;
+ };
+
liointc0: interrupt-controller@1fe11400 {
compatible = "loongson,liointc-2.0";
reg = <0 0x1fe11400 0 0x40>,
--
2.31.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support
2021-11-26 1:52 [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Qing Zhang
2021-11-26 1:52 ` [PATCH v9 2/3] MIPS: Loongson64: DTS: Add pm block node for Loongson-2K1000 Qing Zhang
@ 2021-11-26 1:52 ` Qing Zhang
2021-11-28 17:28 ` Rob Herring
2022-01-02 13:29 ` [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Thomas Bogendoerfer
2022-01-03 19:58 ` Jiaxun Yang
3 siblings, 1 reply; 6+ messages in thread
From: Qing Zhang @ 2021-11-26 1:52 UTC (permalink / raw)
To: Rob Herring, Thomas Bogendoerfer
Cc: Jiaxun Yang, devicetree, linux-mips, linux-kernel
Switch the DT binding to a YAML schema to enable the DT validation.
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
v8-v9:
only modify 'make DT_CHECKER_FLAGS=-m dt_binding_check' warnings/errors
---
.../bindings/mips/loongson/ls2k-reset.yaml | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mips/loongson/ls2k-reset.yaml
diff --git a/Documentation/devicetree/bindings/mips/loongson/ls2k-reset.yaml b/Documentation/devicetree/bindings/mips/loongson/ls2k-reset.yaml
new file mode 100644
index 0000000000000..20b5836efd90a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/loongson/ls2k-reset.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/mips/loongson/ls2k-reset.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Loongson 2K1000 PM Controller
+
+maintainers:
+ - Qing Zhang <zhangqing@loongson.cn>
+
+description: |
+ This controller can be found in Loongson-2K1000 Soc systems.
+
+properties:
+ compatible:
+ const: loongson,ls2k-pm
+
+ reg:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ bus {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ pm: reset-controller@1fe07000 {
+ compatible = "loongson,ls2k-pm";
+ reg = <0 0x1fe07000 0 0x422>;
+ };
+ };
+...
--
2.31.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support
2021-11-26 1:52 ` [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support Qing Zhang
@ 2021-11-28 17:28 ` Rob Herring
0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2021-11-28 17:28 UTC (permalink / raw)
To: Qing Zhang
Cc: Rob Herring, linux-kernel, linux-mips, Thomas Bogendoerfer,
devicetree, Jiaxun Yang
On Fri, 26 Nov 2021 09:52:16 +0800, Qing Zhang wrote:
> Switch the DT binding to a YAML schema to enable the DT validation.
>
> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> ---
> v8-v9:
> only modify 'make DT_CHECKER_FLAGS=-m dt_binding_check' warnings/errors
> ---
> .../bindings/mips/loongson/ls2k-reset.yaml | 38 +++++++++++++++++++
> 1 file changed, 38 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mips/loongson/ls2k-reset.yaml
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver
2021-11-26 1:52 [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Qing Zhang
2021-11-26 1:52 ` [PATCH v9 2/3] MIPS: Loongson64: DTS: Add pm block node for Loongson-2K1000 Qing Zhang
2021-11-26 1:52 ` [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support Qing Zhang
@ 2022-01-02 13:29 ` Thomas Bogendoerfer
2022-01-03 19:58 ` Jiaxun Yang
3 siblings, 0 replies; 6+ messages in thread
From: Thomas Bogendoerfer @ 2022-01-02 13:29 UTC (permalink / raw)
To: Qing Zhang; +Cc: Rob Herring, Jiaxun Yang, devicetree, linux-mips, linux-kernel
On Fri, Nov 26, 2021 at 09:52:14AM +0800, Qing Zhang wrote:
> Add power management register operations to support reboot and poweroff.
>
> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> ---
> v8-v9:
> No change
> ---
> drivers/platform/mips/Kconfig | 6 ++++
> drivers/platform/mips/Makefile | 1 +
> drivers/platform/mips/ls2k-reset.c | 53 ++++++++++++++++++++++++++++++
> 3 files changed, 60 insertions(+)
> create mode 100644 drivers/platform/mips/ls2k-reset.c
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 ]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver
2021-11-26 1:52 [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Qing Zhang
` (2 preceding siblings ...)
2022-01-02 13:29 ` [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Thomas Bogendoerfer
@ 2022-01-03 19:58 ` Jiaxun Yang
3 siblings, 0 replies; 6+ messages in thread
From: Jiaxun Yang @ 2022-01-03 19:58 UTC (permalink / raw)
To: Qing Zhang, Rob Herring, Thomas Bogendoerfer
Cc: devicetree, linux-mips, linux-kernel
在2021年11月26日十一月 上午1:52,Qing Zhang写道:
> Add power management register operations to support reboot and poweroff.
>
> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> ---
> v8-v9:
> No change
> ---
> drivers/platform/mips/Kconfig | 6 ++++
> drivers/platform/mips/Makefile | 1 +
> drivers/platform/mips/ls2k-reset.c | 53 ++++++++++++++++++++++++++++++
> 3 files changed, 60 insertions(+)
> create mode 100644 drivers/platform/mips/ls2k-reset.c
>
> diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig
> index 8ac149173c64b..d421e14823957 100644
> --- a/drivers/platform/mips/Kconfig
> +++ b/drivers/platform/mips/Kconfig
> @@ -30,4 +30,10 @@ config RS780E_ACPI
> help
> Loongson RS780E PCH ACPI Controller driver.
>
> +config LS2K_RESET
> + bool "Loongson-2K1000 Reset Controller"
> + depends on MACH_LOONGSON64 || COMPILE_TEST
> + help
> + Loongson-2K1000 Reset Controller driver.
> +
> endif # MIPS_PLATFORM_DEVICES
> diff --git a/drivers/platform/mips/Makefile
> b/drivers/platform/mips/Makefile
> index 1781490987773..4c71444e453a6 100644
> --- a/drivers/platform/mips/Makefile
> +++ b/drivers/platform/mips/Makefile
> @@ -1,3 +1,4 @@
> # SPDX-License-Identifier: GPL-2.0-only
> obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
> obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
> +obj-$(CONFIG_LS2K_RESET) += ls2k-reset.o
> diff --git a/drivers/platform/mips/ls2k-reset.c
> b/drivers/platform/mips/ls2k-reset.c
> new file mode 100644
> index 0000000000000..b70e7b8a092c2
> --- /dev/null
> +++ b/drivers/platform/mips/ls2k-reset.c
> @@ -0,0 +1,53 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2021, Qing Zhang <zhangqing@loongson.cn>
> + * Loongson-2K1000 reset support
> + */
> +
> +#include <linux/of_address.h>
> +#include <linux/pm.h>
> +#include <asm/reboot.h>
> +
> +#define PM1_STS 0x0c /* Power Management 1 Status Register */
> +#define PM1_CNT 0x14 /* Power Management 1 Control Register */
> +#define RST_CNT 0x30 /* Reset Control Register */
> +
> +static void __iomem *base;
> +
> +static void ls2k_restart(char *command)
> +{
> + writel(0x1, base + RST_CNT);
> +}
> +
> +static void ls2k_poweroff(void)
> +{
> + /* Clear */
> + writel((readl(base + PM1_STS) & 0xffffffff), base + PM1_STS);
> + /* Sleep Enable | Soft Off*/
> + writel(GENMASK(12, 10) | BIT(13), base + PM1_CNT);
> +}
> +
> +static int ls2k_reset_init(void)
> +{
> + struct device_node *np;
> +
> + np = of_find_compatible_node(NULL, NULL, "loongson,ls2k-pm");
> + if (!np) {
> + pr_info("Failed to get PM node\n");
> + return -ENODEV;
Hi Qing,
Could you please remove this print.
Otherwise we will have this suspecious log all loongson64 system, not only ls2k.
Thanks.
- Jiaxun
> + }
> +
> + base = of_iomap(np, 0);
> + if (!base) {
> + pr_info("Failed to map PM register base address\n");
> + return -ENOMEM;
> + }
> +
> + _machine_restart = ls2k_restart;
> + pm_power_off = ls2k_poweroff;
> +
> + of_node_put(np);
> + return 0;
> +}
> +
> +arch_initcall(ls2k_reset_init);
> --
> 2.31.0
--
- Jiaxun
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-03 19:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 1:52 [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Qing Zhang
2021-11-26 1:52 ` [PATCH v9 2/3] MIPS: Loongson64: DTS: Add pm block node for Loongson-2K1000 Qing Zhang
2021-11-26 1:52 ` [PATCH v9 3/3] dt-bindings: mips: Add Loongson-2K1000 reset support Qing Zhang
2021-11-28 17:28 ` Rob Herring
2022-01-02 13:29 ` [PATCH v9 1/3] MIPS: Loongson64: Add Loongson-2K1000 reset platform driver Thomas Bogendoerfer
2022-01-03 19:58 ` Jiaxun Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).