linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Chris Alfred <c.alfred@internode.on.net>
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: Porting a driver to powerpc using FDT
Date: Wed, 16 Jun 2010 12:22:11 -0600	[thread overview]
Message-ID: <AANLkTimArb-UjJMe84Qrd4iNquGHEehbGW1Uciq_zGYm@mail.gmail.com> (raw)
In-Reply-To: <57F24E98919C4D22A784127E6CF1C9DA@kos>

On Tue, Jun 15, 2010 at 4:19 PM, Chris Alfred <c.alfred@internode.on.net> w=
rote:
> I am trying to port a DSA (Distributed Switch Architecture) driver for
> the Micrel KS8995M managed switch connected to a MPC5200. There is an
> SPI interface and MII interface managed by the DSA driver.
>
> I can't understand how probe gets called when the flatted device tree
> (FDT) system is used, and how to bind such a driver using the FDT (if
> you have to at all).
>
> The DSA driver is initialised via:
>
> =A0 =A0// net/dsa/dsa.c
>
> =A0 =A0static struct platform_driver dsa_driver =3D {
> =A0 =A0 .probe =A0=3D dsa_probe,
> =A0 =A0 .remove =A0=3D dsa_remove,
> =A0 =A0 .shutdown =3D dsa_shutdown,
> =A0 =A0 .driver =3D {
> =A0 =A0 =A0.name =3D "dsa",
> =A0 =A0 =A0.owner =3D THIS_MODULE,
> =A0 =A0 },
> =A0 =A0};
>
> =A0 =A0static int __init dsa_init_module(void)
> =A0 =A0{
> =A0 =A0 return platform_driver_register(&dsa_driver);
> =A0 =A0}
>
> dsa_init_module is being called; but how do I get the system to call
> .probe?

You need a platform device registered for the driver to bind against.
On a lot of systems, the machine setup code just registers a
statically allocated platform_device.  You can still do this on
powerpc if you create a new machine specific board file in
arch/powerpc/platforms/ (discouraged, but only mildly so for things
that are very board specific).

The "preferred" approach on device tree systems is to add device tree
hooks to the driver you want to use.  However, I'm not going to ask
you to do that since the current approach for doing so is in the
process of being removed (The current approach is to add a new
of_platform_driver registration for the device driver; but I've got
changes in my tree that will make regular old platform_drivers able to
bind against devices described in the device tree).

To avoid writing new machine-specific code in arch/powerpc/platforms,
then I recommend that you add a node to your .dts file to describe the
DSA complex and write a very simple of_platform_driver that binds
against it.  Then use the probe hook to extract data out of the device
tree node (if needed) and register the appropriate platform_device
(don't forget to make the of_device the parent of the
platform_device).  This can be considered a temporary solution, but it
will not break when I make the infrastructure changes, and then you
can migrate over to the new method at your leisure.

Cheers,
g.

  reply	other threads:[~2010-06-16 18:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 22:19 Porting a driver to powerpc using FDT Chris Alfred
2010-06-16 18:22 ` Grant Likely [this message]
2010-06-16 22:06   ` Chris Alfred
2010-06-16 22:43     ` Grant Likely
2010-06-16 22:48       ` Chris Alfred
2010-06-16 23:14         ` Grant Likely
2010-06-17  4:25           ` Chris Alfred
2010-06-17  4:29             ` Chris Alfred
2010-06-17 14:55             ` Grant Likely
2010-06-17 11:11           ` Chris Alfred
2010-06-17 16:37             ` Grant Likely
2010-06-17 22:15               ` Chris Alfred
  -- strict thread matches above, loose matches on Subject: below --
2010-06-15 22:18 Chris Alfred (Internode)

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=AANLkTimArb-UjJMe84Qrd4iNquGHEehbGW1Uciq_zGYm@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=c.alfred@internode.on.net \
    --cc=linuxppc-dev@lists.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).