From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90457C433F5 for ; Tue, 28 Sep 2021 13:38:15 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DE3160FC2 for ; Tue, 28 Sep 2021 13:38:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0DE3160FC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D783F833ED; Tue, 28 Sep 2021 15:36:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XRlQdv+x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE9038332D; Tue, 28 Sep 2021 15:35:54 +0200 (CEST) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 886B183264 for ; Tue, 28 Sep 2021 15:34:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-ot1-x32e.google.com with SMTP id g62-20020a9d2dc4000000b0054752cfbc59so23251326otb.1 for ; Tue, 28 Sep 2021 06:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TWr3c8K961hfglqhx10wsfEYosB+wB7RXsDXIfTzfSk=; b=XRlQdv+xSwoevk8YL0/uICjrtBG2E0wLge9YxbYd0N230V3k5p5hPdqR7fohJRFeB2 6NcVlk4ZOGvm7TtH7HvQ/qS9V1FMSfLg5jKNIgHKdMxBo7GkC/58n8x2Do3RR2dA07qZ 55Xr/whHYZ4qvKrpIUtCCTeIHqPTcygEtTirldGTm+LrcFykHjeKEeeLyt4WMtq7DAFs qzs9zV20DjzhOINeyviaz8X5tX4mn6qQv2+a+XR7SAfELipDfPZ/d36dNvURj7xXZlbf EMLM2FE3PeqgR8HDCtUgRdnXw/MPI8rkfHvQloqGWtxaE20krqAJSLiDLnxMwIO+Y5rp mjGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TWr3c8K961hfglqhx10wsfEYosB+wB7RXsDXIfTzfSk=; b=WaBrglKycK0pJ7LejGnPLrtNgTjGjThhSZEF4LmvUNjutfrd7VYiu8/UGaxLyGyws5 K2Vb5AB8NuHNPa5TrOmPGsXPZEfCKQku6LO6yKQR0hKIH1lvYHjj8admFkPeFWFcr+/n bZmDNWK/x8PNEGtDaLS6vlhN0zSMfis52jHpmLG0X+/DA3iI5DLGhbXqNEmy+ndonyw8 hCKpWODI1twL+rtkTqoYPVr+rk5FtVAXTPhVe/7dJFtbFJSmlf+PNwF3QqIMQBQm1oIZ w8i6OUq0h0D32XHQRd8ajgeYxpHRYFG9fXdhIjEcFrv5L/deRynMkhRBVbKcYooLnqA2 2ajg== X-Gm-Message-State: AOAM530/81ZUNRPv5xl9ce8y/99raLVSoDcbfxahKRF+u+F21F8GPuJG lf0tjdvmlgry87HyqNNSMv1RBx67/2JQ7Mw+2Uc= X-Google-Smtp-Source: ABdhPJyChNyngEwAks86NsogCv/uT6UUFop0Phy/5yym6DzB21bRsRZ0zJKJYIJF/IkvM6U/9LJ84qX9qXm9aeG3DvM= X-Received: by 2002:a9d:7f8b:: with SMTP id t11mr5296766otp.363.1632836087346; Tue, 28 Sep 2021 06:34:47 -0700 (PDT) MIME-Version: 1.0 References: <20210927234825.823582-1-vladimir.oltean@nxp.com> <20210927234825.823582-4-vladimir.oltean@nxp.com> In-Reply-To: <20210927234825.823582-4-vladimir.oltean@nxp.com> From: Ramon Fried Date: Tue, 28 Sep 2021 16:34:36 +0300 Message-ID: Subject: Re: [PATCH 3/9] net: dsa: allow drivers to get the port OF node To: Vladimir Oltean Cc: U-Boot Mailing List , Joe Hershberger , Priyanka Jain Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Sep 28, 2021 at 2:48 AM Vladimir Oltean wrote: > > In the current DSA switch driver API, only the udevice of the switch > (belonging to UCLASS_DSA) is exposed, as well as an "int port" argument. > So drivers do not have access to the udevice of individual ports > (belonging to UCLASS_ETH), one of the reasons being that not all ports > have an associated UCLASS_ETH udevice. > > However, all DSA ports have an OF node, and in some cases the driver > needs a handle to it, for all ports including the CPU port. Example: the > following Linux per-port device tree property: > > managed = "in-band-status"; > > states whether a port should operate with clause 37 in-band autoneg > enabled or not. > > This patch exposes a function which can be called by individual drivers > as needed. > > Signed-off-by: Vladimir Oltean > --- > include/net/dsa.h | 12 ++++++++++++ > net/dsa-uclass.c | 20 ++++++++++++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index ab2a9dfbea2d..d165427fcd4c 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -6,6 +6,7 @@ > #ifndef __DSA_H__ > #define __DSA_H__ > > +#include > #include > #include > > @@ -145,6 +146,17 @@ int dsa_set_tagging(struct udevice *dev, ushort headroom, ushort tailroom); > */ > struct udevice *dsa_get_master(struct udevice *dev); > > +/** > + * dsa_port_get_ofnode() - Return a reference to the given port's OF node > + * > + * Can be called at driver probe time or later. > + * > + * @dev: DSA switch udevice pointer > + * @port: Port index > + * @return OF node reference if OK, NULL on error > + */ > +ofnode dsa_port_get_ofnode(struct udevice *dev, int port); > + > /** > * dsa_port_get_pdata() - Helper that returns the platdata of an active > * (non-CPU) DSA port device. > diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c > index a9b4484d6d24..61bb47d0102d 100644 > --- a/net/dsa-uclass.c > +++ b/net/dsa-uclass.c > @@ -44,6 +44,26 @@ int dsa_set_tagging(struct udevice *dev, ushort headroom, ushort tailroom) > return 0; > } > > +ofnode dsa_port_get_ofnode(struct udevice *dev, int port) > +{ > + struct dsa_pdata *pdata = dev_get_uclass_plat(dev); > + struct dsa_port_pdata *port_pdata; > + struct udevice *pdev; > + > + if (port == pdata->cpu_port) > + return pdata->cpu_port_node; > + > + for (device_find_first_child(dev, &pdev); > + pdev; > + device_find_next_child(&pdev)) { > + port_pdata = dev_get_parent_plat(pdev); > + if (port_pdata->index == port) > + return dev_ofnode(pdev); > + } > + > + return ofnode_null(); > +} > + > /* returns the DSA master Ethernet device */ > struct udevice *dsa_get_master(struct udevice *dev) > { > -- > 2.25.1 > Reviewed-by: Ramon Fried