iio: magn: ak8975: deploy runtime and system PM
This adds runtime PM support to the AK8975 driver. It solves two problems: - After reading the first value the chip was left in MODE_ONCE, meaning (presumably) it may be consuming more power. Now the runtime PM hooks kick in and set it to POWER_DOWN. - Regulators were simply enabled and left on, making it impossible to turn the power consuming regulators off because of the increased refcount. We now disable the regulators at autosuspend. - We also handle system suspend: by using pm_runtime_force_suspend() and pm_runtime_force_resume() from the system PM sleep hooks, the runtime PM code is managing the power also for this case. It is currently not completely optimal: when the system resumes the AK8975 goes into active mode even if noone is going to use it: currently the force calls need to be paired, but the runtime PM people are working on making it possible to leave devices runtime suspended when coming back from sleep. Inspired by my work on the BH1780 light sensor driver. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Showing
Please register or sign in to comment