mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] i.MX: fec: also enable optional clocks
Date: Fri,  5 May 2017 17:49:18 +0200	[thread overview]
Message-ID: <20170505154920.27685-2-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20170505154920.27685-1-m.grzeschik@pengutronix.de>

This will also enable two more optional clocks. They can be found on
mx6ul, mx6sx and mx28.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/net/fec_imx.c | 29 +++++++++++++++++++++++++++++
 drivers/net/fec_imx.h |  8 ++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index e2b25fe375..8cf7c4fbda 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -662,6 +662,14 @@ static int fec_clk_enable(struct fec_priv *fec)
 			return err;
 	}
 
+	for (i = 0; i < ARRAY_SIZE(fec->opt_clk); i++) {
+		if (!IS_ERR_OR_NULL(fec->opt_clk[i])) {
+			const int err = clk_enable(fec->opt_clk[i]);
+			if (err < 0)
+				return err;
+		}
+	}
+
 	return 0;
 }
 
@@ -673,6 +681,12 @@ static void fec_clk_disable(struct fec_priv *fec)
 		if (!IS_ERR_OR_NULL(fec->clk[i]))
 			clk_disable(fec->clk[i]);
 	}
+
+	for (i = 0; i < ARRAY_SIZE(fec->opt_clk); i++) {
+		if (!IS_ERR_OR_NULL(fec->opt_clk[i])) {
+			clk_disable(fec->opt_clk[i]);
+		}
+	}
 }
 
 static void fec_clk_put(struct fec_priv *fec)
@@ -683,6 +697,11 @@ static void fec_clk_put(struct fec_priv *fec)
 		if (!IS_ERR_OR_NULL(fec->clk[i]))
 			clk_put(fec->clk[i]);
 	}
+
+	for (i = 0; i < ARRAY_SIZE(fec->opt_clk); i++) {
+		if (!IS_ERR_OR_NULL(fec->opt_clk[i]))
+			clk_put(fec->opt_clk[i]);
+	}
 }
 
 static int fec_clk_get(struct fec_priv *fec)
@@ -691,6 +710,9 @@ static int fec_clk_get(struct fec_priv *fec)
 	static const char *clk_names[ARRAY_SIZE(fec->clk)] = {
 		"ipg", "ahb", "ptp"
 	};
+	static const char *opt_clk_names[ARRAY_SIZE(fec->opt_clk)] = {
+		"enet_clk_ref", "enet_out",
+	};
 
 	for (i = 0; i < ARRAY_SIZE(fec->clk); i++) {
 		fec->clk[i] = clk_get(fec->edev.parent, clk_names[i]);
@@ -701,6 +723,13 @@ static int fec_clk_get(struct fec_priv *fec)
 		}
 	}
 
+	for (i = 0; i < ARRAY_SIZE(fec->opt_clk); i++) {
+		fec->opt_clk[i] = clk_get(fec->edev.parent, opt_clk_names[i]);
+		if (IS_ERR(fec->opt_clk[i])) {
+			fec->opt_clk[i] = NULL;
+		}
+	}
+
 	return err;
 }
 
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 85d51bad60..561de0890b 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -137,6 +137,13 @@ enum fec_clock {
 	FEC_CLK_NUM
 };
 
+enum fec_opt_clock {
+	FEC_OPT_CLK_REF,
+	FEC_OPT_CLK_OUT,
+
+	FEC_OPT_CLK_NUM
+};
+
 /**
  * @brief i.MX27-FEC private structure
  */
@@ -153,6 +160,7 @@ struct fec_priv {
 	struct mii_bus miibus;
 	void (*phy_init)(struct phy_device *dev);
 	struct clk *clk[FEC_CLK_NUM];
+	struct clk *opt_clk[FEC_OPT_CLK_NUM];
 	enum fec_type type;
 };
 
-- 
2.11.0


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

  reply	other threads:[~2017-05-05 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05 15:49 [PATCH 0/3] i.MX: fec: enable optional clocks in fec driver Michael Grzeschik
2017-05-05 15:49 ` Michael Grzeschik [this message]
2017-05-05 15:49 ` [PATCH 2/3] ARM: phytec-som-imx6: the ethernet clocks get enabled by fec_imx Michael Grzeschik
2017-05-05 15:49 ` [PATCH 3/3] ARM: mx6sx-sabresdb: " Michael Grzeschik
2017-05-08 11:53 ` [PATCH 0/3] i.MX: fec: enable optional clocks in fec driver 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=20170505154920.27685-2-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@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