Two devices created for one block in device tree?
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Dec 2021 11:15:06 UTC
Hi, is it possible to attach two different devices for one device description in device tree, with some order being guaranted, maybe one device in a pass? To be clear, I am trying to solve problem with PHY being attached to MAC being initialized later. I have a board with two MACs and two PHYs. There is a data connection from MAC to PHY - SGMII, one to one, and there is another connection, MDIO, with a bus controller via second MAC. In a device tree, it looks like this: ethernet@20110000 { status = "okay"; phy-handle = <0x00000010>; }; ethernet@20112000 { status = "okay"; phy-handle = <0x00000011>; ethernet-phy@0 { phandle = <0x00000010>; }; ethernet-phy@1 { phandle = <0x00000011>; }; }; (only some properties written here, just to illustrate the case) So it is basically the same as Routerstation or Routerstation Pro using if_arge interface. I understand the concept of mdio/miiproxy used here, but those boards' configs uses hints, different mechanism, not FDT/DTS. However, the problem is the same - on first pass through device tree, MDIO device is being created and initialized, then PHYs attached are being probed, attached and initialized, and then, in second pass, ethernet inteface is being created, initialized and configured to use PHY already found as prescribed. I searched in recent source tree for inspiration, but there are only three devices with something similar - if_arge.c in sys/mips/atheros, if_are.c in sys/mips/atheros/ar531x, and if_rt.c in sys/dev/rt. The last one, if_rt.c, uses two compatible strings to differentiate MAC and MDIO controllers, maybe they are implemented independently, I don't know, I did not found DTS using it. The rest uses hints, as already mentioned. For now, I see no working method for this scenario. The device in my case is Cadence GEM, MII readreg/writereg function are already there. All I need is just create a proxy for first ethernet, which should use those function accessing MDIO controller for second ethernet. In single pass scenario, this could not work because MDIO controller is not yet working when first ethernet is being initialized. Trying to use multi pass scenario, if I attach MDIO controller on first pass, MAC controller is not attached on second pass, because there is already driver attached. Could anybody provide any hint to me? It could be something obvious I just don't see, also one more complication is the code should be compiled conditionally, maybe using 'options CGEM_MDIO' in config file (just as if_arge and if_are do), because there are other boards with no need for mdio/miiproxy, I'd prefer to use simpler code for this case. Regards, Milan