From patchwork Mon Dec 6 15:25:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1564009 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=sRTyvtti; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J76gx6PXMz9s5P for ; Tue, 7 Dec 2021 02:25:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D5A21830BB; Mon, 6 Dec 2021 16:25:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com 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=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="sRTyvtti"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4183183080; Mon, 6 Dec 2021 16:25:28 +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=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (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 8926682F56 for ; Mon, 6 Dec 2021 16:25:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52d.google.com with SMTP id o20so44472854eds.10 for ; Mon, 06 Dec 2021 07:25:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xIN79yzxeZsFLGZHVCsLct6G2RhQ8CeMCq/n7dqnjAI=; b=sRTyvttih5ygUKQchyMEoysYyeoRGBnJ7YIohahJvk41U7YapQE23lD5EwSli9n8Kq go9Gs+k1t1FPPWJ3KHkNAahEANiOujXnxrC2YneD97/5lEyxGIzwEO8PbbG/CIojH97B Ca1G7NV32YUUKkNWVRNwX1WYNK9WTw2yImxFMYm4eCi7/u8dz9UBpoIJz2WWDulgSJU4 mXYLveKJYI3Cpdn3KeIRDUf2pbvRddmY332QjmvrGR/e7GYp9ezQxVo4rg+UyNaVrXc/ wSXA8dW8rx+TYdQs2p6Yaes8VcsS/wHzBx24tb9kgua9ZFz4R0k+Of+fmX7o/bYFCkc5 YYPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=xIN79yzxeZsFLGZHVCsLct6G2RhQ8CeMCq/n7dqnjAI=; b=qOADbPrSNWtWfDPynuPQgxouIwUDlRn23K/jmPAdipNKUDY9FqMz2hwbhZI1pS3Vk0 2I1eJzITFCMkZjiRfx8jHKmM+N0NI+DcoXfMb66LSns4yPTLLh2YEaNZEK4NfnNoaejg 4kQXu7JUdi9PAAAHxh+6+MUrxLDWArNBOniHadQYWuwSHYOHXVKjBggZvqHr4d1Ax5sh e2SsviQyj6WcipuFt/z/FE4l9umPmCQsWsNmv9QaVVNhv+fSmc8vRwa+zoMiRmgudgER NFj0sOsK8Taj6TyXVQEaf49E9qI/KVqV4bHLFlmHF1Bewzm280GP/7TDeHH97DbGT7Ei KXcw== X-Gm-Message-State: AOAM532k1OnvuHus+Vp2/Gl1UPEj7w+RPCDWJo0DTY/pCIA34cfvKoLe lIjAz73AyBg59VZx9lrumWRr9xahbYEbPQ== X-Google-Smtp-Source: ABdhPJyWHvBQ1RXoglwf5g6tcoKZxjiVnkPLiWMauNOkpTWeWMwIyDbWQOuW55YR4S1ZguZmFWoc5Q== X-Received: by 2002:a17:907:78c4:: with SMTP id kv4mr45948263ejc.271.1638804321909; Mon, 06 Dec 2021 07:25:21 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::45a]) by smtp.gmail.com with ESMTPSA id sg39sm6804974ejc.66.2021.12.06.07.25.21 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Dec 2021 07:25:21 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Joe Hershberger , Ramon Fried Subject: [PATCH v2] net: zynq: Add support for GEM reset Date: Mon, 6 Dec 2021 16:25:20 +0100 Message-Id: <5ae1c85b282d632bb62030f1f24a0065661b9153.1638804318.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 Perform reset before core initialization. Standard flow which close to 99% users are using getting all IPs out of reset that there is no need to reset IP again. This is because of all low level initialization is done in previous bootloader stage. In SOM case these IPs are not touched by previous bootloader stage that's why reset needs to be called before IP is accessed to make sure that it is in correct state. Signed-off-by: Michal Simek Reviewed-by: Ramon Fried --- Changes in v2: - Update commit message drivers/net/zynq_gem.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 91957757727d..5cbe8d28304b 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -217,6 +218,7 @@ struct zynq_gem_priv { bool int_pcs; bool dma_64bit; u32 clk_en_info; + struct reset_ctl_bulk resets; }; static int phy_setup_op(struct zynq_gem_priv *priv, u32 phy_addr, u32 regnum, @@ -688,12 +690,36 @@ static int zynq_gem_miiphy_write(struct mii_dev *bus, int addr, int devad, return phywrite(priv, addr, reg, value); } +static int zynq_gem_reset_init(struct udevice *dev) +{ + struct zynq_gem_priv *priv = dev_get_priv(dev); + int ret; + + ret = reset_get_bulk(dev, &priv->resets); + if (ret == -ENOTSUPP || ret == -ENOENT) + return 0; + else if (ret) + return ret; + + ret = reset_deassert_bulk(&priv->resets); + if (ret) { + reset_release_bulk(&priv->resets); + return ret; + } + + return 0; +} + static int zynq_gem_probe(struct udevice *dev) { void *bd_space; struct zynq_gem_priv *priv = dev_get_priv(dev); int ret; + ret = zynq_gem_reset_init(dev); + if (ret) + return ret; + /* Align rxbuffers to ARCH_DMA_MINALIGN */ priv->rxbuffers = memalign(ARCH_DMA_MINALIGN, RX_BUF * PKTSIZE_ALIGN); if (!priv->rxbuffers)