From patchwork Wed Jul 4 18:33:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 141085 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1097896ljj; Wed, 4 Jul 2018 11:37:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc//iUwmMQadkGaexKV2zfZWPWHL+WZlOmevYdN89dd1ocqnyBBcQ5XEsXKoTr4JmATuH6T X-Received: by 2002:a65:6559:: with SMTP id a25-v6mr2805804pgw.82.1530729455041; Wed, 04 Jul 2018 11:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530729455; cv=none; d=google.com; s=arc-20160816; b=VjahjHRuHc1/cFQZ+55MrTs7VksNMnkuNTl4aJY764e65QgJSePioJLr0AIj/6TZCi u3j3sPzwD2teAPM5LiDk0tH42m+jT0DZ9U3gsngRD0LMitetSJ2nKxJBnqJ8PKs3UYVU yVRqFqYIAXwjk6DPXx+v/pgL+PKpLkbIyPKt9vUFWi30ID+wPLdal4Xq4rHIXQqTL2kV SAbYmShAsiRTGG8DlAGV+cyYLFIRbflfhL0cswEoH8x3+cx3/ZdfaSpjzIIsgGOfypIr kbPcMfRecMhK0/t4gAqmZ2E3ooNYoQyBuFP4fYLrtMMJ0Eb0SSVjf8V93zLzm9sDXKbo m0pg== 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=XrT27mVKerw6PuoIEkPTNA0M5NXJmom0otf62NTCD0w=; b=LNeFPaiORdicPzqUWBy7vsHNB109DdU+BmssBlvWEk9keFOGfTdKFi7QwD3z9KHh0O N5SuF6Zh1GlBMHg1PpPehwzmhTuB4ByeApH6jDm1fdO8HtnS+4QhK9+6axXsbNywLFl9 yf/R+76D+Yp1gjkR2HHYvJXTTH8l/AvsejmbmPBkG1PsyWVOi9NdhXEmabJS/aMhM8nE wEMne/KOYVLTXr6NmYc9xKt4gs6yS90fbkJ/xo9YkYkm0x1hk+orAyjYP3XxrbnLClwa 6qXyKdidJEZzD9eMMxGw4FNpHX6AKrxJq44xi5ju6e/8yyqNhfv/dsPBAttGrPTwtG/d dNhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOULFqfs; 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 d6-v6si3961989pgh.569.2018.07.04.11.37.34; Wed, 04 Jul 2018 11:37:35 -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=QOULFqfs; 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 S1752882AbeGDShc (ORCPT + 10 others); Wed, 4 Jul 2018 14:37:32 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36347 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752578AbeGDSha (ORCPT ); Wed, 4 Jul 2018 14:37:30 -0400 Received: by mail-lj1-f194.google.com with SMTP id u7-v6so2290600lji.3 for ; Wed, 04 Jul 2018 11:37:29 -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=XrT27mVKerw6PuoIEkPTNA0M5NXJmom0otf62NTCD0w=; b=QOULFqfs9ZgQkpbF30MZRqt+wqhVbsKyDcMweXCrDyB3Gxxxf6bdKmUZMSOj59dN+j bMzG+WCSYmWfMTt4TAOdEoSbQICHNoDq9jxUiUlTehLhuVViwRsAQxsyCy7GE0EANDAo IlENZmQXpOVQHg9sp6WNjnceazGDRF23gBufY= 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=XrT27mVKerw6PuoIEkPTNA0M5NXJmom0otf62NTCD0w=; b=mOchBXLutjsBtgd9iPO/fgDAU1XUHi5/bT0s6hj3VqHZcCguuzv2EvsbUF+Clsb6Ou Md0mViZ71M93aJYtHrP83CZqnno7bW9f3Mvrj88tT5oFkLLuLuNSo7LCgerIblRCgwmn tndVPC2drmg/5yAIitsZ2FHzJuYve4DNU9fPlJ2xZzMM6rNIMV4i42HP9J5jHjJVnpt7 GxdlEyerHxZWUShqpfSddVcNvneQ2GWKgXWRkIsafweM3NHwwS2yfheDyBn4IRKa/5UX EtoAjEUSD5ugBcsP1842GR+Nb06YkCV0pfprgei0h2KOkNijlHLgXYkLSZ4eMIrsxjVX tZkQ== X-Gm-Message-State: APt69E1fnHTK6xXHGZzaZpv6NLcIloS5/QL+OSxBAd9hI6oN/zS/C0Hu 58eXH4zpaPkCCvRL6/sfRPwSwrQmVjQ= X-Received: by 2002:a2e:60:: with SMTP id 93-v6mr2213286lja.96.1530729448303; Wed, 04 Jul 2018 11:37:28 -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 g2-v6sm681094ljj.53.2018.07.04.11.37.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jul 2018 11:37:26 -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 v2] net: gemini: Move main init to port Date: Wed, 4 Jul 2018 20:33:23 +0200 Message-Id: <20180704183324.10605-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180704183324.10605-1-linus.walleij@linaro.org> References: <20180704183324.10605-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 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 6b5aa5704c4f..4e341570047f 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; }