From patchwork Thu Jan 20 07:34:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Chiu X-Patchwork-Id: 1582342 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=OQEYGy70; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jfz0q4Rlxz9t2p for ; Fri, 21 Jan 2022 10:16:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D1CF83900; Fri, 21 Jan 2022 00:16:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.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=sifive.com header.i=@sifive.com header.b="OQEYGy70"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21A3C83053; Thu, 20 Jan 2022 08:35:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 CEC5383325 for ; Thu, 20 Jan 2022 08:35:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andy.chiu@sifive.com Received: by mail-pg1-x52a.google.com with SMTP id p125so4895845pga.2 for ; Wed, 19 Jan 2022 23:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vrmHMKWxy+b5RG77hghS4ycnjWT3cpM3soYWk3vlrpY=; b=OQEYGy705kzbmk8PKaN5IjEuyP1yPzWbGSHKBDNizkQasfCPoCquuzo/IadzdISme/ mTJk2uBoBocg2+NTIfNQ7POGST9C7XHJOHyP310I8tDO87jiNLcYiDvoFibWLnxg5mhk aTt7PFNw1eNlpdj9NK+tib3Nr5jiji3dw2ZFiIovxufk3oM7q+INJ/WwhYsz2VRdGXhx e+3GW0wdQmYqHWxYcpOU1K0D+6l7afigz9qLVL/aV2sWebKKBWNpE5BL7EH7Cgoi/Vdy qioXWCgPVqdMY+MoOT2rV2piEgjdTmcmfzn/29Rl4xkTw0wZEZLdpM5KD9uKusT7zYoq GT2A== 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=vrmHMKWxy+b5RG77hghS4ycnjWT3cpM3soYWk3vlrpY=; b=Sa+4N9tEx+V+J+Mm4gCH6rion0auUn7ZMQkfs6dO1ONuYkKoWjsiT9VTZCuJdW4Yal 62vmDT6yz6/5+0ufhLhsoRHbMWbgtVBxIcu9/BE33LByCtA5D1+2z6nTDx1wJQ8slY96 /gPhBTvUPBoXfSaWuZ4hxY48zsGjY4Z58Jj8wp5rB3Y9YWcwQaJZ96cp3aAGD5P6J56N eZ/Nm90Y8Lah4kb85p6Zw4SwPp6+QAvop+cWkH2zGsTX1qaWD0kKYaH2EIn1p0wTDo3G c6kJ+eYqZCeDY/11ljfRA1svGB77QM+sfPX5PkSEMlBzTynfWPrLYKAS8bB9y+1ynbIf j+lg== X-Gm-Message-State: AOAM5315CCgB6iE5lYHKlDMsSepX0ls0gYOMh64SdMpyDO18OeED8OFy miLJPzCLsOL+Ym5kLo4oT+QV1Q== X-Google-Smtp-Source: ABdhPJw+NDzKzSjouswRbGujWjHo+pOeeOB7VU6Hz7JsGMdeNulFr5Rp7Z/9i6Y/e2BiYxfpX6hiYg== X-Received: by 2002:a63:2220:: with SMTP id i32mr27132874pgi.320.1642664118952; Wed, 19 Jan 2022 23:35:18 -0800 (PST) Received: from archlinux.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id k11sm2090796pfu.180.2022.01.19.23.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 23:35:18 -0800 (PST) From: Andy Chiu To: monstr@monstr.eu Cc: Andy Chiu , Joe Hershberger , Ramon Fried , u-boot@lists.denx.de Subject: [PATCH 2/3] net: xilinx: Move setup of 1G MAC to a function Date: Thu, 20 Jan 2022 15:34:19 +0800 Message-Id: <20220120073420.1887809-2-andy.chiu@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220120073420.1887809-1-andy.chiu@sifive.com> References: <20220120073420.1887809-1-andy.chiu@sifive.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 21 Jan 2022 00:16:27 +0100 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.2 at phobos.denx.de X-Virus-Status: Clean Separate the flow out so that it would be easiler to implement error handling logic. Signed-off-by: Andy Chiu --- drivers/net/xilinx_axi_emac.c | 50 +++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 3117dae05e..dbda6c70d8 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -763,38 +763,48 @@ static int axiemac_miiphy_write(struct mii_dev *bus, int addr, int devad, return phywrite(bus->priv, addr, reg, value); } -static int axi_emac_probe(struct udevice *dev) +static int axiemac_setup_emac(struct udevice *dev) { struct axidma_plat *plat = dev_get_plat(dev); struct eth_pdata *pdata = &plat->eth_pdata; struct axidma_priv *priv = dev_get_priv(dev); int ret; + priv->eth_hasnobuf = plat->eth_hasnobuf; + priv->phyaddr = plat->phyaddr; + priv->phy_of_handle = plat->phy_of_handle; + priv->interface = pdata->phy_interface; + + priv->bus = mdio_alloc(); + priv->bus->read = axiemac_miiphy_read; + priv->bus->write = axiemac_miiphy_write; + priv->bus->priv = priv; + + ret = mdio_register_seq(priv->bus, dev_seq(dev)); + if (ret) + return ret; + + axiemac_phy_init(dev); + + return ret; +} + +static int axi_emac_probe(struct udevice *dev) +{ + struct axidma_plat *plat = dev_get_plat(dev); + struct eth_pdata *pdata = &plat->eth_pdata; + struct axidma_priv *priv = dev_get_priv(dev); + priv->iobase = (struct axi_regs *)pdata->iobase; priv->dmatx = plat->dmatx; /* RX channel offset is 0x30 */ priv->dmarx = (struct axidma_reg *)((phys_addr_t)priv->dmatx + 0x30); priv->mactype = plat->mactype; - if (priv->mactype == EMAC_1G) { - priv->eth_hasnobuf = plat->eth_hasnobuf; - priv->phyaddr = plat->phyaddr; - priv->phy_of_handle = plat->phy_of_handle; - priv->interface = pdata->phy_interface; - - priv->bus = mdio_alloc(); - priv->bus->read = axiemac_miiphy_read; - priv->bus->write = axiemac_miiphy_write; - priv->bus->priv = priv; - - ret = mdio_register_seq(priv->bus, dev_seq(dev)); - if (ret) - return ret; - - axiemac_phy_init(dev); - } - - return 0; + if (priv->mactype == EMAC_1G) + return axiemac_setup_emac(dev); + else + return 0; } static int axi_emac_remove(struct udevice *dev)