Skip to contentSkip to conversation

A question on device initialization ordering

DISCUSSION Joshua Scott 2 participants 2 messages Apr 21, 2015 – Apr 22, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

SGksDQoNCkkgaGF2ZSBhIHF1ZXN0aW9uIGFib3V0IHRoZSBvcmRlciBpbiB3aGljaCBkZXZpY2Vz IGFyZSBpbml0aWFsaXplZC4NCg0KVGhlIHNpbXBsZXIgY2FzZSBpcyB0aGlzOiBBIGRldmljZSBY IG5lZWRzIHRvIGJlIHRha2VuIG91dCBvZiByZXNldCBieSANCmFub3RoZXIgZGV2aWNlIFkgYmVm b3JlIGl0IGNhbiBiZSB1c2VkLg0KDQpUbyBnZXQgdGhpcyB0byB3b3JrLCBvbmUgb3B0aW9uIGlz IHRvIG1vZGlmeSB0aGUgZHJpdmVyIGZvciBZIHRvIHVzZSANCmFyY2hfaW5pdGNhbGwgaW5zdGVh ZCBvZiBkZXZpY2VfaW5pdGNhbGwuIFRoaXMgcmVzdWx0cyBpbiBpdCBiZWluZyBydW4gDQpmaXJz dCwgc28gdGhhdCB0aGUgb3RoZXIgZGV2aWNlIFggaXMgb3V0IG9mIHJlc2V0IGJ5IHRoZSB0aW1l IGl0IGlzIA0KaW5pdGlhbGl6ZWQuDQoNCklzIGl0IHBvc3NpYmxlIHdpdGhpbiB0aGUgZGV2aWNl dHJlZSB0byBzcGVjaWZ5IHRoYXQgb25lIGRldmljZSBtdXN0IGJlIA0KaW5pdGlhbGl6ZWQgYmVm b3JlIGF0dGVtcHRpbmcgdG8gaW5pdGlhbGl6ZSBhbm90aGVyICh0byBhdm9pZCBuZWVkaW5nIHRv IA0KbW9kaWZ5IHRoZSBkcml2ZXIpPw0KDQoNCg0KQSBjaGlja2VuLWFuZC1lZ2cgY2FzZTogV2hh dCBpZiB0d28gZGV2aWNlcyB1c2UgYSBjb21tb24gZHJpdmVyLCBidXQgb25lIA0KbXVzdCBmaXJz dCBiZSB1c2VkIHRvIGJyaW5nIHRoZSBvdGhlciBvdXQgb2YgcmVzZXQ/IEVnOiBBIEdQSU8gZXhw YW5kZXIgDQp0aGF0IGlzIGhlbGQgaW4gcmVzZXQgYnkgYW5vdGhlciBHUElPIGV4cGFuZGVyLg0K DQpUaGUgZ29hbCB3b3VsZCBiZSB0bzoNCiAgMS4gSW5pdGlhbGl6ZSB0aGUgZmlyc3QgR1BJTyBl eHBhbmRlcg0KICAyLiBSdW4gYSBkcml2ZXIgdGhhdCB0YWtlcyB0aGUgc2Vjb25kIGV4cGFuZGVy IG91dCBvZiByZXNldCB1c2luZyB0aGUgDQpmaXJzdA0KICAzLiBJbml0aWFsaXplIHRoZSBzZWNv bmQgR1BJTyBleHBhbmRlciAod2hpY2ggdXNlcyB0aGUgc2FtZSBkcml2ZXIgYXMgDQp0aGUgZmly c3QpLg0KDQpJbiB0aGlzIGNhc2UsIGJlY2F1c2UgdGhlIGRyaXZlcnMgZm9yIHN0ZXAgMSBhbmQg c3RlcCAzIGFyZSB0aGUgc2FtZSANCmRyaXZlciwgaXQgaXMgbm90IHBvc3NpYmxlIHRvIGFkanVz dCB0aGUgX2luaXRjYWxsIG9mIHRoZSBkcml2ZXIgZm9yIA0Kc3RlcCAyIHRvIGJlIGluLWJldHdl ZW4gdGhlbS4NCg0KSXMgdGhlcmUgYSB3YXkgdG8gZGVzY3JpYmUgdGhpcyBzaXR1YXRpb24gaW4g YSBkZXZpY2V0cmVlIHN1Y2ggdGhhdCB0aGUgDQpkcml2ZXIgZm9yIHN0ZXAgMiBnZXRzIHJ1biBp bi1iZXR3ZWVuIHdoZW4gdGhlIGZpcnN0IGFuZCBzZWNvbmQgR1BJTyANCmV4cGFuZGVycyBhcmUg aW5pdGlhbGl6ZWQ/DQoNCg0KVGhhbmsgeW91LA0KSm9zaHVhIFNjb3R0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5535EC16.4030609-6g8wRflRTwXFdCa3tKVlE6U/[email protected]

#2 lore raw

Hi Joshua,

Quoted 27 lines · Joshua Scott

I have a question about the order in which devices are initialized.

The simpler case is this: A device X needs to be taken out of reset by another device Y before it can be used.

To get this to work, one option is to modify the driver for Y to use arch_initcall instead of device_initcall. This results in it being run first, so that the other device X is out of reset by the time it is initialized.

Is it possible within the devicetree to specify that one device must be initialized before attempting to initialize another (to avoid needing to modify the driver)?

A chicken-and-egg case: What if two devices use a common driver, but one must first be used to bring the other out of reset? Eg: A GPIO expander that is held in reset by another GPIO expander.

The goal would be to:
1. Initialize the first GPIO expander
2. Run a driver that takes the second expander out of reset using the
first
3. Initialize the second GPIO expander (which uses the same driver as
the first).

Quoted 7 lines

In this case, because the drivers for step 1 and step 3 are the same driver, it is not possible to adjust the _initcall of the driver for step 2 to be in-between them.

Is there a way to describe this situation in a devicetree such that the driver for step 2 gets run in-between when the first and second GPIO expanders are initialized?

If the devices that need to be initialized last are on a child bus, you have to describe that child bus in DT, and it should just work.

If all devices are on the same bus, you could add a phandle pointing to the node for device Y to the node for device X. The driver checks the phandle, and returns -EPROBE_DEFER if it doesn't point to an initialized device yet. That does impact the binding of device X, and requires code changes to the driver for device X.

If this is a generic feature that's required on several devices, it doesn't make sense to change the bindings and driver code for all affected drivers (the driver may be used on another SoC that doesn't have the requirement), you have to group the devices somehow and handle it in a more generic way. Perhaps using PM Domains?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html