[3/3] clk: keystone: syscon-clk: use of_clk_hw_simple_get() for audio refclk

Message ID fe46b97cb6b53ad20397c1569dbbfc2b15239b29.1690885413.git.matthias.schiffer@ew.tq-group.com
State New
Headers
Series clk: keystone: syscon-clk: fixes for audio refclk |

Commit Message

Matthias Schiffer Aug. 1, 2023, 10:36 a.m. UTC
  The binding documentation for ti,am62-audio-refclk specifies that it has 0
clock cells (and Device Trees using the binding as documented have already
existed in vendor kernels for some time). Fix the driver to use
of_clk_hw_simple_get() instead of of_clk_hw_onecell_get(), as attempting
to reference the clock in the Device Tree will fail otherwise.

Fixes: 6acab96ee337 ("clk: keystone: syscon-clk: Add support for audio refclk")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/clk/keystone/syscon-clk.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/clk/keystone/syscon-clk.c b/drivers/clk/keystone/syscon-clk.c
index 9626a877e072..a539dbf2f48e 100644
--- a/drivers/clk/keystone/syscon-clk.c
+++ b/drivers/clk/keystone/syscon-clk.c
@@ -28,6 +28,7 @@  struct ti_syscon_gate_clk_data {
 	const struct ti_syscon_gate_clk_entry *clks;
 	size_t num_clks;
 	bool needs_parent;
+	bool simple; /* Use of_clk_hw_simple_get() rather than onecell */
 };
 
 static struct
@@ -129,6 +130,10 @@  static int ti_syscon_gate_clk_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(regmap),
 				     "failed to get regmap\n");
 
+	if (data->simple && data->num_clks != 1)
+		return dev_err_probe(dev, -EINVAL,
+				     "simple clocks must have exactly 1 entry\n");
+
 	num_parents = of_clk_get_parent_count(dev->of_node);
 	if (data->needs_parent && num_parents == 0)
 		return dev_err_probe(dev, -EINVAL,
@@ -151,8 +156,12 @@  static int ti_syscon_gate_clk_probe(struct platform_device *pdev)
 				 data->clks[i].name);
 	}
 
-	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
-					   hw_data);
+	if (data->simple)
+		return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
+						   hw_data->hws[0]);
+	else
+		return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+						   hw_data);
 }
 
 #define TI_SYSCON_CLK_GATE(_name, _offset, _bit_idx)	\
@@ -208,6 +217,7 @@  static const struct ti_syscon_gate_clk_data am62_audio_clk_data = {
 	.clks = am62_audio_clks,
 	.num_clks = ARRAY_SIZE(am62_audio_clks),
 	.needs_parent = true,
+	.simple = true,
 };
 
 static const struct of_device_id ti_syscon_gate_clk_ids[] = {