From: Linus Walleij <linus.walleij@linaro.org>
To: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>
Cc: "Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Andrew Lunn" <andrew@lunn.ch>,
"Linus Walleij" <linus.walleij@linaro.org>
Subject: [PATCH net-next 4/5 v3] net: gemini: Move main init to port
Date: Wed, 11 Jul 2018 21:32:44 +0200 [thread overview]
Message-ID: <20180711193245.21980-4-linus.walleij@linaro.org> (raw)
In-Reply-To: <20180711193245.21980-1-linus.walleij@linaro.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 <linus.walleij@linaro.org>
---
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(-)
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;
}
--
2.17.1
next prev parent reply other threads:[~2018-07-11 19:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 19:32 [PATCH net-next 1/5 v3] net: gemini: Look up L3 maxlen from table Linus Walleij
2018-07-11 19:32 ` [PATCH net-next 2/5 v3] net: gemini: Improve connection prints Linus Walleij
2018-07-11 19:57 ` Andrew Lunn
2018-07-13 0:39 ` David Miller
2018-07-11 19:32 ` [PATCH net-next 3/5 v3] net: gemini: Allow multiple ports to instantiate Linus Walleij
2018-07-13 0:39 ` David Miller
2018-07-11 19:32 ` Linus Walleij [this message]
2018-07-13 0:39 ` [PATCH net-next 4/5 v3] net: gemini: Move main init to port David Miller
2018-07-11 19:32 ` [PATCH net-next 5/5 v3] net: gemini: Indicate that we can handle jumboframes Linus Walleij
2018-07-11 19:57 ` Andrew Lunn
2018-07-13 0:39 ` David Miller
2018-07-13 0:39 ` [PATCH net-next 1/5 v3] net: gemini: Look up L3 maxlen from table David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180711193245.21980-4-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=ulli.kroll@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).