linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
       [not found]     ` <BANLkTingm7PCJPC-xCremYg_Ab7qFvPSag@mail.gmail.com>
@ 2011-05-10 22:16       ` Stephen Warren
  2011-05-10 22:33         ` John Bonesio
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2011-05-10 22:16 UTC (permalink / raw)
  To: linux-arm-kernel

Olof Johansson wrote at Tuesday, May 10, 2011 4:07 PM:
> > On Tue, May 10, 2011 at 3:03 PM, Stephen Warren <swarren@nvidia.com> wrote:
> > John Bonesio wrote at Tuesday, May 10, 2011 2:14 PM:
> > > This patch changes how sdhci devices are initialized so that a later
> > > patch can easily add support for i2c devies.
> > >
> > > +static struct tegra_sdhci_platform_data sdhci_pdata1 = {
> > > + ? ? .cd_gpio ? ? ? ?= -1,
> > > + ? ? .wp_gpio ? ? ? ?= -1,
> > > + ? ? .power_gpio ? ? = -1,
> > > +};
> > > +
> > So I understand why board-dt is itself registering the SDHCI platform
> > devices itself; so that the pdev initialization path is identical
> > between fully hard-coded boards and board-dt.c.
> > 
> > However, I'm surprised that we would include the platform data for
> > those devices within that argument; if we do that, we'll end up needing
> > different platform data for every board, and devicetree won't have
> > bought us anything.
> > 
> > In other words, I understood that board-dt would register all the
> > platform devices within Tegra, but not set up any of the plataform
> > data, and the device drivers for those devices would be updated to
> > get their platform data from devicetree if available, then fall back
> > to old-style platform data. In other words, the way the SDHCI drivers
> > work today in the devicetree/test branch.
> > 
> > If my understanding is correct, shouldn't the chunk above and the
> > one below be removed?
>
> That's if we cut everything over, I think. until then, this code should
> fill in the platform_device and register it. But the values should come
> from the device tree, and it should only register the controllers that are
> in the tree (and not marked as disabled).

But doesn't that require board-dt.c to walk and parse the devicetree,
extract the platform data from the DT, and fill in the platform data
structures? I thought we'd explicitly talked about that and decided that
was a bad idea, since it'd duplicate each driver's DT parsing into
board-dt.c?

-- 
nvpublic

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-10 22:16       ` [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized Stephen Warren
@ 2011-05-10 22:33         ` John Bonesio
  2011-05-10 22:42           ` Mark Brown
  2011-05-10 23:22           ` Stephen Warren
  0 siblings, 2 replies; 8+ messages in thread
From: John Bonesio @ 2011-05-10 22:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/10/2011 03:16 PM, Stephen Warren wrote:
> Olof Johansson wrote at Tuesday, May 10, 2011 4:07 PM:
>>> On Tue, May 10, 2011 at 3:03 PM, Stephen Warren <swarren@nvidia.com> wrote:
>>> John Bonesio wrote at Tuesday, May 10, 2011 2:14 PM:
>>>> This patch changes how sdhci devices are initialized so that a later
>>>> patch can easily add support for i2c devies.
>>>>
>>>> +static struct tegra_sdhci_platform_data sdhci_pdata1 = {
>>>> +     .cd_gpio        = -1,
>>>> +     .wp_gpio        = -1,
>>>> +     .power_gpio     = -1,
>>>> +};
>>>> +
>>> So I understand why board-dt is itself registering the SDHCI platform
>>> devices itself; so that the pdev initialization path is identical
>>> between fully hard-coded boards and board-dt.c.
>>>
>>> However, I'm surprised that we would include the platform data for
>>> those devices within that argument; if we do that, we'll end up needing
>>> different platform data for every board, and devicetree won't have
>>> bought us anything.
>>>
>>> In other words, I understood that board-dt would register all the
>>> platform devices within Tegra, but not set up any of the plataform
>>> data, and the device drivers for those devices would be updated to
>>> get their platform data from devicetree if available, then fall back
>>> to old-style platform data. In other words, the way the SDHCI drivers
>>> work today in the devicetree/test branch.
>>>
>>> If my understanding is correct, shouldn't the chunk above and the
>>> one below be removed?
>>
>> That's if we cut everything over, I think. until then, this code should
>> fill in the platform_device and register it. But the values should come
>> from the device tree, and it should only register the controllers that are
>> in the tree (and not marked as disabled).
> 
> But doesn't that require board-dt.c to walk and parse the devicetree,
> extract the platform data from the DT, and fill in the platform data
> structures? I thought we'd explicitly talked about that and decided that
> was a bad idea, since it'd duplicate each driver's DT parsing into
> board-dt.c?
> 

The goal I'm working towards right now is to have the platform specific
code continue to register the devices that are inside the SoC. Then use
the device tree to register all other on board devices.

This patch doesn't accomplish the whole goal in one step, but gets the
code a little closer toward this goal.

To accomplish the goal, nodes need to be in the device tree for the
devices inside the SoC. This is then used to attach device tree nodes to
the existing devices - gives us a "hook" on which to "hang" the board
specific devices. There is only one device tree used, so everything
needs to be connected into the same device tree.

These patches just get the i2c controller and driver instantiated. This
includes having the platform code to register the i2c controller in the
"normal" fashion. This patch also gets a device tree node attached to
the i2c device.

A following patch, which I'll send later this week/early next week, will
instantiate the wm8903 audio codec device solely from the device tree.

Hopefully this makes the plan a little clearer. Let me know if you have
any questions.

- John

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-10 22:33         ` John Bonesio
@ 2011-05-10 22:42           ` Mark Brown
  2011-05-10 23:22           ` Stephen Warren
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2011-05-10 22:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 10, 2011 at 03:33:29PM -0700, John Bonesio wrote:

> A following patch, which I'll send later this week/early next week, will
> instantiate the wm8903 audio codec device solely from the device tree.

Please CC me on this work - I've got an interest both from the chip and
subsystem point of view in how this stuff ends up looking and there's
some fun and games with audio in device tree.

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-10 22:33         ` John Bonesio
  2011-05-10 22:42           ` Mark Brown
@ 2011-05-10 23:22           ` Stephen Warren
  2011-05-10 23:33             ` John Bonesio
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Warren @ 2011-05-10 23:22 UTC (permalink / raw)
  To: linux-arm-kernel

John Bonesio wrote at Tuesday, May 10, 2011 4:33 PM:
> The goal I'm working towards right now is to have the platform specific
> code continue to register the devices that are inside the SoC. Then use
> the device tree to register all other on board devices.

Sure, that sounds right.

Which branch are your patches aimed at? My discussions are all based
on my experience with Grant's devicetree/test branch.

> This patch doesn't accomplish the whole goal in one step, but gets the
> code a little closer toward this goal.

So what's confusing me is that I think the devicetree/test branch is
already there; board-dt.c registers all 4 SDHCI controllers,
tegra250.dtsi defines each controller's memory map etc., and disables
them all, then tegra-harmony.dts and tegra-seaboard.dts enable the
relevant subset of those controllers, and provides the required
platform data for them.

When adding the I2C controllers, it seems like they'd just work the
same way as the existing SDHCI code.

So, all this already works without putting the board-specific platform
data definitions into board-dt.c as an temporary measure.

-- 
nvpublic

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-10 23:22           ` Stephen Warren
@ 2011-05-10 23:33             ` John Bonesio
  2011-05-11  5:01               ` Stephen Warren
  0 siblings, 1 reply; 8+ messages in thread
From: John Bonesio @ 2011-05-10 23:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/10/2011 04:22 PM, Stephen Warren wrote:
> John Bonesio wrote at Tuesday, May 10, 2011 4:33 PM:
>> The goal I'm working towards right now is to have the platform specific
>> code continue to register the devices that are inside the SoC. Then use
>> the device tree to register all other on board devices.
> 
> Sure, that sounds right.
> 
> Which branch are your patches aimed at? My discussions are all based
> on my experience with Grant's devicetree/test branch.
> 
>> This patch doesn't accomplish the whole goal in one step, but gets the
>> code a little closer toward this goal.
> 
> So what's confusing me is that I think the devicetree/test branch is
> already there; board-dt.c registers all 4 SDHCI controllers,
> tegra250.dtsi defines each controller's memory map etc., and disables
> them all, then tegra-harmony.dts and tegra-seaboard.dts enable the
> relevant subset of those controllers, and provides the required
> platform data for them.
> 
> When adding the I2C controllers, it seems like they'd just work the
> same way as the existing SDHCI code.

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-10 23:33             ` John Bonesio
@ 2011-05-11  5:01               ` Stephen Warren
  2011-05-11 17:40                 ` John Bonesio
  2011-05-11 18:21                 ` Grant Likely
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Warren @ 2011-05-11  5:01 UTC (permalink / raw)
  To: linux-arm-kernel

John Bonesio wrote at Tuesday, May 10, 2011 5:33 PM:
> On 05/10/2011 04:22 PM, Stephen Warren wrote:
> > John Bonesio wrote at Tuesday, May 10, 2011 4:33 PM:
> >> The goal I'm working towards right now is to have the platform specific
> >> code continue to register the devices that are inside the SoC. Then use
> >> the device tree to register all other on board devices.
> >
> > Sure, that sounds right.
> >
> > Which branch are your patches aimed at? My discussions are all based
> > on my experience with Grant's devicetree/test branch.
> >
> >> This patch doesn't accomplish the whole goal in one step, but gets the
> >> code a little closer toward this goal.
> >
> > So what's confusing me is that I think the devicetree/test branch is
> > already there; board-dt.c registers all 4 SDHCI controllers,
> > tegra250.dtsi defines each controller's memory map etc., and disables
> > them all, then tegra-harmony.dts and tegra-seaboard.dts enable the
> > relevant subset of those controllers, and provides the required
> > platform data for them.
> >
> > When adding the I2C controllers, it seems like they'd just work the
> > same way as the existing SDHCI code.
> 
> From a philosophical point of view, they should be initialized the same
> way.
> 
> Are you thinking that the i2c controller should be in the
> harmony_devices array and initialized with the other devices? If so i2c
> is different in the kernel. An i2c controller isn't registered with
> platform_device_register().

Um. Your patch (and all existing code I'm familiar with) *does* use
platform_device_register for it:

+	platform_device_register(&tegra_i2c_device1);

But, I'm not talking about registering the platform devices, i.e. I'm
not talking about the line of code quoted above. I'm talking about the
platform data setup for those devices, i.e. the following from your
SDHCI patch:

+static struct tegra_sdhci_platform_data sdhci_pdata1 = {
+	.cd_gpio        = -1,
+	.wp_gpio        = -1,
+	.power_gpio     = -1,
+};
...
+	tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;

The SDHCI driver has already been updated to get this platform data
from the OF node in the platform device; it doesn't need hard-coded
platform data to be passed to it.

Similarly, the following from your I2C patch shouldn't be required:

+static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
+	.bus_clk_rate   = 400000,
+};
...
+	tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data;

Instead, the I2C driver should be modified to get its data from the
OF node in the platform device just like the SDHCI driver does. This
should be a pretty trivial amount of code to add to the I2C patch.

> I may not be understanding your question.
> 
> >
> > So, all this already works without putting the board-specific platform
> > data definitions into board-dt.c as an temporary measure.
> >

-- 
nvpublic

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-11  5:01               ` Stephen Warren
@ 2011-05-11 17:40                 ` John Bonesio
  2011-05-11 18:21                 ` Grant Likely
  1 sibling, 0 replies; 8+ messages in thread
From: John Bonesio @ 2011-05-11 17:40 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/10/2011 10:01 PM, Stephen Warren wrote:
> John Bonesio wrote at Tuesday, May 10, 2011 5:33 PM:
>> On 05/10/2011 04:22 PM, Stephen Warren wrote:
>>> John Bonesio wrote at Tuesday, May 10, 2011 4:33 PM:
>>>> The goal I'm working towards right now is to have the platform specific
>>>> code continue to register the devices that are inside the SoC. Then use
>>>> the device tree to register all other on board devices.
>>>
>>> Sure, that sounds right.
>>>
>>> Which branch are your patches aimed at? My discussions are all based
>>> on my experience with Grant's devicetree/test branch.
>>>
>>>> This patch doesn't accomplish the whole goal in one step, but gets the
>>>> code a little closer toward this goal.
>>>
>>> So what's confusing me is that I think the devicetree/test branch is
>>> already there; board-dt.c registers all 4 SDHCI controllers,
>>> tegra250.dtsi defines each controller's memory map etc., and disables
>>> them all, then tegra-harmony.dts and tegra-seaboard.dts enable the
>>> relevant subset of those controllers, and provides the required
>>> platform data for them.
>>>
>>> When adding the I2C controllers, it seems like they'd just work the
>>> same way as the existing SDHCI code.
>>
>> From a philosophical point of view, they should be initialized the same
>> way.
>>
>> Are you thinking that the i2c controller should be in the
>> harmony_devices array and initialized with the other devices? If so i2c
>> is different in the kernel. An i2c controller isn't registered with
>> platform_device_register().
> 
> Um. Your patch (and all existing code I'm familiar with) *does* use
> platform_device_register for it:

oops. Right. I was confusing this with the way i2c devices are
registered. I copied the way i2c was initialized in board-harmony.c

> 
> +	platform_device_register(&tegra_i2c_device1);
> 
> But, I'm not talking about registering the platform devices, i.e. I'm
> not talking about the line of code quoted above. I'm talking about the
> platform data setup for those devices, i.e. the following from your
> SDHCI patch:
> 
> +static struct tegra_sdhci_platform_data sdhci_pdata1 = {
> +	.cd_gpio        = -1,
> +	.wp_gpio        = -1,
> +	.power_gpio     = -1,
> +};
> ...
> +	tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
> 
> The SDHCI driver has already been updated to get this platform data
> from the OF node in the platform device; it doesn't need hard-coded
> platform data to be passed to it.
> 
> Similarly, the following from your I2C patch shouldn't be required:
> 
> +static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
> +	.bus_clk_rate   = 400000,
> +};
> ...
> +	tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data;
> 
> Instead, the I2C driver should be modified to get its data from the
> OF node in the platform device just like the SDHCI driver does. This
> should be a pretty trivial amount of code to add to the I2C patch.

Grant and I have chatted about this. Our plan was to get to a
intermediate step where all of the devices inside the SoC including the
i2c controller (I believe the i2c controller itself is inside the SoC)
continue to be initialized using the current static method
(platform_device_register).

The implementation works like this ...

In tegra_dt_init(), of_platform_prepare() is called before devices are
registered. of_platform_prepare() makes note of all the device tree
nodes without registering anything.

When platform devices are registered (platform_device_register()),
of_platform is notified and it attaches the device tree node to the
device struct.

Then when all the SoC internal devices are done being registered using
the static method, there remains a set of device tree nodes that haven't
been registered as devices in the system. These device tree nodes should
be primarily for devices on the board and not in the SoC.

At this point, of_platform_populate() is called, this registers the
remaining devices in the device tree node so that drivers can be loaded
for them using device tree methods.

The reason for this approach was that this step would make for minimal
impact to existing systems. Yet it would still provide more flexibility
for board specific devices.

The thought was that once this is in place we can collectively
re-evaluate if we want to take the next step and initialize everything
from the device tree.

> 
>> I may not be understanding your question.
>>
>>>
>>> So, all this already works without putting the board-specific platform
>>> data definitions into board-dt.c as an temporary measure.
>>>
> 

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

* [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized
  2011-05-11  5:01               ` Stephen Warren
  2011-05-11 17:40                 ` John Bonesio
@ 2011-05-11 18:21                 ` Grant Likely
  1 sibling, 0 replies; 8+ messages in thread
From: Grant Likely @ 2011-05-11 18:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 11, 2011 at 7:01 AM, Stephen Warren <swarren@nvidia.com> wrote:
> John Bonesio wrote at Tuesday, May 10, 2011 5:33 PM:
> +static struct tegra_sdhci_platform_data sdhci_pdata1 = {
> + ? ? ? .cd_gpio ? ? ? ?= -1,
> + ? ? ? .wp_gpio ? ? ? ?= -1,
> + ? ? ? .power_gpio ? ? = -1,
> +};
> ...
> + ? ? ? tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
>
> The SDHCI driver has already been updated to get this platform data
> from the OF node in the platform device; it doesn't need hard-coded
> platform data to be passed to it.
>
> Similarly, the following from your I2C patch shouldn't be required:
>
> +static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
> + ? ? ? .bus_clk_rate ? = 400000,
> +};
> ...
> + ? ? ? tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data;

Correct.  John, you /should/ be able to simply drop the hunk in this
patch that adds platform_data bits.  All you're doing with this patch
is dropping the local declaration of the platform_devices and using
the ones defined in arch/arm/mach-tegra/devices.c.  Setting the
platform_data pointer is not required.

g.

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

end of thread, other threads:[~2011-05-11 18:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20110510201108.22693.50319.stgit@riker>
     [not found] ` <20110510201414.22693.7427.stgit@riker>
     [not found]   ` <74CDBE0F657A3D45AFBB94109FB122FF04986AA06A@HQMAIL01.nvidia.com>
     [not found]     ` <BANLkTingm7PCJPC-xCremYg_Ab7qFvPSag@mail.gmail.com>
2011-05-10 22:16       ` [RFC 1/2] ARM: Tegra: Device Tree Support: Update how sdhci devices are initialized Stephen Warren
2011-05-10 22:33         ` John Bonesio
2011-05-10 22:42           ` Mark Brown
2011-05-10 23:22           ` Stephen Warren
2011-05-10 23:33             ` John Bonesio
2011-05-11  5:01               ` Stephen Warren
2011-05-11 17:40                 ` John Bonesio
2011-05-11 18:21                 ` Grant Likely

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).