[U-Boot] [PATCH 6/8] net: fec_mxc: Add clock support via CLK
Jagan Teki
jagan at amarulasolutions.com
Mon Jul 30 12:56:23 UTC 2018
Now enet clock support available for imx6qdl and imx6ul,
via CLK framework, so add enable, set_rate support in
drivers.
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
Acked-by: Joe Hershberger <joe.hershberger at ni.com>
---
drivers/net/fec_mxc.c | 58 ++++++++++++++++++++++++++++++++++++++++++-
drivers/net/fec_mxc.h | 5 ++++
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3640ee3471..53b99f6654 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -8,6 +8,7 @@
*/
#include <common.h>
+#include <clk-uclass.h>
#include <dm.h>
#include <environment.h>
#include <malloc.h>
@@ -1297,11 +1298,52 @@ static int fec_mdio_init(struct udevice *dev)
return mdio_register(bus);
}
+#if CONFIG_IS_ENABLED(CLK)
+static int fec_clk_enable(struct fec_priv *priv)
+{
+ int ret;
+
+ ret = clk_enable(&priv->clk_ahb);
+ if (ret) {
+ printf("failed to enable ahb clk\n");
+ return ret;
+ }
+
+ if (generic_clk_valid(&priv->clk_ptp)) {
+ ret = clk_enable(&priv->clk_ptp);
+ if (ret) {
+ printf("failed to set 50MHz rate to ptp clk\n");
+ goto failed_clk_ahb;
+ }
+ }
+
+ if (generic_clk_valid(&priv->clk_enet_out)) {
+ ret = clk_enable(&priv->clk_enet_out);
+ if (ret) {
+ printf("failed to set 50MHz rate to enet_out clk\n");
+ goto failed_clk_ahb;
+ }
+ }
+
+ return 0;
+
+failed_clk_ahb:
+ clk_disable(&priv->clk_ahb);
+ return ret;
+}
+#endif
+
static int fec_enet_init(struct fec_priv *priv)
{
uint32_t start;
int ret;
+#if CONFIG_IS_ENABLED(CLK)
+ ret = fec_clk_enable(priv);
+ if (ret)
+ return ret;
+#endif
+
ret = fec_alloc_descs(priv);
if (ret)
return ret;
@@ -1407,7 +1449,21 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
}
#endif
- return ret;
+#if CONFIG_IS_ENABLED(CLK)
+ ret = clk_get_by_name(dev, "ahb", &priv->clk_ahb);
+ if (ret)
+ ret = PTR_ERR(&priv->clk_ahb);
+
+ ret = clk_get_by_name(dev, "ptp", &priv->clk_ptp);
+ if (ret)
+ dev_dbg(dev, "Warning: failed to get ptp clk\n");
+
+ ret = clk_get_by_name(dev, "enet_out", &priv->clk_enet_out);
+ if (ret)
+ dev_dbg(dev, "Warning: failed to get enet_out clk\n");
+#endif
+
+ return 0;
}
static const struct udevice_id fecmxc_ids[] = {
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 6cf2a8b3cc..76a40053a4 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -250,6 +250,11 @@ struct fec_priv {
struct gpio_desc reset_gpio;
uint32_t reset_delay;
# endif
+#if CONFIG_IS_ENABLED(CLK)
+ struct clk clk_ahb;
+ struct clk clk_ptp;
+ struct clk clk_enet_out;
+# endif
#endif
};
--
2.18.0.321.gffc6fa0e3
More information about the U-Boot
mailing list