Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/3] soc: loongson2_pm: add power management support
@ 2023-05-22  9:31 Yinbo Zhu
  2023-05-22  9:31 ` [PATCH v2 1/3] loongarch: export loongarch pm interface Yinbo Zhu
  2023-05-22  9:31 ` [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm Yinbo Zhu
  0 siblings, 2 replies; 7+ messages in thread
From: Yinbo Zhu @ 2023-05-22  9:31 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Huacai Chen,
	WANG Xuerui, Rafael J . Wysocki, Pavel Machek, Tiezhu Yang,
	Marc Zyngier, Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu,
	linux-pm, devicetree, linux-kernel, loongarch
  Cc: Jianmin Lv, wanghongliang, Liu Peibao, loongson-kernel, Yinbo Zhu

Loongson-2 platform support Power Management Controller (ACPI) and this
series patch was to add PM driver that base on dts and PM binding support.

Change in v2:
		1. Fixup the "suspend-address" description.
		2. Remove the "return -EINVAL" in PM driver probe when firmware
		   no configure "suspend-address" property in dts in oder to
		   other PM state to work.

Yinbo Zhu (3):
  loongarch: export loongarch pm interface
  dt-bindings: soc: add loongson-2 pm
  soc: loongson2_pm: add power management support

 .../soc/loongson/loongson,ls2k-pmc.yaml       |  51 ++++
 MAINTAINERS                                   |   7 +
 arch/loongarch/include/asm/acpi.h             |   5 +-
 arch/loongarch/include/asm/suspend.h          |  10 +
 arch/loongarch/power/suspend.c                |  10 +-
 arch/loongarch/power/suspend_asm.S            |   8 +-
 drivers/soc/loongson/Kconfig                  |  10 +
 drivers/soc/loongson/Makefile                 |   1 +
 drivers/soc/loongson/loongson2_pm.c           | 235 ++++++++++++++++++
 9 files changed, 325 insertions(+), 12 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] loongarch: export loongarch pm interface
  2023-05-22  9:31 [PATCH v2 0/3] soc: loongson2_pm: add power management support Yinbo Zhu
@ 2023-05-22  9:31 ` Yinbo Zhu
  2023-05-24  1:57   ` Huacai Chen
  2023-05-22  9:31 ` [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm Yinbo Zhu
  1 sibling, 1 reply; 7+ messages in thread
From: Yinbo Zhu @ 2023-05-22  9:31 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Huacai Chen,
	WANG Xuerui, Rafael J . Wysocki, Pavel Machek, Tiezhu Yang,
	Marc Zyngier, Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu,
	linux-pm, devicetree, linux-kernel, loongarch
  Cc: Jianmin Lv, wanghongliang, Liu Peibao, loongson-kernel, Yinbo Zhu

Some Power Management Controllers need to support DTS and will use
the suspend interface thus this patch was to export such interface
for their use.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 arch/loongarch/include/asm/acpi.h    |  5 ++---
 arch/loongarch/include/asm/suspend.h | 10 ++++++++++
 arch/loongarch/power/suspend.c       | 10 +++++-----
 arch/loongarch/power/suspend_asm.S   |  8 ++++----
 4 files changed, 21 insertions(+), 12 deletions(-)
 create mode 100644 arch/loongarch/include/asm/suspend.h

diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 976a810352c6..d63507cc705f 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -8,6 +8,7 @@
 #ifndef _ASM_LOONGARCH_ACPI_H
 #define _ASM_LOONGARCH_ACPI_H
 
+#include <asm/suspend.h>
 #ifdef CONFIG_ACPI
 extern int acpi_strict;
 extern int acpi_disabled;
@@ -37,13 +38,11 @@ extern struct list_head acpi_wakeup_device_list;
 
 extern int loongarch_acpi_suspend(void);
 extern int (*acpi_suspend_lowlevel)(void);
-extern void loongarch_suspend_enter(void);
 
 static inline unsigned long acpi_get_wakeup_address(void)
 {
 #ifdef CONFIG_SUSPEND
-	extern void loongarch_wakeup_start(void);
-	return (unsigned long)loongarch_wakeup_start;
+	return (unsigned long)loongson_wakeup_start;
 #endif
 	return 0UL;
 }
diff --git a/arch/loongarch/include/asm/suspend.h b/arch/loongarch/include/asm/suspend.h
new file mode 100644
index 000000000000..a40b42f4f7f3
--- /dev/null
+++ b/arch/loongarch/include/asm/suspend.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_SUSPEND_H
+#define __ASM_SUSPEND_H
+
+void loongson_common_resume(void);
+void loongson_common_suspend(void);
+void loongson_suspend_enter(void);
+void loongson_wakeup_start(void);
+
+#endif
diff --git a/arch/loongarch/power/suspend.c b/arch/loongarch/power/suspend.c
index 5e19733e5e05..0587681b33ce 100644
--- a/arch/loongarch/power/suspend.c
+++ b/arch/loongarch/power/suspend.c
@@ -27,7 +27,7 @@ struct saved_registers {
 };
 static struct saved_registers saved_regs;
 
-static void arch_common_suspend(void)
+void loongson_common_suspend(void)
 {
 	save_counter();
 	saved_regs.pgd = csr_read64(LOONGARCH_CSR_PGDL);
@@ -40,7 +40,7 @@ static void arch_common_suspend(void)
 	loongarch_suspend_addr = loongson_sysconf.suspend_addr;
 }
 
-static void arch_common_resume(void)
+void loongson_common_resume(void)
 {
 	sync_counter();
 	local_flush_tlb_all();
@@ -62,12 +62,12 @@ int loongarch_acpi_suspend(void)
 	enable_gpe_wakeup();
 	enable_pci_wakeup();
 
-	arch_common_suspend();
+	loongson_common_suspend();
 
 	/* processor specific suspend */
-	loongarch_suspend_enter();
+	loongson_suspend_enter();
 
-	arch_common_resume();
+	loongson_common_resume();
 
 	return 0;
 }
diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S
index e2fc3b4e31f0..809abd3b119d 100644
--- a/arch/loongarch/power/suspend_asm.S
+++ b/arch/loongarch/power/suspend_asm.S
@@ -57,13 +57,13 @@
 	.align 12
 
 /* Sleep/wakeup code for Loongson-3 */
-SYM_FUNC_START(loongarch_suspend_enter)
+SYM_FUNC_START(loongson_suspend_enter)
 	SETUP_SLEEP
 	bl		__flush_cache_all
 
 	/* Pass RA and SP to BIOS */
 	addi.d		a1, sp, 0
-	la.pcrel	a0, loongarch_wakeup_start
+	la.pcrel	a0, loongson_wakeup_start
 	la.pcrel	t0, loongarch_suspend_addr
 	ld.d		t0, t0, 0
 	jirl		a0, t0, 0 /* Call BIOS's STR sleep routine */
@@ -72,7 +72,7 @@ SYM_FUNC_START(loongarch_suspend_enter)
 	 * This is where we return upon wakeup.
 	 * Reload all of the registers and return.
 	 */
-SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
+SYM_INNER_LABEL(loongson_wakeup_start, SYM_L_GLOBAL)
 	li.d		t0, CSR_DMW0_INIT	# UC, PLV0
 	csrwr		t0, LOONGARCH_CSR_DMWIN0
 	li.d		t0, CSR_DMW1_INIT	# CA, PLV0
@@ -89,4 +89,4 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
 	SETUP_WAKEUP
 	addi.d		sp, sp, PT_SIZE
 	jr		ra
-SYM_FUNC_END(loongarch_suspend_enter)
+SYM_FUNC_END(loongson_suspend_enter)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm
  2023-05-22  9:31 [PATCH v2 0/3] soc: loongson2_pm: add power management support Yinbo Zhu
  2023-05-22  9:31 ` [PATCH v2 1/3] loongarch: export loongarch pm interface Yinbo Zhu
@ 2023-05-22  9:31 ` Yinbo Zhu
  2023-05-22 12:47   ` Conor Dooley
  1 sibling, 1 reply; 7+ messages in thread
From: Yinbo Zhu @ 2023-05-22  9:31 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Huacai Chen,
	WANG Xuerui, Rafael J . Wysocki, Pavel Machek, Tiezhu Yang,
	Marc Zyngier, Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu,
	linux-pm, devicetree, linux-kernel, loongarch
  Cc: Jianmin Lv, wanghongliang, Liu Peibao, loongson-kernel, Yinbo Zhu

