From patchwork Wed Jul 11 19:32:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 141769 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp676016ljj; Wed, 11 Jul 2018 12:36:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLkaskelJPHhbCEaLnJwfsquI617CMjmRNwbkBLRzri3CPuZB36b/iapv5/P00H+hzaY7f X-Received: by 2002:aa7:850b:: with SMTP id v11-v6mr30846847pfn.165.1531337780332; Wed, 11 Jul 2018 12:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531337780; cv=none; d=google.com; s=arc-20160816; b=zdiesTbOMa9js+6MmbKz5HUnW8LyQ6aGvf4GoW7fDueH3agT7mc6NDr9K6n92emuNU m4P34lbl8EhISsz1zSLr5ud07Ej5fogdSb50VL0uj0pyO/A116jHbnJoNn/Yja6K9xi+ zGkiNOhuevpZwXsHozTjgZ2/3Qtv8pOYFtsguaTEqGrFC/QHDiFXWdAXalIhKGV1Rz36 Lsfz22x1R4eN1VmX/Knn8eCltGmaJ39MCKjgU6Mr/p8AvcsbQQ/h1cOvVrbMcGTqptGP M5BjklxqmXMCa/BZZDjOnShw++ISj1Ij7oYNG0JMlKo6VIqG5BjsuokIHqjqfI/q0yTe DQEw== 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=pl+I3Y1OKFfxSy/bu96YlYHYtgheJ6HfhI3du4hNUCQ=; b=wiH2n6I3fZRZvBiB6RHY5G0zyslyQ6d+epoLOdbmP9DzPwSzetqfDSV9kKG9ch6kNy J/2SxcAkc7ZvivvPUVkjx+wVXbI/Ur0OeOwRksg84Qp5SxJVHseAaDyrzcSoJsLY1Aba pHSaTJYFQsFCix2qJB7BmynIiKkmGN8lRSZkc6yVRW+FyOcHR6grNE7wlN68oT1AKhyt sX2ZbiZgXOmK9Sk7NFmNjtZD0WfK8eZDyg/0mpawekyhySGYca+zHrAlpOv4b0nTE6Lk 8gerTO1alhhS9hxMbrOI4Zey+HwTDX17aMSI2A3cHSo7CBRANGVcGUmOd+3tcRhYpvwl ON0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="i+nh/7tu"; 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 85-v6si21344993pfm.264.2018.07.11.12.36.20; Wed, 11 Jul 2018 12:36:20 -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="i+nh/7tu"; 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 S2388375AbeGKTmG (ORCPT + 10 others); Wed, 11 Jul 2018 15:42:06 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38356 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbeGKTmG (ORCPT ); Wed, 11 Jul 2018 15:42:06 -0400 Received: by mail-lf0-f67.google.com with SMTP id a4-v6so22217072lff.5 for ; Wed, 11 Jul 2018 12:36:17 -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=pl+I3Y1OKFfxSy/bu96YlYHYtgheJ6HfhI3du4hNUCQ=; b=i+nh/7tuNZclV1YvoGeNltWSjanzZiT7dAIBM6017D8/CdmmgxAoYtnmk1qcQdhnP6 S3QEsNyBJ9P2Fh1eeawInjzAUOhyzLi4m0PkAmPlG/c7Q8a3edsxEqfb8fBEVgVFtF4T /UjG6AklFjWPv7GqE4aqsG6CUrdUDH3YavsqI= 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=pl+I3Y1OKFfxSy/bu96YlYHYtgheJ6HfhI3du4hNUCQ=; b=EgAzU+phJpwmgWFYeXYieFCbzIYABJkWJoOnHRncZhsCvWZMvfx9g+3eJ4rg8SCvbr lDoQI+C4hoNKRlXvqw0QK+4a1qmXHa+fXIFwmJkXXtp3BtOSPW3zrp3WQ9iMQQgWQjZD FmAjFEzNanv1Yp8D235cl5/L9qz9WW9nlOwOaTqEDqN4abzbuAj+tTwaJZrKA4vGvPvz GG1joiFSAYadyAImcni5L+cVHOpi4LAIQQjj1Is+GEqKNvholGDnm1FUvqUWHHpZdOf5 DkvaUhq4wekpoNCBuN7IGv3iVzud6kaemhbiLaHBwTM66w+oeBrvMxGxi2xZtjN4oiMF esGQ== X-Gm-Message-State: APt69E1gmU1bAwTspEOL1zHV1cGqhzFSYkBaZUdXxMxXvAjdd6ilw8sM kn13JBekZejmMe8SC+x0MJCH9i5iav0= X-Received: by 2002:a19:c954:: with SMTP id z81-v6mr6570871lff.107.1531337776258; Wed, 11 Jul 2018 12:36:16 -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 y5-v6sm5502299lfc.58.2018.07.11.12.36.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:36:15 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Hans Ulli Kroll , Florian Fainelli , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrew Lunn , Linus Walleij Subject: [PATCH net-next 4/5 v3] net: gemini: Move main init to port Date: Wed, 11 Jul 2018 21:32:44 +0200 Message-Id: <20180711193245.21980-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180711193245.21980-1-linus.walleij@linaro.org> References: <20180711193245.21980-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 --- ChangeLog v2->v3: - No changes, just resending with the rest. ChangeLog v1->v2: - No changes, just resending with the rest. --- 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 2457a1239d69..0f1d26441177 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -151,6 +151,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; @@ -2303,6 +2304,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); @@ -2450,6 +2459,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 */ @@ -2567,7 +2580,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); @@ -2580,8 +2592,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; }