How to configure an embedded linux device with power-cyclable hardware?
by zik from LinuxQuestions.org on (#6E9NQ)
I'm working on an embedded linux device which has a number of I2C-based GPIO expander chips. All the internal gpio expanders are powered on with the rest of the system but one gpio expander is on an external plug-in card which has to be powered on by setting an output on one of the internal gpio expanders. All the internal and external gpio expanders are the same type - pcal9535.
I've created a device tree which successfully brings up all the internal gpio expanders but I'm having problems with the external one.
To power the system on I need to have the gpio-pca953x driver come up first so all the internal expanders come up. Then I can control the output to turn on the external gpio expander. But once I've done that it's too late for the driver to probe the external expander because the probe already failed when I brought the driver up with its power turned off. And if I unload the gpio-pca953x driver entirely and reload it all the other gpios are also affected which causes problems as I'll explain later. So I really want to probe just the external expander again without affecting the internal ones.
This hardware design is intended to allow us to power cycle the external module if a failure is detected. Since the device is unattended there's no option to have a human power cycle it. Ideally we'd power cycle the external module via the power control line and then bring the drivers up again. But since the driver is shared between external and internal expanders I can't see a way to re-probe just the external expander.
FWIW the CPU is a Jetson TX2 NX module and the application is a vehicle telemetry device for fleets.
Surely this problem occurs on devices with hotplugged hardware too?
Does anyone have a good solution?
I've created a device tree which successfully brings up all the internal gpio expanders but I'm having problems with the external one.
To power the system on I need to have the gpio-pca953x driver come up first so all the internal expanders come up. Then I can control the output to turn on the external gpio expander. But once I've done that it's too late for the driver to probe the external expander because the probe already failed when I brought the driver up with its power turned off. And if I unload the gpio-pca953x driver entirely and reload it all the other gpios are also affected which causes problems as I'll explain later. So I really want to probe just the external expander again without affecting the internal ones.
This hardware design is intended to allow us to power cycle the external module if a failure is detected. Since the device is unattended there's no option to have a human power cycle it. Ideally we'd power cycle the external module via the power control line and then bring the drivers up again. But since the driver is shared between external and internal expanders I can't see a way to re-probe just the external expander.
FWIW the CPU is a Jetson TX2 NX module and the application is a vehicle telemetry device for fleets.
Surely this problem occurs on devices with hotplugged hardware too?
Does anyone have a good solution?