[PATCH v8 3/5] clk: en7523: Add support for selecting the Serdes port in SCU
Brian Masney
bmasney at redhat.com
Wed May 20 15:53:51 PDT 2026
Hi Christian,
On Wed, May 20, 2026 at 05:09:08PM +0200, Christian Marangi wrote:
> In the SCU register for clock and reset, there are also some register to
> select the Serdes port mode. The Airoha AN7581 SoC have 4 different Serdes
> that can switch between PCIe, USB or Ethernet mode.
>
> Add a simple PHY provider that expose the .set_mode OP to toggle the
> requested mode for the Serdes port.
>
> Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
> ---
> drivers/clk/Kconfig | 1 +
> drivers/clk/clk-en7523.c | 216 ++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 214 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index b2efbe9f6acb..e60a824b5117 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -221,6 +221,7 @@ config COMMON_CLK_EN7523
> bool "Clock driver for Airoha/EcoNet SoC system clocks"
> depends on OF
> depends on ARCH_AIROHA || ECONET || COMPILE_TEST
> + select GENERIC_PHY
> default ARCH_AIROHA
> help
> This driver provides the fixed clocks and gates present on Airoha
> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 1ab0e2eca5d3..d4b73c5f15b9 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c
> @@ -6,14 +6,18 @@
> #include <linux/io.h>
> #include <linux/mfd/syscon.h>
> #include <linux/platform_device.h>
> +#include <linux/phy.h>
> +#include <linux/phy/phy.h>
> #include <linux/property.h>
> #include <linux/regmap.h>
> #include <linux/reset-controller.h>
> +#include <linux/spinlock.h>
> #include <dt-bindings/clock/en7523-clk.h>
> #include <dt-bindings/reset/airoha,en7523-reset.h>
> #include <dt-bindings/reset/airoha,en7581-reset.h>
> #include <dt-bindings/clock/econet,en751221-scu.h>
> #include <dt-bindings/reset/econet,en751221-scu.h>
> +#include <dt-bindings/soc/airoha,scu-ssr.h>
>
> #define RST_NR_PER_BANK 32
>
> @@ -40,9 +44,22 @@
> #define REG_HIR_MASK GENMASK(31, 16)
> /* EN7581 */
> #define REG_NP_SCU_PCIC 0x88
> +#define REG_NP_SCU_SSR3 0x94
> +#define REG_SSUSB_HSGMII_SEL_MASK BIT(29)
> +#define REG_SSUSB_HSGMII_SEL_HSGMII FIELD_PREP_CONST(REG_SSUSB_HSGMII_SEL_MASK, 0x0)
> +#define REG_SSUSB_HSGMII_SEL_USB FIELD_PREP_CONST(REG_SSUSB_HSGMII_SEL_MASK, 0x1)
> #define REG_NP_SCU_SSTR 0x9c
> #define REG_PCIE_XSI0_SEL_MASK GENMASK(14, 13)
> +#define REG_PCIE_XSI0_SEL_PCIE FIELD_PREP_CONST(REG_PCIE_XSI0_SEL_MASK, 0x0)
> +#define REG_PCIE_XSI0_SEL_XFI FIELD_PREP_CONST(REG_PCIE_XSI0_SEL_MASK, 0x1)
> +#define REG_PCIE_XSI0_SEL_HSGMII FIELD_PREP_CONST(REG_PCIE_XSI0_SEL_MASK, 0x2)
> #define REG_PCIE_XSI1_SEL_MASK GENMASK(12, 11)
> +#define REG_PCIE_XSI1_SEL_PCIE FIELD_PREP_CONST(REG_PCIE_XSI1_SEL_MASK, 0x0)
> +#define REG_PCIE_XSI1_SEL_XFI FIELD_PREP_CONST(REG_PCIE_XSI1_SEL_MASK, 0x1)
> +#define REG_PCIE_XSI1_SEL_HSGMII FIELD_PREP_CONST(REG_PCIE_XSI1_SEL_MASK, 0x2)
> +#define REG_USB_PCIE_SEL_MASK BIT(3)
> +#define REG_USB_PCIE_SEL_PCIE FIELD_PREP_CONST(REG_USB_PCIE_SEL_MASK, 0x0)
> +#define REG_USB_PCIE_SEL_USB FIELD_PREP_CONST(REG_USB_PCIE_SEL_MASK, 0x1)
> #define REG_CRYPTO_CLKSRC2 0x20c
> /* EN751221 */
> #define EN751221_REG_SPI_DIV 0x0cc
> @@ -81,6 +98,8 @@ enum en_hir {
> HIR_MAX = 14,
> };
>
> +#define EN_SERDES_PHY_NUM 4
> +
> struct en_clk_desc {
> int id;
> const char *name;
> @@ -113,6 +132,18 @@ struct en_rst_data {
> struct reset_controller_dev rcdev;
> };
>
> +struct en_serdes_phy_instance {
> + struct phy *phy;
> + unsigned int serdes_port;
> +};
> +
> +struct en_clk_priv {
> + void __iomem *base;
> + /* protect SCU register */
> + spinlock_t lock;
This spinlock is not initialized with spin_lock_init(). You can do this in
en7523_clk_probe() after devm_kzalloc().
With that fixed:
Reviewed-by: Brian Masney <bmasney at redhat.com>
More information about the linux-arm-kernel
mailing list