Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
* Power domain configuration for a i2c module
@ 2019-06-20 22:18 Philip Molloy
  2019-08-15 15:57 ` Philip Molloy
  0 siblings, 1 reply; 2+ messages in thread
From: Philip Molloy @ 2019-06-20 22:18 UTC (permalink / raw)
  To: linux-pm

Hi,

I could use a little help understanding how to set up a power domain for a i2c module. I have corresponding drivers for each i2c device on the module. The i2c devices are all behind a i2c-mux-gpio and a physical i2c mux due to some interesting hardware design choices. I have written a module power driver that hooks up a power GPIO pin to the runtime power management subsystem by implementing dev_pm_ops, calling pm_runtime_enable(), etc.

In the device tree node corresponding to the module power driver I have added `#power-domain-cells = <0>;` to configure it as a provider. And for each i2c device on the module I've added `power-domains` and `power-domains-names` to configure them as consumers.

I'm stuck on what I need to implement to hook this all up. I've done a fair amount of reading, debugging and looking for examples, but it still isn't evident to me what is done automatically and what I need to implement. For example, i2c-mux-gpio is a platform driver and dev_pm_domain_attach(dev, true) is called from platform_drv_probe() so I thought the domain might just power on when i2c-mux-gpio is probed, but that's not what I experienced. Note, my module power driver is also a platform driver.

Any help would be greatly appreciated.

Best,
Philip

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Power domain configuration for a i2c module
  2019-06-20 22:18 Power domain configuration for a i2c module Philip Molloy
@ 2019-08-15 15:57 ` Philip Molloy
  0 siblings, 0 replies; 2+ messages in thread
From: Philip Molloy @ 2019-08-15 15:57 UTC (permalink / raw)
  To: linux-pm; +Cc: Kevin Hilman

Hello,

I've setup a power domain, but I'm having trouble understanding how the domain's power management callbacks are called when a i2c driver is probed.

The domain is intended to cover two external modules. The power to both modules is controlled by a single GPIO. I intend to add several drivers to the domain including drivers for several i2c devices and a MMIO driver to access data streamed from the modules. I've started with one provider and two consumers.

The provider calls pm_genpd_init() and of_genpd_add_provider_simple(). It also implements power_on() and power_of().

provider@0 {
    ...
    power-gpio = <&gpio XX GPIO_ACTIVE_HIGH>;
    ready-gpio = <&gpio XX GPIO_ACTIVE_HIGH>;
    #power-domain-cells = <0>;
};

The consumers are two physical I2C switches:

i2c-mux-gpio {
    compatible = "i2c-mux-gpio";
    ...

    module@1 {
        ...

        tca9543@70 {
            compatible = "nxp,pca943";
            ...
            power-domains = <&provider 0>;
            power-domain-names = "provider";
        };
    };

    module@2 {
        // Same as above
    };
};

When I modprobe i2c-mux-mpca954x it is successfully added to the domain, but probe fails when calling i2c_smbus_write_byte() to verify the mux is present. That is because the modules are not powered on, because the power domain callbacks were not called.

I feel like there are a number of ways this could work. My assumption would be that the i2c driver subsystem would make sure the device is powered on before probe is called. i2c_device_probe() does call dev_pm_domain_attach() before calling driver->probe(), but I don't see where it would power on the device. i2c-mux-pca954x implements a resume callback so I assume it doesn't require any changes.

Any clarity would be greatly appreciated.

Best,
Philip

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 22:18 Power domain configuration for a i2c module Philip Molloy
2019-08-15 15:57 ` Philip Molloy

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org linux-pm@archiver.kernel.org
	public-inbox-index linux-pm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox