Skip to contentSkip to conversation

soc: loongson: Fix some issues about loongson_pm2

PATCH Superseded Binbin Zhou 7 participants 18 messages Aug 28, 2023 – Aug 31, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover soc: loongson: Fix some issues about loongson_pm2

Hi all:

Since commit 67694c076bd7 ("soc: loongson2_pm: add power management support"), the Loongson-2K PM driver was added, some issues have been found and this patch set is planned to fix these issues.

Specific:
Patch 1: Compilation error found by Randy;
Patch 2/3: Add Loongson-2K2000 support;
Patch 4/5: Add Loongson-2K SoC reboot/shutdown support as part of power management.

Thanks.

Binbin Zhou (5):
soc: loongson: loongson_pm2: add dependency for INPUT
dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for

    Loongson-2K2000
  soc: loongson: loongson_pm2: Add missing compatible for
    Loongson-2K2000

dt-bindings: soc: loongson,ls2k-pmc: Allow
syscon-reboot/syscon-poweroff as child
soc: loongson: loongson_pm2: Populate children syscon nodes

 .../soc/loongson/loongson,ls2k-pmc.yaml       | 30 ++++++++++++++++++-
 drivers/soc/loongson/Kconfig                  |  1 +
 drivers/soc/loongson/loongson2_pm.c           |  7 +++++
 3 files changed, 37 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.3
#1 lore raw

PATCH 1/5 soc: loongson: loongson_pm2: add dependency for INPUT

Since commit 67694c076bd7 ("soc: loongson2_pm: add power management support"), the Loongson-2K PM driver was added, but it didn't update the Kconfig entry for the INPUT dependency, leading to build errors, so update the Kconfig entry to depend on INPUT.

/opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function `loongson2_power_button_init':
/work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:101:(.text+0x350): undefined reference to `input_allocate_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:109:(.text+0x3dc): undefined reference to `input_set_capability' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:111:(.text+0x3e4): undefined reference to `input_register_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:125:(.text+0x3fc): undefined reference to input_free_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x58c): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5a0): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x5b4): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5c8): undefined reference to `input_event'

---
 drivers/soc/loongson/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/loongson/Kconfig +1 -0
index 314e13bb3e01..1b57af1e5529 100644
@@ -20,6 +20,7 @@ config LOONGSON2_GUTS
 config LOONGSON2_PM
 	bool "Loongson-2 SoC Power Management Controller Driver"
 	depends on LOONGARCH && OF
+	depends on INPUT
 	help
 	  The Loongson-2's power management controller was ACPI, supports ACPI
 	  S2Idle (Suspend To Idle), ACPI S3 (Suspend To RAM), ACPI S4 (Suspend To
Signature · 1 line
2.39.3
#2 lore raw

Re: [PATCH 1/5] soc: loongson: loongson_pm2: add dependency for INPUT

Quoted 5 lines · Binbin Zhou

Since commit 67694c076bd7 ("soc: loongson2_pm: add power management support"), the Loongson-2K PM driver was added, but it didn't update the Kconfig entry for the INPUT dependency, leading to build errors, so update the Kconfig entry to depend on INPUT.

Quoted 13 lines

/opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function `loongson2_power_button_init':
/work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:101:(.text+0x350): undefined reference to `input_allocate_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:109:(.text+0x3dc): undefined reference to `input_set_capability' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:111:(.text+0x3e4): undefined reference to `input_register_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:125:(.text+0x3fc): undefined reference to input_free_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x58c): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5a0): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x5b4): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5c8): undefined reference to `input_event'

Trim unrelated parts of path and trim logs to show only one warning, not everything.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/5] soc: loongson: loongson_pm2: add dependency for INPUT

In reply to Binbin Zhou

Hi--

Quoted 30 lines · Binbin Zhou

Since commit 67694c076bd7 ("soc: loongson2_pm: add power management support"), the Loongson-2K PM driver was added, but it didn't update the Kconfig entry for the INPUT dependency, leading to build errors, so update the Kconfig entry to depend on INPUT.

/opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function `loongson2_power_button_init':
/work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:101:(.text+0x350): undefined reference to `input_allocate_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:109:(.text+0x3dc): undefined reference to `input_set_capability' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:111:(.text+0x3e4): undefined reference to `input_register_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: /work/lnx/next/linux-next-20230825/LOONG64/../drivers/soc/loongson/loongson2_pm.c:125:(.text+0x3fc): undefined reference to input_free_device' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x58c): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5a0): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_report_key':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:425:(.text+0x5b4): undefined reference to input_event' /opt/crosstool/gcc-13.2.0-nolibc/loongarch64-linux/bin/loongarch64-linux-ld: drivers/soc/loongson/loongson2_pm.o: in function input_sync':
/work/lnx/next/linux-next-20230825/LOONG64/../include/linux/input.h:450:(.text+0x5c8): undefined reference to `input_event'

---
 drivers/soc/loongson/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/loongson/Kconfig +0 -0
index 314e13bb3e01..1b57af1e5529 100644

drivers/soc/loongson/Kconfig config LOONGSON2_GUTS · line 23

Quoted 4 lines
drivers/soc/loongson/Kconfig +1 -0
@@ -20,6 +20,7 @@ config LOONGSON2_GUTS
 config LOONGSON2_PM
 	bool "Loongson-2 SoC Power Management Controller Driver"
 	depends on LOONGARCH && OF
+	depends on INPUT

In the failing .config file, CONFIG_INPUT=m.
This bool kconfig item is still set/enabled after this patch and the build still fails.

You could use
depends on INPUT=y

if that is appropriate. I dunno.

Quoted 3 lines
drivers/soc/loongson/Kconfig +0 -0
 	help
 	  The Loongson-2's power management controller was ACPI, supports ACPI
 	  S2Idle (Suspend To Idle), ACPI S3 (Suspend To RAM), ACPI S4 (Suspend To
Signature · 1 line
~Randy
#4 lore raw

PATCH 2/5 dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

In reply to Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc
       - const: syscon
 
   reg:
Signature · 1 line
2.39.3
#5 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

Quoted 15 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +0 -0
index da2dcfeebf12..7473c5659929 100644

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

Quoted 6 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +0 -0
       - const: syscon
 
   reg:
Signature · 1 line
2.39.3
#6 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

HI Conor:

Thanks for your reply.

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

I noticed the guideline about fallback compatible:

"DO use fallback compatibles when devices are the same as or a subset of prior implementations."

But in fact, ls2k0500/ls2k1000/ls2k2000 are independent, there is no subset. Can we define a "loongson,ls2k-pmc" superset for each ls2k SoC compatible fallback.

Such as:

compatible:
oneOf:
- enum:
- loongson,ls2k0500-pmc
- loongson,ls2k1000-pmc
- loongson,ls2k2000-pmc
- const: loongson,ls2k-pmc
- const: syscon

Thanks.
Binbin

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +0 -1
       - const: syscon
 
   reg:
--

2.39.3

#7 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

Quoted 31 lines · Binbin Zhou

HI Conor:

Thanks for your reply.

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

Quoted 6 lines

I noticed the guideline about fallback compatible:

"DO use fallback compatibles when devices are the same as or a subset of prior implementations."

But in fact, ls2k0500/ls2k1000/ls2k2000 are independent, there is no subset.

We do not consider here ls2k0500/ls2k1000/ls2k2000, but PMC in each of them. If they are independent, why would they use the same interface?

Quoted 5 lines

Can we define a "loongson,ls2k-pmc" superset for each ls2k SoC compatible fallback.

Such as:

Quoted 7 lines

compatible:
oneOf:
- enum:
- loongson,ls2k0500-pmc
- loongson,ls2k1000-pmc
- loongson,ls2k2000-pmc
- const: loongson,ls2k-pmc

This is discouraged. Use 0500 as fallback.

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

Quoted 55 lines · Krzysztof Kozlowski
Quoted 31 lines · Binbin Zhou

HI Conor:

Thanks for your reply.

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

Quoted 6 lines

I noticed the guideline about fallback compatible:

"DO use fallback compatibles when devices are the same as or a subset of prior implementations."

But in fact, ls2k0500/ls2k1000/ls2k2000 are independent, there is no subset.

We do not consider here ls2k0500/ls2k1000/ls2k2000, but PMC in each of them. If they are independent, why would they use the same interface?

Quoted 5 lines

Can we define a "loongson,ls2k-pmc" superset for each ls2k SoC compatible fallback.

Such as:

Quoted 7 lines

compatible:
oneOf:
- enum:
- loongson,ls2k0500-pmc
- loongson,ls2k1000-pmc
- loongson,ls2k2000-pmc
- const: loongson,ls2k-pmc

Quoted 1 line

This is discouraged. Use 0500 as fallback.

The "code" here is also invalid, the oneOf would been to be items.

#9 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

In reply to Krzysztof Kozlowski
Quoted 35 lines · Krzysztof Kozlowski
Quoted 33 lines · Binbin Zhou

HI Conor:

Thanks for your reply.

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

I noticed the guideline about fallback compatible:

Quoted 7 lines
Quoted 4 lines

"DO use fallback compatibles when devices are the same as or a subset of prior implementations."

But in fact, ls2k0500/ls2k1000/ls2k2000 are independent, there is no subset.

We do not consider here ls2k0500/ls2k1000/ls2k2000, but PMC in each of them. If they are independent, why would they use the same interface?

Sorry. I may have misunderstood.
The "subset" in the above guideline, here we should be talking about PMC, not SoC.
For PMC, ls2k0500/ls2k1000/ls2k2000 are the same.

Am I understanding correctly now?

Also, when I said "independent" above, I meant they are three different SoCs.

Thanks.
Binbin

Quoted 21 lines
Quoted 6 lines

Can we define a "loongson,ls2k-pmc" superset for each ls2k SoC compatible fallback.

Such as:

Quoted 7 lines

compatible:
oneOf:
- enum:
- loongson,ls2k0500-pmc
- loongson,ls2k1000-pmc
- loongson,ls2k2000-pmc
- const: loongson,ls2k-pmc

This is discouraged. Use 0500 as fallback.

Best regards,
Krzysztof

maintainer
#10 lore raw

Re: [PATCH 2/5] dt-bindings: soc: loongson,ls2k-pmc: Add missing compatible for Loongson-2K2000

Quoted 45 lines · Binbin Zhou
Quoted 35 lines · Krzysztof Kozlowski
Quoted 33 lines · Binbin Zhou

HI Conor:

Thanks for your reply.

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Binbin Zhou

Document the Power Management Unit system controller compatible for Loongson-2K2000.

This is a missing compatible, now we add it.

---
 .../devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml      | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -0
index da2dcfeebf12..7473c5659929 100644
@@ -15,6 +15,7 @@ properties:
       - enum:
           - loongson,ls2k0500-pmc
           - loongson,ls2k1000-pmc
+          - loongson,ls2k2000-pmc

Same thing here as the driver patch, the pmc on this newly added SoC appears to use the same codepaths as the existing ones. Does it share a programming model & should there be a fallback compatible here?

I noticed the guideline about fallback compatible:

Quoted 7 lines
Quoted 4 lines

"DO use fallback compatibles when devices are the same as or a subset of prior implementations."

But in fact, ls2k0500/ls2k1000/ls2k2000 are independent, there is no subset.

We do not consider here ls2k0500/ls2k1000/ls2k2000, but PMC in each of them. If they are independent, why would they use the same interface?

Quoted 6 lines

Sorry. I may have misunderstood.
The "subset" in the above guideline, here we should be talking about PMC, not SoC.
For PMC, ls2k0500/ls2k1000/ls2k2000 are the same.

Am I understanding correctly now?

The test is can an OS/client which only understands the fallback compatible (loongson,ls2k-pmc) use that h/w block (or some subset of it)? If so, then a fallback is appropriate. If not, then don't use a fallback. If the block in one SoC is a proper subset of another SoC, then make the compatible that's a subset the fallback. However, that's really only helpful if an OS/client already understands the fallback.

Quoted 1 line

Also, when I said "independent" above, I meant they are three different SoCs.

But those SoCs are probably not designed completely independently. An existing SoC is the basis for the next SoC design.

OTOH, things like pinmux, clocks, power mgt, etc. tend to change in every chip.

Rob

#11 lore raw

PATCH 3/5 soc: loongson: loongson_pm2: Add missing compatible for Loongson-2K2000

In reply to Binbin Zhou

Add compatible for Loongson-2K2000, which also has the Loongson2 Power Management Unit system controller.

This is a missing compatible, now we add it.

---
 drivers/soc/loongson/loongson2_pm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/loongson/loongson2_pm.c +1 -0
index 796add6e8b63..6d2b3708e947 100644
@@ -198,6 +198,7 @@ static int loongson2_pm_probe(struct platform_device *pdev)
 static const struct of_device_id loongson2_pm_match[] = {
 	{ .compatible = "loongson,ls2k0500-pmc", },
 	{ .compatible = "loongson,ls2k1000-pmc", },
+	{ .compatible = "loongson,ls2k2000-pmc", },
 	{},
 };
 
Signature · 1 line
2.39.3
#12 lore raw

Re: [PATCH 3/5] soc: loongson: loongson_pm2: Add missing compatible for Loongson-2K2000

Quoted 15 lines · Binbin Zhou

Add compatible for Loongson-2K2000, which also has the Loongson2 Power Management Unit system controller.

This is a missing compatible, now we add it.

---
 drivers/soc/loongson/loongson2_pm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/loongson/loongson2_pm.c +0 -0
index 796add6e8b63..6d2b3708e947 100644

drivers/soc/loongson/loongson2_pm.c static int loongson2_pm_probe(struct platform_device *pdev) · line 201

Quoted 4 lines
drivers/soc/loongson/loongson2_pm.c +1 -0
@@ -198,6 +198,7 @@ static int loongson2_pm_probe(struct platform_device *pdev)
 static const struct of_device_id loongson2_pm_match[] = {
 	{ .compatible = "loongson,ls2k0500-pmc", },
 	{ .compatible = "loongson,ls2k1000-pmc", },
+	{ .compatible = "loongson,ls2k2000-pmc", },

You've not added any new codepaths for this soc, so it is compatible with the existing ones. Why are you not using fallback compatibles for this?

#13 lore raw

Re: [PATCH 3/5] soc: loongson: loongson_pm2: Add missing compatible for Loongson-2K2000

In reply to Binbin Zhou
Quoted 4 lines · Binbin Zhou

Add compatible for Loongson-2K2000, which also has the Loongson2 Power Management Unit system controller.

This is a missing compatible, now we add it.

How is it missing? Was support for it added before but not complete?

Best regards,
Krzysztof

#14 lore raw

PATCH 4/5 dt-bindings: soc: loongson,ls2k-pmc: Allow syscon-reboot/syscon-poweroff as child

In reply to Binbin Zhou

The reboot and poweroff features are actually part of the Power Management Unit system controller, thus allow them as its children, instead of specifying as separate device nodes with syscon phandle.

Without it, the reboot/poweroff feature becomes unavailable.

---
 .../soc/loongson/loongson,ls2k-pmc.yaml       | 29 ++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +28 -1
index 7473c5659929..f9e72b43d10c 100644
@@ -33,6 +33,18 @@ properties:
       addition, the PM need according to it to indicate that current
       SoC whether support Suspend To RAM.
 
+  syscon-poweroff:
+    $ref: /schemas/power/reset/syscon-poweroff.yaml#
+    type: object
+    description:
+      Node for power off method
+
+  syscon-reboot:
+    $ref: /schemas/power/reset/syscon-reboot.yaml#
+    type: object
+    description:
+      Node for reboot method
+
 required:
   - compatible
   - reg
@@ -44,10 +56,25 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/irq.h>
 
-    power-management@1fe27000 {
+    pmc: power-management@1fe27000 {
         compatible = "loongson,ls2k1000-pmc", "syscon";
         reg = <0x1fe27000 0x58>;
         interrupt-parent = <&liointc1>;
         interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
         loongson,suspend-address = <0x0 0x1c000500>;
+
+        syscon-reboot {
+            compatible ="syscon-reboot";
+            regmap = <&pmc>;
+            offset = <0x30>;
+            mask = <0x1>;
+        };
+
+        syscon-poweroff {
+            compatible ="syscon-poweroff";
+            regmap = <&pmc>;
+            offset = <0x14>;
+            mask = <0x3c00>;
+            value = <0x3c00>;
+        };
     };
Signature · 1 line
2.39.3
#15 lore raw

Re: [PATCH 4/5] dt-bindings: soc: loongson,ls2k-pmc: Allow syscon-reboot/syscon-poweroff as child

Quoted 9 lines · Binbin Zhou

The reboot and poweroff features are actually part of the Power Management Unit system controller, thus allow them as its children, instead of specifying as separate device nodes with syscon phandle.

required:
- compatible
- reg

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 59

Quoted 5 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -1
@@ -44,10 +56,25 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/irq.h>
 
-    power-management@1fe27000 {
+    pmc: power-management@1fe27000 {

Drop the label.

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 68

Quoted 9 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +4 -0
         compatible = "loongson,ls2k1000-pmc", "syscon";
         reg = <0x1fe27000 0x58>;
         interrupt-parent = <&liointc1>;
         interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
         loongson,suspend-address = <0x0 0x1c000500>;
+
+        syscon-reboot {
+            compatible ="syscon-reboot";
+            regmap = <&pmc>;

No, why? It does not make much sense and is deprecated.

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 74

Quoted 6 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +6 -0
+            offset = <0x30>;
+            mask = <0x1>;
+        };
+
+        syscon-poweroff {
+            compatible ="syscon-poweroff";

Missing space.

Best regards,
Krzysztof

#16 lore raw

Re: [PATCH 4/5] dt-bindings: soc: loongson,ls2k-pmc: Allow syscon-reboot/syscon-poweroff as child

Hi Krzysztof:

Thanks for your reply.

Quoted 14 lines · Krzysztof Kozlowski
Quoted 12 lines · Binbin Zhou

The reboot and poweroff features are actually part of the Power Management Unit system controller, thus allow them as its children, instead of specifying as separate device nodes with syscon phandle.

required:
- compatible
- reg

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +0 -0
@@ -44,10 +56,25 @@ examples:
   - |
     #include <dt-bindings/interrupt-controller/irq.h>
 
Quoted 4 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 59

Quoted 2 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +1 -1
-    power-management@1fe27000 {
+    pmc: power-management@1fe27000 {

Drop the label.

OK...

Quoted 11 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 68

Quoted 10 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +4 -0
         compatible = "loongson,ls2k1000-pmc", "syscon";
         reg = <0x1fe27000 0x58>;
         interrupt-parent = <&liointc1>;
         interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
         loongson,suspend-address = <0x0 0x1c000500>;
+
+        syscon-reboot {
+            compatible ="syscon-reboot";
+            regmap = <&pmc>;
Quoted 1 line

No, why? It does not make much sense and is deprecated.

Oh, sorry, I should have been more careful, I'll delete it.

Quoted 9 lines

Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml examples: · line 74

Quoted 7 lines
Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml +6 -0
+            offset = <0x30>;
+            mask = <0x1>;
+        };
+
+        syscon-poweroff {
+            compatible ="syscon-poweroff";

Missing space.

I will fix it.

Thanks.
Binbin

Quoted 4 lines

Best regards,
Krzysztof

#17 lore raw

PATCH 5/5 soc: loongson: loongson_pm2: Populate children syscon nodes

In reply to Binbin Zhou

The syscon poweroff and reboot nodes logically belong to the Power Management Unit so populate possible children.

Without it, the reboot/poweroff feature becomes unavailable.

---
 drivers/soc/loongson/loongson2_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/soc/loongson/loongson2_pm.c +6 -0
index 6d2b3708e947..6e8fb170d454 100644
@@ -11,6 +11,7 @@
 #include <linux/input.h>
 #include <linux/suspend.h>
 #include <linux/interrupt.h>
+#include <linux/of_platform.h>
 #include <linux/pm_wakeirq.h>
 #include <linux/platform_device.h>
 #include <asm/bootinfo.h>
@@ -192,6 +193,11 @@ static int loongson2_pm_probe(struct platform_device *pdev)
 	if (loongson_sysconf.suspend_addr)
 		suspend_set_ops(&loongson2_suspend_ops);
 
+	/* Populate children */
+	retval = devm_of_platform_populate(dev);
+	if (retval)
+		dev_err(dev, "Error populating children, reboot and poweroff might not work properly\n");
+
 	return 0;
 }
 
Signature · 1 line
2.39.3