Date: Sun, 2 Mar 2014 18:56:17 -0500 From: Patrick Kelsey <kelsey@ieee.org> To: freebsd-embedded@freebsd.org Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, freebsd-arm@freebsd.org Subject: [PATCH] simplebus child device probe order control via FDT (motivated by BeagleBone Black) Message-ID: <CAD44qMUyqzaFtjgXdgThgHcHjPctx-oZAdhvHp4Kf0G7N4HVog@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--047d7beb9394b8344804f3a86a73 Content-Type: text/plain; charset=ISO-8859-1 Hi, The attached patch (fdt_probe_order_control.patch) allows control over the probe order of simplebus child devices by using a "probe-order" property in simplebus child nodes in the .dts file. This was motivated by booting FreeBSD from the eMMC on a BeagleBone Black, which has a pluggable microSD card slot in addition to the eMMC. The order that the mmc units are defined in sys/boot/fdt/dts/am335x.dtsi causes the pluggable slot to be probed/attached first, so the device name assigned to the eMMC soldered to the board changes depending on whether there is a card in the pluggable slot, which makes establishing appropriate /etc/fstab contents less than convenient. By using the "probe-order" property in sys/boot/fdt/dts/beaglebone-black.dts (see attached beaglebone_black_mmc_probe_order.patch), I am able to swap the order in which the mmc units are probed/attached for that board. This avoids inappropriate hacking of the mmc definition order in am335x.dtsi, which is shared among multiple boards. This is not a general solution to the problem of wanting stable device names for hard-wired MMC devices when pluggable slots are present in the system. There could, for example, be a multi-slot MMC controller with a mixture of hard-wired and pluggable devices attached, and this would not address that case. However, it does address the needs of BeagleBone Black, and the mechanism may be of use for similar issues on other platforms. Both patches were generated against 10-STABLE, r262447. -Patrick --047d7beb9394b8344804f3a86a73 Content-Type: application/octet-stream; name="fdt_probe_order_control.patch" Content-Disposition: attachment; filename="fdt_probe_order_control.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hsaz0nxi0 SW5kZXg6IHN5cy9kZXYvZmR0L3NpbXBsZWJ1cy5jCj09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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oJnNxLCBuZXdfc3FlLCBs aW5rKTsKKwkJCX0KKwkJfSBlbHNlIHsKKwkJCW5ld19zcWUtPnByb2JlX29yZGVyID0gUFJPQkVf VU5PUkRFUkVEOworCQkJVEFJTFFfSU5TRVJUX1RBSUwoJnNxLCBuZXdfc3FlLCBsaW5rKTsKKwkJ fQorCX0KKworCS8qCisJICogQWRkIHRoZSBxdWV1ZWQgc3Vib3JkaW5hdGVzIGFzIGNoaWxkcmVu LgorCSAqLworCVRBSUxRX0ZPUkVBQ0hfU0FGRShzcWUsICZzcSwgbGluaywgc3FlX3RtcCkgewor CQlkdF9jaGlsZCA9IHNxZS0+ZHRfY2hpbGQ7CisJCWZyZWUoc3FlLCBNX1NJTVBMRUJVUyk7CisK IAkJLyogQ2hlY2sgYW5kIHByb2Nlc3MgJ3N0YXR1cycgcHJvcGVydHkuICovCiAJCWlmICghKGZk dF9pc19lbmFibGVkKGR0X2NoaWxkKSkpCiAJCQljb250aW51ZTsK --047d7beb9394b8344804f3a86a73 Content-Type: application/octet-stream; name="beaglebone_black_probe_order.patch" Content-Disposition: attachment; filename="beaglebone_black_probe_order.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hsaz0qzm1 SW5kZXg6IHN5cy9ib290L2ZkdC9kdHMvYmVhZ2xlYm9uZS1ibGFjay5kdHMKPT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQot LS0gc3lzL2Jvb3QvZmR0L2R0cy9iZWFnbGVib25lLWJsYWNrLmR0cwkocmV2aXNpb24gMjYyNDQ3 KQorKysgc3lzL2Jvb3QvZmR0L2R0cy9iZWFnbGVib25lLWJsYWNrLmR0cwkod29ya2luZyBjb3B5 KQpAQCAtMTM2LDggKzEzNiwxMiBAQAogCQltbWNoczFANDgxRDgwMDAgewogICAgICAgICAgICAg ICAgIAlidXMtd2lkdGggPSA8OD47CiAJCQlzdGF0dXMgPSAib2theSI7CisJCQlwcm9iZS1vcmRl ciA9IDwxMDAwPjsKIAkJfTsKIAorCQltbWNoczBANDgwNjAwMDAgeworCQkJcHJvYmUtb3JkZXIg PSA8MTAwMT47CisJCX07CiAgCiAJCWkyY0A0NGUwYjAwMCB7CiAJCQlwbWljQDI0IHsK --047d7beb9394b8344804f3a86a73--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAD44qMUyqzaFtjgXdgThgHcHjPctx-oZAdhvHp4Kf0G7N4HVog>