mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
dm: clk: Update uclass to support livetree
Update the clk uclass to support a live device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a4e0ef50da
commit
aa9bb0944a
|
@ -58,23 +58,22 @@ static int clk_of_xlate_default(struct clk *clk,
|
||||||
int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
|
int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct fdtdec_phandle_args args;
|
struct ofnode_phandle_args args;
|
||||||
struct udevice *dev_clk;
|
struct udevice *dev_clk;
|
||||||
struct clk_ops *ops;
|
struct clk_ops *ops;
|
||||||
|
|
||||||
debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
|
debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
|
||||||
|
|
||||||
assert(clk);
|
assert(clk);
|
||||||
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
|
ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
|
||||||
"clocks", "#clock-cells", 0, index,
|
index, &args);
|
||||||
&args);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n",
|
debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = uclass_get_device_by_of_offset(UCLASS_CLK, args.node, &dev_clk);
|
ret = uclass_get_device_by_ofnode(UCLASS_CLK, args.node, &dev_clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("%s: uclass_get_device_by_of_offset failed: err=%d\n",
|
debug("%s: uclass_get_device_by_of_offset failed: err=%d\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
|
@ -86,10 +85,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
|
||||||
ops = clk_dev_ops(dev_clk);
|
ops = clk_dev_ops(dev_clk);
|
||||||
|
|
||||||
if (ops->of_xlate)
|
if (ops->of_xlate)
|
||||||
ret = ops->of_xlate(clk, (struct ofnode_phandle_args *)&args);
|
ret = ops->of_xlate(clk, &args);
|
||||||
else
|
else
|
||||||
ret = clk_of_xlate_default(clk,
|
ret = clk_of_xlate_default(clk, &args);
|
||||||
(struct ofnode_phandle_args *)&args);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
debug("of_xlate() failed: %d\n", ret);
|
debug("of_xlate() failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -105,8 +103,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
|
||||||
|
|
||||||
debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk);
|
debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk);
|
||||||
|
|
||||||
index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
|
index = dev_read_stringlist_search(dev, "clock-names", name);
|
||||||
"clock-names", name);
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
debug("fdt_stringlist_search() failed: %d\n", index);
|
debug("fdt_stringlist_search() failed: %d\n", index);
|
||||||
return index;
|
return index;
|
||||||
|
|
|
@ -459,7 +459,7 @@ static int zynq_clk_probe(struct udevice *dev)
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
sprintf(name, "gem%d_emio_clk", i);
|
sprintf(name, "gem%d_emio_clk", i);
|
||||||
ret = clk_get_by_name(dev, name, &priv->gem_emio_clk[i]);
|
ret = clk_get_by_name(dev, name, &priv->gem_emio_clk[i]);
|
||||||
if (ret < 0 && ret != -FDT_ERR_NOTFOUND) {
|
if (ret < 0 && ret != -ENODATA) {
|
||||||
dev_err(dev, "failed to get %s clock\n", name);
|
dev_err(dev, "failed to get %s clock\n", name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user