mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/6] net: fsl-fman: reset device before leaving
Date: Thu, 14 Nov 2019 14:00:16 +0100	[thread overview]
Message-ID: <20191114130021.1029-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20191114130021.1029-1-s.hauer@pengutronix.de>

edev->halt is implemented, but not called by the core during shutdown.
We have to call it manually during device remove. With this and also
resetting the whole FMan during shutdown the driver now works properly
when started second stage from another barebox.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/fsl-fman.c     | 19 +++++++++++++++++++
 include/soc/fsl/fsl_fman.h |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 4e6bb2ecfd..287a891a63 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -1175,6 +1175,8 @@ static int fsl_fman_memac_probe(struct device_d *dev)
 	/* alloc the FMan ethernet private struct */
 	fm_eth = xzalloc(sizeof(*fm_eth));
 
+	dev->priv = fm_eth;
+
 	fm_eth->dev = dev;
 
 	ret = fsl_fman_memac_port_bind(fm_eth, FMAN_PORT_TYPE_TX);
@@ -1216,6 +1218,13 @@ static int fsl_fman_memac_probe(struct device_d *dev)
 	return 0;
 }
 
+static void fsl_fman_memac_remove(struct device_d *dev)
+{
+	struct fm_eth *fm_eth = dev->priv;
+
+	fm_eth_halt(&fm_eth->edev);
+}
+
 static int fsl_fman_muram_probe(struct device_d *dev)
 {
 	struct resource *iores;
@@ -1274,6 +1283,7 @@ static struct of_device_id fsl_fman_memac_dt_ids[] = {
 static struct driver_d fman_memac_driver = {
 	.name   = "fsl-fman-memac",
 	.probe  = fsl_fman_memac_probe,
+	.remove = fsl_fman_memac_remove,
 	.of_compatible = DRV_OF_COMPAT(fsl_fman_memac_dt_ids),
 };
 
@@ -1303,6 +1313,7 @@ static int fsl_fman_probe(struct device_d *dev)
 		return PTR_ERR(iores);
 
 	reg = IOMEM(iores->start);
+	dev->priv = reg;
 
 	ret = of_platform_populate(dev->device_node, NULL, dev);
 	if (ret)
@@ -1320,6 +1331,13 @@ static int fsl_fman_probe(struct device_d *dev)
 	return 0;
 }
 
+static void fsl_fman_remove(struct device_d *dev)
+{
+	struct ccsr_fman *reg = dev->priv;
+
+	setbits_be32(&reg->fm_fpm.fmrstc, FMFP_RSTC_RFM);
+}
+
 static struct of_device_id fsl_fman_dt_ids[] = {
 	{
 		.compatible = "fsl,fman",
@@ -1330,6 +1348,7 @@ static struct of_device_id fsl_fman_dt_ids[] = {
 static struct driver_d fman_driver = {
 	.name   = "fsl-fman",
 	.probe  = fsl_fman_probe,
+	.remove = fsl_fman_remove,
 	.of_compatible = DRV_OF_COMPAT(fsl_fman_dt_ids),
 };
 device_platform_driver(fman_driver);
diff --git a/include/soc/fsl/fsl_fman.h b/include/soc/fsl/fsl_fman.h
index 96d61298ef..fd69fded38 100644
--- a/include/soc/fsl/fsl_fman.h
+++ b/include/soc/fsl/fsl_fman.h
@@ -348,6 +348,9 @@ struct fm_fpm {
 /* FPM Flush Control Register */
 #define FMFP_FLC_DISP_LIM_NONE	0x00000000 /* no dispatch limitation */
 
+/* FMan Reset Command Register */
+#define FMFP_RSTC_RFM		0x80000000 /* FMan Soft Reset Command */
+
 /* FMFP_EE - FPM event and enable register */
 #define FMFPEE_DECC		0x80000000 /* double ECC err on FPM ram */
 #define FMFPEE_STL		0x40000000 /* stall of task ... */
-- 
2.24.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-11-14 13:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14 13:00 [PATCH 0/6] fsl-fman patches Sascha Hauer
2019-11-14 13:00 ` Sascha Hauer [this message]
2019-11-14 13:23   ` [PATCH 1/6] net: fsl-fman: reset device before leaving Ahmad Fatoum
2019-11-14 14:36     ` Sascha Hauer
2019-11-14 13:00 ` [PATCH 2/6] net: fsl-fman: Store index for txbd Sascha Hauer
2019-11-14 13:00 ` [PATCH 3/6] net: fsl-fman: move status read into loop Sascha Hauer
2019-11-14 13:00 ` [PATCH 4/6] net: fsl-fman: Store index for rxbd Sascha Hauer
2019-11-14 13:00 ` [PATCH 5/6] net: fsl-fman: simplify setting next offset Sascha Hauer
2019-11-14 13:00 ` [PATCH 6/6] net: fsl-fman: do not leave not transmitted DMA buffers mapped Sascha Hauer

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=20191114130021.1029-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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