summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/clock.c
diff options
context:
space:
mode:
authorSvyatoslav Ryhel <clamor95@gmail.com>2023-02-14 20:35:26 +0300
committerTom <twarren@nvidia.com>2023-02-23 22:55:36 +0300
commita81d792479340bf03131111b285c0f70d27622b6 (patch)
treee0aa21f9c53c44079b0e7dbf7981ec9227d6d646 /arch/arm/mach-tegra/clock.c
parent65e02744ec1517eefb20354db61ddbd9560aba2c (diff)
downloadu-boot-a81d792479340bf03131111b285c0f70d27622b6.tar.xz
ARM: tegra: clock: add clock_decode_pair helper
Get periph clock id and its parent from device tree. This works by looking up the peripheral's 'clocks' node and reading out the second and fourth cells, which are the peripheral and PLL clock numbers. Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30 Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20 Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Signed-off-by: Tom <twarren@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/clock.c')
-rw-r--r--arch/arm/mach-tegra/clock.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 11bffc1701..966009f375 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -678,6 +678,29 @@ int clock_decode_periph_id(struct udevice *dev)
assert(clock_periph_id_isvalid(id));
return id;
}
+
+/*
+ * Get periph clock id and its parent from device tree.
+ *
+ * @param dev udevice associated with FDT node
+ * @param clk_id pointer to u32 array of 2 values
+ * first is periph clock, second is
+ * its PLL parent according to FDT.
+ */
+int clock_decode_pair(struct udevice *dev, int *clk_id)
+{
+ u32 cell[4];
+ int err;
+
+ err = dev_read_u32_array(dev, "clocks", cell, ARRAY_SIZE(cell));
+ if (err)
+ return -EINVAL;
+
+ clk_id[0] = clk_id_to_periph_id(cell[1]);
+ clk_id[1] = clk_id_to_pll_id(cell[3]);
+
+ return 0;
+}
#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
int clock_verify(void)