Skip to content

Commit ae971cc

Browse files
jwrdegoedemchehab
authored andcommitted
media: ipu3-cio2: Defer probing until the PMIC is fully setup
On devices where things are not fully describe in devicetree (1) and where the code thus falls back to calling cio2_bridge_init(), the i2c-clients for any VCMs also need to be instantiated manually. The VCM can be probed by its driver as soon as the code instantiates the i2c-client and this probing must not happen before the PMIC is fully setup. Make cio2_bridge_init() return -EPROBE_DEFER when the PMIC is not fully-setup, deferring the probe of the ipu3-cio2 driver. This is a preparation patch for adding VCM enumeration support to the ipu3-cio2-bridge code. 1) Through embedding of devicetree info in the ACPI tables Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 86790a4 commit ae971cc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/media/pci/intel/ipu3/cio2-bridge.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,40 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge,
308308
return ret;
309309
}
310310

311+
/*
312+
* The VCM cannot be probed until the PMIC is completely setup. We cannot rely
313+
* on -EPROBE_DEFER for this, since the consumer<->supplier relations between
314+
* the VCM and regulators/clks are not described in ACPI, instead they are
315+
* passed as board-data to the PMIC drivers. Since -PROBE_DEFER does not work
316+
* for the clks/regulators the VCM i2c-clients must not be instantiated until
317+
* the PMIC is fully setup.
318+
*
319+
* The sensor/VCM ACPI device has an ACPI _DEP on the PMIC, check this using the
320+
* acpi_dev_ready_for_enumeration() helper, like the i2c-core-acpi code does
321+
* for the sensors.
322+
*/
323+
static int cio2_bridge_sensors_are_ready(void)
324+
{
325+
struct acpi_device *adev;
326+
bool ready = true;
327+
unsigned int i;
328+
329+
for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
330+
const struct cio2_sensor_config *cfg =
331+
&cio2_supported_sensors[i];
332+
333+
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
334+
if (!adev->status.enabled)
335+
continue;
336+
337+
if (!acpi_dev_ready_for_enumeration(adev))
338+
ready = false;
339+
}
340+
}
341+
342+
return ready;
343+
}
344+
311345
int cio2_bridge_init(struct pci_dev *cio2)
312346
{
313347
struct device *dev = &cio2->dev;
@@ -316,6 +350,9 @@ int cio2_bridge_init(struct pci_dev *cio2)
316350
unsigned int i;
317351
int ret;
318352

353+
if (!cio2_bridge_sensors_are_ready())
354+
return -EPROBE_DEFER;
355+
319356
bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
320357
if (!bridge)
321358
return -ENOMEM;

0 commit comments

Comments
 (0)