All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] platform/chrome: Add a new interrupt path for cros_ec_lpc
@ 2018-10-03 18:45 Enrico Granata
  2018-10-10  4:45 ` Benson Leung
  0 siblings, 1 reply; 2+ messages in thread
From: Enrico Granata @ 2018-10-03 18:45 UTC (permalink / raw)
  To: Benson Leung, Olof Johansson, linux-kernel, gwendal; +Cc: Enrico Granata

From: Enrico Granata <egranata@chromium.org>

This commit allows cros_ec_lpc to register a direct IRQ instead of relying
on the ACPI notification chain to receive MKBP events.

This change is done in the interest of allowing reduced jitter in the
communication path between the CrOS EC and the host for receiving sensor
data.

Signed-off-by: Enrico Granata <egranata@chromium.org>
---
 drivers/platform/chrome/cros_ec_lpc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 31c8b8c49e45..07eea608915e 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -25,6 +25,7 @@
 #include <linux/dmi.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/interrupt.h>
 #include <linux/mfd/cros_ec.h>
 #include <linux/mfd/cros_ec_commands.h>
 #include <linux/mfd/cros_ec_lpc_reg.h>
@@ -248,7 +249,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
 	u8 buf[2];
-	int ret;
+	int irq, ret;
 
 	if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
 				 dev_name(dev))) {
@@ -287,6 +288,18 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 			   sizeof(struct ec_response_get_protocol_info);
 	ec_dev->dout_size = sizeof(struct ec_host_request);
 
+	/*
+	 * Some boards do not have an IRQ allotted for cros_ec_lpc,
+	 * which makes ENXIO an expected (and safe) scenario.
+	 */
+	irq = platform_get_irq(pdev, 0);
+	if (irq > 0)
+		ec_dev->irq = irq;
+	else if (irq != -ENXIO) {
+		dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq);
+		return irq;
+	}
+
 	ret = cros_ec_register(ec_dev);
 	if (ret) {
 		dev_err(dev, "couldn't register ec_dev (%d)\n", ret);
@@ -294,11 +307,11 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	}
 
 	/*
-	 * Connect a notify handler to process MKBP messages if we have a
-	 * companion ACPI device.
+	 * If we have a companion ACPI device and no dedicated IRQ
+	 * connect a notify handler to process MKBP messages.
 	 */
 	adev = ACPI_COMPANION(dev);
-	if (adev) {
+	if (adev && ec_dev->irq <= 0) {
 		status = acpi_install_notify_handler(adev->handle,
 						     ACPI_ALL_NOTIFY,
 						     cros_ec_lpc_acpi_notify,
-- 
2.19.0.605.g01d371f741-goog


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

* Re: [PATCH 2/2] platform/chrome: Add a new interrupt path for cros_ec_lpc
  2018-10-03 18:45 [PATCH 2/2] platform/chrome: Add a new interrupt path for cros_ec_lpc Enrico Granata
@ 2018-10-10  4:45 ` Benson Leung
  0 siblings, 0 replies; 2+ messages in thread
From: Benson Leung @ 2018-10-10  4:45 UTC (permalink / raw)
  To: Enrico Granata
  Cc: Benson Leung, Olof Johansson, linux-kernel, gwendal, Enrico Granata

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

Hi Enrico,

On Wed, Oct 03, 2018 at 11:45:06AM -0700, Enrico Granata wrote:
> From: Enrico Granata <egranata@chromium.org>
> 
> This commit allows cros_ec_lpc to register a direct IRQ instead of relying
> on the ACPI notification chain to receive MKBP events.
> 
> This change is done in the interest of allowing reduced jitter in the
> communication path between the CrOS EC and the host for receiving sensor
> data.
> 
> Signed-off-by: Enrico Granata <egranata@chromium.org>

Applied for v4.20. Thanks!

Benson

> ---
>  drivers/platform/chrome/cros_ec_lpc.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
> index 31c8b8c49e45..07eea608915e 100644
> --- a/drivers/platform/chrome/cros_ec_lpc.c
> +++ b/drivers/platform/chrome/cros_ec_lpc.c
> @@ -25,6 +25,7 @@
>  #include <linux/dmi.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/interrupt.h>
>  #include <linux/mfd/cros_ec.h>
>  #include <linux/mfd/cros_ec_commands.h>
>  #include <linux/mfd/cros_ec_lpc_reg.h>
> @@ -248,7 +249,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
>  	acpi_status status;
>  	struct cros_ec_device *ec_dev;
>  	u8 buf[2];
> -	int ret;
> +	int irq, ret;
>  
>  	if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE,
>  				 dev_name(dev))) {
> @@ -287,6 +288,18 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
>  			   sizeof(struct ec_response_get_protocol_info);
>  	ec_dev->dout_size = sizeof(struct ec_host_request);
>  
> +	/*
> +	 * Some boards do not have an IRQ allotted for cros_ec_lpc,
> +	 * which makes ENXIO an expected (and safe) scenario.
> +	 */
> +	irq = platform_get_irq(pdev, 0);
> +	if (irq > 0)
> +		ec_dev->irq = irq;
> +	else if (irq != -ENXIO) {
> +		dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq);
> +		return irq;
> +	}
> +
>  	ret = cros_ec_register(ec_dev);
>  	if (ret) {
>  		dev_err(dev, "couldn't register ec_dev (%d)\n", ret);
> @@ -294,11 +307,11 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
>  	}
>  
>  	/*
> -	 * Connect a notify handler to process MKBP messages if we have a
> -	 * companion ACPI device.
> +	 * If we have a companion ACPI device and no dedicated IRQ
> +	 * connect a notify handler to process MKBP messages.
>  	 */
>  	adev = ACPI_COMPANION(dev);
> -	if (adev) {
> +	if (adev && ec_dev->irq <= 0) {
>  		status = acpi_install_notify_handler(adev->handle,
>  						     ACPI_ALL_NOTIFY,
>  						     cros_ec_lpc_acpi_notify,
> -- 
> 2.19.0.605.g01d371f741-goog
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

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

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

end of thread, other threads:[~2018-10-10  4:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 18:45 [PATCH 2/2] platform/chrome: Add a new interrupt path for cros_ec_lpc Enrico Granata
2018-10-10  4:45 ` Benson Leung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.