Skip to contentSkip to conversation

ARM: socfpga: clk: Obtain handoff base clock via DM

PATCH Superseded Marek Vasut 2 participants 9 messages Aug 8, 2018 – Aug 9, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ARM: socfpga: clk: Obtain handoff base clock via DM

Bind fixed clock driver to the base clock instantiated in the handoff DT and use DM clock framework to get their clock rate. This replaces the ad-hoc DT parsing present thus far.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
---
 arch/arm/mach-socfpga/Kconfig                 |  2 ++
 arch/arm/mach-socfpga/clock_manager_arria10.c | 41 +++++++++++++++++++--------
 2 files changed, 31 insertions(+), 12 deletions(-)
arch/arm/mach-socfpga/Kconfig +2 -0
index 5c1df2cf1f..2655289a72 100644
@@ -11,6 +11,8 @@ config TARGET_SOCFPGA_ARRIA10
 	bool
 	select ALTERA_SDRAM
 	select SPL_BOARD_INIT if SPL
+	select CLK
+	select SPL_CLK if SPL
 
 config TARGET_SOCFPGA_CYCLONE5
 	bool
arch/arm/mach-socfpga/clock_manager_arria10.c +29 -12

72 lines not on this page · raw message

Signature · 1 line
2.16.2
#1 lore raw

PATCH 2/3 ARM: socfpga: clk: Make L4SP and MMC clock calculation Gen5 only

The L4SP and MMC clock precalculation is specific to Gen5, it is not needed on Arria10/Stratix10. Isolate it to Gen5 until there is a proper clock driver for Gen5, at which point this will go away completely.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
---
 arch/arm/mach-socfpga/clock_manager.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-socfpga/clock_manager.c +2 -0
index 59ede59b59..9f3c643df8 100644
@@ -42,9 +42,11 @@ int cm_wait_for_fsm(void)
 
 int set_cpu_clk_info(void)
 {
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	/* Calculate the clock frequencies required for drivers */
 	cm_get_l4_sp_clk_hz();
 	cm_get_mmc_controller_clk_hz();
+#endif
 
 	gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000;
 	gd->bd->bi_dsp_freq = 0;
Signature · 1 line
2.16.2
#2 lore raw

PATCH 2/3 ARM: socfpga: clk: Make L4SP and MMC clock calculation Gen5 only

Quoted 22 lines · Marek Vasut

The L4SP and MMC clock precalculation is specific to Gen5, it is not needed on Arria10/Stratix10. Isolate it to Gen5 until there is a proper
clock driver for Gen5, at which point this will go away completely.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/clock_manager.c | 2 ++

 1 file changed, 2 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/clock_manager.c +0 -0

socfpga/clock_manager.c
index 59ede59b59..9f3c643df8 100644

arch/arm/mach-socfpga/clock_manager.c +0 -0
@@ -42,9 +42,11 @@ int cm_wait_for_fsm(void)


 int set_cpu_clk_info(void)
 {

Quoted 8 lines

+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  /* Calculate the clock frequencies required for drivers */ cm_get_l4_sp_clk_hz(); cm_get_mmc_controller_clk_hz();
+#endif

  gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000; gd->bd->bi_dsp_freq = 0;

#3 lore raw

PATCH 3/3 ARM: socfpga: clk: Drop unused variables on Arria10

In reply to Marek Vasut

The variables removed in this patch are never used, they are only ever assigned and then waste precious memory. Drop both the assignment and the variables.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>
---
 arch/arm/mach-socfpga/clock_manager_arria10.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
arch/arm/mach-socfpga/clock_manager_arria10.c +2 -17
index 59d3f9d50a..6b5c7b1ec4 100644
@@ -17,10 +17,6 @@ static const struct socfpga_clock_manager *clock_manager_base =
 static u32 eosc1_hz;
 static u32 cb_intosc_hz;
 static u32 f2s_free_hz;
-static u32 cm_l4_main_clk_hz;
-static u32 cm_l4_sp_clk_hz;
-static u32 cm_l4_mp_clk_hz;
-static u32 cm_l4_sys_free_clk_hz;
 
 struct mainpll_cfg {
 	u32 vco0_psrc;
@@ -969,18 +965,7 @@ int cm_basic_init(const void *blob)
 	if (rval)
 		return rval;
 
-	rval =  cm_full_cfg(&main_cfg, &per_cfg);
-
-	cm_l4_main_clk_hz =
-		cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB);
-
-	cm_l4_mp_clk_hz = cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB);
-
-	cm_l4_sp_clk_hz = cm_get_l4_sp_clk_hz();
-
-	cm_l4_sys_free_clk_hz = cm_get_noc_clk_hz() / 4;
-
-	return rval;
+	return cm_full_cfg(&main_cfg, &per_cfg);
 }
 
 unsigned long cm_get_mpu_clk_hz(void)
