-1

I have a board with Sitara AM3352 - the networking is not via Ethernet PHY, but with a switch (Marvell 88E6341) that is connected to the CPU with MII. the switch has a port that is connected to a PHY and RJ45 connector.

My Linux version is 4.14

I configured the dts file correctly for having a network, but I also want the MDIO driver to be active so I will be able to manage the switch.

It looks like I can interact the Sitara MDIO controller with "devmem" commands, but I prefer to do it the "normal" way with the kernel devinci-mdio driver.

My dts looks like this:

&cpsw_emac0 {
phy_id = <&davinci_mdio>, <0>;
fixed-link = <1 1 100 0 0>;
phy-mode = "mii";
};

&mac {
slaves = <1>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&cpsw_default>;
pinctrl-1 = <&cpsw_sleep>;
status = "okay";
};

&davinci_mdio {
compatible = "ti,cpsw-mdio";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&davinci_mdio_default>;
pinctrl-1 = <&davinci_mdio_sleep>;
status = "okay";
};

This what I get in the dmesg:

[ 0.975182] mdio_bus fixed-0: GPIO lookup for consumer reset
[ 0.975195] mdio_bus fixed-0: using lookup tables for GPIO lookup
[ 0.975202] mdio_bus fixed-0: lookup for GPIO reset failed
[ 0.975223] libphy: Fixed MDIO Bus: probed
[ 0.994386] mdio_bus 4a101000.mdio: GPIO lookup for consumer reset
[ 0.994398] mdio_bus 4a101000.mdio: using lookup tables for GPIO lookup
[ 0.994405] mdio_bus 4a101000.mdio: lookup for GPIO reset failed
[ 1.047323] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6, bus freq 1000000
[ 1.055025] davinci_mdio 4a101000.mdio: no live phy, scanning all
[ 1.061484] davinci_mdio 4a101000.mdio: mdiobus_register ret=-5

I think it is rather common such design - so if anybody managed to handle this issue, I will much appreciate it if he will share the knowledge. Thanks

Avner Flesch
  • 35
  • 1
  • 7
  • I guess the ones that vote against this post don't have a clue on what the question is about. This issue is very common to whoever uses a board with Sitara with networking via a switch. and believe me, I search and I didn't find the answer. I think that if someone has experience with it - it will be a big deal to share it – Avner Flesch May 21 '21 at 05:06
  • I guess the ones that voted against this post realized that it's not a programming question and so unsuitable for stack-overfow. Maybe try [sf] (but read their help first to confirm it's suitable) – DavidW May 21 '21 at 07:51
  • It is embedded programming - it involves Linux kernel programming and device tree description – Avner Flesch May 21 '21 at 07:55

1 Answers1

1

Active the devinci_mdio kernel driver for a network switch is not trivial, but it must in order to use the Marvell software package to manage the switch. So instead of using the kernel driver - it is possible to access the MDIO controller physical addresses from the Linux userspace with the"mmap" command:

  • In am3352 the MDIO controller address is 0x4a101000 - map this address, the length should be 0x90 bytes.
  • Enable the controller in the address 0x4a101004 with the data 0x410000ff (the ff is for the clock speed, so another value is possible)
  • Read and write will be with address 0x4a101080.

Now you can implement the MDIO read and write functions that are required for Marvell's software package (or for other software packages)

Avner Flesch
  • 35
  • 1
  • 7