Re: [PATCH v6 7/9] PCI: brcmstb: Add control of subdevice voltage regulators
From: Rob Herring
Date: Tue Nov 02 2021 - 12:00:34 EST
On Fri, Oct 29, 2021 at 04:03:15PM -0400, Jim Quinlan wrote:
> This Broadcom STB PCIe RC driver has one port and connects directly to one
> device, be it a switch or an endpoint. We want to be able to turn on/off
> any regulators for that device. Control of regulators is needed because of
> the chicken-and-egg situation: although the regulator is "owned" by the
> device and would be best handled by its driver, the device cannot be
> discovered and probed unless its regulator is already turned on.
I think this can be done in a much more simple way that avoids the
prior patches using the pci_ops.add_bus() (and remove_bus()) hook.
add_bus is called before the core scans a child bus. In the handler, you
just need to get the bridge device, then the bridge DT node, and then
get the regulators and enable.
Given we're talking about standard properties in a standard (bridge)
node, I think the implementation for .add_bus should be common
(drivers/pci/of.c). It doesn't scale to be doing this in every host
bridge driver.
Rob