@@ -1177,5 +1162,5 @@ void cm_print_clock_quick_summary(void)
 	printf("L4 MP       %8d kHz\n",
 	       cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB) / 1000);
 	printf("L4 SP       %8d kHz\n", cm_get_l4_sp_clk_hz() / 1000);
-	printf("L4 sys free %8d kHz\n", cm_l4_sys_free_clk_hz / 1000);
+	printf("L4 sys free %8d kHz\n", cm_get_noc_clk_hz() / 4000);
 }
Signature · 1 line
2.16.2
#4 lore raw

PATCH 3/3 ARM: socfpga: clk: Drop unused variables on Arria10

Quoted 61 lines · Marek Vasut

The variables removed in this patch are never used, they are only ever
assigned and then waste precious memory. Drop both the assignment and the variables.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/clock_manager_arria10.c | 19 ++--------------- --

 1 file changed, 2 insertions(+), 17 deletions(-)
arch/arm/mach-socfpga/clock_manager_arria10.c +0 -4
index 59d3f9d50a..6b5c7b1ec4 100644
@@ -17,10 +17,6 @@ static const struct socfpga_clock_manager
 *clock_manager_base =
  static u32 eosc1_hz;
  static u32 cb_intosc_hz;
  static u32 f2s_free_hz;
-static u32 cm_l4_main_clk_hz;
-static u32 cm_l4_sp_clk_hz;
-static u32 cm_l4_mp_clk_hz;
-static u32 cm_l4_sys_free_clk_hz;


 struct mainpll_cfg {
  u32 vco0_psrc;

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -969,18 +965,7 @@ int cm_basic_init(const void *blob)
  	if (rval)
  		return rval;

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -4
-	rval =  cm_full_cfg(&main_cfg, &per_cfg);
-
-	cm_l4_main_clk_hz =
-		cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB

);

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -2
-
-	cm_l4_mp_clk_hz =

cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB);

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -6
-
-	cm_l4_sp_clk_hz = cm_get_l4_sp_clk_hz();
-
-	cm_l4_sys_free_clk_hz = cm_get_noc_clk_hz() / 4;
-
-	return rval;
+	return cm_full_cfg(&main_cfg, &per_cfg);

 }
 unsigned long cm_get_mpu_clk_hz(void)

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -1177,5 +1162,5 @@ void cm_print_clock_quick_summary(void)
  	printf("L4 MP       %8d kHz\n",

         cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB) / 1000);
  printf("L4 SP       %8d kHz\n", cm_get_l4_sp_clk_hz() / 1000);

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -1
-	printf("L4 sys free %8d kHz\n", cm_l4_sys_free_clk_hz /

1000);

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -0
+	printf("L4 sys free %8d kHz\n", cm_get_noc_clk_hz() / 4000);
Quoted 1 line

 }

#5 lore raw

PATCH 1/3 ARM: socfpga: clk: Obtain handoff base clock via DM

In reply to Marek Vasut
Quoted 81 lines · Marek Vasut