Add the Loongson-2 SoC Power Management Controller binding with DT
schema format using json-schema.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
 .../soc/loongson/loongson,ls2k-pmc.yaml       | 51 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml

diff --git a/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
new file mode 100644
index 000000000000..ddad62889c60
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/loongson/loongson,ls2k-pmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-2 Power Manager controller
+
+maintainers:
+  - Yinbo Zhu <zhuyinbo@loongson.cn>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - loongson,ls2k-pmc
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  suspend-address:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      The "suspend-address" is a deep sleep state (Suspend To RAM)
+      firmware entry address which was jumped from kernel and it's
+      value was dependent on specific platform firmware code. In
+      addition, the PM need according to it to indicate that current
+      SoC whether support Suspend To RAM.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    pmc: pm@1fe27000 {
+        compatible = "loongson,ls2k-pmc", "syscon";
+        reg = <0x1fe27000 0x58>;
+        interrupt-parent = <&liointc1>;
+        interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+        suspend-address = <0x1c000500>;
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index 7a91f14cad2e..bcd05f1fa5c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12190,6 +12190,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/hwinfo/loongson,ls2k-chipid.yaml
 F:	drivers/soc/loongson/loongson2_guts.c
 
+LOONGSON-2 SOC SERIES PM DRIVER
+M:	Yinbo Zhu <zhuyinbo@loongson.cn>
+L:	linux-pm@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
+
 LOONGSON-2 SOC SERIES PINCTRL DRIVER
 M:	zhanghongchen <zhanghongchen@loongson.cn>
 M:	Yinbo Zhu <zhuyinbo@loongson.cn>
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm
  2023-05-22  9:31 ` [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm Yinbo Zhu
@ 2023-05-22 12:47   ` Conor Dooley
  2023-05-23  3:22     ` zhuyinbo
  0 siblings, 1 reply; 7+ messages in thread
From: Conor Dooley @ 2023-05-22 12:47 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Huacai Chen,
	WANG Xuerui, Rafael J . Wysocki, Pavel Machek, Tiezhu Yang,
	Marc Zyngier, Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu,
	linux-pm, devicetree, linux-kernel, loongarch, Jianmin Lv,
	wanghongliang, Liu Peibao, loongson-kernel

[-- Attachment #1: Type: text/plain, Size: 3024 bytes --]

Hey!

On Mon, May 22, 2023 at 05:31:55PM +0800, Yinbo Zhu wrote:
> Add the Loongson-2 SoC Power Management Controller binding with DT
> schema format using json-schema.

Grabbing thread from lore.kernel.org/all/20230522093156.7108-3-zhuyinbo%40loongson.cn/t.mbox.gz
Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
  [PATCH v2 1/3] loongarch: export loongarch pm interface
    + Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
  [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm
    + Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
  ERROR: missing [3/3]!
---
Total patches: 2
---
WARNING: Thread incomplete!
Applying: loongarch: export loongarch pm interface
Applying: dt-bindings: soc: add loongson-2 pm

Looks like the user for these bindings got lost somewhere along the way?
Please make sure to keep a series threaded.

> 
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
>  .../soc/loongson/loongson,ls2k-pmc.yaml       | 51 +++++++++++++++++++
>  MAINTAINERS                                   |  6 +++
>  2 files changed, 57 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
> new file mode 100644
> index 000000000000..ddad62889c60
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
> @@ -0,0 +1,51 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/soc/loongson/loongson,ls2k-pmc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson-2 Power Manager controller
> +
> +maintainers:
> +  - Yinbo Zhu <zhuyinbo@loongson.cn>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - loongson,ls2k-pmc
> +      - const: syscon
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  suspend-address:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      The "suspend-address" is a deep sleep state (Suspend To RAM)
> +      firmware entry address which was jumped from kernel and it's
> +      value was dependent on specific platform firmware code. In
> +      addition, the PM need according to it to indicate that current
> +      SoC whether support Suspend To RAM.

I (still) think this property is rather odd, maybe I am just not really
understanding the property as it seems to be described partly in terms
of operating system behaviour rather than its actual function. "was
jumped from kernel" I don't get.

The whole setup here seems a bit odd, but that's for the loongson arch
folks reviewing the actual code to comment on!

Thanks,
Conor.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm
  2023-05-22 12:47   ` Conor Dooley
@ 2023-05-23  3:22     ` zhuyinbo
  0 siblings, 0 replies; 7+ messages in thread
From: zhuyinbo @ 2023-05-23  3:22 UTC (permalink / raw)
  To: Conor Dooley
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Huacai Chen,
	WANG Xuerui, Rafael J . Wysocki, Pavel Machek, Tiezhu Yang,
	Marc Zyngier, Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu,
	linux-pm, devicetree, linux-kernel, loongarch, Jianmin Lv,
	wanghongliang, Liu Peibao, loongson-kernel, zhuyinbo



在 2023/5/22 下午8:47, Conor Dooley 写道:
> Hey!
> 
> On Mon, May 22, 2023 at 05:31:55PM +0800, Yinbo Zhu wrote:
>> Add the Loongson-2 SoC Power Management Controller binding with DT
>> schema format using json-schema.
> 
> Grabbing thread from lore.kernel.org/all/20230522093156.7108-3-zhuyinbo%40loongson.cn/t.mbox.gz
> Checking for newer revisions
> Grabbing search results from lore.kernel.org
> Analyzing 3 messages in the thread
> Checking attestation on all messages, may take a moment...
> ---
>    [PATCH v2 1/3] loongarch: export loongarch pm interface
>      + Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
>    [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm
>      + Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
>    ERROR: missing [3/3]!
> ---
> Total patches: 2
> ---
> WARNING: Thread incomplete!
> Applying: loongarch: export loongarch pm interface
> Applying: dt-bindings: soc: add loongson-2 pm
> 
> Looks like the user for these bindings got lost somewhere along the way?
> Please make sure to keep a series threaded.

okay, I got it.  I will use a thread to send a series patch.

> 
>>
>> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
>> ---
>>   .../soc/loongson/loongson,ls2k-pmc.yaml       | 51 +++++++++++++++++++
>>   MAINTAINERS                                   |  6 +++
>>   2 files changed, 57 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
>> new file mode 100644
>> index 000000000000..ddad62889c60
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
>> @@ -0,0 +1,51 @@
>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/soc/loongson/loongson,ls2k-pmc.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Loongson-2 Power Manager controller
>> +
>> +maintainers:
>> +  - Yinbo Zhu <zhuyinbo@loongson.cn>
>> +
>> +properties:
>> +  compatible:
>> +    items:
>> +      - enum:
>> +          - loongson,ls2k-pmc
>> +      - const: syscon
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  interrupts:
>> +    maxItems: 1
>> +
>> +  suspend-address:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      The "suspend-address" is a deep sleep state (Suspend To RAM)
>> +      firmware entry address which was jumped from kernel and it's
>> +      value was dependent on specific platform firmware code. In
>> +      addition, the PM need according to it to indicate that current
>> +      SoC whether support Suspend To RAM.
> 
> I (still) think this property is rather odd, maybe I am just not really
> understanding the property as it seems to be described partly in terms
> of operating system behaviour rather than its actual function. "was
> jumped from kernel" I don't get.

The function Suspend-To-RAM include kernel logic and firmware logic and
if no define "suspend-address" that kernel will can't into firmware 
after suspend to ram and the Suspend-To-RAM function will not be 
finished in LoongArch.


> 
> The whole setup here seems a bit odd, but that's for the loongson arch
> folks reviewing the actual code to comment on!

okay, I got it.

Thanks
Yinbo.
> 
> Thanks,
> Conor.
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] loongarch: export loongarch pm interface
  2023-05-22  9:31 ` [PATCH v2 1/3] loongarch: export loongarch pm interface Yinbo Zhu
@ 2023-05-24  1:57   ` Huacai Chen
  2023-05-24  3:41     ` zhuyinbo
  0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2023-05-24  1:57 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, WANG Xuerui,
	Rafael J . Wysocki, Pavel Machek, Tiezhu Yang, Marc Zyngier,
	Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu, linux-pm,
	devicetree, linux-kernel, loongarch, Jianmin Lv, wanghongliang,
	Liu Peibao, loongson-kernel

Hi, Yinbo,

The title can be regular:
 LoongArch: Export some arch-specific pm interfaces

And in commit message,
"Some Power Management Controllers" should be
"Some power management controllers" or
"Some PMC (Power Management Controllers)"

Huacai

On Mon, May 22, 2023 at 5:32 PM Yinbo Zhu <zhuyinbo@loongson.cn> wrote:
>
> Some Power Management Controllers need to support DTS and will use
> the suspend interface thus this patch was to export such interface
> for their use.
>
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
>  arch/loongarch/include/asm/acpi.h    |  5 ++---
>  arch/loongarch/include/asm/suspend.h | 10 ++++++++++
>  arch/loongarch/power/suspend.c       | 10 +++++-----
>  arch/loongarch/power/suspend_asm.S   |  8 ++++----
>  4 files changed, 21 insertions(+), 12 deletions(-)
>  create mode 100644 arch/loongarch/include/asm/suspend.h
>
> diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
> index 976a810352c6..d63507cc705f 100644
> --- a/arch/loongarch/include/asm/acpi.h
> +++ b/arch/loongarch/include/asm/acpi.h
> @@ -8,6 +8,7 @@
>  #ifndef _ASM_LOONGARCH_ACPI_H
>  #define _ASM_LOONGARCH_ACPI_H
>
> +#include <asm/suspend.h>
>  #ifdef CONFIG_ACPI
>  extern int acpi_strict;
>  extern int acpi_disabled;
> @@ -37,13 +38,11 @@ extern struct list_head acpi_wakeup_device_list;
>
>  extern int loongarch_acpi_suspend(void);
>  extern int (*acpi_suspend_lowlevel)(void);
> -extern void loongarch_suspend_enter(void);
>
>  static inline unsigned long acpi_get_wakeup_address(void)
>  {
>  #ifdef CONFIG_SUSPEND
> -       extern void loongarch_wakeup_start(void);
> -       return (unsigned long)loongarch_wakeup_start;
> +       return (unsigned long)loongson_wakeup_start;
>  #endif
>         return 0UL;
>  }
> diff --git a/arch/loongarch/include/asm/suspend.h b/arch/loongarch/include/asm/suspend.h
> new file mode 100644
> index 000000000000..a40b42f4f7f3
> --- /dev/null
> +++ b/arch/loongarch/include/asm/suspend.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __ASM_SUSPEND_H
> +#define __ASM_SUSPEND_H
> +
> +void loongson_common_resume(void);
> +void loongson_common_suspend(void);
> +void loongson_suspend_enter(void);
> +void loongson_wakeup_start(void);
> +
> +#endif
> diff --git a/arch/loongarch/power/suspend.c b/arch/loongarch/power/suspend.c
> index 5e19733e5e05..0587681b33ce 100644
> --- a/arch/loongarch/power/suspend.c
> +++ b/arch/loongarch/power/suspend.c
> @@ -27,7 +27,7 @@ struct saved_registers {
>  };
>  static struct saved_registers saved_regs;
>
> -static void arch_common_suspend(void)
> +void loongson_common_suspend(void)
>  {
>         save_counter();
>         saved_regs.pgd = csr_read64(LOONGARCH_CSR_PGDL);
> @@ -40,7 +40,7 @@ static void arch_common_suspend(void)
>         loongarch_suspend_addr = loongson_sysconf.suspend_addr;
>  }
>
> -static void arch_common_resume(void)
> +void loongson_common_resume(void)
>  {
>         sync_counter();
>         local_flush_tlb_all();
> @@ -62,12 +62,12 @@ int loongarch_acpi_suspend(void)
>         enable_gpe_wakeup();
>         enable_pci_wakeup();
>
> -       arch_common_suspend();
> +       loongson_common_suspend();
>
>         /* processor specific suspend */
> -       loongarch_suspend_enter();
> +       loongson_suspend_enter();
>
> -       arch_common_resume();
> +       loongson_common_resume();
>
>         return 0;
>  }
> diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S
> index e2fc3b4e31f0..809abd3b119d 100644
> --- a/arch/loongarch/power/suspend_asm.S
> +++ b/arch/loongarch/power/suspend_asm.S
> @@ -57,13 +57,13 @@
>         .align 12
>
>  /* Sleep/wakeup code for Loongson-3 */
> -SYM_FUNC_START(loongarch_suspend_enter)
> +SYM_FUNC_START(loongson_suspend_enter)
>         SETUP_SLEEP
>         bl              __flush_cache_all
>
>         /* Pass RA and SP to BIOS */
>         addi.d          a1, sp, 0
> -       la.pcrel        a0, loongarch_wakeup_start
> +       la.pcrel        a0, loongson_wakeup_start
>         la.pcrel        t0, loongarch_suspend_addr
>         ld.d            t0, t0, 0
>         jirl            a0, t0, 0 /* Call BIOS's STR sleep routine */
> @@ -72,7 +72,7 @@ SYM_FUNC_START(loongarch_suspend_enter)
>          * This is where we return upon wakeup.
>          * Reload all of the registers and return.
>          */
> -SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
> +SYM_INNER_LABEL(loongson_wakeup_start, SYM_L_GLOBAL)
>         li.d            t0, CSR_DMW0_INIT       # UC, PLV0
>         csrwr           t0, LOONGARCH_CSR_DMWIN0
>         li.d            t0, CSR_DMW1_INIT       # CA, PLV0
> @@ -89,4 +89,4 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
>         SETUP_WAKEUP
>         addi.d          sp, sp, PT_SIZE
>         jr              ra
> -SYM_FUNC_END(loongarch_suspend_enter)
> +SYM_FUNC_END(loongson_suspend_enter)
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] loongarch: export loongarch pm interface
  2023-05-24  1:57   ` Huacai Chen
@ 2023-05-24  3:41     ` zhuyinbo
  0 siblings, 0 replies; 7+ messages in thread
