summaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2021-06-25 09:25:30 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-25 10:01:00 +0200
commitcd23b6facf33cc9bdaa90ea8c0479ef6959f2860 (patch)
treeac21e99434cc129425e36ca034abc30731436f7e /drivers/spi
parentb052703f0d141a1caf7dfaca16f905308e03487f (diff)
downloadbarebox-cd23b6facf33cc9bdaa90ea8c0479ef6959f2860.tar.gz
barebox-cd23b6facf33cc9bdaa90ea8c0479ef6959f2860.tar.xz
common: add initial barebox deep-probe support
The barebox 'deep probe' or 'probe on demand' mechanism is the answer of unwanted -EPROBE_DEFER failures. The EPROBE_DEFER error code was introduced by commit ab3da15bc14c ("base: Introduce deferred probing") and since then it causes a few problems. The error is returned if either the device is not yet present or the driver is not yet registered. This makes sense on linux systems where modules and hot-plug devices are used very often but not for barebox. The module support is rarely used and devices aren't hot pluggable. The current barebox behaviour populates all devices before the drivers are registered so all devices are present during the driver registration. So the driver probe() function gets called immediately after the driver registration and causes the -EPROBE_DEFER error if this driver depends on an other not yet registered driver. To get rid of the EPROBE_DEFER error code we need to reorder the device population and the driver registration. All drivers must be registered first. In an ideal world all driver can be registered by the same initcall level. Then devices are getting populated which causes calling the driver probe() function but this time resources/devices are created on demand if not yet available. Dependencies between devices are normally expressed as references to other device nodes. With deep probe barebox provides helper functions which take a device node and probe the device behind that node if necessary. This means instead of returning -EPROBE_DEFER, we can now make the desired resources available once we need them. If the resource can't be created we are returning -ENODEV since we are not supporting hot-plugging. Dropping EPROBE_DEFER is the long-term goal, avoid initcall shifting is the short-term goal. Call it deep-probe since the on-demand device creation can create very deep stacks. This commit adds the initial support for: spi, i2c, reset, regulator, gpio and clk resource on-demand creation. The deep-probe mechanism must be enabled for each board to avoid breaking changes using deep_probe_enable(). This can be changed later after all boards are converted to the new mechanism. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.pengutronix.de/20201021115813.31645-8-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210625072540.32717-10-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8421d9d7c1..d1d3bdcc41 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -107,6 +107,8 @@ struct spi_device *spi_new_device(struct spi_controller *ctrl,
if (status)
goto fail;
+ chip->device_node->dev = &proxy->dev;
+
return proxy;
fail:
free(proxy);