All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis.oss@gmail.com>
To: robh@kernel.org, marcel@holtmann.org, sre@kernel.org,
	loic.poulain@gmail.com, johan@kernel.org, lukas@wunner.de,
	hdegoede@redhat.com, rafael@kernel.org, greg@kroah.com
Cc: linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-acpi@vger.kernel.org, frederic.danis.oss@gmail.com
Subject: [PATCH v3 2/2] ACPI / scan: Fix enumeration for special UART devices
Date: Wed, 11 Oct 2017 10:32:14 +0200	[thread overview]
Message-ID: <1507710734-32520-3-git-send-email-frederic.danis.oss@gmail.com> (raw)
In-Reply-To: <1507710734-32520-1-git-send-email-frederic.danis.oss@gmail.com>

UART devices is expected to be enumerated by SerDev subsystem.

During ACPI scan, serial devices behind SPI, I2C or UART buses are not
enumerated, allowing them to be enumerated by their respective parents.

Rename *spi_i2c_slave* to *serial_bus_slave* as this will be used for serial
devices on serial buses (SPI, I2C or UART).

On Macs an empty ResourceTemplate is returned for uart slaves.
Instead the device properties "baud", "parity", "dataBits", "stopBits" are
provided. Add a check for "baud" in acpi_is_serial_bus_slave().

Signed-off-by: Frédéric Danis <frederic.danis.oss@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/acpi/scan.c     | 37 +++++++++++++++++--------------------
 include/acpi/acpi_bus.h |  2 +-
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 602f8ff..860b698 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1505,41 +1505,38 @@ static void acpi_init_coherency(struct acpi_device *adev)
 	adev->flags.coherent_dma = cca;
 }
 
-static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
+static int acpi_check_serial_bus_slave(struct acpi_resource *ares, void *data)
 {
-	bool *is_spi_i2c_slave_p = data;
+	bool *is_serial_bus_slave_p = data;
 
 	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
 		return 1;
 
-	/*
-	 * devices that are connected to UART still need to be enumerated to
-	 * platform bus
-	 */
-	if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
-		*is_spi_i2c_slave_p = true;
+	*is_serial_bus_slave_p = true;
 
 	 /* no need to do more checking */
 	return -1;
 }
 
-static bool acpi_is_spi_i2c_slave(struct acpi_device *device)
+static bool acpi_is_serial_bus_slave(struct acpi_device *device)
 {
 	struct list_head resource_list;
-	bool is_spi_i2c_slave = false;
+	bool is_serial_bus_slave = false;
 
 	/* Macs use device properties in lieu of _CRS resources */
 	if (x86_apple_machine &&
 	    (fwnode_property_present(&device->fwnode, "spiSclkPeriod") ||
-	     fwnode_property_present(&device->fwnode, "i2cAddress")))
+	     fwnode_property_present(&device->fwnode, "i2cAddress") ||
+	     fwnode_property_present(&device->fwnode, "baud")))
 		return true;
 
 	INIT_LIST_HEAD(&resource_list);
-	acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
-			       &is_spi_i2c_slave);
+	acpi_dev_get_resources(device, &resource_list,
+			       acpi_check_serial_bus_slave,
+			       &is_serial_bus_slave);
 	acpi_dev_free_resource_list(&resource_list);
 
-	return is_spi_i2c_slave;
+	return is_serial_bus_slave;
 }
 
 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
@@ -1557,7 +1554,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	acpi_bus_get_flags(device);
 	device->flags.match_driver = false;
 	device->flags.initialized = true;
-	device->flags.spi_i2c_slave = acpi_is_spi_i2c_slave(device);
+	device->flags.serial_bus_slave = acpi_is_serial_bus_slave(device);
 	acpi_device_clear_enumerated(device);
 	device_initialize(&device->dev);
 	dev_set_uevent_suppress(&device->dev, true);
