net: phy: aquantia: add firmware load support
authorRobert Marko <robimarko@gmail.com>
Tue, 14 Nov 2023 14:08:43 +0000 (15:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 16 Nov 2023 22:10:29 +0000 (22:10 +0000)
commite93984ebc1c82bd34f7a1b3391efaceee0a8ae96
treead8ffb518a926ae259a1111231352161571adc9a
parente1fbfa4a995d42e02e22b0dff2f8b4fdee1504b3
net: phy: aquantia: add firmware load support

Aquantia PHY-s require firmware to be loaded before they start operating.
It can be automatically loaded in case when there is a SPI-NOR connected
to Aquantia PHY-s or can be loaded from the host via MDIO.

This patch adds support for loading the firmware via MDIO as in most cases
there is no SPI-NOR being used to save on cost.
Firmware loading code itself is ported from mainline U-boot with cleanups.

The firmware has mixed values both in big and little endian.
PHY core itself is big-endian but it expects values to be in little-endian.
The firmware is little-endian but CRC-16 value for it is stored at the end
of firmware in big-endian.

It seems the PHY does the conversion internally from firmware that is
little-endian to the PHY that is big-endian on using the mailbox
but mailbox returns a big-endian CRC-16 to verify the written data
integrity.

Co-developed-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Robert Marko <robimarko@gmail.com>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/aquantia/Kconfig
drivers/net/phy/aquantia/Makefile
drivers/net/phy/aquantia/aquantia.h
drivers/net/phy/aquantia/aquantia_firmware.c [new file with mode: 0644]
drivers/net/phy/aquantia/aquantia_main.c