From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dustin Byford <dustin@cumulusnetworks.com>,
Wolfram Sang <wsa@the-dreams.de>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, rjw@rjwysocki.net, "Puustinen,
Ismo" <ismo.puustinen@intel.com>
Subject: Re: [PATCH v3 1/1] i2c: add ACPI support for I2C mux ports
Date: Tue, 20 Oct 2015 12:16:04 +0300 [thread overview]
Message-ID: <1445332564.22669.2.camel@linux.intel.com> (raw)
In-Reply-To: <1445293740-28537-2-git-send-email-dustin@cumulusnetworks.com>
+Cc: Ismo Puustinen
On Mon, 2015-10-19 at 15:29 -0700, Dustin Byford wrote:
> Although I2C mux devices are easily enumerated using ACPI (_HID/_CID
> or
> device property compatible string match) enumerating I2C client
> devices
> connected through a I2C mux device requires a little extra work.
>
> This change implements a method for describing an I2C device
> hierarchy that
> includes mux devices by using an ACPI Device() for each mux channel
> along
> with an _ADR to set the channel number for the device. See
> Documentation/acpi/i2c-muxes.txt for a simple example.
Ismo, can you test this patch on top of what you have to see if it goes
smoothly (no break of Galileo Gen2 support) ?
>
> Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
> ---
> Documentation/acpi/i2c-muxes.txt | 58
> ++++++++++++++++++++++++++++++++++++++++
> drivers/i2c/i2c-core.c | 15 +++++++++--
> drivers/i2c/i2c-mux.c | 8 ++++++
> include/linux/acpi.h | 6 +++++
> 4 files changed, 85 insertions(+), 2 deletions(-)
> create mode 100644 Documentation/acpi/i2c-muxes.txt
>
> diff --git a/Documentation/acpi/i2c-muxes.txt
> b/Documentation/acpi/i2c-muxes.txt
> new file mode 100644
> index 0000000..9fcc4f0
> --- /dev/null
> +++ b/Documentation/acpi/i2c-muxes.txt
> @@ -0,0 +1,58 @@
> +ACPI I2C Muxes
> +--------------
> +
> +Describing an I2C device hierarchy that includes I2C muxes requires
> an ACPI
> +Device () scope per mux channel.
> +
> +Consider this topology:
> +
> ++------+ +------+
> +| SMB1 |-->| MUX0 |--CH00--> i2c client A (0x50)
> +| | | 0x70 |--CH01--> i2c client B (0x50)
> ++------+ +------+
> +
> +which corresponds to the following ASL:
> +
> +Device (SMB1)
> +{
> + Name (_HID, ...)
> + Device (MUX0)
> + {
> + Name (_HID, ...)
> + Name (_CRS, ResourceTemplate () {
> + I2cSerialBus (0x70, ControllerInitiated, I2C_SPEED,
> + AddressingMode7Bit, "^SMB1", 0x00,
> + ResourceConsumer,,)
> + }
> +
> + Device (CH00)
> + {
> + Name (_ADR, 0)
> +
> + Device (CLIA)
> + {
> + Name (_HID, ...)
> + Name (_CRS, ResourceTemplate () {
> + I2cSerialBus (0x50, ControllerInitiated,
> I2C_SPEED,
> + AddressingMode7Bit, "^CH00", 0x00,
> + ResourceConsumer,,)
> + }
> + }
> + }
> +
> + Device (CH01)
> + {
> + Name (_ADR, 1)
> +
> + Device (CLIB)
> + {
> + Name (_HID, ...)
> + Name (_CRS, ResourceTemplate () {
> + I2cSerialBus (0x50, ControllerInitiated,
> I2C_SPEED,
> + AddressingMode7Bit, "^CH01", 0x00,
> + ResourceConsumer,,)
> + }
> + }
> + }
> + }
> +}
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 579b99d..af0811c 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -156,7 +156,7 @@ static acpi_status
> acpi_i2c_add_device(acpi_handle handle, u32 level,
> info.fwnode = acpi_fwnode_handle(adev);
>
> memset(&lookup, 0, sizeof(lookup));
> - lookup.adapter_handle = ACPI_HANDLE(adapter->dev.parent);
> + lookup.adapter_handle = ACPI_HANDLE(&adapter->dev);
> lookup.device_handle = handle;
> lookup.info = &info;
>
> @@ -212,7 +212,7 @@ static void acpi_i2c_register_devices(struct
> i2c_adapter *adap)
> {
> acpi_status status;
>
> - if (!adap->dev.parent || !has_acpi_companion(adap-
> >dev.parent))
> + if (!has_acpi_companion(&adap->dev))
> return;
>
> status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
> ACPI_ROOT_OBJECT,
> @@ -1667,6 +1667,17 @@ int i2c_add_adapter(struct i2c_adapter
> *adapter)
> struct device *dev = &adapter->dev;
> int id;
>
> + /*
> + * By default, associate I2C adapters with their parent
> device's ACPI
> + * node.
> + */
> + if (!has_acpi_companion(dev)) {
> + struct acpi_device *adev = ACPI_COMPANION(dev-
> >parent);
> +
> + if (adev)
> + ACPI_COMPANION_SET(dev, adev);
> + }
> +
> if (dev->of_node) {
> id = of_alias_get_id(dev->of_node, "i2c");
> if (id >= 0) {
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 2ba7c0f..00fc5b1 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -25,6 +25,7 @@
> #include <linux/i2c.h>
> #include <linux/i2c-mux.h>
> #include <linux/of.h>
> +#include <linux/acpi.h>
>
> /* multiplexer per channel data */
> struct i2c_mux_priv {
> @@ -173,6 +174,13 @@ struct i2c_adapter *i2c_add_mux_adapter(struct
> i2c_adapter *parent,
> }
> }
>
> + /*
> + * Associate the mux channel with an ACPI node.
> + */
> + if (has_acpi_companion(mux_dev))
> + acpi_preset_companion(&priv->adap.dev,
> ACPI_COMPANION(mux_dev),
> + chan_id);
> +
> if (force_nr) {
> priv->adap.nr = force_nr;
> ret = i2c_add_numbered_adapter(&priv->adap);
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 51a96a8..66564f8 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -505,6 +505,12 @@ static inline bool has_acpi_companion(struct
> device *dev)
> return false;
> }
>
> +static inline void acpi_preset_companion(struct device *dev,
> + struct acpi_device *parent,
> u64 addr)
> +{
> + return;
> +}
> +
> static inline const char *acpi_dev_name(struct acpi_device *adev)
> {
> return NULL;
For me seems this one can go separately. Rafael, what do you think?
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2015-10-20 9:16 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 23:59 [RFC PATCH 0/1] i2c: scan ACPI enumerated I2C mux channels Dustin Byford
2015-08-13 23:59 ` [RFC PATCH 1/1] i2c: acpi: " Dustin Byford
[not found] ` <1439510358-16664-1-git-send-email-dustin-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-08-14 19:31 ` [RFC v2 0/1] " Dustin Byford
2015-08-14 19:31 ` [RFC v2 1/1] " Dustin Byford
2015-10-09 21:42 ` Wolfram Sang
2015-10-09 21:50 ` Dustin Byford
2015-10-09 21:51 ` Wolfram Sang
2015-08-15 20:22 ` [RFC v2 0/1] " Wolfram Sang
2015-08-17 12:03 ` Mika Westerberg
2015-08-17 19:00 ` Dustin Byford
2015-09-29 23:19 ` Dustin Byford
2015-09-30 9:43 ` Mika Westerberg
2015-09-30 12:52 ` Rafael J. Wysocki
2015-09-30 13:57 ` Mika Westerberg
2015-09-30 17:54 ` Dustin Byford
2015-10-10 0:41 ` [PATCH 0/2] " Dustin Byford
2015-10-10 0:41 ` [PATCH 1/2] i2c: scan entire ACPI namespace for I2C connections Dustin Byford
2015-10-12 10:46 ` Mika Westerberg
2015-10-12 11:20 ` Andy Shevchenko
2015-10-12 17:00 ` Dustin Byford
2015-10-12 19:01 ` Rafael J. Wysocki
2015-10-12 18:57 ` Dustin Byford
2015-10-10 0:41 ` [PATCH 2/2] i2c: add ACPI support for I2C mux ports Dustin Byford
2015-10-10 1:03 ` kbuild test robot
2015-10-12 10:50 ` Mika Westerberg
2015-10-12 18:32 ` Dustin Byford
2015-10-13 11:32 ` Mika Westerberg
2015-10-19 9:01 ` [PATCH v2 0/1] i2c: acpi: scan ACPI enumerated I2C mux channels Dustin Byford
2015-10-19 22:28 ` [PATCH v3 " Dustin Byford
2015-10-19 22:29 ` [PATCH v3 1/1] i2c: add ACPI support for I2C mux ports Dustin Byford
2015-10-20 9:16 ` Andy Shevchenko [this message]
2015-10-20 12:51 ` Mika Westerberg
2015-10-20 17:49 ` Dustin Byford
2015-10-20 23:13 ` Rafael J. Wysocki
2015-10-21 8:12 ` Mika Westerberg
2015-10-21 8:21 ` Dustin Byford
2015-10-21 8:34 ` Mika Westerberg
2015-10-21 8:52 ` Dustin Byford
2015-10-21 9:08 ` Mika Westerberg
2015-10-21 9:25 ` Dustin Byford
2015-10-21 22:39 ` Rafael J. Wysocki
2015-10-22 9:27 ` Dustin Byford
2015-10-20 23:12 ` Rafael J. Wysocki
2015-10-21 8:02 ` Mika Westerberg
2015-10-22 9:17 ` [PATCH v4 0/2] i2c: acpi: scan ACPI enumerated I2C mux channels Dustin Byford
2015-10-22 9:17 ` [PATCH v4 1/2] acpi: add acpi_preset_companion() stub Dustin Byford
2015-10-23 8:33 ` Mika Westerberg
2015-10-25 13:40 ` Rafael J. Wysocki
2015-10-25 15:01 ` Rafael J. Wysocki
2015-10-22 9:17 ` [PATCH v4 2/2] i2c: add ACPI support for I2C mux ports Dustin Byford
2015-10-23 8:40 ` Mika Westerberg
2015-10-23 10:16 ` Wolfram Sang
2015-10-23 13:13 ` Mika Westerberg
2015-10-23 13:40 ` Mika Westerberg
2015-10-23 13:55 ` Jarkko Nikula
2015-10-23 19:27 ` [PATCH v5 0/2] i2c: acpi: scan ACPI enumerated I2C mux channels Dustin Byford
2015-10-23 19:27 ` [PATCH v5 1/2] acpi: add acpi_preset_companion() stub Dustin Byford
2015-10-24 16:41 ` Wolfram Sang
2015-10-25 15:00 ` Rafael J. Wysocki
2015-10-23 19:27 ` [PATCH v5 2/2] i2c: add ACPI support for I2C mux ports Dustin Byford
2015-10-25 14:53 ` [PATCH v5 0/2] i2c: acpi: scan ACPI enumerated I2C mux channels Wolfram Sang
2015-10-25 15:15 ` Dustin Byford
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=1445332564.22669.2.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dustin@cumulusnetworks.com \
--cc=ismo.puustinen@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rjw@rjwysocki.net \
--cc=wsa@the-dreams.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).