net: phy: extend PHY package API to support multiple global address
authorChristian Marangi <ansuelsmth@gmail.com>
Fri, 15 Dec 2023 13:15:32 +0000 (14:15 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 17 Dec 2023 20:10:07 +0000 (20:10 +0000)
commit9eea577eb1155fe4a183bc5e7bf269b0b2e7a6ba
treeb2543c72a1a46290ae3f113d4f3d3a7cda9b2530
parentebb30ccbbdbd6fae5177b676da4f4ac92bb4f635
net: phy: extend PHY package API to support multiple global address

Current API for PHY package are limited to single address to configure
global settings for the PHY package.

It was found that some PHY package (for example the qca807x, a PHY
package that is shipped with a bundle of 5 PHY) requires multiple PHY
address to configure global settings. An example scenario is a PHY that
have a dedicated PHY for PSGMII/serdes calibrarion and have a specific
PHY in the package where the global PHY mode is set and affects every
other PHY in the package.

Change the API in the following way:
- Change phy_package_join() to take the base addr of the PHY package
  instead of the global PHY addr.
- Make __/phy_package_write/read() require an additional arg that
  select what global PHY address to use by passing the offset from the
  base addr passed on phy_package_join().

Each user of this API is updated to follow this new implementation
following a pattern where an enum is defined to declare the offset of the
addr.

We also drop the check if shared is defined as any user of the
phy_package_read/write is expected to use phy_package_join first. Misuse
of this will correctly trigger a kernel panic for NULL pointer
exception.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/bcm54140.c
drivers/net/phy/mscc/mscc.h
drivers/net/phy/mscc/mscc_main.c
drivers/net/phy/phy_device.c
include/linux/phy.h