Re: Davicom DM9000A on MPC5200B (powerpc) works using a dirty offsetting and byte trick

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Grant Likely
Date: Friday, March 6, 2009 - 8:02 am

On Fri, Feb 20, 2009 at 2:51 AM, Henk Stegeman <henk.stegeman@gmail.com> wrote:

The ethernet node doesn't have any children, so drop the #size-cells
and #address-cells properties.


Drop device_type too.  It only makes sense if you're running real OpenFirmware.


Just make this reg = <0xfb000000 0x00000004>;.  Specify in the
documentation for the "davicom,dm9000" binding that the address
register is at offset 0 and the data register is at offset 2.

Actually, since this is the local plus bus, you should have this node
as a child of the localplus node.  Like this:

localbus {
    compatible = "fsl,mpc5200b-lpb", "fsl,mpc5200-lpb", "simple-bus";
    #address-cells = <2>;  // first cell is CS#, second is offset
    #size-cells = <1>;
    ranges = <1 0 0xfb000000 0x4>;  // CS#1, offset 0, mapped to
0xfb000000, size=4
    enet1: ethernet@fb000000 {
        compatible = "davicom,dm9000";
        reg = <0xfb000000 0x00000002            // DM9000 Address register
        mac-address = [ 00 00 00 00 00 00 ]; // Filled in by u-boot
        interrupts = <1 1 0>;                   // External interrupt 1
    };
};

Doing it this way provides drivers with the ability to get the chip
select number, which is important if you ever decide to use the
Localplus fifo to transfer to/from the device.


If the driver cannot handle big endian machines, then it is a driver
bug.  Don't be afraid to modify the driver to fix this and send a
patch.


Personally, I'd use the of_platform bus infrastructure to probe the
new device.  Register an of_platform_driver which will bind against
the device node for the ethernet device.  Then you have a choice:
option 1)  Your driver's probe method can either create a child
platform device which the original driver can bind against with the
correct pdata, or
option 2) your new driver can call into the original driver at a point
that bypasses the platform bus bindings (because they are handled by
the of_platform bus instead).

I typically choose option 2 because it requires less overhead and less
memory (one fewer probe call and one fewer struct device), but it will
probably require a little bit of refactoring the original driver to
provide call points to bypass the platform bus binding bit of the
driver.  I've done this many times, but it does depend on the driver
maintainer being okay with multiple bus bindings (platform and
of_platform) for a driver.  This is an ongoing debate.

See drivers/video/xilinxfb.c for an example of a driver with both
platform and of_platform bus bindings.  You'll notice at the end of
the file that both a platform driver and an of_platform driver are
getting registered.


no.  If CMD could appear at a different offset, then define an
optional property (maybe cmd-reg-offset = <2>;) to handle the case
where CMD appears at a different offset.


This I don't know.  I'd have to play with it to figure it out.


Fix the driver.  It will result in a more useful driver for everyone
at the end of the day.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Davicom DM9000A on MPC5200B (powerpc) works using a di ..., Grant Likely, (Fri Mar 6, 8:02 am)