Board fixup for phy: selecting location for phy_register_fixup_for_id

Hello

I realize this is possibly off topic but I think I’ll get some reasonable feedback here.

I’m interfacing to a different phy (LXT972, yes I know it’s old;-) and everything works perfectly with the genphy driver however, the led control registers aren’t set the way I want them to be. I verified that I can set the registers through the uboot mdio interface but, of course, the phy is reset when linux loads the network driver.

I see plenty of references in the kernel phy driver code to setting board specific fixups and I’ve also seen references to mii fixups instituted through the device tree. After considering both solutions the board fixup path seems more straight forward as I couldn’t determine that the dt mii fixup was implemented in the beaglebone branch.

Obligatory info:

buildroot

ti kernel 4.1.36
uclibc 0.9.30

Beaglebone black C version.

So;

I have two locations where I believe it is reasonable to apply a local patch for my build and I want someone to comment on them; either that one is more appropriate than the other or that there is a more elegant solution.

Fixup function: Defined in a header file.

static int [myboard_phy_fixups](http://lxr.free-electrons.com/ident?v=4.1;i=mpc8568_mds_phy_fixups)(struct [phy_device](http://lxr.free-electrons.com/ident?v=4.1;i=phy_device) *phydev)
{
<b> _/* Set LED function */_</b>
    [err](http://lxr.free-electrons.com/ident?v=4.1;i=err) = [phy_write](http://lxr.free-electrons.com/ident?v=4.1;i=phy_write)(phydev,0x14, 0x341A);

    if ([err](http://lxr.free-electrons.com/ident?v=4.1;i=err))
            return [err](http://lxr.free-electrons.com/ident?v=4.1;i=err);
    [temp](http://lxr.free-electrons.com/ident?v=4.1;i=temp) = [phy_read](http://lxr.free-electrons.com/ident?v=4.1;i=phy_read)(phydev, 0x14);

Hello

A follow up for anyone with a similar question.

I placed the function declaration in “include/linux/phy.h”, the function body in “drivers/net/phy/phy-device.c”, and registered the fixup in the same file at “__init phy_init()” after the “mdio_bus_init()” call.

Two small differences from the code below.

Declaration and function changed to “int myboard_phy_fixups(struct phy_device *phydev)”

the registration function was changed to “phy_register_fixup_for_uid(0x001378E2, 0xFFFFFFFF, myboard_phy_fixups);”

A blatant hack but it worked.

Regards

Chris