@@ -1841,10 +1838,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
 static void acpi_default_enumeration(struct acpi_device *device)
 {
 	/*
-	 * Do not enumerate SPI/I2C slaves as they will be enumerated by their
-	 * respective parents.
+	 * Do not enumerate SPI/I2C/UART slaves as they will be enumerated by
+	 * their respective parents.
 	 */
-	if (!device->flags.spi_i2c_slave) {
+	if (!device->flags.serial_bus_slave) {
 		acpi_create_platform_device(device, NULL);
 		acpi_device_set_enumerated(device);
 	} else {
@@ -1941,7 +1938,7 @@ static void acpi_bus_attach(struct acpi_device *device)
 		return;
 
 	device->flags.match_driver = true;
-	if (ret > 0 && !device->flags.spi_i2c_slave) {
+	if (ret > 0 && !device->flags.serial_bus_slave) {
 		acpi_device_set_enumerated(device);
 		goto ok;
 	}
@@ -1950,7 +1947,7 @@ static void acpi_bus_attach(struct acpi_device *device)
 	if (ret < 0)
 		return;
 
-	if (!device->pnp.type.platform_id && !device->flags.spi_i2c_slave)
+	if (!device->pnp.type.platform_id && !device->flags.serial_bus_slave)
 		acpi_device_set_enumerated(device);
 	else
 		acpi_default_enumeration(device);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index fa15052..f849be2 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -211,7 +211,7 @@ struct acpi_device_flags {
 	u32 of_compatible_ok:1;
 	u32 coherent_dma:1;
 	u32 cca_seen:1;
-	u32 spi_i2c_slave:1;
+	u32 serial_bus_slave:1;
 	u32 reserved:19;
 };
 
-- 
2.7.4


  parent reply	other threads:[~2017-10-11  8:32 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  8:32 [PATCH v3 0/2] ACPI serdev support Frédéric Danis
2017-10-11  8:32 ` Frédéric Danis
     [not found] ` <1507710734-32520-1-git-send-email-frederic.danis.oss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-10-11  8:32   ` [PATCH v3 1/2] serdev: Add ACPI support Frédéric Danis
2017-10-11  8:32     ` Frédéric Danis
2017-10-11  8:43     ` Johan Hovold
2017-10-11  8:32 ` Frédéric Danis [this message]
2017-10-15  9:57   ` [PATCH v3 2/2] ACPI / scan: Fix enumeration for special UART devices Lukas Wunner
     [not found]   ` <1507710734-32520-3-git-send-email-frederic.danis.oss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-31 14:21     ` [v3,2/2] " Graeme Gregory
2018-01-31 14:21       ` Graeme Gregory
2018-02-02 10:03       ` Frédéric Danis
2018-02-02 10:03         ` Frédéric Danis
2018-02-02 15:28         ` Graeme Gregory
2017-10-11  9:03 ` [PATCH v3 0/2] ACPI serdev support Johan Hovold
2017-10-11 13:09   ` Rafael J. Wysocki
2017-10-11 13:09     ` Rafael J. Wysocki
2017-10-11 18:32     ` Marcel Holtmann
2017-10-11 18:32       ` Marcel Holtmann
2017-10-18 14:46       ` Frédéric Danis
2017-10-18 14:56         ` Greg Kroah-Hartman
     [not found]           ` <20171018145608.GB27138-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-10-19 14:23             ` Johan Hovold
2017-10-19 14:23               ` Johan Hovold
2017-10-19 14:26               ` Hans de Goede
2017-10-19 14:32                 ` Marcel Holtmann
2017-10-19 14:56                   ` Hans de Goede
2017-10-19 16:15                     ` Loic Poulain
     [not found]                       ` <CAMZdPi_ZpNrdjJPnS_rQ9t3oYe6+en9oHQMjmMjx_xHL-WWZKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-19 18:50                         ` Hans de Goede
2017-10-19 18:50                           ` Hans de Goede
2017-10-19 19:00                           ` Marcel Holtmann
     [not found]                             ` <FFD85CA6-6BD9-45AA-B3C2-898212711C0C-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
2017-10-19 19:05                               ` Hans de Goede
2017-10-19 19:05                                 ` Hans de Goede
2017-10-21  9:59                             ` Johan Hovold
     [not found]                 ` <877ea825-eec5-d982-f962-d67067749009-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-10-19 14:32                   ` Johan Hovold
2017-10-19 14:32                     ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507710734-32520-3-git-send-email-frederic.danis.oss@gmail.com \
    --to=frederic.danis.oss@gmail.com \
    --cc=greg@kroah.com \
    --cc=hdegoede@redhat.com \
    --cc=johan@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=loic.poulain@gmail.com \
    --cc=lukas@wunner.de \
    --cc=marcel@holtmann.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.