Porting a driver to powerpc using FDT

Grant Likely grant.likely at secretlab.ca
Thu Jun 17 09:14:39 EST 2010


On Wed, Jun 16, 2010 at 4:48 PM, Chris Alfred <c.alfred at internode.on.net> wrote:
>>> dsa_of_init is successfully called; but dsa_of_probe is not called.
>>
>> That means the node is not being used to register an of_device.  I
>> need some more information to suggest how best to fix this.
>
>> What SoC are you using?
>> What file in arch/powerpc/platforms/* is used to setup your machine?
>
> We are using the MPC5200. Very similar to the Lite5200.

So you're board is driver by arch/powerpc/platforms/52xx/mpc5200_simple.c then?

>
>> It would help to have a copy of your full .dts file.
>
> /*
>  * jkc5200n8 board Device Tree Source
>  *
>  * Copyright 2006-2007 Secret Lab Technologies Ltd.
>  * Grant Likely <grant.likely at secretlab.ca>
>  *
>  * This program is free software; you can redistribute  it and/or
> modify it
>  * under  the terms of  the GNU General  Public License as published
> by the
>  * Free Software Foundation;  either version 2 of the  License, or (at
> your
>  * option) any later version.
>  */
>
> /dts-v1/;
>
> / {
>  model = "fsl,jkc5200n8";
>  compatible = "fsl,jkc5200n8";

Replace these two instances of 'fsl,' with this vendor name of this
board.  fsl means freescale, and I'm guessing freescale didn't design
this board.

>  #address-cells = <1>;
>  #size-cells = <1>;
>  interrupt-parent = <&mpc5200_pic>;
>
>  cpus {
>  #address-cells = <1>;
>  #size-cells = <0>;
>
>  PowerPC,5200 at 0 {
>   device_type = "cpu";
>   reg = <0>;
>   d-cache-line-size = <32>;
>   i-cache-line-size = <32>;
>   d-cache-size = <0x4000>; // L1, 16K
>   i-cache-size = <0x4000>; // L1, 16K
>   timebase-frequency = <0>; // from bootloader
>   bus-frequency = <0>;  // from bootloader
>   clock-frequency = <0>;  // from bootloader
>  };
>  };
>
>  memory {
>  device_type = "memory";
>  reg = <0x00000000 0x10000000>; // 256MB
>  };
>
>  dsa {
>  compatible = "dsa-of";
>  reg = <0 0>;   // unused

As mentioned, drop the reg property and be more specific in the
compatible value.

Okay, so the problem is that the 5200 board support doesn't understand
that this device is a real device.  The solution (and this isn't
perfect, but I'm working to make this better) is to put the node in a
place where the platform code actually processes it.  If you do the
following, then it should start working:

virtual-devices {
        compatible = "simple-bus";
        dsa {
              compatible = "<vendor>,jkc5200n8-dsa";
        };
};

Note that I've encoded the board name in the compatible value.  Until
(when/if) there is a 'generic' binding for DSA devices, you should
just use a string that is board specific.

You can look under /sys/devices to see if your device actually gets
registered or not.

This is *not* ideal.  The support code should pick up the device even
as a child of the root node, but I've got to make some changes to the
registration code to make it work correctly.

Cheers,
g.


More information about the Linuxppc-dev mailing list