From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D93AC43334 for ; Mon, 20 Jun 2022 15:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243434AbiFTPMX (ORCPT ); Mon, 20 Jun 2022 11:12:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242704AbiFTPMH (ORCPT ); Mon, 20 Jun 2022 11:12:07 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3895F1658C for ; Mon, 20 Jun 2022 08:02:47 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id w9so3199809lji.4 for ; Mon, 20 Jun 2022 08:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=odsCatuXRn3NiFBtyBRCzHVor61VJmIiPLvNMLhLp6I=; b=aZ2SA144QSpo6RHPerj2ftJyZhKtwm1sbmaAaXQeL8x/+FjvAw1MuVtdCiO1orB+c5 PssXfydj1OxhxMzSx5OEdScZJfG+HvDkJxx5WkSBG4es+EcPWMncU9JqCqrPGSPMTcbz muMw85qeCuumFnWW1OKyMMbnPM1C4Rix+jVgu0ta9mx2SRKIU4hEpsivzXa6TzH4xyW/ cwOez0dj6qOpr7ErEML5XyhVBcRzLLN5mwunrciIkU1gTa8ys3ekZ4fh0LNrNwudQghn ivCGgNJK73nka/wA1n8QIfPFx96JR/3yPdqHxwR+Nd53rGfsrImCxuN9gJ2ixjmVIk/G ru5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=odsCatuXRn3NiFBtyBRCzHVor61VJmIiPLvNMLhLp6I=; b=ZYf4KlkzEXHGEf9s2UJR8WQkKOdxCvG9EiCNLj01Rs8+3cjV0Sk4yecCBI/GXPWyrZ 0rD4g+tS3hViD7Di4GX38HC+vh5Cr9J9E7cvUY50ceXJKFZB267H0u7bkZvdNOZSkE9b OFPWbo92SjyPS0X4TO5ceuzTBLYP0xMOnaREQjTo/Pc8P9MAXIFXf+cgsMwnsa3ylAWA MEawvmUK4cVHtc1Cw90vyFQCAZABw04l3u8iLEnDM+XC8xLI9NVJH/2QK74JKV1m6sYf kDP/rRz7wwtv6Z+02kMXqNh5U8p3lLGdme1n3wemOKro2swZzCAvpVQ2tdUqJUv8LaEU 21MQ== X-Gm-Message-State: AJIora9caTh9PL9bHp4H8gO8mgg4/6eJgD7T+KDf6gy6zemg+Yhpt1HA pwy8KmzL6d7Z/cz8g7NriCgyEOepSebVZQ== X-Google-Smtp-Source: AGRyM1uVExzZpk82Zbw+UxgYL4S8+8n1cDZH0dX8WGn051iDAvPPamQIsf6HPyuEmJXNRZSVdWgdJA== X-Received: by 2002:a05:651c:b29:b0:255:6ecc:96f with SMTP id b41-20020a05651c0b2900b002556ecc096fmr11849054ljr.176.1655737365366; Mon, 20 Jun 2022 08:02:45 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:44 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 01/12] net: phy: fixed_phy: switch to fwnode_ API Date: Mon, 20 Jun 2022 17:02:14 +0200 Message-Id: <20220620150225.1307946-2-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch allows to use fixed_phy driver and its helper functions without Device Tree dependency, by swtiching from of_ to fwnode_ API. Signed-off-by: Marcin Wojtas --- include/linux/phy_fixed.h | 4 +-- drivers/net/mdio/of_mdio.c | 2 +- drivers/net/phy/fixed_phy.c | 37 ++++++++------------ 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h index 52bc8e487ef7..449a927231ec 100644 --- a/include/linux/phy_fixed.h +++ b/include/linux/phy_fixed.h @@ -19,7 +19,7 @@ extern int fixed_phy_add(unsigned int irq, int phy_id, struct fixed_phy_status *status); extern struct phy_device *fixed_phy_register(unsigned int irq, struct fixed_phy_status *status, - struct device_node *np); + struct fwnode_handle *fwnode); =20 extern struct phy_device * fixed_phy_register_with_gpiod(unsigned int irq, @@ -38,7 +38,7 @@ static inline int fixed_phy_add(unsigned int irq, int phy= _id, } static inline struct phy_device *fixed_phy_register(unsigned int irq, struct fixed_phy_status *status, - struct device_node *np) + struct fwnode_handle *fwnode) { return ERR_PTR(-ENODEV); } diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index 9e3c815a070f..d755fe1ecdda 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -421,7 +421,7 @@ int of_phy_register_fixed_link(struct device_node *np) return -ENODEV; =20 register_phy: - return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, np)); + return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, of_fwnode_ha= ndle(np))); } EXPORT_SYMBOL(of_phy_register_fixed_link); =20 diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c index aef739c20ac4..0dbe6c344b05 100644 --- a/drivers/net/phy/fixed_phy.c +++ b/drivers/net/phy/fixed_phy.c @@ -15,9 +15,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -186,16 +186,15 @@ static void fixed_phy_del(int phy_addr) } } =20 -#ifdef CONFIG_OF_GPIO -static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np) +static struct gpio_desc *fixed_phy_get_gpiod(struct fwnode_handle *fwnode) { - struct device_node *fixed_link_node; + struct fwnode_handle *fixed_link_node; struct gpio_desc *gpiod; =20 - if (!np) + if (!fwnode) return NULL; =20 - fixed_link_node =3D of_get_child_by_name(np, "fixed-link"); + fixed_link_node =3D fwnode_get_named_child_node(fwnode, "fixed-link"); if (!fixed_link_node) return NULL; =20 @@ -204,7 +203,7 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct dev= ice_node *np) * Linux device associated with it, we simply have obtain * the GPIO descriptor from the device tree like this. */ - gpiod =3D fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node), + gpiod =3D fwnode_gpiod_get_index(fixed_link_node, "link", 0, GPIOD_IN, "mdio"); if (IS_ERR(gpiod) && PTR_ERR(gpiod) !=3D -EPROBE_DEFER) { if (PTR_ERR(gpiod) !=3D -ENOENT) @@ -212,20 +211,14 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct d= evice_node *np) fixed_link_node); gpiod =3D NULL; } - of_node_put(fixed_link_node); + fwnode_handle_put(fixed_link_node); =20 return gpiod; } -#else -static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np) -{ - return NULL; -} -#endif =20 static struct phy_device *__fixed_phy_register(unsigned int irq, struct fixed_phy_status *status, - struct device_node *np, + struct fwnode_handle *fwnode, struct gpio_desc *gpiod) { struct fixed_mdio_bus *fmb =3D &platform_fmb; @@ -238,7 +231,7 @@ static struct phy_device *__fixed_phy_register(unsigned= int irq, =20 /* Check if we have a GPIO associated with this fixed phy */ if (!gpiod) { - gpiod =3D fixed_phy_get_gpiod(np); + gpiod =3D fixed_phy_get_gpiod(fwnode); if (IS_ERR(gpiod)) return ERR_CAST(gpiod); } @@ -269,8 +262,8 @@ static struct phy_device *__fixed_phy_register(unsigned= int irq, phy->asym_pause =3D status->asym_pause; } =20 - of_node_get(np); - phy->mdio.dev.of_node =3D np; + fwnode_handle_get(fwnode); + phy->mdio.dev.fwnode =3D fwnode; phy->is_pseudo_fixed_link =3D true; =20 switch (status->speed) { @@ -299,7 +292,7 @@ static struct phy_device *__fixed_phy_register(unsigned= int irq, ret =3D phy_device_register(phy); if (ret) { phy_device_free(phy); - of_node_put(np); + fwnode_handle_put(fwnode); fixed_phy_del(phy_addr); return ERR_PTR(ret); } @@ -309,9 +302,9 @@ static struct phy_device *__fixed_phy_register(unsigned= int irq, =20 struct phy_device *fixed_phy_register(unsigned int irq, struct fixed_phy_status *status, - struct device_node *np) + struct fwnode_handle *fwnode) { - return __fixed_phy_register(irq, status, np, NULL); + return __fixed_phy_register(irq, status, fwnode, NULL); } EXPORT_SYMBOL_GPL(fixed_phy_register); =20 @@ -327,7 +320,7 @@ EXPORT_SYMBOL_GPL(fixed_phy_register_with_gpiod); void fixed_phy_unregister(struct phy_device *phy) { phy_device_remove(phy); - of_node_put(phy->mdio.dev.of_node); + fwnode_handle_put(phy->mdio.dev.fwnode); fixed_phy_del(phy->mdio.addr); } EXPORT_SYMBOL_GPL(fixed_phy_unregister); --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21980C43334 for ; Mon, 20 Jun 2022 15:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243092AbiFTPMd (ORCPT ); Mon, 20 Jun 2022 11:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242950AbiFTPMI (ORCPT ); Mon, 20 Jun 2022 11:12:08 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCF91A055 for ; Mon, 20 Jun 2022 08:02:48 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id c4so17680624lfj.12 for ; Mon, 20 Jun 2022 08:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xFucQ3C/FYSxEEKLXgm7WEUAFTqRGfOx5PDeN0uOhvc=; b=I/l5jek5ysAPkzJhksovOM5xmWjXfNbCusHoQYicryGVeH2FpRoLLs1n7zbOGDy0w0 2JhlU2J/4rMAtZMYtqplfZSwsvgYiaLEJ0i1gdIj6W69DJ7tznZre1A5fQKR+WtgEzkf Jgfms8bXzux9le5rE4IsfakL8nt33uedbbwWUeNEkjghENjTsacOG46qJV38EP1WH7oI eReHw7Eqzr5imRh9gcg8olJHtAWHq147h0oWqlYVSyDpvi181fBSDXat/KfmQco8FoaA QdHlrunaRjrMS5tCDCnBrYKFtfrYRXxDCw6EljUXWA9R+PA1zBJen6/tkE7Gzemjk4hf YNLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xFucQ3C/FYSxEEKLXgm7WEUAFTqRGfOx5PDeN0uOhvc=; b=mZaKHkIWN5cX11JEbMmMSnpRBa0XVsqeUpAWF2FN+DN7LNZE3Hb0sasZ4rbqbJSVXQ 4slUudBRTc34rtjaIltmg5UDljgsWG8Ip2ekOE9LB7hXaVSD7L4x4xzaSGqjp3VOfXY4 UC6sgFuizlFfZ2qjNO47cIOdWCQK2880SVQAg4TsvV/vJBwnRafs4H4a3SooJKJNJ8w7 Jk9CEBlnCLD3bD6ua+ZsLZc3zDOzT50w+Xst78nkXrj00PZSU5V/rOl8rJRllWztDo99 xe07G7wGXPK+E5jeoRqzJso9Lkx59c+nSudcj36g3VVJlsKaLg4+P1STozJiVybN1svW R05g== X-Gm-Message-State: AJIora+41XXsU9KJWPXm8piVJTTkpGsgb6hq+oUaYBMqGpQxXXXlzYLI cO+f1Ek24aiRmrZsDdiL97Uw8tMg/tFo7Q== X-Google-Smtp-Source: AGRyM1uP5Akkrn+zO5ywGqHgQ1zT/LsX1aQLDykb/IEqucwHpSCG6STCHEn2ODcLvYDyjcwthz1pGA== X-Received: by 2002:a05:6512:2207:b0:47f:70b3:52d with SMTP id h7-20020a056512220700b0047f70b3052dmr2566673lfu.174.1655737366560; Mon, 20 Jun 2022 08:02:46 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:46 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 02/12] net: mdio: switch fixed-link PHYs API to fwnode_ Date: Mon, 20 Jun 2022 17:02:15 +0200 Message-Id: <20220620150225.1307946-3-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" fixed-link PHYs API is used by DSA and a number of drivers and was depending on of_. Switch to fwnode_ so to make it hardware description agnostic and allow to be used in ACPI world as well. Signed-off-by: Marcin Wojtas --- include/linux/fwnode_mdio.h | 19 ++++ drivers/net/mdio/fwnode_mdio.c | 100 ++++++++++++++++++++ drivers/net/mdio/of_mdio.c | 79 +--------------- 3 files changed, 122 insertions(+), 76 deletions(-) diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h index faf603c48c86..98755b8c6c8a 100644 --- a/include/linux/fwnode_mdio.h +++ b/include/linux/fwnode_mdio.h @@ -16,6 +16,11 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *m= dio, int fwnode_mdiobus_register_phy(struct mii_bus *bus, struct fwnode_handle *child, u32 addr); =20 +int fwnode_phy_register_fixed_link(struct fwnode_handle *fwnode); + +void fwnode_phy_deregister_fixed_link(struct fwnode_handle *fwnode); + +bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode); #else /* CONFIG_FWNODE_MDIO */ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, @@ -30,6 +35,20 @@ static inline int fwnode_mdiobus_register_phy(struct mii= _bus *bus, { return -EINVAL; } + +static inline int fwnode_phy_register_fixed_link(struct fwnode_handle *fwn= ode) +{ + return -ENODEV; +} + +static inline void fwnode_phy_deregister_fixed_link(struct fwnode_handle *= fwnode) +{ +} + +static inline bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode) +{ + return false; +} #endif =20 #endif /* __LINUX_FWNODE_MDIO_H */ diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1c1584fca632..b1c20c48b6cb 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -10,6 +10,7 @@ #include #include #include +#include =20 MODULE_AUTHOR("Calvin Johnson "); MODULE_LICENSE("GPL"); @@ -147,3 +148,102 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, return 0; } EXPORT_SYMBOL(fwnode_mdiobus_register_phy); + +/* + * fwnode_phy_is_fixed_link() and fwnode_phy_register_fixed_link() must + * support two bindings: + * - the old binding, where 'fixed-link' was a property with 5 + * cells encoding various information about the fixed PHY + * - the new binding, where 'fixed-link' is a sub-node of the + * Ethernet device. + */ +bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *fixed_link_node; + const char *managed; + int len; + + /* New binding */ + fixed_link_node =3D fwnode_get_named_child_node(fwnode, "fixed-link"); + if (fixed_link_node) { + fwnode_handle_put(fixed_link_node); + return true; + } + + if (fwnode_property_read_string(fwnode, "managed", &managed) =3D=3D 0 && + strcmp(managed, "auto") !=3D 0) + return true; + + /* Old binding */ + len =3D fwnode_property_read_u32_array(fwnode, "fixed-link", NULL, 0); + if (len =3D=3D (5 * sizeof(u32))) + return true; + + return false; +} +EXPORT_SYMBOL(fwnode_phy_is_fixed_link); + +int fwnode_phy_register_fixed_link(struct fwnode_handle *fwnode) +{ + struct fixed_phy_status status =3D {}; + struct fwnode_handle *fixed_link_node; + u32 fixed_link_prop[5]; + const char *managed; + + if (fwnode_property_read_string(fwnode, "managed", &managed) =3D=3D 0 && + strcmp(managed, "in-band-status") =3D=3D 0) { + /* status is zeroed, namely its .link member */ + goto register_phy; + } + + /* New binding */ + fixed_link_node =3D fwnode_get_named_child_node(fwnode, "fixed-link"); + if (fixed_link_node) { + status.link =3D 1; + status.duplex =3D fwnode_property_present(fixed_link_node, + "full-duplex"); + if (fwnode_property_read_u32(fixed_link_node, "speed", + &status.speed)) { + fwnode_handle_put(fixed_link_node); + return -EINVAL; + } + status.pause =3D fwnode_property_present(fixed_link_node, "pause"); + status.asym_pause =3D fwnode_property_present(fixed_link_node, + "asym-pause"); + fwnode_handle_put(fixed_link_node); + + goto register_phy; + } + + /* Old binding */ + if (fwnode_property_read_u32_array(fwnode, "fixed-link", fixed_link_prop, + ARRAY_SIZE(fixed_link_prop)) =3D=3D 0) { + status.link =3D 1; + status.duplex =3D fixed_link_prop[1]; + status.speed =3D fixed_link_prop[2]; + status.pause =3D fixed_link_prop[3]; + status.asym_pause =3D fixed_link_prop[4]; + goto register_phy; + } + + return -ENODEV; + +register_phy: + return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, fwnode)); +} +EXPORT_SYMBOL(fwnode_phy_register_fixed_link); + +void fwnode_phy_deregister_fixed_link(struct fwnode_handle *fwnode) +{ + struct phy_device *phydev; + + phydev =3D fwnode_phy_find_device(fwnode); + if (!phydev) + return; + + fixed_phy_unregister(phydev); + + put_device(&phydev->mdio.dev); /* fwnode_phy_find_device() */ + phy_device_free(phydev); /* fixed_phy_register() */ +} +EXPORT_SYMBOL(fwnode_phy_deregister_fixed_link); diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index d755fe1ecdda..409da6e92f7d 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -351,91 +351,18 @@ EXPORT_SYMBOL(of_phy_get_and_connect); */ bool of_phy_is_fixed_link(struct device_node *np) { - struct device_node *dn; - int len, err; - const char *managed; - - /* New binding */ - dn =3D of_get_child_by_name(np, "fixed-link"); - if (dn) { - of_node_put(dn); - return true; - } - - err =3D of_property_read_string(np, "managed", &managed); - if (err =3D=3D 0 && strcmp(managed, "auto") !=3D 0) - return true; - - /* Old binding */ - if (of_get_property(np, "fixed-link", &len) && - len =3D=3D (5 * sizeof(__be32))) - return true; - - return false; + return fwnode_phy_is_fixed_link(of_fwnode_handle(np)); } EXPORT_SYMBOL(of_phy_is_fixed_link); =20 int of_phy_register_fixed_link(struct device_node *np) { - struct fixed_phy_status status =3D {}; - struct device_node *fixed_link_node; - u32 fixed_link_prop[5]; - const char *managed; - - if (of_property_read_string(np, "managed", &managed) =3D=3D 0 && - strcmp(managed, "in-band-status") =3D=3D 0) { - /* status is zeroed, namely its .link member */ - goto register_phy; - } - - /* New binding */ - fixed_link_node =3D of_get_child_by_name(np, "fixed-link"); - if (fixed_link_node) { - status.link =3D 1; - status.duplex =3D of_property_read_bool(fixed_link_node, - "full-duplex"); - if (of_property_read_u32(fixed_link_node, "speed", - &status.speed)) { - of_node_put(fixed_link_node); - return -EINVAL; - } - status.pause =3D of_property_read_bool(fixed_link_node, "pause"); - status.asym_pause =3D of_property_read_bool(fixed_link_node, - "asym-pause"); - of_node_put(fixed_link_node); - - goto register_phy; - } - - /* Old binding */ - if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop, - ARRAY_SIZE(fixed_link_prop)) =3D=3D 0) { - status.link =3D 1; - status.duplex =3D fixed_link_prop[1]; - status.speed =3D fixed_link_prop[2]; - status.pause =3D fixed_link_prop[3]; - status.asym_pause =3D fixed_link_prop[4]; - goto register_phy; - } - - return -ENODEV; - -register_phy: - return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, of_fwnode_ha= ndle(np))); + return fwnode_phy_register_fixed_link(of_fwnode_handle(np)); } EXPORT_SYMBOL(of_phy_register_fixed_link); =20 void of_phy_deregister_fixed_link(struct device_node *np) { - struct phy_device *phydev; - - phydev =3D of_phy_find_device(np); - if (!phydev) - return; - - fixed_phy_unregister(phydev); - - put_device(&phydev->mdio.dev); /* of_phy_find_device() */ - phy_device_free(phydev); /* fixed_phy_register() */ + fwnode_phy_deregister_fixed_link(of_fwnode_handle(np)); } EXPORT_SYMBOL(of_phy_deregister_fixed_link); --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74167C43334 for ; Mon, 20 Jun 2022 15:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243179AbiFTPMh (ORCPT ); Mon, 20 Jun 2022 11:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242963AbiFTPMJ (ORCPT ); Mon, 20 Jun 2022 11:12:09 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C922FC for ; Mon, 20 Jun 2022 08:02:49 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id c30so12223363ljr.9 for ; Mon, 20 Jun 2022 08:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e2Cd3eQM+C0dmzMqQNndhsAzgMvOaojaEFbBvNt2Fic=; b=Y4nEEPRsmVHDrSrrfoAQXg2HXs8O1oRslQ0rXWFDmT1MQg4bHUJL2uHX/OOCRvZAW4 2S6o+7TVjw/ERDVOILwrSaPS//OM63T7tfMQ4K/VVBbwUrIjCmSeHYpfukvEnXSaH3GS g9RopuRsVEIfV6WG/l0vQ8Q8QjuOD79ofy6E9L+ud6q0kHSVqfMLkHrRPYzRV83RZdXv 182nkIlpjYjDUe6WaGf4cfvKkOVyzgEpWJBMRJVB5+qoNl/WL0IOIaE6l2MgkrQsuYHU C3O/mpbvUhWnVF473pNgkRNOL/MnwEH2NvhmlPAS7T0YMgj854Mca35OKYj/8+gOunDY 8qiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e2Cd3eQM+C0dmzMqQNndhsAzgMvOaojaEFbBvNt2Fic=; b=fQtYRlRGgGGTZxl1Z71jYchLVoR4DULYa6KR/KLUL5AyRj5n1xlnrwzDu6h5nSKRRR MemuzC5q1IoCUzIaS6+RS8RNmIww6WjnoraiacYfEeP96pN8VUxq52Vh+VYYhpJNrBkW WMf0bJFXh9fK9c8R0Lfr6fX4zP8GAVfL0oWMBzO0UEcLG6kvkroQXDws6Fluf4mrq4UT OYEk58f6/76d46Tt4fn7WMs3DPiAeNSYS+HiIpGLTmcYKLzDDHpu9uZ0S55/P+4lO7bg yWmwdakojGCyrY78eqiV7jPHNYJtEV8ZCUmoKsS5e2MfHqZuANlB1+Dr5zClqJQF7/j7 uXiw== X-Gm-Message-State: AJIora+IAJMSp62aZDtDJPmn9+xYJImMUG2ygrry+rzwgpbvei5gKlSv YmFW1ttY75hgL6hhQ90m18tPkP583BYbow== X-Google-Smtp-Source: AGRyM1sssAdqhBLIlWixMfcjN1PbIhBI1R2jYI1eP+BdaY9z+Y9WaAwKpF25q33k5Pl/owqtSeU3RA== X-Received: by 2002:a2e:a289:0:b0:258:e917:36a4 with SMTP id k9-20020a2ea289000000b00258e91736a4mr11965710lja.510.1655737367628; Mon, 20 Jun 2022 08:02:47 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:47 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 03/12] net: dsa: switch to device_/fwnode_ APIs Date: Mon, 20 Jun 2022 17:02:16 +0200 Message-Id: <20220620150225.1307946-4-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In order to support both ACPI and DT, modify the generic DSA code to use device_/fwnode_ equivalent routines. No functional change is introduced by this patch. Signed-off-by: Marcin Wojtas --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 76 +++++++++++--------- net/dsa/port.c | 54 +++++++------- net/dsa/slave.c | 6 +- 4 files changed, 71 insertions(+), 66 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 14f07275852b..692c1dddc5f8 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -299,6 +299,7 @@ struct dsa_port { u8 setup:1; =20 struct device_node *dn; + struct fwnode_handle *fwnode; unsigned int ageing_time; =20 struct dsa_bridge *bridge; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index cac48a741f27..039022bf914b 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -493,7 +493,7 @@ static int dsa_port_setup(struct dsa_port *dp) =20 break; case DSA_PORT_TYPE_USER: - of_get_mac_address(dp->dn, dp->mac); + fwnode_get_mac_address(dp->fwnode, dp->mac); err =3D dsa_slave_create(dp); if (err) break; @@ -853,7 +853,7 @@ static int dsa_switch_setup_tag_protocol(struct dsa_swi= tch *ds) static int dsa_switch_setup(struct dsa_switch *ds) { struct dsa_devlink_priv *dl_priv; - struct device_node *dn; + struct fwnode_handle *fwnode; struct dsa_port *dp; int err; =20 @@ -909,10 +909,10 @@ static int dsa_switch_setup(struct dsa_switch *ds) =20 dsa_slave_mii_bus_init(ds); =20 - dn =3D of_get_child_by_name(ds->dev->of_node, "mdio"); + fwnode =3D fwnode_get_named_child_node(ds->dev->fwnode, "mdio"); =20 - err =3D of_mdiobus_register(ds->slave_mii_bus, dn); - of_node_put(dn); + err =3D of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode)); + fwnode_handle_put(fwnode); if (err < 0) goto free_slave_mii_bus; } @@ -1482,24 +1482,34 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, = struct net_device *master, return 0; } =20 -static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) +static int dsa_port_parse_of(struct dsa_port *dp, struct fwnode_handle *fw= node) { - struct device_node *ethernet =3D of_parse_phandle(dn, "ethernet", 0); - const char *name =3D of_get_property(dn, "label", NULL); - bool link =3D of_property_read_bool(dn, "link"); + struct fwnode_handle *ethernet =3D fwnode_find_reference(fwnode, "etherne= t", 0); + bool link =3D fwnode_property_present(fwnode, "link"); + const char *name; + int ret; + + ret =3D fwnode_property_read_string(fwnode, "label", &name); + if (ret) + return ret; =20 - dp->dn =3D dn; + dp->fwnode =3D fwnode; + dp->dn =3D to_of_node(fwnode); =20 - if (ethernet) { + if (!IS_ERR(ethernet)) { struct net_device *master; const char *user_protocol; =20 - master =3D of_find_net_device_by_node(ethernet); - of_node_put(ethernet); + master =3D of_find_net_device_by_node(to_of_node(ethernet)); + fwnode_handle_put(ethernet); if (!master) return -EPROBE_DEFER; =20 - user_protocol =3D of_get_property(dn, "dsa-tag-protocol", NULL); + ret =3D fwnode_property_read_string(fwnode, "dsa-tag-protocol", + &user_protocol); + if (ret) + user_protocol =3D NULL; + return dsa_port_parse_cpu(dp, master, user_protocol); } =20 @@ -1510,34 +1520,34 @@ static int dsa_port_parse_of(struct dsa_port *dp, s= truct device_node *dn) } =20 static int dsa_switch_parse_ports_of(struct dsa_switch *ds, - struct device_node *dn) + struct fwnode_handle *fwnode) { - struct device_node *ports, *port; + struct fwnode_handle *ports, *port; struct dsa_port *dp; int err =3D 0; u32 reg; =20 - ports =3D of_get_child_by_name(dn, "ports"); + ports =3D fwnode_get_named_child_node(fwnode, "ports"); if (!ports) { /* The second possibility is "ethernet-ports" */ - ports =3D of_get_child_by_name(dn, "ethernet-ports"); + ports =3D fwnode_get_named_child_node(fwnode, "ethernet-ports"); if (!ports) { dev_err(ds->dev, "no ports child node found\n"); return -EINVAL; } } =20 - for_each_available_child_of_node(ports, port) { - err =3D of_property_read_u32(port, "reg", ®); + fwnode_for_each_available_child_node(ports, port) { + err =3D fwnode_property_read_u32(port, "reg", ®); if (err) { - of_node_put(port); + fwnode_handle_put(port); goto out_put_node; } =20 if (reg >=3D ds->num_ports) { dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", port, reg, ds->num_ports); - of_node_put(port); + fwnode_handle_put(port); err =3D -EINVAL; goto out_put_node; } @@ -1546,24 +1556,24 @@ static int dsa_switch_parse_ports_of(struct dsa_swi= tch *ds, =20 err =3D dsa_port_parse_of(dp, port); if (err) { - of_node_put(port); + fwnode_handle_put(port); goto out_put_node; } } =20 out_put_node: - of_node_put(ports); + fwnode_handle_put(ports); return err; } =20 static int dsa_switch_parse_member_of(struct dsa_switch *ds, - struct device_node *dn) + struct fwnode_handle *fwnode) { u32 m[2] =3D { 0, 0 }; int sz; =20 /* Don't error out if this optional property isn't found */ - sz =3D of_property_read_variable_u32_array(dn, "dsa,member", m, 2, 2); + sz =3D fwnode_property_read_u32_array(fwnode, "dsa,member", m, 2); if (sz < 0 && sz !=3D -EINVAL) return sz; =20 @@ -1600,11 +1610,11 @@ static int dsa_switch_touch_ports(struct dsa_switch= *ds) return 0; } =20 -static int dsa_switch_parse_of(struct dsa_switch *ds, struct device_node *= dn) +static int dsa_switch_parse_of(struct dsa_switch *ds, struct fwnode_handle= *fwnode) { int err; =20 - err =3D dsa_switch_parse_member_of(ds, dn); + err =3D dsa_switch_parse_member_of(ds, fwnode); if (err) return err; =20 @@ -1612,7 +1622,7 @@ static int dsa_switch_parse_of(struct dsa_switch *ds,= struct device_node *dn) if (err) return err; =20 - return dsa_switch_parse_ports_of(ds, dn); + return dsa_switch_parse_ports_of(ds, fwnode); } =20 static int dsa_port_parse(struct dsa_port *dp, const char *name, @@ -1705,20 +1715,20 @@ static int dsa_switch_probe(struct dsa_switch *ds) { struct dsa_switch_tree *dst; struct dsa_chip_data *pdata; - struct device_node *np; + struct fwnode_handle *fwnode; int err; =20 if (!ds->dev) return -ENODEV; =20 pdata =3D ds->dev->platform_data; - np =3D ds->dev->of_node; + fwnode =3D ds->dev->fwnode; =20 if (!ds->num_ports) return -EINVAL; =20 - if (np) { - err =3D dsa_switch_parse_of(ds, np); + if (fwnode) { + err =3D dsa_switch_parse_of(ds, fwnode); if (err) dsa_switch_release_ports(ds); } else if (pdata) { diff --git a/net/dsa/port.c b/net/dsa/port.c index 3738f2d40a0b..a0e46e276de0 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -6,10 +6,9 @@ * Vivien Didelot */ =20 +#include #include #include -#include -#include =20 #include "dsa_priv.h" =20 @@ -1379,20 +1378,20 @@ void dsa_port_set_tag_protocol(struct dsa_port *cpu= _dp, =20 static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp) { - struct device_node *phy_dn; + struct fwnode_handle *phy_handle; struct phy_device *phydev; =20 - phy_dn =3D of_parse_phandle(dp->dn, "phy-handle", 0); - if (!phy_dn) + phy_handle =3D fwnode_find_reference(dp->fwnode, "phy-handle", 0); + if (IS_ERR(phy_handle)) return NULL; =20 - phydev =3D of_phy_find_device(phy_dn); + phydev =3D fwnode_phy_find_device(phy_handle); if (!phydev) { - of_node_put(phy_dn); + fwnode_handle_put(phy_handle); return ERR_PTR(-EPROBE_DEFER); } =20 - of_node_put(phy_dn); + fwnode_handle_put(phy_handle); return phydev; } =20 @@ -1524,11 +1523,10 @@ static const struct phylink_mac_ops dsa_port_phylin= k_mac_ops =3D { int dsa_port_phylink_create(struct dsa_port *dp) { struct dsa_switch *ds =3D dp->ds; - phy_interface_t mode; - int err; + int mode; =20 - err =3D of_get_phy_mode(dp->dn, &mode); - if (err) + mode =3D fwnode_get_phy_mode(dp->fwnode); + if (mode < 0) mode =3D PHY_INTERFACE_MODE_NA; =20 /* Presence of phylink_mac_link_state or phylink_mac_an_restart is @@ -1541,7 +1539,7 @@ int dsa_port_phylink_create(struct dsa_port *dp) if (ds->ops->phylink_get_caps) ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); =20 - dp->pl =3D phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), + dp->pl =3D phylink_create(&dp->pl_config, dp->fwnode, mode, &dsa_port_phylink_mac_ops); if (IS_ERR(dp->pl)) { pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl)); @@ -1591,14 +1589,13 @@ static int dsa_port_setup_phy_of(struct dsa_port *d= p, bool enable) =20 static int dsa_port_fixed_link_register_of(struct dsa_port *dp) { - struct device_node *dn =3D dp->dn; struct dsa_switch *ds =3D dp->ds; struct phy_device *phydev; int port =3D dp->index; - phy_interface_t mode; + int mode; int err; =20 - err =3D of_phy_register_fixed_link(dn); + err =3D fwnode_phy_register_fixed_link(dp->fwnode); if (err) { dev_err(ds->dev, "failed to register the fixed PHY of port %d\n", @@ -1606,10 +1603,10 @@ static int dsa_port_fixed_link_register_of(struct d= sa_port *dp) return err; } =20 - phydev =3D of_phy_find_device(dn); + phydev =3D fwnode_phy_find_device(dp->fwnode); =20 - err =3D of_get_phy_mode(dn, &mode); - if (err) + mode =3D fwnode_get_phy_mode(dp->fwnode); + if (mode < 0) mode =3D PHY_INTERFACE_MODE_NA; phydev->interface =3D mode; =20 @@ -1626,7 +1623,6 @@ static int dsa_port_fixed_link_register_of(struct dsa= _port *dp) static int dsa_port_phylink_register(struct dsa_port *dp) { struct dsa_switch *ds =3D dp->ds; - struct device_node *port_dn =3D dp->dn; int err; =20 dp->pl_config.dev =3D ds->dev; @@ -1636,7 +1632,7 @@ static int dsa_port_phylink_register(struct dsa_port = *dp) if (err) return err; =20 - err =3D phylink_of_phy_connect(dp->pl, port_dn, 0); + err =3D phylink_fwnode_phy_connect(dp->pl, dp->fwnode, 0); if (err && err !=3D -ENODEV) { pr_err("could not attach to PHY: %d\n", err); goto err_phy_connect; @@ -1651,27 +1647,27 @@ static int dsa_port_phylink_register(struct dsa_por= t *dp) =20 int dsa_port_link_register_of(struct dsa_port *dp) { + struct fwnode_handle *phy_handle; struct dsa_switch *ds =3D dp->ds; - struct device_node *phy_np; int port =3D dp->index; =20 if (!ds->ops->adjust_link) { - phy_np =3D of_parse_phandle(dp->dn, "phy-handle", 0); - if (of_phy_is_fixed_link(dp->dn) || phy_np) { + phy_handle =3D fwnode_find_reference(dp->fwnode, "phy-handle", 0); + if (fwnode_phy_is_fixed_link(dp->fwnode) || !IS_ERR(phy_handle)) { if (ds->ops->phylink_mac_link_down) ds->ops->phylink_mac_link_down(ds, port, MLO_AN_FIXED, PHY_INTERFACE_MODE_NA); - of_node_put(phy_np); + fwnode_handle_put(dp->fwnode); return dsa_port_phylink_register(dp); } - of_node_put(phy_np); + fwnode_handle_put(dp->fwnode); return 0; } =20 dev_warn(ds->dev, "Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n"); =20 - if (of_phy_is_fixed_link(dp->dn)) + if (fwnode_phy_is_fixed_link(dp->fwnode)) return dsa_port_fixed_link_register_of(dp); else return dsa_port_setup_phy_of(dp, true); @@ -1690,8 +1686,8 @@ void dsa_port_link_unregister_of(struct dsa_port *dp) return; } =20 - if (of_phy_is_fixed_link(dp->dn)) - of_phy_deregister_fixed_link(dp->dn); + if (fwnode_phy_is_fixed_link(dp->fwnode)) + fwnode_phy_deregister_fixed_link(dp->fwnode); else dsa_port_setup_phy_of(dp, false); } diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 2e1ac638d135..b801795d73a6 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include #include #include @@ -2204,7 +2202,6 @@ static int dsa_slave_phy_connect(struct net_device *s= lave_dev, int addr, static int dsa_slave_phy_setup(struct net_device *slave_dev) { struct dsa_port *dp =3D dsa_slave_to_port(slave_dev); - struct device_node *port_dn =3D dp->dn; struct dsa_switch *ds =3D dp->ds; u32 phy_flags =3D 0; int ret; @@ -2228,7 +2225,7 @@ static int dsa_slave_phy_setup(struct net_device *sla= ve_dev) if (ds->ops->get_phy_flags) phy_flags =3D ds->ops->get_phy_flags(ds, dp->index); =20 - ret =3D phylink_of_phy_connect(dp->pl, port_dn, phy_flags); + ret =3D phylink_fwnode_phy_connect(dp->pl, dp->fwnode, phy_flags); if (ret =3D=3D -ENODEV && ds->slave_mii_bus) { /* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead @@ -2341,6 +2338,7 @@ int dsa_slave_create(struct dsa_port *port) =20 SET_NETDEV_DEV(slave_dev, port->ds->dev); slave_dev->dev.of_node =3D port->dn; + slave_dev->dev.fwnode =3D port->fwnode; slave_dev->vlan_features =3D master->vlan_features; =20 p =3D netdev_priv(slave_dev); --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B2DFC433EF for ; Mon, 20 Jun 2022 15:12:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243634AbiFTPMp (ORCPT ); Mon, 20 Jun 2022 11:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242414AbiFTPML (ORCPT ); Mon, 20 Jun 2022 11:12:11 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E4F1F2F for ; Mon, 20 Jun 2022 08:02:52 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id o23so5097504ljg.13 for ; Mon, 20 Jun 2022 08:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b2AKescmGlKNcLJ4HDilF0tkENV4Ss4sdm70D7RL07I=; b=rC8BmvECl/r/bwfRj5gY7fodnhLqkpD4/oDWpi9b3OqcVG5ZUJBUxXg0eHvaiSIWpc IT0YD2Adcjo4ZMc0x840TpCxLky45HTQiPIqUJydervFxSXgtIcppzWfcZJkhi72SNWK ouR22ZiEzbdEvSDFvDiye0JCgRhLdiHKKGP+ntSIGgjXXI4ldbxIpPo4P9c8iwDSBepI 6pqwl4764R9eFoPbY170VW85np3DEMUShyv2BXRJ+7aUB/zHKPp5vSfT2bxjQzx95L3L xAeDffMP12clZd831cesX422+qx0HE/HsovbR9uhU4jPNhwKdQnrj9nw58DePoQtc9rR NbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b2AKescmGlKNcLJ4HDilF0tkENV4Ss4sdm70D7RL07I=; b=22nlJmyLkZZVQSSLxn1bCyNsdcDTJqGaKhBjZxEFeYD4PkWlNl907aM9cXwPTGgHIW OATmE9pGhoEoVBTVs0kPwMLuRYv7g4sUfWpAVScj//F4rt5oUcxdy7eeM0KgfXtFSXnE VQg+NM+G3xj09yt2KbkNEtupr7w0xHXWvo+arHaHOdIV/Iq66opHs74nVDe12SzSAifq 2Ppfz32sA7KoIGdiYG+ta2htD00SAVjPGIJGfHx1AfPrC8bU7YFZOrGOJVRxogOovJ91 V1/wAsx0gBoDdU4a09Td/Fe4OarVdXYPOGG0i5OrXphkwJBt89JBnGr8SId+/VDe1zW7 fvkw== X-Gm-Message-State: AJIora+Bh5cKwNNc9kI62KK6VryXOdrf0AEmxlHV4nr2XLXOPb3fgqzq zG2uaskECZYZVACVCiy01pyqjWUGcdtgfQ== X-Google-Smtp-Source: AGRyM1vbXLtUNjH0AC77POL9h5Lp/wi5D1FylX8FlzNfPcENyyC4zuvZ6/whXb8+g5bZ5gWNdMZBTw== X-Received: by 2002:a05:651c:1502:b0:255:b837:a27a with SMTP id e2-20020a05651c150200b00255b837a27amr11499984ljf.284.1655737369056; Mon, 20 Jun 2022 08:02:49 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:48 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 04/12] net: mvpp2: initialize port fwnode pointer Date: Mon, 20 Jun 2022 17:02:17 +0200 Message-Id: <20220620150225.1307946-5-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As a preparation to switch the DSA subsystem from using of_find_net_device_by_node() to its more generic fwnode_ equivalent, the port's device structure should be updated with its fwnode pointer, similarly to of_node - see analogous commit c4053ef32208 ("net: mvpp2: initialize port of_node pointer"). This patch is required to prevent a regression before updating the DSA API on boards that connect the mvpp2 port to switch, such as Clearfog GT-8K or CN913x CEx7 Evaluation Board. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/= ethernet/marvell/mvpp2/mvpp2_main.c index b84128b549b4..cd2f113bb1a4 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -6869,6 +6869,7 @@ static int mvpp2_port_probe(struct platform_device *p= dev, /* 9704 =3D=3D 9728 - 20 and rounding to 8 */ dev->max_mtu =3D MVPP2_BM_JUMBO_PKT_SIZE; dev->dev.of_node =3D port_node; + dev->dev.fwnode =3D port_fwnode; =20 port->pcs_gmac.ops =3D &mvpp2_phylink_gmac_pcs_ops; port->pcs_xlg.ops =3D &mvpp2_phylink_xlg_pcs_ops; --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55EEFC433EF for ; Mon, 20 Jun 2022 15:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243303AbiFTPMn (ORCPT ); Mon, 20 Jun 2022 11:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242380AbiFTPML (ORCPT ); Mon, 20 Jun 2022 11:12:11 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F331E8F for ; Mon, 20 Jun 2022 08:02:52 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id c30so12223514ljr.9 for ; Mon, 20 Jun 2022 08:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t4fm7chK+9HP+V4kfjA7VXym1QH3FPQZTxUsVRysYlI=; b=GC02YJZFg88R2E6b7Wy1WLcpX7Ar2kvhBGaz/xonS8B5DjkgBc2uwF6qOcPbPkBIE/ 6bpk0yfhSgNWi0ygLzCSnaJ7KOh7HuFYVvqdVbQwX709iQGr3ro2PElbJC54njuEgtCu i2tupv/SHrxy3o9t875X8LbtPxLNGfUJqy+/ff9966/cFdEJcXB2F9v+M/mfH+exNX3N mRPMTu1qSpRGj8giJ9pmfaoSugiOKJw6BDvp/9XU5DF/uGpxrNtmrmaFr1c7kzxAxN4e davPWJ20AqSd9nu1kiPF/smDxl4EwtiozhanuxLeF9Gu4RLy7p6ta4DePU//03kyur8v nGGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t4fm7chK+9HP+V4kfjA7VXym1QH3FPQZTxUsVRysYlI=; b=3DktRXVM49IYsWAnJ/UU11lyL+bK0KKQRDZyyzqpemg8MpxS2ICFvfjZ2toR8hiLCb I5lQvW9A554C/Q32ZmJUEYLYvmbZu69OUgR3znwsjpeZ5IXgXD0KCRlIEciL0IeCna0D OglqMcTDhbK3UGdxdTe4loz2Vpc52dsH/bmVlZElR5bNjLk6cFlRKiXQu/QRiqfwGwSS pWYh9oEsKI6B1ptmwl3sYN/ZK/88uRsRRMYJtj1m2jbUYkdFHYm1KRlsKuF4f9n7bqr0 cuLJ/q6MKJO0u9UZuXJysKqa3Pp7zWGu+sjDCaRtEF6Onk6XjawksEUHWMntZR/9dPr8 uN1Q== X-Gm-Message-State: AJIora//bxs9lvV7mEKZjhrSN5Q2EXSBMSjBimXfnLV5HBVNhzXsE0uv FmJoDv8lW4cJLaFR1qiye0VlY6xIO2aE+A== X-Google-Smtp-Source: AGRyM1uYOZ02rYHZJgaSORea5LGhaa+Fo4kElEGhfJGAzyML5aZG9cH/D2CN0E16ZUk+OzgFKnWGqg== X-Received: by 2002:a05:651c:244:b0:255:32c8:dd42 with SMTP id x4-20020a05651c024400b0025532c8dd42mr11790566ljn.101.1655737370158; Mon, 20 Jun 2022 08:02:50 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:49 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 05/12] net: core: switch to fwnode_find_net_device_by_node() Date: Mon, 20 Jun 2022 17:02:18 +0200 Message-Id: <20220620150225.1307946-6-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A helper function which allows getting the struct net_device pointer associated with a given device tree node can be more generic and also support alternative hardware description. Switch to fwnode_ and update the only existing caller in DSA subsystem. Signed-off-by: Marcin Wojtas Reported-by: kernel test robot --- include/linux/etherdevice.h | 1 + include/linux/of_net.h | 6 ------ net/core/net-sysfs.c | 18 ++++++++---------- net/dsa/dsa2.c | 3 ++- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 92b10e67d5f8..a335775af244 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -35,6 +35,7 @@ int nvmem_get_mac_address(struct device *dev, void *addrb= uf); int device_get_mac_address(struct device *dev, char *addr); int device_get_ethdev_address(struct device *dev, struct net_device *netde= v); int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr); +struct net_device *fwnode_find_net_device_by_node(struct fwnode_handle *fw= node); =20 u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 le= n); __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev); diff --git a/include/linux/of_net.h b/include/linux/of_net.h index 0484b613ca64..f672f831292d 100644 --- a/include/linux/of_net.h +++ b/include/linux/of_net.h @@ -15,7 +15,6 @@ struct net_device; extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interf= ace); extern int of_get_mac_address(struct device_node *np, u8 *mac); int of_get_ethdev_address(struct device_node *np, struct net_device *dev); -extern struct net_device *of_find_net_device_by_node(struct device_node *n= p); #else static inline int of_get_phy_mode(struct device_node *np, phy_interface_t *interface) @@ -32,11 +31,6 @@ static inline int of_get_ethdev_address(struct device_no= de *np, struct net_devic { return -ENODEV; } - -static inline struct net_device *of_find_net_device_by_node(struct device_= node *np) -{ - return NULL; -} #endif =20 #endif /* __LINUX_OF_NET_H */ diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index d49fc974e630..837f67f1f3a4 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -1934,11 +1935,10 @@ static struct class net_class __ro_after_init =3D { .get_ownership =3D net_get_ownership, }; =20 -#ifdef CONFIG_OF -static int of_dev_node_match(struct device *dev, const void *data) +static int fwnode_dev_node_match(struct device *dev, const void *data) { for (; dev; dev =3D dev->parent) { - if (dev->of_node =3D=3D data) + if (dev->fwnode =3D=3D data) return 1; } =20 @@ -1946,26 +1946,24 @@ static int of_dev_node_match(struct device *dev, co= nst void *data) } =20 /* - * of_find_net_device_by_node - lookup the net device for the device node - * @np: OF device node + * fwnode_find_net_device_by_node - lookup the net device for the device n= ode + * @fwnode: firmware node * - * Looks up the net_device structure corresponding with the device node. + * Looks up the net_device structure corresponding with the fwnode. * If successful, returns a pointer to the net_device with the embedded * struct device refcount incremented by one, or NULL on failure. The * refcount must be dropped when done with the net_device. */ -struct net_device *of_find_net_device_by_node(struct device_node *np) +struct net_device *fwnode_find_net_device_by_node(struct fwnode_handle *fw= node) { struct device *dev; =20 - dev =3D class_find_device(&net_class, NULL, np, of_dev_node_match); + dev =3D class_find_device(&net_class, NULL, fwnode, fwnode_dev_node_match= ); if (!dev) return NULL; =20 return to_net_dev(dev); } -EXPORT_SYMBOL(of_find_net_device_by_node); -#endif =20 /* Delete sysfs entries but hold kobject reference until after all * netdev references are gone. diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 039022bf914b..5e11d66f9057 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -7,6 +7,7 @@ */ =20 #include +#include #include #include #include @@ -1500,7 +1501,7 @@ static int dsa_port_parse_of(struct dsa_port *dp, str= uct fwnode_handle *fwnode) struct net_device *master; const char *user_protocol; =20 - master =3D of_find_net_device_by_node(to_of_node(ethernet)); + master =3D fwnode_find_net_device_by_node(ethernet); fwnode_handle_put(ethernet); if (!master) return -EPROBE_DEFER; --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC190C43334 for ; Mon, 20 Jun 2022 15:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241975AbiFTPNB (ORCPT ); Mon, 20 Jun 2022 11:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243310AbiFTPMO (ORCPT ); Mon, 20 Jun 2022 11:12:14 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E4C5F89 for ; Mon, 20 Jun 2022 08:02:54 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id s10so12206500ljh.12 for ; Mon, 20 Jun 2022 08:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/EdxkH4fP0zqJATydAHLXu3mRsR+HclXmov1NWv6EHk=; b=SRAAsjAAJry/wEZv46Yv2kZoDW6yLFk+/MU0hcz/UFP8Xv4zTtmkJ4vcKqMOe9yXji 3DETO2Omf28vecJPHHw/Fr7623f1Locm4Yw//wT56jHgEG1NcFFnR9D5Ukgdu5hSrcF1 HBGPUoI/6Em9j22nofiO/Go+lz9k+aoHoN5UrWqkq0V79MEgQb56au1V2Si2LLyV8GqP +T65+SizTW9QOpqwb4acq7XAEBBFM3v5lOtfNsKJpZT/2g7lsYpxvPQeA0vB4zEels7B 8QkdtjzAZFlcIHIged0Ox9FX6X3p8cAKagYQwlHChZm9zqAENVkalOXwjY2IsWZxuzUv btWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/EdxkH4fP0zqJATydAHLXu3mRsR+HclXmov1NWv6EHk=; b=wgjrnAsheJjpGBi33365jU6PjAFT3oM12Zm4YARTnawUSlV1cDR5bEt6H6O8tHMiIg 1ZucrC5ZH5Lxc5ux84oPN5i9cGEKaQ19BDeDjvXvTW1DtmQyvbb3jgCPYpcm7/cXIvaI hhip5J03L3nVtfP/efXSps1OccC5FAgZ0HM+2RpsFvn4tLg3JHXlIF3KcNKVBpYl7j1Y yCNPujmZ9vSsGDyxoh6YN115jJU7gqcpvRCacBlZM882LW9J5c1t2ETcuEpjECPt5q2O R3BFLvA1aybhdcjPS1g2w+/LGXJ1d5II3qFs9/r0+5qm0X2tAWxkreFUol6chRWCy7vC hsag== X-Gm-Message-State: AJIora/GWg37epVK7LrL9il+OM7rIBIu8w+zRC3YuKaKlJksXD1d5QWi eiccQuNJpdNlFMKr+3wOwvhTDZRBs3MaOQ== X-Google-Smtp-Source: AGRyM1ucPSh7wwP+2gyt89hjNQtLW/miFV9yXLuoSMYVAKWa4WBZ9gQ6SIX8q98ZpaQMBfD8re+kqg== X-Received: by 2002:a2e:a268:0:b0:255:9eaf:3422 with SMTP id k8-20020a2ea268000000b002559eaf3422mr11448243ljm.461.1655737371334; Mon, 20 Jun 2022 08:02:51 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:50 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 06/12] net: mdio: introduce fwnode_mdiobus_register_device() Date: Mon, 20 Jun 2022 17:02:19 +0200 Message-Id: <20220620150225.1307946-7-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As a preparation patch to extend MDIO capabilities in the ACPI world, introduce fwnode_mdiobus_register_device() to register non-PHY devices on the mdiobus. While at it, also use the newly introduced fwnode operation in of_mdiobus_phy_device_register(). Signed-off-by: Marcin Wojtas --- include/linux/fwnode_mdio.h | 3 ++ drivers/net/mdio/fwnode_mdio.c | 29 ++++++++++++++++++++ drivers/net/mdio/of_mdio.c | 26 +----------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h index 98755b8c6c8a..39d74c5d1bb0 100644 --- a/include/linux/fwnode_mdio.h +++ b/include/linux/fwnode_mdio.h @@ -16,6 +16,9 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *md= io, int fwnode_mdiobus_register_phy(struct mii_bus *bus, struct fwnode_handle *child, u32 addr); =20 +int fwnode_mdiobus_register_device(struct mii_bus *mdio, + struct fwnode_handle *child, u32 addr); + int fwnode_phy_register_fixed_link(struct fwnode_handle *fwnode); =20 void fwnode_phy_deregister_fixed_link(struct fwnode_handle *fwnode); diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index b1c20c48b6cb..97abfaf88030 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -149,6 +149,35 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, } EXPORT_SYMBOL(fwnode_mdiobus_register_phy); =20 +int fwnode_mdiobus_register_device(struct mii_bus *mdio, + struct fwnode_handle *child, u32 addr) +{ + struct mdio_device *mdiodev; + int rc; + + mdiodev =3D mdio_device_create(mdio, addr); + if (IS_ERR(mdiodev)) + return PTR_ERR(mdiodev); + + /* Associate the fwnode with the device structure so it + * can be looked up later. + */ + device_set_node(&mdiodev->dev, child); + + /* All data is now stored in the mdiodev struct; register it. */ + rc =3D mdio_device_register(mdiodev); + if (rc) { + mdio_device_free(mdiodev); + fwnode_handle_put(child); + return rc; + } + + dev_dbg(&mdio->dev, "registered mdio device %p fwnode at address %i\n", + child, addr); + return 0; +} +EXPORT_SYMBOL(fwnode_mdiobus_register_device); + /* * fwnode_phy_is_fixed_link() and fwnode_phy_register_fixed_link() must * support two bindings: diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index 409da6e92f7d..522dbee419fe 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -51,31 +51,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, static int of_mdiobus_register_device(struct mii_bus *mdio, struct device_node *child, u32 addr) { - struct fwnode_handle *fwnode =3D of_fwnode_handle(child); - struct mdio_device *mdiodev; - int rc; - - mdiodev =3D mdio_device_create(mdio, addr); - if (IS_ERR(mdiodev)) - return PTR_ERR(mdiodev); - - /* Associate the OF node with the device structure so it - * can be looked up later. - */ - fwnode_handle_get(fwnode); - device_set_node(&mdiodev->dev, fwnode); - - /* All data is now stored in the mdiodev struct; register it. */ - rc =3D mdio_device_register(mdiodev); - if (rc) { - mdio_device_free(mdiodev); - of_node_put(child); - return rc; - } - - dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", - child, addr); - return 0; + return fwnode_mdiobus_register_device(mdio, of_fwnode_handle(child), addr= ); } =20 /* The following is a list of PHY compatible strings which appear in --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F1C2CCA479 for ; Mon, 20 Jun 2022 15:12:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243647AbiFTPMu (ORCPT ); Mon, 20 Jun 2022 11:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243288AbiFTPMO (ORCPT ); Mon, 20 Jun 2022 11:12:14 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2022617F for ; Mon, 20 Jun 2022 08:02:54 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id w20so17682277lfa.11 for ; Mon, 20 Jun 2022 08:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7RYmX6hwDcKGiQHQEayVLNO5diQlCW4Y4Deqwz4h8T8=; b=J7f4T8YnKHMS90UGD6gxXSuB7x2Hg6/2jTVv/VoOmma8k9lrBsmRLZDs8GHCK0fOcV BfFrqQlgSLL+Hur5zSzTBp6invCr+HxiGZaurvWwoK5F2vdD/LaRMryeUG1J0nWVAwaI ayTBVBxeU+mi5xMt73C8Z5w5Ou16ed5i/fx0KKQA1bPV5gsiMrQvsH3/D0a7QF0jJqrn WwyN8zKdC6FGDZN/rEUxI4jp+/KsTZCOOS9ajE5p1A/E47CRd35v+Fb8m/GgZGPeiT3h ZrQEcRXcFHkV+2S+f860tEg+zRuu/zxdVoGHNsbBMRHwmdwXW7UU9W+437UcF/GKLUn5 v8TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7RYmX6hwDcKGiQHQEayVLNO5diQlCW4Y4Deqwz4h8T8=; b=TuHU4LO5Ae/MxF1YZdzwv+cQg2IXI89f9aeY8uL/Sq4cLfEuOme+TLHKYqPXtrHA+E y/w5EcSH2dBiDYlpJsXHOzVNnHqdAJhKT8Bjbu/U2l5+TZbhIyUhtBHdaLY0y/JmKjuq 8kZ1z331q53paupw3XgiCvQ6K2m3VpzWfAydREBC49QRGVvrYQEmXb+SdZnoQXgSDupK f0pAs4eQxCtcYsBr59gBuFZp3O0+9QlHtZKF52xMb9DdKnAd7SELfiebA4tg6zrElXMi +wHa7xAJw7wFl30Hy/CqhYhsManRnA796JB+KFwAnUfwFwoQSRT/JAnu8JH1f/JBZdcp PV7g== X-Gm-Message-State: AJIora/wUYlzttkWr6R0BfnykCQ/iaE2tVLwPjSf8Xju9vXI6RuQR4Lh SsziVso0jTMXJhRs9Emr6eoLir9i/OCKWg== X-Google-Smtp-Source: AGRyM1sWO6KOjp1s3p12U7eWklYIpDeYsTWAh5PfOMGJbed42f5P8rcRGwK+1A3uhwLmCbi9uFJtjg== X-Received: by 2002:a05:6512:1684:b0:47f:5f27:b006 with SMTP id bu4-20020a056512168400b0047f5f27b006mr7010050lfb.225.1655737372485; Mon, 20 Jun 2022 08:02:52 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:52 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 07/12] net: mdio: allow registering non-PHY devices in ACPI world Date: Mon, 20 Jun 2022 17:02:20 +0200 Message-Id: <20220620150225.1307946-8-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch utilizes the newly added fwnode_mdiobus_register_device function and enables registration of non-PHY MDIO devices. For that purpose a helper routine is added, allowing to determine, whether the device associated to ACPI node is a PHY. In addition to that update, allow matching child devices' drivers based on their ACPI ID. Signed-off-by: Marcin Wojtas --- drivers/net/mdio/acpi_mdio.c | 40 +++++++++++++++++++- drivers/net/phy/mdio_bus.c | 4 ++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c index d77c987fda9c..b5d7404afc5e 100644 --- a/drivers/net/mdio/acpi_mdio.c +++ b/drivers/net/mdio/acpi_mdio.c @@ -17,6 +17,41 @@ MODULE_AUTHOR("Calvin Johnson "); MODULE_LICENSE("GPL"); =20 +/** + * acpi_mdiobus_child_is_phy - check if device associated with fwnode is a= PHY. + * @fwnode: pointer to MDIO bus child fwnode and is expected to represent = ACPI + * device object. + * + * The function returns true if the child node is for a PHY. + * It must comprise either: + * o Compatible string of "ethernet-phy-idX.X" + * o Compatible string of "ethernet-phy-ieee802.3-c45" + * o Compatible string of "ethernet-phy-ieee802.3-c22" + * o No _HID or _CID fields. + */ +static bool acpi_mdiobus_child_is_phy(struct fwnode_handle *child) +{ + struct acpi_device *adev =3D to_acpi_device_node(child); + u32 phy_id; + + if (fwnode_get_phy_id(child, &phy_id) !=3D -EINVAL) + return true; + + if (fwnode_property_match_string(child, "compatible", + "ethernet-phy-ieee802.3-c45") =3D=3D 0) + return true; + + if (fwnode_property_match_string(child, "compatible", + "ethernet-phy-ieee802.3-c22") =3D=3D 0) + return true; + + /* Default to PHY if no _HID or _CID found in the fwnode. */ + if (list_empty(&adev->pnp.ids)) + return true; + + return false; +} + /** * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI = ASL. * @mdio: pointer to mii_bus structure @@ -47,7 +82,10 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct f= wnode_handle *fwnode) if (ret || addr >=3D PHY_MAX_ADDR) continue; =20 - ret =3D fwnode_mdiobus_register_phy(mdio, child, addr); + if (acpi_mdiobus_child_is_phy(child)) + ret =3D fwnode_mdiobus_register_phy(mdio, child, addr); + else + ret =3D fwnode_mdiobus_register_device(mdio, child, addr); if (ret =3D=3D -ENODEV) dev_err(&mdio->dev, "MDIO device at address %d is missing.\n", diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 8a2dbe849866..b3c2f966be4b 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -8,6 +8,7 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include #include #include #include @@ -989,6 +990,9 @@ static int mdio_bus_match(struct device *dev, struct de= vice_driver *drv) if (of_driver_match_device(dev, drv)) return 1; =20 + if (acpi_driver_match_device(dev, drv)) + return 1; + if (mdio->bus_match) return mdio->bus_match(dev, drv); =20 --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B2CFC43334 for ; Mon, 20 Jun 2022 15:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243741AbiFTPNG (ORCPT ); Mon, 20 Jun 2022 11:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242154AbiFTPMP (ORCPT ); Mon, 20 Jun 2022 11:12:15 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FEB164CE for ; Mon, 20 Jun 2022 08:02:55 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id k20so5834326ljg.2 for ; Mon, 20 Jun 2022 08:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RDW0iKUe4rl0AxxyRpSUfzqnbvrj0hO4TPTr9mwh6kI=; b=FEg3yuw9zuj0apotExwlLW1q5suVP6iGt/1G6WRjuwHmcCvuxI1Tsf0SZ2F8Cn+q2t mx4RPLR22FvnM7Q+zZurckshwY6mIap7dqn2mGeElD5DaJdpjkZT/WFzsUjq7GGitpBT YB3asvifr/wTkfhr0F6EFymDcrS9lx+famqRA53ZoPQJDNrECye82zNCvZ/ifwz2S+uV 1Z8u/fhSkEBWPMruUTO5XOWnFFrcYbR6EaVbuu8zAPTJdP/2CxT8AiliZoFLiBoCuWDG 0It84USVCUeZopmhbdIUswnZvu25VRiydCuJ2tNC1BfVu1ScHheK7q3/OsO65eqXy8h2 MEpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RDW0iKUe4rl0AxxyRpSUfzqnbvrj0hO4TPTr9mwh6kI=; b=JLnxuH19yfI7o+tDy/fHxAFp1yOOpZGGv0IvAUK1aabHJnjm8YW6squd0r9NZkXSz0 KWxFbQoEG+uVxh9N13DEvcyLfhKAtj3zHf9PYDrigIjvBB/6ivucPir9pIv57BpIi/pD 0WKQcYGwXUnOR2WjAMVkLl6R/nDLx8V5lWoRns1i+oD+v617UH6GVC5McTry6j1XmMdn 3l1iKwJRNh0nvZmK4wcrC0hKxL4Kj0oOUG2qmkHYTQ28hV+ChcPfVMhSMsI/hHBJcSh4 lykD8EuTLsSbhGVnpwR1ps3BE9GxFPQkvZt5812UNY2lp2v0m0UDChMDFy67m921zNHK CP7g== X-Gm-Message-State: AJIora+YlQAD+oO7AsZXfSWu1zYVq/wQq1+t5giJWIO+ewv87oOR/BE2 LFsGAwEJonNXXDRtG3pUQ4uggaegndMjFA== X-Google-Smtp-Source: AGRyM1tbm7QFG8lIJaukpRbduMFt0tpvrn9FXfCi0u/0W1N99p3BoT6LfGzkkKNb1ZzphlH4rxS4ug== X-Received: by 2002:a2e:b0ce:0:b0:25a:6ad3:1ee7 with SMTP id g14-20020a2eb0ce000000b0025a6ad31ee7mr3842974ljl.1.1655737373671; Mon, 20 Jun 2022 08:02:53 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:53 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 08/12] ACPI: scan: prevent double enumeration of MDIO bus children Date: Mon, 20 Jun 2022 17:02:21 +0200 Message-Id: <20220620150225.1307946-9-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The MDIO bus is responsible for probing and registering its respective children, such as PHYs or other kind of devices. It is required that ACPI scan code should not enumerate such devices, leaving this task for the generic MDIO bus routines, which are initiated by the controller driver. This patch prevents unwanted enumeration of the devices by setting 'enumeration_by_parent' flag, depending on whether their parent device is a member of a known list of MDIO controllers. For now, the Marvell MDIO controllers' IDs are added. Signed-off-by: Marcin Wojtas --- drivers/acpi/scan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 762b61f67e6c..d703c35dc218 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1716,6 +1716,18 @@ static bool acpi_is_indirect_io_slave(struct acpi_de= vice *device) return parent && !acpi_match_device_ids(parent, indirect_io_hosts); } =20 +static bool acpi_is_mdio_child(struct acpi_device *device) +{ + struct acpi_device *parent =3D device->parent; + static const struct acpi_device_id mdio_controllers[] =3D { + {"MRVL0100", 0}, + {"MRVL0101", 0}, + {} + }; + + return parent && !acpi_match_device_ids(parent, mdio_controllers); +} + static bool acpi_device_enumeration_by_parent(struct acpi_device *device) { struct list_head resource_list; @@ -1756,6 +1768,9 @@ static bool acpi_device_enumeration_by_parent(struct = acpi_device *device) if (acpi_is_indirect_io_slave(device)) return true; =20 + if (acpi_is_mdio_child(device)) + return true; + /* Macs use device properties in lieu of _CRS resources */ if (x86_apple_machine && (fwnode_property_present(&device->fwnode, "spiSclkPeriod") || --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB4C5C43334 for ; Mon, 20 Jun 2022 15:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243824AbiFTPNU (ORCPT ); Mon, 20 Jun 2022 11:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243362AbiFTPMP (ORCPT ); Mon, 20 Jun 2022 11:12:15 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3CD12630 for ; Mon, 20 Jun 2022 08:02:56 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id i18so4061261lfu.8 for ; Mon, 20 Jun 2022 08:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lWuaSG6HSKcvFGFyg+g82A5w5pDsH3NkEfBqjUDTkfk=; b=U6ZqexpWMwtNfy4fgrFqttD04y6IMahzDMMf5MP3BVVrG8OG0j4iKbznvGKRVKIH3x EbRPXFceUxsEy2hVgGms7e9b4L9Hvh53LP5Ga76s+m097zlmDDUUg+lLVsqajUGMSDlq j4orC0Fc6GDqnK49q0OJTmQfKv4I53zdBQ11H9R/d0lZgqJ13ku6CQtkA/AWQaRq7aih VmynjT9xCgHmfPyGaXlgPPCFcghOwgX1qxNvJTHwpNqc4F+wW5MYZY969bwMwoER4bco /o/bW3mJpIPeXmDoMvjJyweDcd6Cmfk7liDWCYmF1jO+pGGbH8dD+y2wEAVPaxF1UvHF 7wpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lWuaSG6HSKcvFGFyg+g82A5w5pDsH3NkEfBqjUDTkfk=; b=L8hejgTWybeAqOiC6QxWtpqmd+i4f/PntI0KTeSEYKsIgixRop9wSDCYUpHYUuuwHj Xbz7qq24SwEwxagzBswHXSqoL6hvvwRADOT+Gcy5ZqN3kPb/f/SbxUDQsLgAROI7EIrj DRTHz6gr5Q/HHvHaWl55YXoml3/kR37gCryZmv3DCkp2vwa42z0RA1ZBJiuLX4b32TRE 1aOtPih8bUTq7lZiNexiwJzsqxpZ7/d7bcpJqz29x+H915JNzQbw5enibezggak8kdc4 HG8p3cv1m4MajRd9msboP3k1MKth2HRq+kIpxTObFphKCgVO5PBix41PIY6S47VoN8VT JD1w== X-Gm-Message-State: AJIora+63vMCG5G70PBjm12Nj+gc7/EHemu1OfuVTu34zzD8iF9jTVsk CHMewXoVgjAIx16CXKL3u8XbilG9W6NYsA== X-Google-Smtp-Source: AGRyM1uTGnXuPfk4GfByLJogKz1YnhnU1O9BZc/Qm5s2OM28A/6t4nD5tutEGUS8JHtjHKclXDPDwg== X-Received: by 2002:a05:6512:3fa0:b0:47f:5758:1951 with SMTP id x32-20020a0565123fa000b0047f57581951mr8779287lfa.609.1655737374810; Mon, 20 Jun 2022 08:02:54 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:54 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 09/12] Documentation: ACPI: DSD: introduce DSA description Date: Mon, 20 Jun 2022 17:02:22 +0200 Message-Id: <20220620150225.1307946-10-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Describe the Distributed Switch Architecture (DSA) - compliant MDIO devices. In ACPI world they are represented as children of the MDIO busses, which are responsible for their enumeration based on the standard _ADR fields and description in _DSD objects under device properties UUID [1]. [1] http://www.uefi.org/sites/default/files/resources/_DSD-device-propertie= s-UUID.pdf Signed-off-by: Marcin Wojtas --- Documentation/firmware-guide/acpi/dsd/dsa.rst | 359 ++++++++++++++++++++ Documentation/firmware-guide/acpi/index.rst | 1 + 2 files changed, 360 insertions(+) create mode 100644 Documentation/firmware-guide/acpi/dsd/dsa.rst diff --git a/Documentation/firmware-guide/acpi/dsd/dsa.rst b/Documentation/= firmware-guide/acpi/dsd/dsa.rst new file mode 100644 index 000000000000..dba76d89f4e6 --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/dsa.rst @@ -0,0 +1,359 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +DSA in ACPI +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The **Distributed Switch Architecture (DSA)** devices on an MDIO bus [dsa] +are enumerated using fwnode_mdiobus_register_device() and later probed +by a dedicated driver based on the ACPI ID match result. + +In DSDT/SSDT the scope of switch device is extended by the front-panel +and one or more so called 'CPU' switch ports. Additionally +subsequent MDIO busses with attached PHYs can be described. + +This document presents the switch description with the required subnodes +and _DSD properties. + +These properties are defined in accordance with the "Device +Properties UUID For _DSD" [dsd-guide] document and the +daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device +Data Descriptors containing them. + +Switch device +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The switch device is represented as a child node of the MDIO bus. +It must comprise the _HID (and optionally _CID) field, so to allow matching +with appropriate driver via ACPI ID. The other obligatory field is +_ADR with the device address on the MDIO bus [adr]. Below example +shows 'SWI0' switch device at address 0x4 on the 'SMI0' bus. + +.. code-block:: none + + Scope (\_SB.SMI0) + { + Name (_HID, "MRVL0100") + Name (_UID, 0x00) + Method (_STA) + { + Return (0xF) + } + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, + 0xf212a200, + 0x00000010, + ) + }) + Device (SWI0) + { + Name (_HID, "MRVL0120") + Name (_UID, 0x00) + Name (_ADR, 0x4) + <...> + } + } + +Switch MDIO bus +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +A switch internal MDIO bus, please refer to 'MDIO bus and PHYs in ACPI' [p= hy] +document for more details. Its name must be set to **MDIO** for proper +enumeration by net/dsa API. + +Switch MDIO bus declaration example: +------------------------------------ + +.. code-block:: none + + Scope (\_SB.SMI0.SWI0) + { + Name (_HID, "MRVL0120") + Name (_UID, 0x00) + Name (_ADR, 0x4) + Device (MDIO) { + Name (_ADR, 0x0) + Device (S0P0) + { + Name (_ADR, 0x11) + } + Device (S0P1) + { + Name (_ADR, 0x12) + } + Device (S0P2) + { + Name (_ADR, 0x13) + } + Device (S0P3) + { + Name (_ADR, 0x14) + } + } + <...> + } + +Switch ports +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ports must be grouped under **PRTS** switch child device. They +should comprise a _ADR field with a port enumerator [adr] and +other properties in a standard _DSD object [dsa-properties]. + +label +----- +A property with a string value describing port's name in the OS. In case t= he +port is connected to the MAC ('CPU' port), its value should be set to "cpu= ". + +phy-handle +---------- +For each MAC node, a device property "phy-handle" is used to reference +the PHY that is registered on an MDIO bus. This is mandatory for +network interfaces that have PHYs connected to MAC via MDIO bus. +See [phy] for more details. + +ethernet +-------- +A property valid for the so called 'CPU' port and should comprise a refere= nce +to the MAC object declared in the DSDT/SSDT. + +fixed-link +---------- +The 'fixed-link' is described by a data-only subnode of the +port, which is linked in the _DSD package via +hierarchical data extension (UUID dbb8e3e6-5886-4ba6-8795-1319f52a966b +in accordance with [dsd-guide] "_DSD Implementation Guide" document). +The subnode should comprise a required property ("speed") and +possibly the optional ones - complete list of parameters and +their values are specified in [ethernet-controller]. +See [phy] for more details. + +Switch ports' description example: +---------------------------------- + +.. code-block:: none + + Scope (\_SB.SMI0.SWI0) + { + Name (_HID, "MRVL0120") + Name (_UID, 0x00) + Name (_ADR, 0x4) + Device (PRTS) { + Name (_ADR, 0x0) + Device (PRT1) + { + Name (_ADR, 0x1) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan2"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S0P0}, + } + }) + } + Device (PRT2) + { + Name (_ADR, 0x2) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan1"}, + }, + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), + Package () { + Package () {"fixed-link", "LNK0"} + } + }) + Name (LNK0, Package(){ // Data-only subnode of port + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"speed", 1000}, + Package () {"full-duplex", 1} + } + }) + } + Device (PRT3) + { + Name (_ADR, 0x3) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan4"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S0P2}, + } + }) + } + Device (PRT4) + { + Name (_ADR, 0x4) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan3"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S0P3}, + } + }) + } + Device (PRT5) + { + Name (_ADR, 0x5) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "cpu"}, + Package () { "ethernet", \_SB.PP20.ETH2}, + } + }) + } + } + <...> + } + +Full DSA description example +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +Below example comprises MDIO bus ('SMI0') with a PHY at address 0x0 ('PHY0= ') +and a switch ('SWI0') at 0x4. The so called 'CPU' port ('PRT5') is connect= ed to +the SoC's MAC (\_SB.PP20.ETH2). 'PRT2' port is configured as 1G fixed-link. + +.. code-block:: none + + Scope (\_SB.SMI0) + { + Name (_HID, "MRVL0100") + Name (_UID, 0x00) + Method (_STA) + { + Return (0xF) + } + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, + 0xf212a200, + 0x00000010, + ) + }) + Device (PHY0) + { + Name (_ADR, 0x0) + } + Device (SWI0) + { + Name (_HID, "MRVL0120") + Name (_UID, 0x00) + Name (_ADR, 0x4) + Device (PRTS) { + Name (_ADR, 0x0) + Device (PRT1) + { + Name (_ADR, 0x1) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan2"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S= 0P0}, + } + }) + } + Device (PRT2) + { + Name (_ADR, 0x2) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan1"}, + }, + ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), + Package () { + Package () {"fixed-link", "LNK0"} + } + }) + Name (LNK0, Package(){ // Data-only subnode of port + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"speed", 1000}, + Package () {"full-duplex", 1} + } + }) + } + Device (PRT3) + { + Name (_ADR, 0x3) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan4"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S= 0P2}, + } + }) + } + Device (PRT4) + { + Name (_ADR, 0x4) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "lan3"}, + Package () { "phy-handle", \_SB.SMI0.SWI0.MDIO.S= 0P3}, + } + }) + } + Device (PRT5) + { + Name (_ADR, 0x5) + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "label", "cpu"}, + Package () { "ethernet", \_SB.PP20.ETH2}, + } + }) + } + } + Device (MDIO) { + Name (_ADR, 0x0) + Device (S0P0) + { + Name (_ADR, 0x11) + } + Device (S0P2) + { + Name (_ADR, 0x13) + } + Device (S0P3) + { + Name (_ADR, 0x14) + } + } + } + } + +TODO +=3D=3D=3D=3D + +* Add support for cascade switch connections via port's 'link' property [d= sa-properties]. + +References +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +[adr] ACPI Specifications, Version 6.4 - Paragraph 6.1.1 _ADR Address + https://uefi.org/specs/ACPI/6.4/06_Device_Configuration/Device_Configu= ration.html#adr-address + +[dsa] + Documentation/networking/dsa/dsa.rst + +[dsa-properties] + Documentation/devicetree/bindings/net/dsa/dsa-port.yaml + +[dsd-guide] DSD Guide. + https://github.com/UEFI/DSD-Guide/blob/main/dsd-guide.adoc, referenced + 2022-06-20. + +[dsd-properties-rules] + Documentation/firmware-guide/acpi/DSD-properties-rules.rst + +[ethernet-controller] + Documentation/devicetree/bindings/net/ethernet-controller.yaml + +[phy] Documentation/networking/phy.rst diff --git a/Documentation/firmware-guide/acpi/index.rst b/Documentation/fi= rmware-guide/acpi/index.rst index b6a42f4ffe03..a6ed5ba90cdd 100644 --- a/Documentation/firmware-guide/acpi/index.rst +++ b/Documentation/firmware-guide/acpi/index.rst @@ -10,6 +10,7 @@ ACPI Support namespace dsd/graph dsd/data-node-references + dsd/dsa dsd/leds dsd/phy enumeration --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A7B3C433EF for ; Mon, 20 Jun 2022 15:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243428AbiFTPO5 (ORCPT ); Mon, 20 Jun 2022 11:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243368AbiFTPMP (ORCPT ); Mon, 20 Jun 2022 11:12:15 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC171F637 for ; Mon, 20 Jun 2022 08:02:57 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f39so2084503lfv.3 for ; Mon, 20 Jun 2022 08:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WfituUDSg5fEW4dKt2h3fMS4b0IrVjkU8185C8pJjBY=; b=kFdZRoBhFIxJZLPTayXCJlh5xBCUkR1K1zZ2YflpY7c0rNVWSY5swaSK9jMmPGXzxQ 1GqoSBU6NUtXhV/7NpOPU415njrI7EcPXH9XBXd4WeC09TyT7aDShPFqectxf2XnTjKY X3C+gzqVgKqrfcGzRjiq9IsokgayDx9Kp7GcauUWykhbBQlMsWd8EOV4IaSf6cl1JH9m 4LnTKNKhmnC3xGA7mV5LH3e8TIDxFESOVT9cCG43VVnWG699CI5DKudZneoExnyrS4LM ciWgtqOkaSmQjqfXB8SBoVjO9AlBPTrxQOKUvOTYOrQUx0YFbbDI3XM47H1u7DvEwL6s PPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WfituUDSg5fEW4dKt2h3fMS4b0IrVjkU8185C8pJjBY=; b=kuvEqdyp5K3Z/fgy6tYNI/u4yWhpkRoxVIgDOU81zRJHoiSbve2Kzkz1uo0HB38CoP V/F+Wx7zMw/fcM3gSfC7/dpkF28VAmFcB6SiFIb9g/1Ya3SbxunxkJWv18Sz0CvQ6B5T PEn46zSZFgCnCyUfGHx+4s/u1nvW/397695pTx54mNQdsgHdeEWsI07kA+xIUPJiEqmz 7W7Dq92rWJPUE5TlFoAdSQAHxbPG3+WSar/R7YPpobTVzWNgGcev7TbWnSLAKqOTnGvp 2xX73ntkUUnOYTp4o6pqvLDGNybYCK2m0suPM13gRJYOGq0ks+WViMw8V9QxrhOhnBv0 Zi8Q== X-Gm-Message-State: AJIora9sNcBX+68uQ3y+x74/oVN29muqBUX1yIRM2pySX9UQ7kPoXmxK K2IpxubaK4Ebp5gwrSVLyMooYzKav4qzeA== X-Google-Smtp-Source: AGRyM1vqri5GOOgVM3EWWhhIHFGXwMbDMwQp2NcgRArqY1SeTMY9aLG3jE7fpVm9+Dh+PwPmgb5/Dw== X-Received: by 2002:a05:6512:214d:b0:47f:5a25:ac11 with SMTP id s13-20020a056512214d00b0047f5a25ac11mr7963474lfr.627.1655737376113; Mon, 20 Jun 2022 08:02:56 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:55 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 10/12] net: dsa: add ACPI support Date: Mon, 20 Jun 2022 17:02:23 +0200 Message-Id: <20220620150225.1307946-11-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Although the recent switch to device_/fwnode_ API covers the most of modifications required for supporting ACPI, minor additional changes should be applied: * Use different subnode names with ACPI for 'ports' and 'mdio': * Naming of the nodes in ACPI must conform the namespace constraints, with regards to the characters' type and ACPI_NAMESEG_SIZE [1]. Because of that, the 'ports' subnode name used in device tree case, is not appropriate in ACPI world. This patch updates the subnode name depending on the hardware description type in runtime. * Obtain ports indexes from _ADR fields * Same as in the MDIO PHY case, use this standard field instead of parsing 'reg' property from _DSD object. * For now cascade topology remains unsupported in ACPI world, so disable ports connected to other switch devices. [1] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI= _Software_Programming_Model.html#acpi-namespace Signed-off-by: Marcin Wojtas --- net/dsa/dsa2.c | 35 +++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 5e11d66f9057..53837dad1cca 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -6,6 +6,8 @@ * Copyright (c) 2016 Andrew Lunn */ =20 +#include +#include #include #include #include @@ -854,6 +856,7 @@ static int dsa_switch_setup_tag_protocol(struct dsa_swi= tch *ds) static int dsa_switch_setup(struct dsa_switch *ds) { struct dsa_devlink_priv *dl_priv; + char mdio_node_name[] =3D "mdio"; struct fwnode_handle *fwnode; struct dsa_port *dp; int err; @@ -910,9 +913,16 @@ static int dsa_switch_setup(struct dsa_switch *ds) =20 dsa_slave_mii_bus_init(ds); =20 - fwnode =3D fwnode_get_named_child_node(ds->dev->fwnode, "mdio"); + /* Update subnode name if operating in the ACPI world. */ + if (is_acpi_node(fwnode)) + strncpy(mdio_node_name, "MDIO", ACPI_NAMESEG_SIZE); =20 - err =3D of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode)); + fwnode =3D fwnode_get_named_child_node(ds->dev->fwnode, mdio_node_name); + + if (is_acpi_node(fwnode)) + err =3D acpi_mdiobus_register(ds->slave_mii_bus, fwnode); + else + err =3D of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode)); fwnode_handle_put(fwnode); if (err < 0) goto free_slave_mii_bus; @@ -1374,6 +1384,15 @@ static int dsa_port_parse_user(struct dsa_port *dp, = const char *name) =20 static int dsa_port_parse_dsa(struct dsa_port *dp) { + /* Cascade switch connection is not supported in ACPI world. */ + if (is_acpi_node(dp->fwnode)) { + dev_warn(dp->ds->dev, + "DSA type is not supported with ACPI, disable port #%d\n", + dp->index); + dp->type =3D DSA_PORT_TYPE_UNUSED; + return 0; + } + dp->type =3D DSA_PORT_TYPE_DSA; =20 return 0; @@ -1524,11 +1543,16 @@ static int dsa_switch_parse_ports_of(struct dsa_swi= tch *ds, struct fwnode_handle *fwnode) { struct fwnode_handle *ports, *port; + char ports_node_name[] =3D "ports"; struct dsa_port *dp; int err =3D 0; u32 reg; =20 - ports =3D fwnode_get_named_child_node(fwnode, "ports"); + /* Update subnode name if operating in the ACPI world. */ + if (is_acpi_node(fwnode)) + strncpy(ports_node_name, "PRTS", ACPI_NAMESEG_SIZE); + + ports =3D fwnode_get_named_child_node(fwnode, ports_node_name); if (!ports) { /* The second possibility is "ethernet-ports" */ ports =3D fwnode_get_named_child_node(fwnode, "ethernet-ports"); @@ -1539,7 +1563,10 @@ static int dsa_switch_parse_ports_of(struct dsa_swit= ch *ds, } =20 fwnode_for_each_available_child_node(ports, port) { - err =3D fwnode_property_read_u32(port, "reg", ®); + if (is_acpi_node(port)) + err =3D acpi_get_local_address(ACPI_HANDLE_FWNODE(port), ®); + else + err =3D fwnode_property_read_u32(port, "reg", ®); if (err) { fwnode_handle_put(port); goto out_put_node; --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9230C433EF for ; Mon, 20 Jun 2022 15:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243787AbiFTPNQ (ORCPT ); Mon, 20 Jun 2022 11:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243364AbiFTPMP (ORCPT ); Mon, 20 Jun 2022 11:12:15 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9B71EED7 for ; Mon, 20 Jun 2022 08:02:57 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id b23so3654710ljh.7 for ; Mon, 20 Jun 2022 08:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sH5mdU0J82lSBubyPIxIw/XIt0m9sm0DajZ7R0PZmFM=; b=knaJ8eJAzYF2U1LYJ1OxeeM1p3RjFGe574cRemVmlbNHTejes4i6AYL3jRMyvOtZ7v 1fS4SAr4Ktc0OTo4P7z+pflNDq1ID5JQ5zbdvjnjbnqUlHXsw9MlMA5FczYtmZj2sHWQ O7mgMEC7mlsws04CCUl8x2lUlBCwkCGFbZFLp1jUEEl+cL/3LRPWzTOLZM9FWqk7aEMQ zvdRX+UGVNE/Iodgbp8j90mjh8ubaeFxf0o2H6gHJCxY4AmfEr6aMBzLQ5gXb7C6E78K noaqIpK0dNrMiLMvv2XiuoprCbOcqEbg1QjkDRvAjLjty+GuuiAGmy+wj+Yz1aug2bd9 TAxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sH5mdU0J82lSBubyPIxIw/XIt0m9sm0DajZ7R0PZmFM=; b=quhj9D0yelqeqleFXO/6ee4IDPf5CP3rJ38Pj4m5g2FQjrL1L/qfgN7xtsW/kEDsLm ncE/D5YLG1f98j/0fP/0icJp4+WpHXoc8jPlDlKMPmU9F3X9XeZDi9c9IHVhd9Kus691 kNftNQHJ+EN53t6UvFQn1rokxDT9Laa4jjvA8geqLTRVXnkd8drQopbQuF2AoU4gTQS7 E/2bKTP4aTyNCnYy4bv2eLXlfa8wpOYZYWb2iGnKPPVh3U2G50eegtcP9JuLEE0D82ax S9ex3b9kM9CtYH7UwBqigOuguil4/XDoijs0yAh1pJOh0MERmsXXOU6CQc7oRup5B0/p WnVw== X-Gm-Message-State: AJIora9nyslH2s6fhmzwYAz25olJe8xZjcCkjP59hOxlxz/aP3dk7dD/ J/yiHRwmnf8jCTrwEjMtvwja2zUnEliWTQ== X-Google-Smtp-Source: AGRyM1uiyaR+g5NXDERpjkMHAfHMuJYfDGHDxYxby94uVCwaSCkyGa0OMkqKgsg6hF0M/5asgijo4A== X-Received: by 2002:a05:651c:4d1:b0:255:c269:da49 with SMTP id e17-20020a05651c04d100b00255c269da49mr12310504lji.54.1655737377262; Mon, 20 Jun 2022 08:02:57 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:56 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 11/12] net: dsa: mv88e6xxx: switch to device_/fwnode_ APIs Date: Mon, 20 Jun 2022 17:02:24 +0200 Message-Id: <20220620150225.1307946-12-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In order to support both ACPI and DT, modify the generic DSA code to use device_/fwnode_ equivalent routines. No functional change is introduced by this patch. Signed-off-by: Marcin Wojtas --- drivers/net/dsa/mv88e6xxx/chip.c | 53 ++++++++++---------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/c= hip.c index 0b49d243e00b..556defa4379d 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3278,7 +3278,7 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e= 6xxx_chip *chip, int port) =20 static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) { - struct device_node *phy_handle =3D NULL; + struct fwnode_handle *phy_handle =3D NULL; struct dsa_switch *ds =3D chip->ds; struct dsa_port *dp; int tx_amp; @@ -3475,15 +3475,15 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_ch= ip *chip, int port) if (chip->info->ops->serdes_set_tx_amplitude) { dp =3D dsa_to_port(ds, port); if (dp) - phy_handle =3D of_parse_phandle(dp->dn, "phy-handle", 0); + phy_handle =3D fwnode_find_reference(dp->fwnode, "phy-handle", 0); =20 - if (phy_handle && !of_property_read_u32(phy_handle, - "tx-p2p-microvolt", - &tx_amp)) + if (!IS_ERR(phy_handle) && !fwnode_property_read_u32(phy_handle, + "tx-p2p-microvolt", + &tx_amp)) err =3D chip->info->ops->serdes_set_tx_amplitude(chip, port, tx_amp); - if (phy_handle) { - of_node_put(phy_handle); + if (!IS_ERR(phy_handle)) { + fwnode_handle_put(phy_handle); if (err) return err; } @@ -3867,10 +3867,11 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus= , int phy, int reg, u16 val) } =20 static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, - struct device_node *np, + struct fwnode_handle *fwnode, bool external) { static int index; + struct device_node *np =3D to_of_node(fwnode); struct mv88e6xxx_mdio_bus *mdio_bus; struct mii_bus *bus; int err; @@ -3949,18 +3950,18 @@ static void mv88e6xxx_mdios_unregister(struct mv88e= 6xxx_chip *chip) } =20 static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, - struct device_node *np) + struct fwnode_handle *fwnode) { - struct device_node *child; + struct fwnode_handle *child; int err; =20 /* Always register one mdio bus for the internal/default mdio * bus. This maybe represented in the device tree, but is * optional. */ - child =3D of_get_child_by_name(np, "mdio"); + child =3D fwnode_get_named_child_node(fwnode, "mdio"); err =3D mv88e6xxx_mdio_register(chip, child, false); - of_node_put(child); + fwnode_handle_put(child); if (err) return err; =20 @@ -3968,13 +3969,13 @@ static int mv88e6xxx_mdios_register(struct mv88e6xx= x_chip *chip, * which say they are compatible with the external mdio * bus. */ - for_each_available_child_of_node(np, child) { - if (of_device_is_compatible( - child, "marvell,mv88e6xxx-mdio-external")) { + fwnode_for_each_available_child_node(fwnode, child) { + if (fwnode_property_match_string(child, "compatible", + "marvell,mv88e6xxx-mdio-external") =3D=3D 0) { err =3D mv88e6xxx_mdio_register(chip, child, true); if (err) { mv88e6xxx_mdios_unregister(chip); - of_node_put(child); + fwnode_handle_put(child); return err; } } @@ -6962,16 +6963,16 @@ static int mv88e6xxx_probe(struct mdio_device *mdio= dev) struct dsa_mv88e6xxx_pdata *pdata =3D mdiodev->dev.platform_data; const struct mv88e6xxx_info *compat_info =3D NULL; struct device *dev =3D &mdiodev->dev; - struct device_node *np =3D dev->of_node; + struct fwnode_handle *fwnode =3D dev->fwnode; struct mv88e6xxx_chip *chip; int port; int err; =20 - if (!np && !pdata) + if (!fwnode && !pdata) return -EINVAL; =20 - if (np) - compat_info =3D of_device_get_match_data(dev); + if (fwnode) + compat_info =3D device_get_match_data(dev); =20 if (pdata) { compat_info =3D pdata_device_get_match_data(dev); @@ -7030,9 +7031,9 @@ static int mv88e6xxx_probe(struct mdio_device *mdiode= v) mv88e6xxx_phy_init(chip); =20 if (chip->info->ops->get_eeprom) { - if (np) - of_property_read_u32(np, "eeprom-length", - &chip->eeprom_len); + if (fwnode) + device_property_read_u32(dev, "eeprom-length", + &chip->eeprom_len); else chip->eeprom_len =3D pdata->eeprom_len; } @@ -7043,8 +7044,8 @@ static int mv88e6xxx_probe(struct mdio_device *mdiode= v) if (err) goto out; =20 - if (np) { - chip->irq =3D of_irq_get(np, 0); + if (fwnode) { + chip->irq =3D fwnode_irq_get(fwnode, 0); if (chip->irq =3D=3D -EPROBE_DEFER) { err =3D chip->irq; goto out; @@ -7082,7 +7083,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiode= v) if (err) goto out_g1_atu_prob_irq; =20 - err =3D mv88e6xxx_mdios_register(chip, np); + err =3D mv88e6xxx_mdios_register(chip, fwnode); if (err) goto out_g1_vtu_prob_irq; =20 --=20 2.29.0 From nobody Sun Apr 26 08:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40981C43334 for ; Mon, 20 Jun 2022 15:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243169AbiFTPOt (ORCPT ); Mon, 20 Jun 2022 11:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241872AbiFTPMX (ORCPT ); Mon, 20 Jun 2022 11:12:23 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 197761FA50 for ; Mon, 20 Jun 2022 08:03:00 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id t25so17702927lfg.7 for ; Mon, 20 Jun 2022 08:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=79HyXuMDzSUSAqm9LJDxm1QulLKFCMJuKULtDaG7pgg=; b=nFzaIAZullAM5QpV7lhiewLkjFv18wWs2j2rGdYzDLGAKqfmRPytd4UVWA0Sfl8EJ2 9d5m4M40GMi7QHDQ9TRwYn4Z9lkJNm2cUfefT8nA9Q/zGr4agzJ1BBbVQ9jKfFyEHmtx ePBznUBHD79+Z1j+mba+bqQTBIH2bJUV38tvJfn/nNjom4f3tYypl9LBWzsfCiDgjYX/ 7p1zgdkbcrzfnDn1XpWzPxkn1j/Z1oI0UWMzZtzVwFfMLXUWB6/cXOE5cCHUSYk0sgBk AWdAp5D8krh12xI1gZlvwuFmpn7/ZqcR8oTGJ9FEQf5A2tG5dpHH6vd84+ZI5slXizXb dcMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=79HyXuMDzSUSAqm9LJDxm1QulLKFCMJuKULtDaG7pgg=; b=H2wvifn5BNkx5n547CrPDUiq/d4Nrpe4bq1E4T0WBYHhwE6KI6iYBjaCGatTwxqqHu BKQKJC8AvDrcceD7Bu6sFg8VXpxhald3QJD1oWi6sIg/ZPFF1n/r8mQC+ZM63sbcbUIe cH8b7ZVdIiQhTGM63XjQ0lT41qCCB8ZOMje/bVnrCnQUIEweo+8khrg9EXPI4HwHqP44 5JxPAqbXk0KyomVEUAGOG9t4cBtwzt3LwdbLv3tcnWWP31P4SBnNzasQFsoXNRqzVIdy TfSUd59lCH1+G7fBN4WsHQ7ixu7BYpo8e2pOLoOix6aKPSDuQTgqSIKN3dHUsQXIho9o J/MA== X-Gm-Message-State: AJIora+N3SxICshkwXENZHaXN55tK1Hw+X7sxDFf3kLd0tnNLwa7muMI JagxUQmZ0Yk2DiSTeJk7MmzhLZ67DGKbFg== X-Google-Smtp-Source: AGRyM1sZjX433uIfDuDxIJjCxeAulm4JqpTHnUDqeXfKIxktT74nYmgA/6lU+5nPFAWsS0NTA+T+Pg== X-Received: by 2002:a05:6512:3c87:b0:47f:70a0:b8f2 with SMTP id h7-20020a0565123c8700b0047f70a0b8f2mr2584155lfv.407.1655737378368; Mon, 20 Jun 2022 08:02:58 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e19-20020a05651236d300b0047f79f7758asm17564lfs.22.2022.06.20.08.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:02:58 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com, lenb@kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com, gjb@semihalf.com, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com, Samer.El-Haj-Mahmoud@arm.com, upstream@semihalf.com Subject: [net-next: PATCH 12/12] net: dsa: mv88e6xxx: add ACPI support Date: Mon, 20 Jun 2022 17:02:25 +0200 Message-Id: <20220620150225.1307946-13-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220620150225.1307946-1-mw@semihalf.com> References: <20220620150225.1307946-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Previous patches dropped the strict dependency on the OF_* API in both generic DSA subsystem and the mv88e6xxx driver. As a result the ACPI support can be introduced by adding the necessary ID's in the acpi_match_table and a two minor required adjustments, i.e. different mdiobus registration and MDIO subnode name, so to conform ACPI namespace requirements [1]. [1] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI= _Software_Programming_Model.html#acpi-namespace Signed-off-by: Marcin Wojtas Reported-by: kernel test robot --- drivers/net/dsa/mv88e6xxx/chip.c | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/c= hip.c index 556defa4379d..a74e528184aa 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -10,6 +10,8 @@ * Vivien Didelot */ =20 +#include +#include #include #include #include @@ -3913,7 +3915,10 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_= chip *chip, goto out; } =20 - err =3D of_mdiobus_register(bus, np); + if (is_acpi_node(fwnode)) + err =3D acpi_mdiobus_register(bus, fwnode); + else + err =3D of_mdiobus_register(bus, np); if (err) { dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); mv88e6xxx_g2_irq_mdio_free(chip, bus); @@ -3952,14 +3957,19 @@ static void mv88e6xxx_mdios_unregister(struct mv88e= 6xxx_chip *chip) static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, struct fwnode_handle *fwnode) { + char mdio_node_name[] =3D "mdio"; struct fwnode_handle *child; int err; =20 + /* Update subnode name if operating in the ACPI world. */ + if (is_acpi_node(fwnode)) + strncpy(mdio_node_name, "MDIO", ACPI_NAMESEG_SIZE); + /* Always register one mdio bus for the internal/default mdio * bus. This maybe represented in the device tree, but is * optional. */ - child =3D fwnode_get_named_child_node(fwnode, "mdio"); + child =3D fwnode_get_named_child_node(fwnode, mdio_node_name); err =3D mv88e6xxx_mdio_register(chip, child, false); fwnode_handle_put(child); if (err) @@ -7177,6 +7187,16 @@ static const struct of_device_id mv88e6xxx_of_match[= ] =3D { =20 MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); =20 +#ifdef CONFIG_ACPI +static const struct acpi_device_id sdhci_mv88e6xxx_acpi_ids[] =3D { + { .id =3D "MRVL0120", (kernel_ulong_t)&mv88e6xxx_table[MV88E6085]}, + { .id =3D "MRVL0121", (kernel_ulong_t)&mv88e6xxx_table[MV88E6190]}, + { .id =3D "MRVL0122", (kernel_ulong_t)&mv88e6xxx_table[MV88E6250]}, + {} +}; +MODULE_DEVICE_TABLE(acpi, sdhci_mv88e6xxx_acpi_ids); +#endif + static struct mdio_driver mv88e6xxx_driver =3D { .probe =3D mv88e6xxx_probe, .remove =3D mv88e6xxx_remove, @@ -7184,6 +7204,7 @@ static struct mdio_driver mv88e6xxx_driver =3D { .mdiodrv.driver =3D { .name =3D "mv88e6085", .of_match_table =3D mv88e6xxx_of_match, + .acpi_match_table =3D ACPI_PTR(sdhci_mv88e6xxx_acpi_ids), .pm =3D &mv88e6xxx_pm_ops, }, }; --=20 2.29.0