summaryrefslogtreecommitdiffstats
path: root/sys/dev/extres/clk/clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/extres/clk/clk.c')
-rw-r--r--sys/dev/extres/clk/clk.c79
1 files changed, 77 insertions, 2 deletions
diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c
index f1ed098..07cbd6b 100644
--- a/sys/dev/extres/clk/clk.c
+++ b/sys/dev/extres/clk/clk.c
@@ -487,10 +487,10 @@ clkdom_dump(struct clkdom * clkdom)
CLK_TOPO_SLOCK();
TAILQ_FOREACH(clknode, &clkdom->clknode_list, clkdom_link) {
rv = clknode_get_freq(clknode, &freq);
- printf("Clock: %s, parent: %s(%d), freq: %llu\n", clknode->name,
+ printf("Clock: %s, parent: %s(%d), freq: %ju\n", clknode->name,
clknode->parent == NULL ? "(NULL)" : clknode->parent->name,
clknode->parent_idx,
- ((rv == 0) ? freq: rv));
+ (uintmax_t)((rv == 0) ? freq: rv));
}
CLK_TOPO_UNLOCK();
}
@@ -818,6 +818,10 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags,
/* We have exclusive topology lock, node lock is not needed. */
CLK_TOPO_XASSERT();
+ /* Check for no change */
+ if (clknode->freq == freq)
+ return (0);
+
parent_freq = 0;
/*
@@ -1258,4 +1262,75 @@ clk_get_by_ofw_name(device_t dev, const char *name, clk_t *clk)
return (rv);
return (clk_get_by_ofw_index(dev, idx, clk));
}
+
+/* --------------------------------------------------------------------------
+ *
+ * Support functions for parsing various clock related OFW things.
+ */
+
+/*
+ * Get "clock-output-names" and (optional) "clock-indices" lists.
+ * Both lists are alocated using M_OFWPROP specifier.
+ *
+ * Returns number of items or 0.
+ */
+int
+clk_parse_ofw_out_names(device_t dev, phandle_t node, const char ***out_names,
+ uint32_t **indices)
+{
+ int name_items, rv;
+
+ *out_names = NULL;
+ *indices = NULL;
+ if (!OF_hasprop(node, "clock-output-names"))
+ return (0);
+ rv = ofw_bus_string_list_to_array(node, "clock-output-names",
+ out_names);
+ if (rv <= 0)
+ return (0);
+ name_items = rv;
+
+ if (!OF_hasprop(node, "clock-indices"))
+ return (name_items);
+ rv = OF_getencprop_alloc(node, "clock-indices", sizeof (uint32_t),
+ (void **)indices);
+ if (rv != name_items) {
+ device_printf(dev, " Size of 'clock-output-names' and "
+ "'clock-indices' differs\n");
+ free(*out_names, M_OFWPROP);
+ free(*indices, M_OFWPROP);
+ return (0);
+ }
+ return (name_items);
+}
+
+/*
+ * Get output clock name for single output clock node.
+ */
+int
+clk_parse_ofw_clk_name(device_t dev, phandle_t node, const char **name)
+{
+ const char **out_names;
+ const char *tmp_name;
+ int rv;
+
+ *name = NULL;
+ if (!OF_hasprop(node, "clock-output-names")) {
+ tmp_name = ofw_bus_get_name(dev);
+ if (tmp_name == NULL)
+ return (ENXIO);
+ *name = strdup(tmp_name, M_OFWPROP);
+ return (0);
+ }
+ rv = ofw_bus_string_list_to_array(node, "clock-output-names",
+ &out_names);
+ if (rv != 1) {
+ free(out_names, M_OFWPROP);
+ device_printf(dev, "Malformed 'clock-output-names' property\n");
+ return (ENXIO);
+ }
+ *name = strdup(out_names[0], M_OFWPROP);
+ free(out_names, M_OFWPROP);
+ return (0);
+}
#endif
OpenPOWER on IntegriCloud