From patchwork Sat Jun 30 16:18:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 140683 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2138973ljj; Sat, 30 Jun 2018 09:20:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLlUNNq/f5RPXqYwAkF8WsDJrw7K8x3D9SWB1gPHLv2/KuZc63CAXxr+4kXJT2JrpDBiTvX X-Received: by 2002:a17:902:6b86:: with SMTP id p6-v6mr19455703plk.75.1530375655390; Sat, 30 Jun 2018 09:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530375655; cv=none; d=google.com; s=arc-20160816; b=tUooQx90NHw+u/4qObUvjZjw6ceuCIWlca/2/bRGI6cxe1S4BNosinV1Zt2a+wgqDN AJEFx6COUTpx4UN8cT1ENonOMcVVLf4dQ8itHhTiD8AOUu32TaaTZKd2/GvoomA/O6Ip DfeZWFT1BlSg4wuQkN8jtH0zNk10gKsFQSqRBTJnOqol52bq0f8DLvf6HxSz7Dx1YBGM OEpMWuUJSsREIN3FVJDrnRqbbvxIN5prY6SZ7v9Bx4aD+QgobngYUVTBbJoo+Z3nc43y VMwywSLe4zhHwlpUdbR4z/j3DBHrXDnpMfdWBjhqJvrK6mWngmtxnlR0aG36DvtaUZnH Dscg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=UxpUcszz9WFS4pG/wLl3BHuJI4EYo2qBSZxxg9tbKcg=; b=xUjrTkR+xP4DEQW+5LIQ0thwmIJufXdO/awwraNdJS49cKTESBqflWjUFO+cAzE5Tk +pIOrD0L+CuVqVLUq4afh3xb3mvSKdoLdTm+qMZpR6KRKt+7cVosP7U/Q0/lv/1jYUWO zgsfHqJa5G+IBMiHP6BpjDQ1dxWa8qsp7IMmySwfJPldJzpHlPOr5gnehrWz/A96+xRl 4WnkuKq4VbVEJI/wkF1isfERXk0hZIMu45KUMjzAc5QdJU5ng7e/W0ZZvKPnd/0EW0sJ K3WEMqJhoczrN15nV9qM2+uFFlfUzPcp1kNNAYFV3VEzom0wvp2IWfCHAPLZ5ODWW1UH w9vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQLjXu4+; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78-v6si12501422pfb.204.2018.06.30.09.20.55; Sat, 30 Jun 2018 09:20:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQLjXu4+; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbeF3QUo (ORCPT + 9 others); Sat, 30 Jun 2018 12:20:44 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36123 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbeF3QUh (ORCPT ); Sat, 30 Jun 2018 12:20:37 -0400 Received: by mail-lf0-f66.google.com with SMTP id n24-v6so8948143lfh.3 for ; Sat, 30 Jun 2018 09:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UxpUcszz9WFS4pG/wLl3BHuJI4EYo2qBSZxxg9tbKcg=; b=AQLjXu4+JgWTbe+Tu+FY65iKD6OgseSvYA2948WZvbz/ooxw44nwEFzbuCyAETgXQI anGHmDrjdj2t5uwMM3lRpDtuUvBUgAALRXnAF2X+w+KeHVyqVZD7Lql92OtkL2Sgzh59 ljgpM+W4YXDFmfhuorSy5Uwa9vPb2f7XViqao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UxpUcszz9WFS4pG/wLl3BHuJI4EYo2qBSZxxg9tbKcg=; b=oPc+s7RrBB8An4/oKnQxIRGtZdIZXE7Qqq4eUQIZrGuUg2It2KKDuXfDFBw/KT/5As IAXunvffJrGIqyDbpvJj/z1GqK/fQXw6lPi7sI1pEwh7X5RNI8uGroaGwvXGnHRSrmBz QWB5LIYLM5ydeXOa6qYjxUEiT0kB5eZ0WCGd17kiEJdpC4ia1nlslVWv7QV2cVacN0Wd e8h46ud4KQ4ZXHwgLsqlbq23mjgRydI0N+PZ7xeKpDThDqcbSNzuJGe4azf39AhiV6rA HdrjxLEi3r2xZI7t7cgHpuhorORNg4PSTuDJ3ttMumzk0ZmvS7m3egMmsgkrbJeAM8La ytcA== X-Gm-Message-State: APt69E1cIMrErqZzRKZRKd3Oiw9HnEDtkbdgeTT8M7KzECWoPxahrl9w q3UlxoQ2XS2wELy3YiH91iY4Z7BTPw8= X-Received: by 2002:a19:138b:: with SMTP id 11-v6mr9483220lft.74.1530375635971; Sat, 30 Jun 2018 09:20:35 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 93-v6sm2271978lfy.64.2018.06.30.09.20.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Jun 2018 09:20:34 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , Linus Walleij Subject: [PATCH net-next 4/5] net: gemini: Move main init to port Date: Sat, 30 Jun 2018 18:18:05 +0200 Message-Id: <20180630161806.24312-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180630161806.24312-1-linus.walleij@linaro.org> References: <20180630161806.24312-1-linus.walleij@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The initialization sequence for the ethernet, setting up interrupt routing and such things, need to be done after both the ports are clocked and reset. Before this the config will not "take". Move the initialization to the port probe function and keep track of init status in the state. Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 8d192fcd51c8..79324bbfd768 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -146,6 +146,7 @@ struct gemini_ethernet { void __iomem *base; struct gemini_ethernet_port *port0; struct gemini_ethernet_port *port1; + bool initialized; spinlock_t irq_lock; /* Locks IRQ-related registers */ unsigned int freeq_order; @@ -2301,6 +2302,14 @@ static void gemini_port_remove(struct gemini_ethernet_port *port) static void gemini_ethernet_init(struct gemini_ethernet *geth) { + /* Only do this once both ports are online */ + if (geth->initialized) + return; + if (geth->port0 && geth->port1) + geth->initialized = true; + else + return; + writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_0_REG); writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_1_REG); writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_2_REG); @@ -2447,6 +2456,10 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) geth->port0 = port; else geth->port1 = port; + + /* This will just be done once both ports are up and reset */ + gemini_ethernet_init(geth); + platform_set_drvdata(pdev, port); /* Set up and register the netdev */ @@ -2564,7 +2577,6 @@ static int gemini_ethernet_probe(struct platform_device *pdev) spin_lock_init(&geth->irq_lock); spin_lock_init(&geth->freeq_lock); - gemini_ethernet_init(geth); /* The children will use this */ platform_set_drvdata(pdev, geth); @@ -2577,8 +2589,8 @@ static int gemini_ethernet_remove(struct platform_device *pdev) { struct gemini_ethernet *geth = platform_get_drvdata(pdev); - gemini_ethernet_init(geth); geth_cleanup_freeq(geth); + geth->initialized = false; return 0; }