summaryrefslogtreecommitdiff
path: root/arch/arm/mach-imx
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2016-03-01 16:05:30 +0100
committerOleksandr Suvorov <oleksandr.suvorov@toradex.com>2021-01-27 11:01:48 +0200
commit548f21092d61ac289f2261ed539c24d513425859 (patch)
tree1b0937ea67c884dd957270da73f3da8869a4f498 /arch/arm/mach-imx
parent65d622c3ada8a0ee159ee3c8684027ee424b37ec (diff)
mach-imx7d.c: use enet_out clk to decide on PHY clock
The i.MX 7 can provide a reference clock to the PHY or use a reference clock from an external circuit. If the device-tree node with compatible "fsl,imx7d-fec" has a clock named enet_out then provide the clock from the i.MX 7, if such a clock is missing use a clock provided from an external circuit. Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com> (cherry picked from commit 73c06d69321c45b69ffc864cbaaa7143da87d186) (cherry picked from commit d46df0826a9f948f05b71da80aa9397cb9337537) (cherry picked from commit 6cc8215ec5dc009d87a8ae862ee2f8a0ae46ac62)
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r--arch/arm/mach-imx/mach-imx7d.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/arch/arm/mach-imx/mach-imx7d.c b/arch/arm/mach-imx/mach-imx7d.c
index 6de67da201ca..8bd6c6fe8811 100644
--- a/arch/arm/mach-imx/mach-imx7d.c
+++ b/arch/arm/mach-imx/mach-imx7d.c
@@ -2,6 +2,7 @@
/*
* Copyright (C) 2015 Freescale Semiconductor, Inc.
*/
+#include <linux/clk.h>
#include <linux/irqchip.h>
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
@@ -83,15 +84,38 @@ static void __init imx7d_enet_mdio_fixup(void)
static void __init imx7d_enet_clk_sel(void)
{
+ struct device_node *np;
+ struct clk *enet_out_clk;
struct regmap *gpr;
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-fec");
+ if (!np) {
+ pr_warn("%s: failed to find fec node\n", __func__);
+ return;
+ }
+
+ enet_out_clk = of_clk_get_by_name(np, "enet_out");
+
gpr = syscon_regmap_lookup_by_compatible("fsl,imx7d-iomuxc-gpr");
+
if (!IS_ERR(gpr)) {
- regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, 0);
- regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, IMX7D_GPR1_ENET1_CLK_DIR_MASK);
+ if (IS_ERR(enet_out_clk)) {
+ pr_info("%s: failed to get enet_out clock, assuming ext. clock source\n", __func__);
+ /* use external clock for PHY */
+ regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK);
+ regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, 0);
+ } else {
+ pr_info("%s: found enet_out clock, assuming internal clock source\n", __func__);
+ /* use internal clock generation and output it to PHY */
+ regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, 0);
+ regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, IMX7D_GPR1_ENET1_CLK_DIR_MASK);
+ clk_put(enet_out_clk);
+
+ }
} else {
pr_err("failed to find fsl,imx7d-iomux-gpr regmap\n");
}
+ of_node_put(np);
}
static inline void imx7d_enet_init(void)