Subject: Re: [RFC] MDIO firmware upload for offloading CPU

From: Andrew Lunn <[email-masked]>
Date: Sun, 22 Mar 2020 22:09:58 +0100

> > Hi Andreas
> > 
> > You say there is no PHY. So is the MDIO bus used for anything other
> > than firmware upload?
> 
> Yes - there are four other PHYs on the bus, everything is attached to
> the Lantiq Gigabit switch. I wasn't clear enough in this regard.

O.K. That makes it more difficult. Does probing just these four PHYs
upset the firmware upload? You need to probe them in order to use
them.

> > This two stage firmware upload is messy. If it had been just MDIO i
> > would of said do it from the kernel, as part of the Atheros SoC WiFi
> > driver. MDIO is a nice simple interface. Sending Ethernet frames is a
> > bit harder. Still, if you can do it all in the wifi driver, i
> > would. You can use phandle's to get references to the MDIO bus and the
> > Ehernet interface. There are examples of this in net/dsa/dsa2.c.
> 
> A bit more info on the two-stage firmware upload: The Atheros SoC is a
> complete AR9342 or QCA9558 SoC with 64MB or 128MB RAM. The stage 1
> firmware only initializes the Ethernet connection and waits for the
> stage 2 firmware. The latter consists in the vendor implementation of a
> Linux kernel and minimal user space, the wireless cards are then somehow
> "exported" over Ethernet to the Lantiq SoC. On the Lantiq, they look
> like local Atheros interfaces  - it looks a lot like ath9k-htc with a
> different transport

So the traditional model would be, the driver on the Lantiq for the
interfaces would be responsible for downloading the firmware to the
Atheros. Is there a driver for the ath9k-htc transport? That transport
is probably specific to the Atheros chip. So you can do the firmware
download from there.

Do you only use one address on the MDIO bus for firmware download?
Another option would be to have an mdio 'device' with a driver. When
the MDIO bus is enumerated by of_mdiobus_register(), it would find
this 'device' in DT, and load the driver for it. That driver could
then download the firmware over MDIO, and then later Ethernet. All the
infrastructure is in place for this. It is used by Ethernet switches
on MDIO busses.

	 Andrew