aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Meng2018-10-11 00:06:58 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commit8d773c4ab3f77a5a6ceed974d00083a312454660 (patch)
tree4b5411d76a591071a8f210833b6832ac03a18176 /drivers
parente601ab1bb69901420ba2c55d2f2d194a38739182 (diff)
downloadu-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.tar.gz
u-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.tar.xz
u-boot-8d773c4ab3f77a5a6ceed974d00083a312454660.zip
dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()
Currently the comments of several APIs (eg: dm_init_and_scan()) say: @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. The 'Pre-Relocation Support' chapter in doc/driver-model/README.txt documents the same that both device tree properties and driver flag are supported. However the implementation only checks these special device tree properties without checking the driver flag at all. This updates lists_bind_fdt() to consider both scenarios. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Squashed in http://patchwork.ozlabs.org/patch/996473/ : Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/device.c2
-rw-r--r--drivers/core/lists.c9
-rw-r--r--drivers/core/root.c12
-rw-r--r--drivers/misc/imx8/scu.c4
-rw-r--r--drivers/serial/serial-uclass.c2
-rw-r--r--drivers/timer/timer-uclass.c2
6 files changed, 17 insertions, 14 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5176aa3f86..47a697f3e5 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -834,5 +834,5 @@ int dev_enable_by_path(const char *path)
834 if (ret) 834 if (ret)
835 return ret; 835 return ret;
836 836
837 return lists_bind_fdt(parent, node, NULL); 837 return lists_bind_fdt(parent, node, NULL, false);
838} 838}
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index a1677269d8..a1f828463e 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -122,7 +122,8 @@ static int driver_check_compatible(const struct udevice_id *of_match,
122 return -ENOENT; 122 return -ENOENT;
123} 123}
124 124
125int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp) 125int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
126 bool pre_reloc_only)
126{ 127{
127 struct driver *driver = ll_entry_start(struct driver, driver); 128 struct driver *driver = ll_entry_start(struct driver, driver);
128 const int n_ents = ll_entry_count(struct driver, driver); 129 const int n_ents = ll_entry_count(struct driver, driver);
@@ -171,6 +172,12 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp)
171 if (entry == driver + n_ents) 172 if (entry == driver + n_ents)
172 continue; 173 continue;
173 174
175 if (pre_reloc_only) {
176 if (!dm_ofnode_pre_reloc(node) &&
177 !(entry->flags & DM_FLAG_PRE_RELOC))
178 return 0;
179 }
180
174 pr_debug(" - found match at '%s'\n", entry->name); 181 pr_debug(" - found match at '%s'\n", entry->name);
175 ret = device_bind_with_driver_data(parent, entry, name, 182 ret = device_bind_with_driver_data(parent, entry, name,
176 id->data, node, &dev); 183 id->data, node, &dev);
diff --git a/drivers/core/root.c b/drivers/core/root.c
index b54bf5bcdc..cd6a5a0276 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -222,14 +222,12 @@ static int dm_scan_fdt_live(struct udevice *parent,
222 int ret = 0, err; 222 int ret = 0, err;
223 223
224 for (np = node_parent->child; np; np = np->sibling) { 224 for (np = node_parent->child; np; np = np->sibling) {
225 if (pre_reloc_only &&
226 !of_find_property(np, "u-boot,dm-pre-reloc", NULL))
227 continue;
228 if (!of_device_is_available(np)) { 225 if (!of_device_is_available(np)) {
229 pr_debug(" - ignoring disabled device\n"); 226 pr_debug(" - ignoring disabled device\n");
230 continue; 227 continue;
231 } 228 }
232 err = lists_bind_fdt(parent, np_to_ofnode(np), NULL); 229 err = lists_bind_fdt(parent, np_to_ofnode(np), NULL,
230 pre_reloc_only);
233 if (err && !ret) { 231 if (err && !ret) {
234 ret = err; 232 ret = err;
235 debug("%s: ret=%d\n", np->name, ret); 233 debug("%s: ret=%d\n", np->name, ret);
@@ -282,14 +280,12 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
282 continue; 280 continue;
283 } 281 }
284 282
285 if (pre_reloc_only &&
286 !dm_fdt_pre_reloc(blob, offset))
287 continue;
288 if (!fdtdec_get_is_enabled(blob, offset)) { 283 if (!fdtdec_get_is_enabled(blob, offset)) {
289 pr_debug(" - ignoring disabled device\n"); 284 pr_debug(" - ignoring disabled device\n");
290 continue; 285 continue;
291 } 286 }
292 err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL); 287 err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL,
288 pre_reloc_only);
293 if (err && !ret) { 289 if (err && !ret) {
294 ret = err; 290 ret = err;
295 debug("%s: ret=%d\n", node_name, ret); 291 debug("%s: ret=%d\n", node_name, ret);
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c
index 0647ddf103..b824ac79e6 100644
--- a/drivers/misc/imx8/scu.c
+++ b/drivers/misc/imx8/scu.c
@@ -223,7 +223,7 @@ static int imx8_scu_bind(struct udevice *dev)
223 if (node < 0) 223 if (node < 0)
224 panic("No clk node found\n"); 224 panic("No clk node found\n");
225 225
226 ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child); 226 ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child, true);
227 if (ret) 227 if (ret)
228 return ret; 228 return ret;
229 229
@@ -234,7 +234,7 @@ static int imx8_scu_bind(struct udevice *dev)
234 if (node < 0) 234 if (node < 0)
235 panic("No iomuxc node found\n"); 235 panic("No iomuxc node found\n");
236 236
237 ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child); 237 ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child, true);
238 if (ret) 238 if (ret)
239 return ret; 239 return ret;
240 240
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 665cca85cb..3ded62732d 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -62,7 +62,7 @@ static int serial_check_stdout(const void *blob, struct udevice **devp)
62 * anyway. 62 * anyway.
63 */ 63 */
64 if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node), 64 if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
65 devp)) { 65 devp, false)) {
66 if (!device_probe(*devp)) 66 if (!device_probe(*devp))
67 return 0; 67 return 0;
68 } 68 }
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index fe73f71819..12ee6eb804 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -108,7 +108,7 @@ int notrace dm_timer_init(void)
108 * If the timer is not marked to be bound before 108 * If the timer is not marked to be bound before
109 * relocation, bind it anyway. 109 * relocation, bind it anyway.
110 */ 110 */
111 if (!lists_bind_fdt(dm_root(), node, &dev)) { 111 if (!lists_bind_fdt(dm_root(), node, &dev, false)) {
112 ret = device_probe(dev); 112 ret = device_probe(dev);
113 if (ret) 113 if (ret)
114 return ret; 114 return ret;