EMC device-tree node now contains new emc-stats sub-node which needs to
be skipped when timing nodes are parsed by EMC driver, otherwise driver
will try to parse the emc-stats as a timing node and will error out.

Signed-off-by: Dmitry Osipenko <dig...@gmail.com>
---
 drivers/memory/tegra/tegra20-emc.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/tegra/tegra20-emc.c 
b/drivers/memory/tegra/tegra20-emc.c
index 69ccb3fe5b0b..27242659dfd6 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -349,7 +349,10 @@ static int tegra_emc_load_timings_from_dt(struct tegra_emc 
*emc,
        int child_count;
        int err;
 
-       child_count = of_get_child_count(node);
+       child = of_find_node_by_name(node, "emc-stats");
+       of_node_put(child);
+
+       child_count = of_get_child_count(node) - (child ? 1 : 0);
        if (!child_count) {
                dev_err(emc->dev, "no memory timings in DT node: %pOF\n", node);
                return -EINVAL;
@@ -364,6 +367,9 @@ static int tegra_emc_load_timings_from_dt(struct tegra_emc 
*emc,
        timing = emc->timings;
 
        for_each_child_of_node(node, child) {
+               if (of_device_is_compatible(child, 
"nvidia,tegra20-emc-statistics"))
+                       continue;
+
                err = load_one_timing_from_dt(emc, timing++, child);
                if (err) {
                        of_node_put(child);
@@ -391,7 +397,11 @@ tegra_emc_find_node_by_ram_code(struct device *dev)
        u32 value, ram_code;
        int err;
 
-       if (of_get_child_count(dev->of_node) == 0) {
+       /* old device-trees don't have emc-stats node */
+       np = of_find_node_by_name(dev->of_node, "emc-stats");
+       of_node_put(np);
+
+       if (of_get_child_count(dev->of_node) == (np ? 1 : 0)) {
                dev_info(dev, "device-tree doesn't have memory timings\n");
                return NULL;
        }
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to