From: Frank Bormann <fbormann-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
To: Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
Cc: Linux I2C List <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: platform_data in i2c device drivers
Date: Thu, 20 Mar 2014 12:12:23 -0400 [thread overview]
Message-ID: <532B1367.8050906@yahoo.com> (raw)
In-Reply-To: <1511928.3cA2QKoAZt@avalon>
Hi Laurent,
First of all, thank you so much for your detailed explanation. This really helps
out a lot.
Your assumptions are correct, I am needed working on an ARM device and it uses
device tree for driver configuration.
Just to confirm that I understand you correctly, what you're saying is that the
platform_data and the device tree configuration mechanisms have an exclusive-or
relationship, at least when it comes down to an individual driver, is that
correct? And, if there is no platform_data provided, it is perfectly permissible
for the probe function of the driver to make call to of_* functions to read its
configuration? Provided that the kernel has Open Firmware and Device Tree
support enabled of course.
Would it also acceptable for a driver's probe function to allocate memory for a
platform_data instance and use the platform_data member in client->dev to store
a pointer to it if no previous platform_data is available from the
i2c_board_info configuration mechanism? Again provided of course that the memory
is freed and the platform_data member in client->dev set back to null in the
remove function of the driver.
Thank you,
Frank
On 19/03/14 08:10 PM, Laurent Pinchart wrote:
> You're looking at two different configuration mechanisms, which probably
> explains your confusion.
>
> Platform data is the oldest mechanism used to pass configuration information
> to the driver. This is largely used through the Linux kernel on a wide range
> of architectures. The idea is to store device-specific configuration
> information in board files (as you mentioned DT I'll assume you're working on
> ARM, so that would be arch/arm/mach-*/board-*.c) using driver-specific
> structures and associate those structures with devices. Drivers can then
> retrieve the platform data at probe time and configure the device accordingly.
>
> The way platform data is associated with devices depends on the bus type. For
> I2C the i2c_board_info structure, used to instantiate I2C devices in board
> code, has a void *platform_data field that can be set to point to a platform
> data structure. You can find an example of this in the i2c3_devices array in
> arch/arm/mach-shmobile/board-kzm9g.c.
>
> Device tree (DT) is a newer mechanism to specify hardware configuration.
> Instead of relying on C board files that contain a mix a code and data, the
> platform is described in a tree-like structure of devices with properties
> associated to all those devices. That structure is called the device tree and
> is compiled as a binary that gets passed to the kernel at boot time. When
> using the device tree, drivers don't receive platform data anymore but are
> responsible for parsing the content of the device tree to read platform-
> specific hardware configuration information. The content of device tree nodes
> is defined in documents called DT bindings that can be found in
> Documentation/devicetree/bindings/ (i2c/i2c-mux-pca954x.txt in this case).
>
> A NULL platform_data pointer can then mean either that your platform boots
> using the device tree, or that the board file doesn't specify any platform
> data for the device in case of legacy (non-DT) boot. There's also a hybrid
> method that can be used to associated platform data declared in C files to DT
> nodes, but that's for special cases only and shouldn't be used for the
> pca954x.
>
> This being said, if your platform uses the device tree, you shouldn't (in
> theory at least) need static I2C bus numbers. This is why there is no DT
> property similar to the platform data adap_id field defined in the pca954x DT
> bindings.
next prev parent reply other threads:[~2014-03-20 16:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 22:32 platform_data in i2c device drivers Frank Bormann
[not found] ` <532A1B12.8080400-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20 0:10 ` Laurent Pinchart
2014-03-20 16:12 ` Frank Bormann [this message]
[not found] ` <532B1367.8050906-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20 16:25 ` Ben Dooks
[not found] ` <532B1689.3080202-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2014-03-20 17:16 ` Frank Bormann
[not found] ` <532B2273.8040004-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20 17:51 ` Laurent Pinchart
2014-03-21 15:55 ` Frank Bormann
[not found] ` <532C60EC.3060405-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-21 16:01 ` Laurent Pinchart
[not found] ` <534FF708.7040409@yahoo.com>
[not found] ` <534FF708.7040409-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-04-17 15:46 ` [PATCH] i2c-mux-pca954x: allow downstream bus numbers to be specified in the dts Laurent Pinchart
2014-04-17 18:00 ` Laxman Dewangan
[not found] ` <535016B5.7060006-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-04-22 21:46 ` Frank Bormann
[not found] ` <53501564.1090607@yahoo.com>
[not found] ` <53501564.1090607-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-04-17 20:15 ` Laurent Pinchart
[not found] ` <CAE6_GsvJpajY==6MJExo3T7FrVF_LNGcoozq0N5KEBho9y5NWw@mail.gmail.com>
[not found] ` <CAE6_GsvJpajY==6MJExo3T7FrVF_LNGcoozq0N5KEBho9y5NWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-17 20:42 ` Laurent Pinchart
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=532B1367.8050906@yahoo.com \
--to=fbormann-/e1597as9lqavxtiumwx3w@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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).