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 11:21:17 -0700 [thread overview]
Message-ID: <49A9809D.9000307@mlbassoc.com> (raw)
In-Reply-To: <fa686aa40902281004r5fcb67f4md328d79dd1d5d82c@mail.gmail.com>
Grant Likely wrote:
> On Sat, Feb 28, 2009 at 10:46 AM, Gary Thomas <gary@mlbassoc•com> wrote:
>> Still looking for some help... I need to be able to locate
>> the kernel platform_device which corresponds to an instance
>> from my OF tree. Basically, I have a [somewhat] unrelated
>> driver which needs to know these things, so the drivers in
>> question should not have to be affected.
>>
>> In particular, I'm working with the net/dsa drivers (Distributed
>> Switch Architecture) which need access to the network driver as
>> well as the MII/MDIO bus driver. It doesn't make sense to tie
>> those drivers back to DSA, but rather let the DSA driver find
>> its way to them.
>>
>> I've defined this in by DTS tree:
>> lan1 {
>> cell-index = <0x01>;
>
> Side note, why do you have cell-index here? I suspect that you're
> using it incorrectly.
Probably - I don't think I need it anyway.
>> compatible = "marvell,m88e609x";
>> net_dev = "fsl-gianfar.0";
>> mii_bus = "fsl-gianfar_mdio.14";
>
> These two lines don't make much sense. They are encoding Linux
> internal details with could very well change in the future.
>
>> net_devX = <ð0>;
>> mii_busX = <&mii_bus>;
>
> This is the right thing to do. This give you the phandle to the relevant node.
As I suspected.
> Once you have a handle to the node, you can iterate through the
> of_platform bus devices and look for a node which has a matching node
> pointer stored in archdata. That will give you a struct device which
> is contained by a struct of_device (note well: this will give you an
> of_device, not a platform_device.)
I have code which does this already, but I could not figure out
how to get from the of_device node to the actual platform_device.
for_each_compatible_node(np, NULL, "marvell,m88e609x") {
const phandle *ph;
struct device *dev;
struct of_device *of_dev;
ph = of_get_property(np, "net_devX", NULL);
if (ph == NULL) {
printk("%s: missing 'net_dev'\n", np->name);
break;
}
of_dev = of_find_device_by_phandle(*ph);
}
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.
> I'm working on a set of patches which should make this much easier.
> I'll try to remember to CC you when I post them to the list.
Looking forward to your code/ideas
>> };
>> ... two ways to find the same node.
>>
>> Using 'net_dev' (which I admit is pretty hokey), I can look
>> up the corresponding platform device, which does work for
>> the DSA layer. What I want is to be able to get to this
>> from the 'net_devX' pointer, but I don't seem to be able
>> to get out of the OF tree and into the actual platform
>> device tree to find the appropriate instance.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
next prev parent reply other threads:[~2009-02-28 18:21 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 [this message]
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
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=49A9809D.9000307@mlbassoc.com \
--to=gary@mlbassoc$(echo .)com \
--cc=grant.likely@secretlab$(echo .)ca \
--cc=linuxppc-dev@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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