Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* RE: [PATCH] ACPICA: Events: support fixed pcie wake event
       [not found] <1617278736-7400-1-git-send-email-lvjianmin@loongson.cn>
@ 2021-04-01 20:56 ` Moore, Robert
  2021-04-15  8:35   ` Jianmin Lv
  0 siblings, 1 reply; 2+ messages in thread
From: Moore, Robert @ 2021-04-01 20:56 UTC (permalink / raw)
  To: Jianmin Lv, Kaneda, Erik, Wysocki, Rafael J, Len Brown
  Cc: linux-acpi, devel, linux-kernel

Can you send/point us to the spec that this change is based upon?
Thanks,
Bob


-----Original Message-----
From: Jianmin Lv <lvjianmin@loongson.cn> 
Sent: Thursday, April 01, 2021 5:06 AM
To: Moore, Robert <robert.moore@intel.com>; Kaneda, Erik <erik.kaneda@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org; lvjianmin <lvjianmin@loongson.cn>
Subject: [PATCH] ACPICA: Events: support fixed pcie wake event

From: lvjianmin <lvjianmin@loongson.cn>

Some chipsets support fixed pcie wake event which is defined in the PM1 block, such as LS7A1000 of Loongson company, so we add code to handle it.

Signed-off-by: lvjianmin <lvjianmin@loongson.cn>

diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c index 35385148fedb..08ba368beb2d 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -185,6 +185,10 @@ u32 acpi_ev_fixed_event_detect(void)
 		return (int_status);
 	}
 
+	if (fixed_enable & ACPI_BITMASK_PCIEXP_WAKE_DISABLE)
+		fixed_enable &= ~ACPI_BITMASK_PCIEXP_WAKE_DISABLE;
+	else
+		fixed_enable |= ACPI_BITMASK_PCIEXP_WAKE_DISABLE;
 	ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
 			  "Fixed Event Block: Enable %08X Status %08X\n",
 			  fixed_enable, fixed_status));
@@ -250,8 +254,8 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
 	if (!acpi_gbl_fixed_event_handlers[event].handler) {
 		(void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
 					      enable_register_id,
-					      ACPI_DISABLE_EVENT);
-
+						event == ACPI_EVENT_PCIE_WAKE ?
+						ACPI_ENABLE_EVENT : ACPI_DISABLE_EVENT);
 		ACPI_ERROR((AE_INFO,
 			    "No installed handler for fixed event - %s (%u), disabling",
 			    acpi_ut_get_event_name(event), event)); diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 14baa13bf848..7e7ea4c2e914 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -312,6 +312,18 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
 				    [ACPI_EVENT_SLEEP_BUTTON].
 				    status_register_id, ACPI_CLEAR_STATUS);
 
+	/* Enable pcie wake event if support */
+	if ((acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE)) {
+		(void)
+		acpi_write_bit_register(acpi_gbl_fixed_event_info
+				[ACPI_EVENT_PCIE_WAKE].
+				enable_register_id, ACPI_DISABLE_EVENT);
+		(void)
+		acpi_write_bit_register(acpi_gbl_fixed_event_info
+				[ACPI_EVENT_PCIE_WAKE].
+				status_register_id, ACPI_CLEAR_STATUS);
+	}
+
 	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
 	return_ACPI_STATUS(status);
 }
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 59a48371a7bc..68baf16d8a02 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -186,6 +186,10 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
 					ACPI_BITREG_RT_CLOCK_ENABLE,
 					ACPI_BITMASK_RT_CLOCK_STATUS,
 					ACPI_BITMASK_RT_CLOCK_ENABLE},
+	/* ACPI_EVENT_PCIE_WAKE		*/ {ACPI_BITREG_PCIEXP_WAKE_STATUS,
+					ACPI_BITREG_PCIEXP_WAKE_DISABLE,
+					ACPI_BITMASK_PCIEXP_WAKE_STATUS,
+					ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
 };
 #endif				/* !ACPI_REDUCED_HARDWARE */
 
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 92c71dfce0d5..0b6c72033487 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -714,7 +714,8 @@ typedef u32 acpi_event_type;
 #define ACPI_EVENT_POWER_BUTTON         2
 #define ACPI_EVENT_SLEEP_BUTTON         3
 #define ACPI_EVENT_RTC                  4
