linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Cc: Srinivas Pandruvada
	<srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Jean-Michel Hautbois
	<jhautbois-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	pawel.moll-5wv7dgnIgG8@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org,
	Jean-Michel Hautbois
	<jean-michel.hautbois-JiVWUdsMzBtWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH v2] i2c: Add generic support passing secondary devices addresses
Date: Tue, 19 Apr 2016 17:40:27 +0300	[thread overview]
Message-ID: <20160419144027.GH1725@lahna.fi.intel.com> (raw)
In-Reply-To: <5716333D.1040106-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>

On Tue, Apr 19, 2016 at 03:31:41PM +0200, Lars-Peter Clausen wrote:
> It adds a standard API for dealing with devices that have more than one
> address. It uses the normal way of specifying multiple (named) address in DT.
> 
> reg = <0xa>, <0xb>, <0xc>;
> reg-names = "main", "aux1", "aux2";
> 
> The function the new i2c_new_secondary_device() function takes the name of
> the address region and allocates a dummy I2C client for it, which can be
> used to access that I2C part of the device that responds to that region. The
> name is used to lookup the address from the name to address map.

Thanks for the explanation.

Yes, I think we can support this in ACPI using both _DSD and built-in
properties so we do not need to add new fields to struct acpi_device
like we did with GPIOs. If _DSD does not have "reg-names" property we
can provide built-in version in a driver:

	static const char *mydev_reg_names[] = { "main", "aux1", "aux2" };
		
	static struct property_entry mydev_properties[] = {
		PROPERTY_ENTRY_STRING_ARRAY("reg-names", mydev_reg_names),
		{ },
	};

Then call device_add_properties() for the "primary" I2C client to make
them available to the unified properties API.

The i2c_new_secondary_device() would then look like:

	struct i2c_client *i2c_new_secondary_device(struct i2c_client *client,
					    const char *name, u16 default_addr)
	{       
		struct device_node *np = client->dev.of_node;
		u32 addr = default_addr;
		int i;
		
		i = device_property_match_string(&client->dev, "reg-names", name);
		if (i >= 0) {
			if (np) {
				of_property_read_u32_index(np, "reg", i, &addr);
			} else if (has_acpi_companion(&client->dev)) {
				/* Look for the ith I2cSerialBus() in _CRS */
			}
		}

		dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr);
		return i2c_new_dummy(client->adapter, addr);
	}
	EXPORT_SYMBOL_GPL(i2c_new_secondary_device);

The above should work with both DT and ACPI so I'm OK with the current
patch. We can add ACPI parts later when needed.

Srinivas, do you think this works with the sensor stuff?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-19 14:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-31 15:33 [PATCH v2] i2c: Add generic support passing secondary devices addresses Jean-Michel Hautbois
2016-02-01 14:46 ` Rob Herring
2016-03-24 10:11   ` Jean-Michel Hautbois
2016-03-24 14:02     ` Rob Herring
2016-04-14 19:10 ` Wolfram Sang
2016-04-15  8:01 ` Mika Westerberg
2016-04-18 15:20   ` Srinivas Pandruvada
     [not found]     ` <1460992811.8946.22.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-18 15:26       ` Lars-Peter Clausen
     [not found]         ` <5714FCBE.3060009-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2016-04-19 12:40           ` Mika Westerberg
2016-04-19 13:02             ` Lars-Peter Clausen
2016-04-19 13:16               ` Mika Westerberg
2016-04-19 13:31                 ` Lars-Peter Clausen
     [not found]                   ` <5716333D.1040106-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2016-04-19 14:40                     ` Mika Westerberg [this message]
2016-04-19 16:27                       ` Srinivas Pandruvada
     [not found]                       ` <20160419144027.GH1725-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2016-04-24 20:14                         ` Wolfram Sang
2016-04-25  7:25                           ` Mika Westerberg
2016-04-25  7:39                             ` Wolfram Sang
2016-04-25  7:41                               ` Mika Westerberg
2016-06-03  8:24                                 ` Lars-Peter Clausen
2016-04-19 13:49                 ` Wolfram Sang
2016-04-19 14:42                   ` Mika Westerberg
2016-06-05  6:15 ` Wolfram Sang

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=20160419144027.GH1725@lahna.fi.intel.com \
    --to=mika.westerberg-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=jean-michel.hautbois-JiVWUdsMzBtWk0Htik3J/w@public.gmane.org \
    --cc=jhautbois-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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 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).