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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AC40BC00140 for ; Mon, 8 Aug 2022 12:17:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4F9E845F6; Mon, 8 Aug 2022 14:16:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z1l57MoN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBFE784853; Mon, 8 Aug 2022 14:16:38 +0200 (CEST) Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) (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 ADAAF841AB for ; Mon, 8 Aug 2022 14:16:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=joel.stan@gmail.com Received: by mail-pg1-x532.google.com with SMTP id d7so8363881pgc.13 for ; Mon, 08 Aug 2022 05:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc; bh=d9DG0M1wRZ40HpYAPqaRGqdRd5O9bo64fLRQsazdwH0=; b=Z1l57MoN+dSbkJsLkZuZQ456Ksn9TsLFKfn3V05xI7uL/o88XvRG8/jNg/R1cpdvBS qhzSkn+xpVs9/ok1EmXw1GSOkvAJU+EnASumPVU6H9n692RvMkT+G7g/AeI7PQa/j5Mc s9WIYcKFjCBFgIxVor+4ZjQkg6XQcQJsCNwxTkQ2FnrI9cdwSfUmLtIIEdfAGQtoCJPv 7QMKBB7E2rftvWEY6NHl6Hxcrt9s/e2U9giAQg7HCUH1zp5BhsDGL0dGIDaBQXYmtKP5 zjAbxes7cBgEC8NWTfqZfPgsvG7FHpkZSPXv5GKugQuMSyqiHre0RHYQvXaeICM1k3zm IIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc; bh=d9DG0M1wRZ40HpYAPqaRGqdRd5O9bo64fLRQsazdwH0=; b=3d7kUXEd8Lg8VHJDE+0Fj9wwUraZfDnlDaw5NpmJ3BH92p59DB3F3qiLfYy8EzQHQR UgHKl5NN7VSgPz4B5zwKbQjrvXgqVjylOVxUY5I4QOIiLQIlHQbmRze8iZ+DCtLXIKRk DiU86O6AoVeOUECDZ4yUAcnFSrN447xDD0intjCvErN/4hyGCW7y08mDZmfXB75gPboI mH4FmifxKCKxmCTjH/xf2aYqPybzKYKNkbUY2H1yRj1Y/gigtExiIgdoNWSqa21/mL+C UNKQFFh4EHFi52TLDL8qho5KvcJT58IIcquQ6V/4mTfL2d2VkhENJ/eQ6U+PWuye8Pjh SMpw== X-Gm-Message-State: ACgBeo1zH+XxWWPZnYLeoPqNbNpOF/f60oTBeBOhnHykaqwvH8DwnROW PDyeDEbwgxXvbJPie2nPEcQ= X-Google-Smtp-Source: AA6agR4wtop1r+nhsldD+TSCXbczlYUDXbz/ptASk0D01CF7DgqF85XiyS/5QUeg/khvENNE8PZ5/Q== X-Received: by 2002:a05:6a00:21c8:b0:52b:ffc0:15e7 with SMTP id t8-20020a056a0021c800b0052bffc015e7mr18412574pfj.29.1659960993875; Mon, 08 Aug 2022 05:16:33 -0700 (PDT) Received: from voyager.lan ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id t16-20020a62d150000000b0052b6ed5ca40sm8482163pfl.192.2022.08.08.05.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 05:16:33 -0700 (PDT) From: Joel Stanley To: Joe Hershberger , Ramon Fried , Ryan Chen , BMC-SW@aspeedtech.com Cc: Samuel Mendoza-Jonas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , u-boot@lists.denx.de Subject: [PATCH v4 3/4] net/ftgmac100: Add NC-SI mode support Date: Mon, 8 Aug 2022 21:46:05 +0930 Message-Id: <20220808121606.188002-4-joel@jms.id.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808121606.188002-1-joel@jms.id.au> References: <20220808121606.188002-1-joel@jms.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean From: Samuel Mendoza-Jonas Update the ftgmac100 driver to support NC-SI instead of an mdio phy where available. This is a common setup for Aspeed AST2x00 platforms. NC-SI mode is determined from the device-tree if either phy-mode sets it or the use-ncsi property exists. If set then normal mdio setup is skipped in favour of the NC-SI phy. Signed-off-by: Samuel Mendoza-Jonas Signed-off-by: Joel Stanley Reviewed-by: Cédric Le Goater Reviewed-by: Ramon Fried --- v4: Add r-b from Cédric and Ramon v3: - Simplify ncsi enable by re-using pdata->phy_interface parsing. use-ncsi still overrides this value. - Fix up freeing in remove callback per Joe's review drivers/net/ftgmac100.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index 78779d7d60b9..69370ea5cca2 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -188,7 +188,7 @@ static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv) struct phy_device *phydev = priv->phydev; u32 maccr; - if (!phydev->link) { + if (!phydev->link && priv->phy_mode != PHY_INTERFACE_MODE_NCSI) { dev_err(phydev->dev, "No link\n"); return -EREMOTEIO; } @@ -228,7 +228,8 @@ static int ftgmac100_phy_init(struct udevice *dev) if (!phydev) return -ENODEV; - phydev->supported &= PHY_GBIT_FEATURES; + if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI) + phydev->supported &= PHY_GBIT_FEATURES; if (priv->max_speed) { ret = phy_set_supported(phydev, priv->max_speed); if (ret) @@ -308,7 +309,8 @@ static void ftgmac100_stop(struct udevice *dev) writel(0, &ftgmac100->maccr); - phy_shutdown(priv->phydev); + if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI) + phy_shutdown(priv->phydev); } static int ftgmac100_start(struct udevice *dev) @@ -580,6 +582,9 @@ static int ftgmac100_probe(struct udevice *dev) priv->max_speed = pdata->max_speed; priv->phy_addr = 0; + if (dev_read_bool(dev, "use-ncsi")) + priv->phy_mode = PHY_INTERFACE_MODE_NCSI; + #ifdef CONFIG_PHY_ADDR priv->phy_addr = CONFIG_PHY_ADDR; #endif @@ -592,7 +597,8 @@ static int ftgmac100_probe(struct udevice *dev) * If DM MDIO is enabled, the MDIO bus will be initialized later in * dm_eth_phy_connect */ - if (!IS_ENABLED(CONFIG_DM_MDIO)) { + if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI && + !IS_ENABLED(CONFIG_DM_MDIO)) { ret = ftgmac100_mdio_init(dev); if (ret) { dev_err(dev, "Failed to initialize mdiobus: %d\n", ret); -- 2.35.1