-#define ACPI_EVENT_MAX                  4
+#define ACPI_EVENT_PCIE_WAKE            5
+#define ACPI_EVENT_MAX                  5
 #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
 
 /*
--
2.27.0


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

* Re: [PATCH] ACPICA: Events: support fixed pcie wake event
  2021-04-01 20:56 ` [PATCH] ACPICA: Events: support fixed pcie wake event Moore, Robert
@ 2021-04-15  8:35   ` Jianmin Lv
  0 siblings, 0 replies; 2+ messages in thread
From: Jianmin Lv @ 2021-04-15  8:35 UTC (permalink / raw)
  To: Moore, Robert, Kaneda, Erik, Wysocki, Rafael J, Len Brown
  Cc: linux-acpi, devel, linux-kernel

Hi, Bob

Thanks for your reply!

I have submitted V2 in which related description in ACPI spec are added, 
please review it.


See V2 at:

https://lore.kernel.org/linux-acpi/1617335733-5942-1-git-send-email-lvjianmin@loongson.cn/T/#u

Thanks sincerely!

On 04/01/2021 04:56 PM, Moore, Robert wrote:
> Can you send/point us to the spec that this change is based upon?
> Thanks,
> Bob
>
>
> -----Original Message-----
> From: Jianmin Lv <lvjianmin@loongson.cn>
> Sent: Thursday, April 01, 2021 5:06 AM
> To: Moore, Robert <robert.moore@intel.com>; Kaneda, Erik <erik.kaneda@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org; lvjianmin <lvjianmin@loongson.cn>
> Subject: [PATCH] ACPICA: Events: support fixed pcie wake event
>
> From: lvjianmin <lvjianmin@loongson.cn>
>
> Some chipsets support fixed pcie wake event which is defined in the PM1 block, such as LS7A1000 of Loongson company, so we add code to handle it.
>
> Signed-off-by: lvjianmin <lvjianmin@loongson.cn>
>
> diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c index 35385148fedb..08ba368beb2d 100644
> --- a/drivers/acpi/acpica/evevent.c
> +++ b/drivers/acpi/acpica/evevent.c
> @@ -185,6 +185,10 @@ u32 acpi_ev_fixed_event_detect(void)
>   		return (int_status);
>   	}
>   
> +	if (fixed_enable & ACPI_BITMASK_PCIEXP_WAKE_DISABLE)
> +		fixed_enable &= ~ACPI_BITMASK_PCIEXP_WAKE_DISABLE;
> +	else
> +		fixed_enable |= ACPI_BITMASK_PCIEXP_WAKE_DISABLE;
>   	ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
>   			  "Fixed Event Block: Enable %08X Status %08X\n",
>   			  fixed_enable, fixed_status));
> @@ -250,8 +254,8 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
>   	if (!acpi_gbl_fixed_event_handlers[event].handler) {
>   		(void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
>   					      enable_register_id,
> -					      ACPI_DISABLE_EVENT);
> -
> +						event == ACPI_EVENT_PCIE_WAKE ?
> +						ACPI_ENABLE_EVENT : ACPI_DISABLE_EVENT);
>   		ACPI_ERROR((AE_INFO,
>   			    "No installed handler for fixed event - %s (%u), disabling",
>   			    acpi_ut_get_event_name(event), event)); diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index 14baa13bf848..7e7ea4c2e914 100644
> --- a/drivers/acpi/acpica/hwsleep.c
> +++ b/drivers/acpi/acpica/hwsleep.c
> @@ -312,6 +312,18 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
>   				    [ACPI_EVENT_SLEEP_BUTTON].
>   				    status_register_id, ACPI_CLEAR_STATUS);
>   
> +	/* Enable pcie wake event if support */
> +	if ((acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE)) {
> +		(void)
> +		acpi_write_bit_register(acpi_gbl_fixed_event_info
> +				[ACPI_EVENT_PCIE_WAKE].
> +				enable_register_id, ACPI_DISABLE_EVENT);
> +		(void)
> +		acpi_write_bit_register(acpi_gbl_fixed_event_info
> +				[ACPI_EVENT_PCIE_WAKE].
> +				status_register_id, ACPI_CLEAR_STATUS);
> +	}
> +
>   	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
>   	return_ACPI_STATUS(status);
>   }
> diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index 59a48371a7bc..68baf16d8a02 100644
> --- a/drivers/acpi/acpica/utglobal.c
> +++ b/drivers/acpi/acpica/utglobal.c
> @@ -186,6 +186,10 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
>   					ACPI_BITREG_RT_CLOCK_ENABLE,
>   					ACPI_BITMASK_RT_CLOCK_STATUS,
>   					ACPI_BITMASK_RT_CLOCK_ENABLE},
> +	/* ACPI_EVENT_PCIE_WAKE		*/ {ACPI_BITREG_PCIEXP_WAKE_STATUS,
> +					ACPI_BITREG_PCIEXP_WAKE_DISABLE,
> +					ACPI_BITMASK_PCIEXP_WAKE_STATUS,
> +					ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
>   };
>   #endif				/* !ACPI_REDUCED_HARDWARE */
>   
> diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 92c71dfce0d5..0b6c72033487 100644
> --- a/include/acpi/actypes.h
> +++ b/include/acpi/actypes.h
> @@ -714,7 +714,8 @@ typedef u32 acpi_event_type;
>   #define ACPI_EVENT_POWER_BUTTON         2
>   #define ACPI_EVENT_SLEEP_BUTTON         3
>   #define ACPI_EVENT_RTC                  4
> -#define ACPI_EVENT_MAX                  4
> +#define ACPI_EVENT_PCIE_WAKE            5
> +#define ACPI_EVENT_MAX                  5
>   #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
>   
>   /*
> --
> 2.27.0


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1617278736-7400-1-git-send-email-lvjianmin@loongson.cn>
2021-04-01 20:56 ` [PATCH] ACPICA: Events: support fixed pcie wake event Moore, Robert
2021-04-15  8:35   ` Jianmin Lv

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git