Bind fixed clock driver to the base clock instantiated in the handoff DT and use DM clock framework to get their clock rate. This replaces the ad-hoc DT parsing present thus far.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/Kconfig                 |  2 ++ arch/arm/mach-socfpga/clock_manager_arria10.c | 41
+++++++++++++++++++--------

 2 files changed, 31 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/Kconfig +0 -0

socfpga/Kconfig
index 5c1df2cf1f..2655289a72 100644

arch/arm/mach-socfpga/Kconfig +0 -0
@@ -11,6 +11,8 @@ config TARGET_SOCFPGA_ARRIA10

  bool
  select ALTERA_SDRAM
  select SPL_BOARD_INIT if SPL

arch/arm/mach-socfpga/Kconfig +2 -0
+	select CLK
+	select SPL_CLK if SPL


 config TARGET_SOCFPGA_CYCLONE5
  bool

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
index defa2f6261..59d3f9d50a 100644
@@ -7,6 +7,8 @@
  #include <fdtdec.h>
  #include <asm/io.h>
  #include <dm.h>
+#include <clk.h>
+#include <dm/device-internal.h>
  #include <asm/arch/clock_manager.h>


 static const struct socfpga_clock_manager *clock_manager_base =

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -141,9 +143,9 @@ struct strtopu32 {
  };


 const struct strtopu32 dt_to_val[] = {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -3
-	{ "/clocks/altera_arria10_hps_eosc1", &eosc1_hz},
-	{ "/clocks/altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz},
-	{ "/clocks/altera_arria10_hps_f2h_free", &f2s_free_hz},
+	{ "altera_arria10_hps_eosc1", &eosc1_hz },
+	{ "altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz },
+	{ "altera_arria10_hps_f2h_free", &f2s_free_hz },

 };

 static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_tab,

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -163,28 +165,43 @@ static int of_to_struct(const void *blob, int

node, const struct strtou32 *cfg_t
  return 0;
 }

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-static void of_get_input_clks(const void *blob)
+static int of_get_input_clks(const void *blob)

 {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	int node, i;
+	struct udevice *dev;
+	struct clk clk;
+	int i, ret;


  for (i = 0; i < ARRAY_SIZE(dt_to_val); i++) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-		node = fdt_path_offset(blob, dt_to_val[i].str);
+		memset(&clk, 0, sizeof(clk));

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		if (node < 0)
-			continue;
+		ret = uclass_get_device_by_name(UCLASS_CLK,

dt_to_val[i].str,

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -0
+						&dev);
+		if (ret)
+			return ret;

arch/arm/mach-socfpga/clock_manager_arria10.c static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_t · line 182

Quoted 3 lines
arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		fdtdec_get_int_array(blob, node, "clock-frequency",
-				     dt_to_val[i].p, 1);
+		ret = device_probe(dev);

uclass_get_device_by_name() will call to device_probe() function. So, can remove this.

Quoted 29 lines
arch/arm/mach-socfpga/clock_manager_arria10.c +8 -0
+		if (ret)
+			return ret;
+
+		ret = clk_request(dev, &clk);
+		if (ret)
+			return ret;
+
+		*dt_to_val[i].p = clk_get_rate(&clk);

  }

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
+
+	return 0;

 }

 static int of_get_clk_cfg(const void *blob, struct mainpll_cfg *main_cfg,
    struct perpll_cfg *per_cfg) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-	int node, child, len;
+	int ret, node, child, len;

  const char *node_name;

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	of_get_input_clks(blob);
+	ret = of_get_input_clks(blob);
+	if (ret)
+		return ret;


  node = fdtdec_next_compatible(blob, 0,
COMPAT_ALTERA_SOCFPGA_CLK_INIT);

#6 lore raw

PATCH 1/3 ARM: socfpga: clk: Obtain handoff base clock via DM

Quoted 79 lines · Ley Foon Tan
Quoted 78 lines · Marek Vasut

Bind fixed clock driver to the base clock instantiated in the handoff DT and use DM clock framework to get their clock rate. This replaces the ad-hoc DT parsing present thus far.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/Kconfig                 |  2 ++ arch/arm/mach-socfpga/clock_manager_arria10.c | 41
+++++++++++++++++++--------

 2 files changed, 31 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/Kconfig +0 -0

socfpga/Kconfig
index 5c1df2cf1f..2655289a72 100644

arch/arm/mach-socfpga/Kconfig +0 -0
@@ -11,6 +11,8 @@ config TARGET_SOCFPGA_ARRIA10

  bool
  select ALTERA_SDRAM
  select SPL_BOARD_INIT if SPL

arch/arm/mach-socfpga/Kconfig +2 -0
+	select CLK
+	select SPL_CLK if SPL


 config TARGET_SOCFPGA_CYCLONE5
  bool

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
index defa2f6261..59d3f9d50a 100644
@@ -7,6 +7,8 @@
  #include <fdtdec.h>
  #include <asm/io.h>
  #include <dm.h>
+#include <clk.h>
+#include <dm/device-internal.h>
  #include <asm/arch/clock_manager.h>


 static const struct socfpga_clock_manager *clock_manager_base =

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -141,9 +143,9 @@ struct strtopu32 {
  };


 const struct strtopu32 dt_to_val[] = {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -3
-	{ "/clocks/altera_arria10_hps_eosc1", &eosc1_hz},
-	{ "/clocks/altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz},
-	{ "/clocks/altera_arria10_hps_f2h_free", &f2s_free_hz},
+	{ "altera_arria10_hps_eosc1", &eosc1_hz },
+	{ "altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz },
+	{ "altera_arria10_hps_f2h_free", &f2s_free_hz },

 };

 static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_tab,

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -163,28 +165,43 @@ static int of_to_struct(const void *blob, int

node, const struct strtou32 *cfg_t
  return 0;
 }

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-static void of_get_input_clks(const void *blob)
+static int of_get_input_clks(const void *blob)

 {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	int node, i;
+	struct udevice *dev;
+	struct clk clk;
+	int i, ret;


  for (i = 0; i < ARRAY_SIZE(dt_to_val); i++) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-		node = fdt_path_offset(blob, dt_to_val[i].str);
+		memset(&clk, 0, sizeof(clk));

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		if (node < 0)
-			continue;
+		ret = uclass_get_device_by_name(UCLASS_CLK,

dt_to_val[i].str,

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -0
+						&dev);
Quoted 8 lines

arch/arm/mach-socfpga/clock_manager_arria10.c static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_t · line 182

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
+		if (ret)
+			return ret;

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		fdtdec_get_int_array(blob, node, "clock-frequency",
-				     dt_to_val[i].p, 1);
+		ret = device_probe(dev);

uclass_get_device_by_name() will call to device_probe() function. So, can remove this.

Are you sure about that ? Why so ?

Quoted 29 lines
Quoted 29 lines
arch/arm/mach-socfpga/clock_manager_arria10.c +8 -0
+		if (ret)
+			return ret;
+
+		ret = clk_request(dev, &clk);
+		if (ret)
+			return ret;
+
+		*dt_to_val[i].p = clk_get_rate(&clk);

  }

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
+
+	return 0;

 }

 static int of_get_clk_cfg(const void *blob, struct mainpll_cfg *main_cfg,
    struct perpll_cfg *per_cfg) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-	int node, child, len;
+	int ret, node, child, len;

  const char *node_name;

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	of_get_input_clks(blob);
+	ret = of_get_input_clks(blob);
+	if (ret)
+		return ret;


  node = fdtdec_next_compatible(blob, 0,
COMPAT_ALTERA_SOCFPGA_CLK_INIT);

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH 1/3 ARM: socfpga: clk: Obtain handoff base clock via DM

Quoted 96 lines · Marek Vasut
Quoted 87 lines · Ley Foon Tan
Quoted 85 lines · Marek Vasut

Bind fixed clock driver to the base clock instantiated in the handoff
DT and use DM clock framework to get their clock rate. This replaces
the ad-hoc DT parsing present thus far.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/Kconfig                 |  2 ++ arch/arm/mach-socfpga/clock_manager_arria10.c | 41
+++++++++++++++++++--------

 2 files changed, 31 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/Kconfig +0 -0

socfpga/Kconfig
index 5c1df2cf1f..2655289a72 100644

arch/arm/mach-socfpga/Kconfig +0 -0
@@ -11,6 +11,8 @@ config TARGET_SOCFPGA_ARRIA10

  bool
  select ALTERA_SDRAM
  select SPL_BOARD_INIT if SPL

arch/arm/mach-socfpga/Kconfig +2 -0
+	select CLK
+	select SPL_CLK if SPL


 config TARGET_SOCFPGA_CYCLONE5
  bool

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
index defa2f6261..59d3f9d50a 100644
@@ -7,6 +7,8 @@
  #include <fdtdec.h>
  #include <asm/io.h>
  #include <dm.h>
+#include <clk.h>
+#include <dm/device-internal.h>
  #include <asm/arch/clock_manager.h>


 static const struct socfpga_clock_manager *clock_manager_base =

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -141,9 +143,9 @@ struct strtopu32 {
  };


 const struct strtopu32 dt_to_val[] = {

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -2
-	{ "/clocks/altera_arria10_hps_eosc1", &eosc1_hz},
-	{ "/clocks/altera_arria10_hps_cb_intosc_ls",

&cb_intosc_hz},

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	{ "/clocks/altera_arria10_hps_f2h_free", &f2s_free_hz},
+	{ "altera_arria10_hps_eosc1", &eosc1_hz },
+	{ "altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz },
+	{ "altera_arria10_hps_f2h_free", &f2s_free_hz },

 };

 static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_tab,

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -163,28 +165,43 @@ static int of_to_struct(const void *blob,

int
node, const struct strtou32 *cfg_t return 0;
 }

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-static void of_get_input_clks(const void *blob)
+static int of_get_input_clks(const void *blob)

 {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	int node, i;
+	struct udevice *dev;
+	struct clk clk;
+	int i, ret;


  for (i = 0; i < ARRAY_SIZE(dt_to_val); i++) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-		node = fdt_path_offset(blob, dt_to_val[i].str);
+		memset(&clk, 0, sizeof(clk));

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		if (node < 0)
-			continue;
+		ret = uclass_get_device_by_name(UCLASS_CLK,

dt_to_val[i].str,

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -0
+						&dev);
+		if (ret)
+			return ret;
Quoted 8 lines

arch/arm/mach-socfpga/clock_manager_arria10.c static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_t · line 182

Quoted 5 lines

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -1
-		fdtdec_get_int_array(blob, node, "clock-

frequency",

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-				     dt_to_val[i].p, 1);
+		ret = device_probe(dev);

uclass_get_device_by_name() will call to device_probe() function. So,
can remove this.

Quoted 1 line

Are you sure about that ? Why so ?

It will call to device_probe() function eventually. See code in http://
git.denx.de/?p=u-boot.git;a=blob;f=drivers/core/uclass.c

The sequence:
uclass_get_device_by_name() --> uclass_get_device_tail() --

Quoted 1 line

 device_probe()

I used uclass_get_device() function before, it has same implementation as uclass_get_device_by_name(). We don't need call to device_probe() manually.

Regards
Ley Foon

#8 lore raw

PATCH 1/3 ARM: socfpga: clk: Obtain handoff base clock via DM

Quoted 97 lines · Ley Foon Tan
Quoted 96 lines · Marek Vasut
Quoted 95 lines · Ley Foon Tan
Quoted 88 lines · Marek Vasut

Bind fixed clock driver to the base clock instantiated in the handoff
DT and use DM clock framework to get their clock rate. This replaces
the ad-hoc DT parsing present thus far.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Ley Foon Tan <[email protected]>

---
 arch/arm/mach-socfpga/Kconfig                 |  2 ++ arch/arm/mach-socfpga/clock_manager_arria10.c | 41
+++++++++++++++++++--------

 2 files changed, 31 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/Kconfig +0 -0

socfpga/Kconfig
index 5c1df2cf1f..2655289a72 100644

arch/arm/mach-socfpga/Kconfig +0 -0
@@ -11,6 +11,8 @@ config TARGET_SOCFPGA_ARRIA10

  bool
  select ALTERA_SDRAM
  select SPL_BOARD_INIT if SPL

arch/arm/mach-socfpga/Kconfig +2 -0
+	select CLK
+	select SPL_CLK if SPL


 config TARGET_SOCFPGA_CYCLONE5
  bool

arch/arm/mach-socfpga/clock_manager_arria10.c +2 -0
index defa2f6261..59d3f9d50a 100644
@@ -7,6 +7,8 @@
  #include <fdtdec.h>
  #include <asm/io.h>
  #include <dm.h>
+#include <clk.h>
+#include <dm/device-internal.h>
  #include <asm/arch/clock_manager.h>


 static const struct socfpga_clock_manager *clock_manager_base =

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -141,9 +143,9 @@ struct strtopu32 {
  };


 const struct strtopu32 dt_to_val[] = {

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -2
-	{ "/clocks/altera_arria10_hps_eosc1", &eosc1_hz},
-	{ "/clocks/altera_arria10_hps_cb_intosc_ls",

&cb_intosc_hz},

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	{ "/clocks/altera_arria10_hps_f2h_free", &f2s_free_hz},
+	{ "altera_arria10_hps_eosc1", &eosc1_hz },
+	{ "altera_arria10_hps_cb_intosc_ls", &cb_intosc_hz },
+	{ "altera_arria10_hps_f2h_free", &f2s_free_hz },

 };

 static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_tab,

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -0
@@ -163,28 +165,43 @@ static int of_to_struct(const void *blob,

int
node, const struct strtou32 *cfg_t return 0;
 }

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-static void of_get_input_clks(const void *blob)
+static int of_get_input_clks(const void *blob)

 {

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -1
-	int node, i;
+	struct udevice *dev;
+	struct clk clk;
+	int i, ret;


  for (i = 0; i < ARRAY_SIZE(dt_to_val); i++) {

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-		node = fdt_path_offset(blob, dt_to_val[i].str);
+		memset(&clk, 0, sizeof(clk));

arch/arm/mach-socfpga/clock_manager_arria10.c +1 -2
-		if (node < 0)
-			continue;
+		ret = uclass_get_device_by_name(UCLASS_CLK,

dt_to_val[i].str,

arch/arm/mach-socfpga/clock_manager_arria10.c +3 -0
+						&dev);
+		if (ret)
+			return ret;

arch/arm/mach-socfpga/clock_manager_arria10.c +0 -1
-		fdtdec_get_int_array(blob, node, "clock-

frequency",

arch/arm/mach-socfpga/clock_manager_arria10.c static int of_to_struct(const void *blob, int node, const struct strtou32 *cfg_t · line 182

Quoted 2 lines
arch/arm/mach-socfpga/clock_manager_arria10.c +1 -1
-				     dt_to_val[i].p, 1);
+		ret = device_probe(dev);

uclass_get_device_by_name() will call to device_probe() function. So,
can remove this.

Quoted 8 lines
Quoted 1 line

Are you sure about that ? Why so ?

It will call to device_probe() function eventually. See code in http://
git.denx.de/?p=u-boot.git;a=blob;f=drivers/core/uclass.c

The sequence:
uclass_get_device_by_name() --> uclass_get_device_tail() --

Quoted 1 line

 device_probe()

Ah, you're right. Thanks !

Signature · 2 lines
Best regards,
Marek Vasut