Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp489489rdb; Thu, 19 Oct 2023 09:54:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiU+xAvpegXrTtvcUv+QycO+TzqqrFhDsW0NJkl+3zNA+89V7VjHILY2xp97GPJXQGGSXM X-Received: by 2002:a05:6a21:7883:b0:17b:c254:a6a9 with SMTP id bf3-20020a056a21788300b0017bc254a6a9mr1545030pzc.50.1697734465109; Thu, 19 Oct 2023 09:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697734465; cv=none; d=google.com; s=arc-20160816; b=ZlOFlb9JFaN1xYKyGEZ8MlkeC/JHQ+BDVL/ocptF8YgHgzWyQpY8kecRNMnm1UiIYv 7/hYiUZkdbAq6vN+uOZqe1weIUmomSdG3nSJgzakaa3ijKbyzYjc33gMov1sU3rlHnD3 RukbwaW2EMxPniHrO0n7+6/Pmv1K8JOBm9sn8L7SqEFgZqTur1v6L8TdHnaNqq+yQDLu AHrbQzp5VelpsYFMtF0i2sGOh2l3Klkej2Bm18Xg36ZGvmmscbNZFldGVDcybNV8S9jO 1hRKf+zwo8bTlcFk5ydqBldlAtFLrYYdZbfShbJv5rGRCa6W4jhOJwLWFHzyGZZVWwq1 Rs2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LnQzaD7UARmrsNP+XgiTfV7s8JM3EDm7yuLQmmghN7M=; fh=fZIaR5RlX6Ft2ANrm/YtUefjL8/a7asfm4zmoasOuOQ=; b=EyjPZJg/sDDSEYcupWAYKi96HtrAHzUF+jdq3xgtXIT7XFbxLIBd8WT6juHjmQDy8R a6NugDrGJY+lqrmsdnbFf1W0nf8g5ae251BzYEaZ72MO4GNzjBHMR9Q1Lbt9UmnAb14l SHvHZTyrlr8FScH3FWFd2EY3vBTmpKyjIcD3YlmidjQgC6f5aSkYfpQahVNIHKRhacsC GLa/7cSvjmzwZePdj0Upp7/C0+q6phtRMuTbgbnS8+gqI+5qE46FkWXewFi2QfQRJBZ1 l/KTNSN7nyzISk5BA6ghdhF8DXdh3z84lChsvBKgX6ZJGDE/JQLjzv/rJccmDJ2IROjJ FLtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LG0jSdYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q5-20020a170902dac500b001bc17ab8d6esi2810164plx.530.2023.10.19.09.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LG0jSdYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2B2C082BB188; Thu, 19 Oct 2023 09:54:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233081AbjJSQyQ (ORCPT + 99 others); Thu, 19 Oct 2023 12:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbjJSQyP (ORCPT ); Thu, 19 Oct 2023 12:54:15 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE7312D; Thu, 19 Oct 2023 09:54:13 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9c603e235d1so517363766b.3; Thu, 19 Oct 2023 09:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697734452; x=1698339252; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LnQzaD7UARmrsNP+XgiTfV7s8JM3EDm7yuLQmmghN7M=; b=LG0jSdYwli2aw8XpS1zSr7K59N/NXuRoinCNHC1DRuAzCcxobVwX9+BQWeum08gpbB Pj+zdPBSOIL1gJY20r2nzF9gpr8y4MTpxmgInpyILoEZmgVCwbs5xF9PzTeIq2omde4n iHZtD2hRpVaw8r3SbE3vpOeinSZmgPXv8k0YAAxFnvGL0Lcfm1XR28rt4m2D32NILOpt 0NTXhOMR6DTFeXAgHOIIzPdUG7YpnUOic2o+b9Cz80XmavTgf2HoiQiC1eFSy0RvzIzw 0FRRUZp487fywTUqdKY3ZgBvoffYR0MtX0vFgZv88Vy0W8E/yJ6O+slwzCtwdCkWtU0p KltA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697734452; x=1698339252; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LnQzaD7UARmrsNP+XgiTfV7s8JM3EDm7yuLQmmghN7M=; b=mQc9D3gIpP/+lfeoboadTls7maYGwbEz0dELkU1KmF5NGjMmr33iTl7STvDhc6GCDn jJn+F24rnJLQV7NwFewPJTB72huBbLuYJEtRPF3dkL/2QTX7Ejq5+LV46AaycidYeEG4 +elzF0Pzo7RD8MQROezINWTIxdcrujvdwQMbzxlLfEDayyf1sm8i8ldr7NBonpNVqHPt tbiX+320tjOfoSUgbAo01ntCNZvjhaEAB2lcbB8+8h6IXGx4J6A4HwVtseCDEWOBas8m DYly4j83bcPlzvWiP7Aca1Od9K/UR7txcn9gc2fV0I4M17BAKRg4VLKqf6A/a+fePUnP NzjA== X-Gm-Message-State: AOJu0Yyx+pt0CERt+AJlK1AtFyfwniUe8fjHKN0myOoaD3cKv/c5+SKa a/twTmbevRD6uHH+I4WoTGg= X-Received: by 2002:a17:907:1c24:b0:9bf:32c8:30ff with SMTP id nc36-20020a1709071c2400b009bf32c830ffmr2396776ejc.25.1697734451925; Thu, 19 Oct 2023 09:54:11 -0700 (PDT) Received: from skbuf ([188.26.57.160]) by smtp.gmail.com with ESMTPSA id a21-20020a1709063e9500b009adc77fe164sm3772714ejj.66.2023.10.19.09.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:54:11 -0700 (PDT) Date: Thu, 19 Oct 2023 19:54:09 +0300 From: Vladimir Oltean To: Ante Knezic Cc: netdev@vger.kernel.org, woojung.huh@microchip.com, andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, marex@denx.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: Re: [PATCH net-next v3 2/2] net:dsa:microchip: add property to select internal RMII reference clock Message-ID: <20231019165409.5sgkyvxsidrrptgh@skbuf> References: <351f7993397a496bf7d6d79b9096079a41157919.1697620929.git.ante.knezic@helmholz.de> <893a3ad19b28c6bb1bf5ea18dee2fa5855f0c207.1697620929.git.ante.knezic@helmholz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <893a3ad19b28c6bb1bf5ea18dee2fa5855f0c207.1697620929.git.ante.knezic@helmholz.de> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 09:54:22 -0700 (PDT) On Wed, Oct 18, 2023 at 11:24:14AM +0200, Ante Knezic wrote: > Microchip KSZ8863/KSZ8873 have the ability to select between internal > and external RMII reference clock. By default, reference clock > needs to be provided via REFCLKI_3 pin. If required, device can be > setup to provide RMII clock internally so that REFCLKI_3 pin can be > left unconnected. > Add a new "microchip,rmii-clk-internal" property which will set > RMII clock reference to internal. If property is not set, reference > clock needs to be provided externally. > > Signed-off-by: Ante Knezic > --- > drivers/net/dsa/microchip/ksz8795.c | 10 +++++++++- > drivers/net/dsa/microchip/ksz8795_reg.h | 3 +++ > drivers/net/dsa/microchip/ksz_common.h | 1 + > 3 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c > index 91aba470fb2f..b50ad9552c65 100644 > --- a/drivers/net/dsa/microchip/ksz8795.c > +++ b/drivers/net/dsa/microchip/ksz8795.c > @@ -1312,8 +1312,16 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port) > ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_ENABLE, true); > > if (cpu_port) { > - if (!ksz_is_ksz88x3(dev)) > + if (!ksz_is_ksz88x3(dev)) { > ksz8795_cpu_interface_select(dev, port); > + } else { > + dev->rmii_clk_internal = of_property_read_bool(dev->dev->of_node, > + "microchip,rmii-clk-internal"); > + > + ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE, > + KSZ88X3_PORT3_RMII_CLK_INTERNAL, > + dev->rmii_clk_internal); Odd code placement, and it looks too crammed/shifted to the right due to indentation. The calling pattern is as follows: ksz8_port_setup() has 2 callers. One is from ds->ops->port_setup() -> ksz_port_setup() -> filters out everything except user ports -> dev->dev_ops->port_setup() -> ksz8_port_setup() and the other is from ds->ops->setup() // switch-wide -> dev->dev_ops->config_cpu_port() -> ksz8_config_cpu_port() -> ksz8_port_setup() So user ports and CPU ports meet at ksz8_port_setup() from different call paths, but I think it's strange to continue this coding pattern for port stuff that's not common between user ports and CPU ports. For that reason, the placement of the existing ksz8795_cpu_interface_select() is also weird, when it could have been directly placed under ksz8_config_cpu_port(), and it would have not confusingly shared a code path with user ports. Could you please add a dedicated ksz88x3_config_rmii_clk(), called directly from ksz8_config_cpu_port()? It can have this as first step: if (!ksz_is_ksz88x3(dev)) return 0; and then the rest of the code can have a single level of indentation, which would look much more natural. > + } > > member = dsa_user_ports(ds); > } else { >