From: zhuyinbo @ 2023-05-24  3:41 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, WANG Xuerui,
	Rafael J . Wysocki, Pavel Machek, Tiezhu Yang, Marc Zyngier,
	Youling Tang, Baoqi Zhang, Arnd Bergmann, Yun Liu, linux-pm,
	devicetree, linux-kernel, loongarch, Jianmin Lv, wanghongliang,
	Liu Peibao, loongson-kernel, zhuyinbo



在 2023/5/24 上午9:57, Huacai Chen 写道:
> Hi, Yinbo,
> 
> The title can be regular:
>   LoongArch: Export some arch-specific pm interfaces
> 
> And in commit message,
> "Some Power Management Controllers" should be
> "Some power management controllers" or
> "Some PMC (Power Management Controllers)"


okay, I got it.

Thanks.
> 
> Huacai
> 
> On Mon, May 22, 2023 at 5:32 PM Yinbo Zhu <zhuyinbo@loongson.cn> wrote:
>>
>> Some Power Management Controllers need to support DTS and will use
>> the suspend interface thus this patch was to export such interface
>> for their use.
>>
>> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
>> ---
>>   arch/loongarch/include/asm/acpi.h    |  5 ++---
>>   arch/loongarch/include/asm/suspend.h | 10 ++++++++++
>>   arch/loongarch/power/suspend.c       | 10 +++++-----
>>   arch/loongarch/power/suspend_asm.S   |  8 ++++----
>>   4 files changed, 21 insertions(+), 12 deletions(-)
>>   create mode 100644 arch/loongarch/include/asm/suspend.h
>>
>> diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
>> index 976a810352c6..d63507cc705f 100644
>> --- a/arch/loongarch/include/asm/acpi.h
>> +++ b/arch/loongarch/include/asm/acpi.h
>> @@ -8,6 +8,7 @@
>>   #ifndef _ASM_LOONGARCH_ACPI_H
>>   #define _ASM_LOONGARCH_ACPI_H
>>
>> +#include <asm/suspend.h>
>>   #ifdef CONFIG_ACPI
>>   extern int acpi_strict;
>>   extern int acpi_disabled;
>> @@ -37,13 +38,11 @@ extern struct list_head acpi_wakeup_device_list;
>>
>>   extern int loongarch_acpi_suspend(void);
>>   extern int (*acpi_suspend_lowlevel)(void);
>> -extern void loongarch_suspend_enter(void);
>>
>>   static inline unsigned long acpi_get_wakeup_address(void)
>>   {
>>   #ifdef CONFIG_SUSPEND
>> -       extern void loongarch_wakeup_start(void);
>> -       return (unsigned long)loongarch_wakeup_start;
>> +       return (unsigned long)loongson_wakeup_start;
>>   #endif
>>          return 0UL;
>>   }
>> diff --git a/arch/loongarch/include/asm/suspend.h b/arch/loongarch/include/asm/suspend.h
>> new file mode 100644
>> index 000000000000..a40b42f4f7f3
>> --- /dev/null
>> +++ b/arch/loongarch/include/asm/suspend.h
>> @@ -0,0 +1,10 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef __ASM_SUSPEND_H
>> +#define __ASM_SUSPEND_H
>> +
>> +void loongson_common_resume(void);
>> +void loongson_common_suspend(void);
>> +void loongson_suspend_enter(void);
>> +void loongson_wakeup_start(void);
>> +
>> +#endif
>> diff --git a/arch/loongarch/power/suspend.c b/arch/loongarch/power/suspend.c
>> index 5e19733e5e05..0587681b33ce 100644
>> --- a/arch/loongarch/power/suspend.c
>> +++ b/arch/loongarch/power/suspend.c
>> @@ -27,7 +27,7 @@ struct saved_registers {
>>   };
>>   static struct saved_registers saved_regs;
>>
>> -static void arch_common_suspend(void)
>> +void loongson_common_suspend(void)
>>   {
>>          save_counter();
>>          saved_regs.pgd = csr_read64(LOONGARCH_CSR_PGDL);
>> @@ -40,7 +40,7 @@ static void arch_common_suspend(void)
>>          loongarch_suspend_addr = loongson_sysconf.suspend_addr;
>>   }
>>
>> -static void arch_common_resume(void)
>> +void loongson_common_resume(void)
>>   {
>>          sync_counter();
>>          local_flush_tlb_all();
>> @@ -62,12 +62,12 @@ int loongarch_acpi_suspend(void)
>>          enable_gpe_wakeup();
>>          enable_pci_wakeup();
>>
>> -       arch_common_suspend();
>> +       loongson_common_suspend();
>>
>>          /* processor specific suspend */
>> -       loongarch_suspend_enter();
>> +       loongson_suspend_enter();
>>
>> -       arch_common_resume();
>> +       loongson_common_resume();
>>
>>          return 0;
>>   }
>> diff --git a/arch/loongarch/power/suspend_asm.S b/arch/loongarch/power/suspend_asm.S
>> index e2fc3b4e31f0..809abd3b119d 100644
>> --- a/arch/loongarch/power/suspend_asm.S
>> +++ b/arch/loongarch/power/suspend_asm.S
>> @@ -57,13 +57,13 @@
>>          .align 12
>>
>>   /* Sleep/wakeup code for Loongson-3 */
>> -SYM_FUNC_START(loongarch_suspend_enter)
>> +SYM_FUNC_START(loongson_suspend_enter)
>>          SETUP_SLEEP
>>          bl              __flush_cache_all
>>
>>          /* Pass RA and SP to BIOS */
>>          addi.d          a1, sp, 0
>> -       la.pcrel        a0, loongarch_wakeup_start
>> +       la.pcrel        a0, loongson_wakeup_start
>>          la.pcrel        t0, loongarch_suspend_addr
>>          ld.d            t0, t0, 0
>>          jirl            a0, t0, 0 /* Call BIOS's STR sleep routine */
>> @@ -72,7 +72,7 @@ SYM_FUNC_START(loongarch_suspend_enter)
>>           * This is where we return upon wakeup.
>>           * Reload all of the registers and return.
>>           */
>> -SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
>> +SYM_INNER_LABEL(loongson_wakeup_start, SYM_L_GLOBAL)
>>          li.d            t0, CSR_DMW0_INIT       # UC, PLV0
>>          csrwr           t0, LOONGARCH_CSR_DMWIN0
>>          li.d            t0, CSR_DMW1_INIT       # CA, PLV0
>> @@ -89,4 +89,4 @@ SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
>>          SETUP_WAKEUP
>>          addi.d          sp, sp, PT_SIZE
>>          jr              ra
>> -SYM_FUNC_END(loongarch_suspend_enter)
>> +SYM_FUNC_END(loongson_suspend_enter)
>> --
>> 2.20.1
>>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-24  3:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22  9:31 [PATCH v2 0/3] soc: loongson2_pm: add power management support Yinbo Zhu
2023-05-22  9:31 ` [PATCH v2 1/3] loongarch: export loongarch pm interface Yinbo Zhu
2023-05-24  1:57   ` Huacai Chen
2023-05-24  3:41     ` zhuyinbo
2023-05-22  9:31 ` [PATCH v2 2/3] dt-bindings: soc: add loongson-2 pm Yinbo Zhu
2023-05-22 12:47   ` Conor Dooley
2023-05-23  3:22     ` zhuyinbo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox