Date: Fri, 9 Dec 2016 21:00:16 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r309769 - stable/11/sys/dev/extres/clk Message-ID: <201612092100.uB9L0G4J061896@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Fri Dec 9 21:00:16 2016 New Revision: 309769 URL: https://svnweb.freebsd.org/changeset/base/309769 Log: MFC r308298, r308440 r308298: Add clk_set_assigned assigned-clock-parents are DT properties used to configure some default parent clocks on one node. Reviewed by: mmel r308440: Do not warn if the 'assigned-clock-parents' property does not exists. Modified: stable/11/sys/dev/extres/clk/clk.c stable/11/sys/dev/extres/clk/clk.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/extres/clk/clk.c ============================================================================== --- stable/11/sys/dev/extres/clk/clk.c Fri Dec 9 20:57:43 2016 (r309768) +++ stable/11/sys/dev/extres/clk/clk.c Fri Dec 9 21:00:16 2016 (r309769) @@ -1196,7 +1196,49 @@ clk_get_by_id(device_t dev, struct clkdo #ifdef FDT int -clk_get_by_ofw_index(device_t dev, phandle_t cnode, int idx, clk_t *clk) +clk_set_assigned(device_t dev, phandle_t node) +{ + clk_t clk, clk_parent; + int error, nclocks, i; + + error = ofw_bus_parse_xref_list_get_length(node, + "assigned-clock-parents", "#clock-cells", &nclocks); + + if (error != 0) { + if (error != ENOENT) + device_printf(dev, + "cannot parse assigned-clock-parents property\n"); + return (error); + } + + for (i = 0; i < nclocks; i++) { + error = clk_get_by_ofw_index_prop(dev, 0, + "assigned-clock-parents", i, &clk_parent); + if (error != 0) { + device_printf(dev, "cannot get parent %d\n", i); + return (error); + } + + error = clk_get_by_ofw_index_prop(dev, 0, "assigned-clocks", + i, &clk); + if (error != 0) { + device_printf(dev, "cannot get assigned clock %d\n", i); + clk_release(clk_parent); + return (error); + } + + error = clk_set_parent_by_clk(clk, clk_parent); + clk_release(clk_parent); + clk_release(clk); + if (error != 0) + return (error); + } + + return (0); +} + +int +clk_get_by_ofw_index_prop(device_t dev, phandle_t cnode, const char *prop, int idx, clk_t *clk) { phandle_t parent, *cells; device_t clockdev; @@ -1214,7 +1256,7 @@ clk_get_by_ofw_index(device_t dev, phand } - rv = ofw_bus_parse_xref_list_alloc(cnode, "clocks", "#clock-cells", idx, + rv = ofw_bus_parse_xref_list_alloc(cnode, prop, "#clock-cells", idx, &parent, &ncells, &cells); if (rv != 0) { return (rv); @@ -1247,6 +1289,12 @@ done: } int +clk_get_by_ofw_index(device_t dev, phandle_t cnode, int idx, clk_t *clk) +{ + return (clk_get_by_ofw_index_prop(dev, cnode, "clocks", idx, clk)); +} + +int clk_get_by_ofw_name(device_t dev, phandle_t cnode, const char *name, clk_t *clk) { int rv, idx; Modified: stable/11/sys/dev/extres/clk/clk.h ============================================================================== --- stable/11/sys/dev/extres/clk/clk.h Fri Dec 9 20:57:43 2016 (r309768) +++ stable/11/sys/dev/extres/clk/clk.h Fri Dec 9 21:00:16 2016 (r309769) @@ -129,7 +129,9 @@ int clk_set_parent_by_clk(clk_t clk, clk const char *clk_get_name(clk_t clk); #ifdef FDT +int clk_set_assigned(device_t dev, phandle_t node); int clk_get_by_ofw_index(device_t dev, phandle_t node, int idx, clk_t *clk); +int clk_get_by_ofw_index_prop(device_t dev, phandle_t cnode, const char *prop, int idx, clk_t *clk); int clk_get_by_ofw_name(device_t dev, phandle_t node, const char *name, clk_t *clk); int clk_parse_ofw_out_names(device_t dev, phandle_t node,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612092100.uB9L0G4J061896>