Board fixup for phy: selecting location for phy_register_fixup_for_id

62 views
Skip to first unread message

Chris LaRocque

unread,
May 1, 2017, 5:37:59 PM5/1/17
to BeagleBoard
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(struct phy_device *phydev)
{
    /* Set LED function */
    err = phy_write(phydev,0x14, 0x341A);

    if (err)
            return err;
    temp = phy_read(phydev, 0x14);
  if (temp <=0)
          return temp;
    return err;
}
Function call to be added in the indicated location.
phy_register_fixup_for_id(phy_id, myboard_phy_fixups);
The two locations for inserting the register_fixup call:

1: In "Linux/arch/arm/mach-davinci/common.c/davinci_common/ @davinci_common_init" just prior to the function return.

Thanks in advance for your advice, thoughts, and opinions.
Chris LaRocque 

Chris LaRocque

unread,
May 3, 2017, 2:29:46 PM5/3/17
to BeagleBoard
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
Reply all
Reply to author
Forward
0 new messages