From: Gary Thomas <gary@mlbassoc.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Linux PPC Development <linuxppc-dev@ozlabs.org>
Subject: Re: OF device mappings
Date: Sat, 28 Feb 2009 13:25:04 -0700 [thread overview]
Message-ID: <49A99DA0.8080609@mlbassoc.com> (raw)
In-Reply-To: <fa686aa40902281219y463ebabao3445c790798c4bfd@mail.gmail.com>
Grant Likely wrote:
> On Sat, Feb 28, 2009 at 12:18 PM, Gary Thomas <gary@mlbassoc.com> wrote:
>> Grant Likely wrote:
>>>> How do I find the platform_device which was created when this
>>>> particular of_device was instantiated? I made sure that this code
>>>> is run late - after all the of_devices have been handled.
>>> Again, there is no platform_device. of_device *is* the device that was created.
>> But this doesn't work :-( I also don't understand how you
>> can say "there is no platform_device" - they are everywhere,
>> corresponding to actual device instances, as the system
>> creates them, typically in a driver 'probe' function.
>
> No, "struct device" is everywhere. "struct platform_device" is a
> particular container for a "struct device", just like "struct
> of_device" is another kind of container for "struct device". The
> board setup code (stuff in arch/powerpc/platforms/*) often calls into
> the of_platform bus to automatically register an of_device for many of
> the nodes in the device tree. platform_devices are typically
> explicitly registered by board setup code and has not relationship
> whatsoever with the of_platform bus.
>
>> I've tried both ways. If I look up the of_platform node and
>> then pass the 'dev' structure to the DSA driver, it doesn't work.
>> If I look up the actual device instance from the platform_bus
>> and pass that to the driver, it does.
>>
>> How do I get to the proper 'dev' structure which will make the
>> DSA driver work?
>>
>> More details - the DSA driver is expecting to get the 'dev'
>> structure pointer which was created in the gianfar driver,
>> static int gfar_probe(struct platform_device *pdev)
>> namely '&pdev->dev' -- this works.
>
> Ah, it becomes clear now. I seen that the gianfar driver has only
> recently been converted from a platform bus driver to an of_platform
> bus driver (see git commit b31a1d8b41513b96e9c7ec2f68c5734cef0b26a4).
> It will be released as part of 2.6.29.
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b31a1d8b41513b96e9c7ec2f68c5734cef0b26a4
>
> So, for the kernel version you're using, the
> of_find_device_by_phandle() call will never work. It will for 2.6.29
> and beyond. Currently, there is code in arch/powerpc/sysdev/fsl_soc.c
> which creates the platform_device which you're looking for. Look into
> that code to figure out how to get a pointer to that platform_device.
> you can probably iterate over the platform bus (hint: look at
> bus_find_device() and friends) to find it.
Glad we're singing from the same score now :-)
I'm working from a stock 2.6.28 kernel - upgrading to anything
newer is a bit iffy. Is the code you are referring to in the
latest 2.6.29-rc? and I should steal from there?
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
next prev parent reply other threads:[~2009-02-28 20:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-28 17:46 OF device mappings Gary Thomas
2009-02-28 18:04 ` Grant Likely
2009-02-28 18:21 ` Gary Thomas
2009-02-28 18:44 ` Grant Likely
2009-02-28 19:18 ` Gary Thomas
2009-02-28 20:19 ` Grant Likely
2009-02-28 20:25 ` Gary Thomas [this message]
2009-02-28 21:05 ` Benjamin Herrenschmidt
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=49A99DA0.8080609@mlbassoc.com \
--to=gary@mlbassoc.com \
--cc=grant.likely@secretlab.ca \
--cc=linuxppc-dev@ozlabs.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).