aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 00:17:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 00:17:00 -0500
commit92a578b064d0227a3a7fbbdb9e29dbab7f8d400e (patch)
tree1979a62f38e24997a7312c4ce753860cc95b389b
parentc75059c46293adf1560162c17148ab94624f5ed2 (diff)
parente3d857e1ae787a5e268bc89425aadae09c8e95a4 (diff)
Merge tag 'pm+acpi-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: "This time we have some more new material than we used to have during the last couple of development cycles. The most important part of it to me is the introduction of a unified interface for accessing device properties provided by platform firmware. It works with Device Trees and ACPI in a uniform way and drivers using it need not worry about where the properties come from as long as the platform firmware (either DT or ACPI) makes them available. It covers both devices and "bare" device node objects without struct device representation as that turns out to be necessary in some cases. This has been in the works for quite a few months (and development cycles) and has been approved by all of the relevant maintainers. On top of that, some drivers are switched over to the new interface (at25, leds-gpio, gpio_keys_polled) and some additional changes are made to the core GPIO subsystem to allow device drivers to manipulate GPIOs in the "canonical" way on platforms that provide GPIO information in their ACPI tables, but don't assign names to GPIO lines (in which case the driver needs to do that on the basis of what it knows about the device in question). That also has been approved by the GPIO core maintainers and the rfkill driver is now going to use it. Second is support for hardware P-states in the intel_pstate driver. It uses CPUID to detect whether or not the feature is supported by the processor in which case it will be enabled by default. However, it can be disabled entirely from the kernel command line if necessary. Next is support for a platform firmware interface based on ACPI operation regions used by the PMIC (Power Management Integrated Circuit) chips on the Intel Baytrail-T and Baytrail-T-CR platforms. That interface is used for manipulating power resources and for thermal management: sensor temperature reporting, trip point setting and so on. Also the ACPI core is now going to support the _DEP configuration information in a limited way. Basically, _DEP it supposed to reflect off-the-hierarchy dependencies between devices which may be very indirect, like when AML for one device accesses locations in an operation region handled by another device's driver (usually, the device depended on this way is a serial bus or GPIO controller). The support added this time is sufficient to make the ACPI battery driver work on Asus T100A, but it is general enough to be able to cover some other use cases in the future. Finally, we have a new cpufreq driver for the Loongson1B processor. In addition to the above, there are fixes and cleanups all over the place as usual and a traditional ACPICA update to a recent upstream release. As far as the fixes go, the ACPI LPSS (Low-power Subsystem) driver for Intel platforms should be able to handle power management of the DMA engine correctly, the cpufreq-dt driver should interact with the thermal subsystem in a better way and the ACPI backlight driver should handle some more corner cases, among other things. On top of the ACPICA update there are fixes for race conditions in the ACPICA's interrupt handling code which might lead to some random and strange looking failures on some systems. In the cleanups department the most visible part is the series of commits targeted at getting rid of the CONFIG_PM_RUNTIME configuration option. That was triggered by a discussion regarding the generic power domains code during which we realized that trying to support certain combinations of PM config options was painful and not really worth it, because nobody would use them in production anyway. For this reason, we decided to make CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and that lead to the conclusion that the latter became redundant and CONFIG_PM could be used instead of it. The material here makes that replacement in a major part of the tree, but there will be at least one more batch of that in the second part of the merge window. Specifics: - Support for retrieving device properties information from ACPI _DSD device configuration objects and a unified device properties interface for device drivers (and subsystems) on top of that. As stated above, this works with Device Trees and ACPI and allows device drivers to be written in a platform firmware (DT or ACPI) agnostic way. The at25, leds-gpio and gpio_keys_polled drivers are now going to use this new interface and the GPIO subsystem is additionally modified to allow device drivers to assign names to GPIO resources returned by ACPI _CRS objects (in case _DSD is not present or does not provide the expected data). The changes in this set are mostly from Mika Westerberg, Rafael J Wysocki, Aaron Lu, and Darren Hart with some fixes from others (Fabio Estevam, Geert Uytterhoeven). - Support for Hardware Managed Performance States (HWP) as described in Volume 3, section 14.4, of the Intel SDM in the intel_pstate driver. CPUID is used to detect whether or not the feature is supported by the processor. If supported, it will be enabled automatically unless the intel_pstate=no_hwp switch is present in the kernel command line. From Dirk Brandewie. - New Intel Broadwell-H ID for intel_pstate (Dirk Brandewie). - Support for firmware interface based on ACPI operation regions used by the PMIC chips on the Intel Baytrail-T and Baytrail-T-CR platforms for power resource control and thermal management (Aaron Lu). - Limited support for retrieving off-the-hierarchy dependencies between devices from ACPI _DEP device configuration objects and deferred probing support for the ACPI battery driver based on the _DEP information to make that driver work on Asus T100A (Lan Tianyu). - New cpufreq driver for the Loongson1B processor (Kelvin Cheung). - ACPICA update to upstream revision 20141107 which only affects tools (Bob Moore). - Fixes for race conditions in the ACPICA's interrupt handling code and in the ACPI code related to system suspend and resume (Lv Zheng and Rafael J Wysocki). - ACPI core fix for an RCU-related issue in the ioremap() regions management code that slowed down significantly after CPUs had been allowed to enter idle states even if they'd had RCU callbakcs queued and triggered some problems in certain proprietary graphics driver (and elsewhere). The fix replaces synchronize_rcu() in that code with synchronize_rcu_expedited() which makes the issue go away. From Konstantin Khlebnikov. - ACPI LPSS (Low-Power Subsystem) driver fix to handle power management of the DMA engine included into the LPSS correctly. The problem is that the DMA engine doesn't have ACPI PM support of its own and it simply is turned off when the last LPSS device having ACPI PM support goes into D3cold. To work around that, the PM domain used by the ACPI LPSS driver is redesigned so at least one device with ACPI PM support will be on as long as the DMA engine is in use. From Andy Shevchenko. - ACPI backlight driver fix to avoid using it on "Win8-compatible" systems where it doesn't work and where it was used by default by mistake (Aaron Lu). - Assorted minor ACPI core fixes and cleanups from Tomasz Nowicki, Sudeep Holla, Huang Rui, Hanjun Guo, Fabian Frederick, and Ashwin Chaugule (mostly related to the upcoming ARM64 support). - Intel RAPL (Running Average Power Limit) power capping driver fixes and improvements including new processor IDs (Jacob Pan). - Generic power domains modification to power up domains after attaching devices to them to meet the expectations of device drivers and bus types assuming devices to be accessible at probe time (Ulf Hansson). - Preliminary support for controlling device clocks from the generic power domains core code and modifications of the ARM/shmobile platform to use that feature (Ulf Hansson). - Assorted minor fixes and cleanups of the generic power domains core code (Ulf Hansson, Geert Uytterhoeven). - Assorted minor fixes and cleanups of the device clocks control code in the PM core (Geert Uytterhoeven, Grygorii Strashko). - Consolidation of device power management Kconfig options by making CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and removing the latter which is now redundant (Rafael J Wysocki and Kevin Hilman). That is the first batch of the changes needed for this purpose. - Core device runtime power management support code cleanup related to the execution of callbacks (Andrzej Hajda). - cpuidle ARM support improvements (Lorenzo Pieralisi). - cpuidle cleanup related to the CPUIDLE_FLAG_TIME_VALID flag and a new MAINTAINERS entry for ARM Exynos cpuidle (Daniel Lezcano and Bartlomiej Zolnierkiewicz). - New cpufreq driver callback (->ready) to be executed when the cpufreq core is ready to use a given policy object and cpufreq-dt driver modification to use that callback for cooling device registration (Viresh Kumar). - cpufreq core fixes and cleanups (Viresh Kumar, Vince Hsu, James Geboski, Tomeu Vizoso). - Assorted fixes and cleanups in the cpufreq-pcc, intel_pstate, cpufreq-dt, pxa2xx cpufreq drivers (Lenny Szubowicz, Ethan Zhao, Stefan Wahren, Petr Cvek). - OPP (Operating Performance Points) framework modification to allow OPPs to be removed too and update of a few cpufreq drivers (cpufreq-dt, exynos5440, imx6q, cpufreq) to remove OPPs (added during initialization) on driver removal (Viresh Kumar). - Hibernation core fixes and cleanups (Tina Ruchandani and Markus Elfring). - PM Kconfig fix related to CPU power management (Pankaj Dubey). - cpupower tool fix (Prarit Bhargava)" * tag 'pm+acpi-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (120 commits) i2c-omap / PM: Drop CONFIG_PM_RUNTIME from i2c-omap.c dmaengine / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM tools: cpupower: fix return checks for sysfs_get_idlestate_count() drivers: sh / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM e1000e / igb / PM: Eliminate CONFIG_PM_RUNTIME MMC / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM MFD / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM misc / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM input / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM leds: leds-gpio: Fix multiple instances registration without 'label' property iio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hsi / OMAP / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM i2c-hid / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM drm / exynos / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM gpio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hwrandom / exynos / PM: Use CONFIG_PM in #ifdef block / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM USB / PM: Drop CONFIG_PM_RUNTIME from the USB core PM: Merge the SET*_RUNTIME_PM_OPS() macros ...
-rw-r--r--Documentation/ABI/stable/sysfs-bus-usb14
-rw-r--r--Documentation/ABI/testing/sysfs-bus-usb19
-rw-r--r--Documentation/acpi/gpio-properties.txt96
-rw-r--r--Documentation/cpu-freq/intel-pstate.txt37
-rw-r--r--Documentation/devicetree/bindings/arm/idle-states.txt20
-rw-r--r--Documentation/gpio/consumer.txt18
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--Documentation/usb/power-management.txt17
-rw-r--r--MAINTAINERS10
-rw-r--r--arch/arm/include/asm/cpuidle.h1
-rw-r--r--arch/arm/mach-davinci/cpuidle.c1
-rw-r--r--arch/arm/mach-imx/cpuidle-imx5.c1
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6q.c3
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6sl.c3
-rw-r--r--arch/arm/mach-omap2/cpuidle34xx.c7
-rw-r--r--arch/arm/mach-omap2/cpuidle44xx.c5
-rw-r--r--arch/arm/mach-s3c24xx/h1940-bluetooth.c4
-rw-r--r--arch/arm/mach-s3c24xx/h1940.h4
-rw-r--r--arch/arm/mach-s3c24xx/mach-h1940.c3
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c3
-rw-r--r--arch/arm/mach-s3c64xx/cpuidle.c1
-rw-r--r--arch/arm/mach-shmobile/pm-r8a7779.c3
-rw-r--r--arch/arm/mach-shmobile/pm-rmobile.c3
-rw-r--r--arch/arm/mach-shmobile/pm-sh7372.c4
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra114.c1
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra20.c3
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra30.c1
-rw-r--r--arch/arm/plat-orion/gpio.c3
-rw-r--r--arch/arm/plat-orion/include/plat/orion-gpio.h5
-rw-r--r--arch/ia64/Kconfig2
-rw-r--r--arch/mips/include/asm/idle.h1
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/kernel/cpu/shmobile/cpuidle.c3
-rw-r--r--arch/x86/include/asm/cpufeature.h5
-rw-r--r--arch/x86/include/uapi/asm/msr-index.h41
-rw-r--r--arch/x86/kernel/apm_32.c1
-rw-r--r--arch/x86/kernel/cpu/scattered.c5
-rw-r--r--block/blk-core.c6
-rw-r--r--block/elevator.c2
-rw-r--r--drivers/acpi/Kconfig36
-rw-r--r--drivers/acpi/Makefile5
-rw-r--r--drivers/acpi/acpi_lpss.c98
-rw-r--r--drivers/acpi/acpica/acglobal.h1
-rw-r--r--drivers/acpi/acpica/aclocal.h4
-rw-r--r--drivers/acpi/acpica/evgpe.c9
-rw-r--r--drivers/acpi/acpica/hwgpe.c53
-rw-r--r--drivers/acpi/acpica/utresrc.c2
-rw-r--r--drivers/acpi/acpica/utxface.c4
-rw-r--r--drivers/acpi/acpica/utxfinit.c11
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/device_pm.c10
-rw-r--r--drivers/acpi/internal.h6
-rw-r--r--drivers/acpi/osl.c8
-rw-r--r--drivers/acpi/pci_irq.c2
-rw-r--r--drivers/acpi/pmic/intel_pmic.c354
-rw-r--r--drivers/acpi/pmic/intel_pmic.h25
-rw-r--r--drivers/acpi/pmic/intel_pmic_crc.c211
-rw-r--r--drivers/acpi/pmic/intel_pmic_xpower.c268
-rw-r--r--drivers/acpi/processor_idle.c20
-rw-r--r--drivers/acpi/property.c551
-rw-r--r--drivers/acpi/scan.c214
-rw-r--r--drivers/acpi/sleep.c2
-rw-r--r--drivers/acpi/tables.c68
-rw-r--r--drivers/acpi/utils.c5
-rw-r--r--drivers/acpi/video.c15
-rw-r--r--drivers/amba/bus.c2
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/power/clock_ops.c150
-rw-r--r--drivers/base/power/domain.c147
-rw-r--r--drivers/base/power/domain_governor.c11
-rw-r--r--drivers/base/power/opp.c196
-rw-r--r--drivers/base/power/power.h56
-rw-r--r--drivers/base/power/qos.c5
-rw-r--r--drivers/base/power/runtime.c76
-rw-r--r--drivers/base/power/sysfs.c19
-rw-r--r--drivers/base/property.c431
-rw-r--r--drivers/char/hw_random/exynos-rng.c2
-rw-r--r--drivers/cpufreq/Kconfig57
-rw-r--r--drivers/cpufreq/Kconfig.arm8
-rw-r--r--drivers/cpufreq/Makefile4
-rw-r--r--drivers/cpufreq/arm_big_little.c7
-rw-r--r--drivers/cpufreq/arm_big_little.h5
-rw-r--r--drivers/cpufreq/arm_big_little_dt.c1
-rw-r--r--drivers/cpufreq/cpufreq-dt.c66
-rw-r--r--drivers/cpufreq/cpufreq.c53
-rw-r--r--drivers/cpufreq/exynos5440-cpufreq.c5
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c11
-rw-r--r--drivers/cpufreq/intel_pstate.c146
-rw-r--r--drivers/cpufreq/ls1x-cpufreq.c223
-rw-r--r--drivers/cpufreq/pcc-cpufreq.c7
-rw-r--r--drivers/cpuidle/cpuidle-arm64.c14
-rw-r--r--drivers/cpuidle/cpuidle-at91.c1
-rw-r--r--drivers/cpuidle/cpuidle-big_little.c6
-rw-r--r--drivers/cpuidle/cpuidle-calxeda.c1
-rw-r--r--drivers/cpuidle/cpuidle-cps.c7
-rw-r--r--drivers/cpuidle/cpuidle-exynos.c1
-rw-r--r--drivers/cpuidle/cpuidle-kirkwood.c1
-rw-r--r--drivers/cpuidle/cpuidle-mvebu-v7.c8
-rw-r--r--drivers/cpuidle/cpuidle-powernv.c6
-rw-r--r--drivers/cpuidle/cpuidle-pseries.c3
-rw-r--r--drivers/cpuidle/cpuidle-ux500.c3
-rw-r--r--drivers/cpuidle/cpuidle-zynq.c1
-rw-r--r--drivers/cpuidle/driver.c1
-rw-r--r--drivers/cpuidle/dt_idle_states.c12
-rw-r--r--drivers/cpuidle/governors/ladder.c2
-rw-r--r--drivers/cpuidle/governors/menu.c2
-rw-r--r--drivers/dma/dw/core.c11
-rw-r--r--drivers/dma/nbpfaxi.c2
-rw-r--r--drivers/dma/ste_dma40.c2
-rw-r--r--drivers/dma/tegra20-apb-dma.c2
-rw-r--r--drivers/gpio/devres.c32
-rw-r--r--drivers/gpio/gpio-omap.c8
-rw-r--r--drivers/gpio/gpio-sch.c293
-rw-r--r--drivers/gpio/gpio-zynq.c2
-rw-r--r--drivers/gpio/gpiolib-acpi.c117
-rw-r--r--drivers/gpio/gpiolib.c85
-rw-r--r--drivers/gpio/gpiolib.h7
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimc.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_g2d.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gsc.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_rotator.c2
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c2
-rw-r--r--drivers/hsi/controllers/omap_ssi.c2
-rw-r--r--drivers/hsi/controllers/omap_ssi_port.c2
-rw-r--r--drivers/i2c/busses/i2c-hix5hd2.c2
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c2
-rw-r--r--drivers/i2c/busses/i2c-omap.c2
-rw-r--r--drivers/i2c/i2c-core.c1
-rw-r--r--drivers/idle/intel_idle.c108
-rw-r--r--drivers/iio/accel/bmc150-accel.c4
-rw-r--r--drivers/iio/accel/kxcjk-1013.c4
-rw-r--r--drivers/iio/gyro/bmg160.c4
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c112
-rw-r--r--drivers/input/keyboard/samsung-keypad.c2
-rw-r--r--drivers/input/touchscreen/cyttsp4_core.c2
-rw-r--r--drivers/leds/leds-gpio.c150
-rw-r--r--drivers/media/platform/coda/coda-common.c4
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c6
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is-i2c.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c2
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c2
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c4
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_pm.c10
-rw-r--r--drivers/mfd/ab8500-gpadc.c2
-rw-r--r--drivers/mfd/arizona-core.c4
-rw-r--r--drivers/mfd/axp20x.c3
-rw-r--r--drivers/mfd/intel_soc_pmic_crc.c3
-rw-r--r--drivers/mfd/wm8994-core.c2
-rw-r--r--drivers/misc/apds990x.c4
-rw-r--r--drivers/misc/bh1770glc.c2
-rw-r--r--drivers/misc/eeprom/at25.c34
-rw-r--r--drivers/misc/lis3lv02d/lis3lv02d_i2c.c4
-rw-r--r--drivers/misc/mei/mei_dev.h4
-rw-r--r--drivers/misc/mei/pci-me.c8
-rw-r--r--drivers/misc/mei/pci-txe.c8
-rw-r--r--drivers/mmc/core/bus.c4
-rw-r--r--drivers/mmc/host/mmci.c2
-rw-r--r--drivers/mmc/host/sdhci-acpi.c2
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c4
-rw-r--r--drivers/mmc/host/sdhci-pci.c18
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c2
-rw-r--r--drivers/mmc/host/sdhci-s3c.c6
-rw-r--r--drivers/mmc/host/sdhci.c7
-rw-r--r--drivers/mmc/host/sdhci.h3
-rw-r--r--drivers/mmc/host/sh_mobile_sdhi.c2
-rw-r--r--drivers/mmc/host/tmio_mmc.c2
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c6
-rw-r--r--drivers/of/base.c33
-rw-r--r--drivers/pci/pci-driver.c20
-rw-r--r--drivers/pci/pci-sysfs.c4
-rw-r--r--drivers/pci/pcie/Kconfig2
-rw-r--r--drivers/powercap/Kconfig2
-rw-r--r--drivers/powercap/intel_rapl.c264
-rw-r--r--drivers/sh/pm_runtime.c4
-rw-r--r--drivers/spi/spi-pl022.c2
-rw-r--r--drivers/usb/core/driver.c6
-rw-r--r--drivers/usb/core/hcd-pci.c11
-rw-r--r--drivers/usb/core/hcd.c12
-rw-r--r--drivers/usb/core/hub.c6
-rw-r--r--drivers/usb/core/port.c4
-rw-r--r--drivers/usb/core/sysfs.c13
-rw-r--r--drivers/usb/core/usb.c4
-rw-r--r--drivers/usb/core/usb.h23
-rw-r--r--drivers/usb/host/ehci-pci.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c5
-rw-r--r--drivers/usb/host/u132-hcd.c3
-rw-r--r--drivers/usb/host/xhci-hub.c2
-rw-r--r--drivers/usb/host/xhci.c29
-rw-r--r--drivers/usb/phy/phy-msm-usb.c2
-rw-r--r--include/acpi/acbuffer.h14
-rw-r--r--include/acpi/acpi_bus.h35
-rw-r--r--include/acpi/acpixf.h2
-rw-r--r--include/acpi/actypes.h4
-rw-r--r--include/acpi/processor.h7
-rw-r--r--include/linux/acpi.h167
-rw-r--r--include/linux/blkdev.h4
-rw-r--r--include/linux/cpufreq.h54
-rw-r--r--include/linux/cpuidle.h4
-rw-r--r--include/linux/gpio/consumer.h7
-rw-r--r--include/linux/gpio_keys.h3
-rw-r--r--include/linux/leds.h3
-rw-r--r--include/linux/of.h34
-rw-r--r--include/linux/pm.h19
-rw-r--r--include/linux/pm_clock.h8
-rw-r--r--include/linux/pm_domain.h17
-rw-r--r--include/linux/pm_opp.h12
-rw-r--r--include/linux/pm_qos.h38
-rw-r--r--include/linux/pm_runtime.h21
-rw-r--r--include/linux/property.h143
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/linux/usb/hcd.h7
-rw-r--r--kernel/power/Kconfig7
-rw-r--r--kernel/power/hibernate.c14
-rw-r--r--kernel/power/power.h3
-rw-r--r--kernel/power/snapshot.c9
-rw-r--r--kernel/power/swap.c43
-rw-r--r--net/rfkill/rfkill-gpio.c18
-rw-r--r--tools/power/cpupower/utils/cpuidle-info.c8
220 files changed, 4877 insertions, 1526 deletions
diff --git a/Documentation/ABI/stable/sysfs-bus-usb b/Documentation/ABI/stable/sysfs-bus-usb
index e2bc700a6f9c..831f15d9672f 100644
--- a/Documentation/ABI/stable/sysfs-bus-usb
+++ b/Documentation/ABI/stable/sysfs-bus-usb
@@ -32,10 +32,9 @@ Date: January 2008
32KernelVersion: 2.6.25 32KernelVersion: 2.6.25
33Contact: Sarah Sharp <sarah.a.sharp@intel.com> 33Contact: Sarah Sharp <sarah.a.sharp@intel.com>
34Description: 34Description:
35 If CONFIG_PM_RUNTIME is enabled then this file 35 If CONFIG_PM is enabled, then this file is present. When read,
36 is present. When read, it returns the total time (in msec) 36 it returns the total time (in msec) that the USB device has been
37 that the USB device has been connected to the machine. This 37 connected to the machine. This file is read-only.
38 file is read-only.
39Users: 38Users:
40 PowerTOP <powertop@lists.01.org> 39 PowerTOP <powertop@lists.01.org>
41 https://01.org/powertop/ 40 https://01.org/powertop/
@@ -45,10 +44,9 @@ Date: January 2008
45KernelVersion: 2.6.25 44KernelVersion: 2.6.25
46Contact: Sarah Sharp <sarah.a.sharp@intel.com> 45Contact: Sarah Sharp <sarah.a.sharp@intel.com>
47Description: 46Description:
48 If CONFIG_PM_RUNTIME is enabled then this file 47 If CONFIG_PM is enabled, then this file is present. When read,
49 is present. When read, it returns the total time (in msec) 48 it returns the total time (in msec) that the USB device has been
50 that the USB device has been active, i.e. not in a suspended 49 active, i.e. not in a suspended state. This file is read-only.
51 state. This file is read-only.
52 50
53 Tools can use this file and the connected_duration file to 51 Tools can use this file and the connected_duration file to
54 compute the percentage of time that a device has been active. 52 compute the percentage of time that a device has been active.
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb
index 614d451cee41..e5cc7633d013 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -104,16 +104,15 @@ What: /sys/bus/usb/devices/.../power/usb2_hardware_lpm
104Date: September 2011 104Date: September 2011
105Contact: Andiry Xu <andiry.xu@amd.com> 105Contact: Andiry Xu <andiry.xu@amd.com>
106Description: 106Description:
107 If CONFIG_PM_RUNTIME is set and a USB 2.0 lpm-capable device 107 If CONFIG_PM is set and a USB 2.0 lpm-capable device is plugged
108 is plugged in to a xHCI host which support link PM, it will 108 in to a xHCI host which support link PM, it will perform a LPM
109 perform a LPM test; if the test is passed and host supports 109 test; if the test is passed and host supports USB2 hardware LPM
110 USB2 hardware LPM (xHCI 1.0 feature), USB2 hardware LPM will 110 (xHCI 1.0 feature), USB2 hardware LPM will be enabled for the
111 be enabled for the device and the USB device directory will 111 device and the USB device directory will contain a file named
112 contain a file named power/usb2_hardware_lpm. The file holds 112 power/usb2_hardware_lpm. The file holds a string value (enable
113 a string value (enable or disable) indicating whether or not 113 or disable) indicating whether or not USB2 hardware LPM is
114 USB2 hardware LPM is enabled for the device. Developer can 114 enabled for the device. Developer can write y/Y/1 or n/N/0 to
115 write y/Y/1 or n/N/0 to the file to enable/disable the 115 the file to enable/disable the feature.
116 feature.
117 116
118What: /sys/bus/usb/devices/.../removable 117What: /sys/bus/usb/devices/.../removable
119Date: February 2012 118Date: February 2012
diff --git a/Documentation/acpi/gpio-properties.txt b/Documentation/acpi/gpio-properties.txt
new file mode 100644
index 000000000000..ae36fcf86dc7
--- /dev/null
+++ b/Documentation/acpi/gpio-properties.txt
@@ -0,0 +1,96 @@
1_DSD Device Properties Related to GPIO
2--------------------------------------
3
4With the release of ACPI 5.1 and the _DSD configuration objecte names
5can finally be given to GPIOs (and other things as well) returned by
6_CRS. Previously, we were only able to use an integer index to find
7the corresponding GPIO, which is pretty error prone (it depends on
8the _CRS output ordering, for example).
9
10With _DSD we can now query GPIOs using a name instead of an integer
11index, like the ASL example below shows:
12
13 // Bluetooth device with reset and shutdown GPIOs
14 Device (BTH)
15 {
16 Name (_HID, ...)
17
18 Name (_CRS, ResourceTemplate ()
19 {
20 GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
21 "\\_SB.GPO0", 0, ResourceConsumer) {15}
22 GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
23 "\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
24 })
25
26 Name (_DSD, Package ()
27 {
28 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
29 Package ()
30 {
31 Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
32 Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
33 }
34 })
35 }
36
37The format of the supported GPIO property is:
38
39 Package () { "name", Package () { ref, index, pin, active_low }}
40
41 ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
42 typically this is the device itself (BTH in our case).
43 index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
44 pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
45 active_low - If 1 the GPIO is marked as active_low.
46
47Since ACPI GpioIo() resource does not have a field saying whether it is
48active low or high, the "active_low" argument can be used here. Setting
49it to 1 marks the GPIO as active low.
50
51In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
52resource, second pin in that resource with the GPIO number of 31.
53
54ACPI GPIO Mappings Provided by Drivers
55--------------------------------------
56
57There are systems in which the ACPI tables do not contain _DSD but provide _CRS
58with GpioIo()/GpioInt() resources and device drivers still need to work with
59them.
60
61In those cases ACPI device identification objects, _HID, _CID, _CLS, _SUB, _HRV,
62available to the driver can be used to identify the device and that is supposed
63to be sufficient to determine the meaning and purpose of all of the GPIO lines
64listed by the GpioIo()/GpioInt() resources returned by _CRS. In other words,
65the driver is supposed to know what to use the GpioIo()/GpioInt() resources for
66once it has identified the device. Having done that, it can simply assign names
67to the GPIO lines it is going to use and provide the GPIO subsystem with a
68mapping between those names and the ACPI GPIO resources corresponding to them.
69
70To do that, the driver needs to define a mapping table as a NULL-terminated
71array of struct acpi_gpio_mapping objects that each contain a name, a pointer
72to an array of line data (struct acpi_gpio_params) objects and the size of that
73array. Each struct acpi_gpio_params object consists of three fields,
74crs_entry_index, line_index, active_low, representing the index of the target
75GpioIo()/GpioInt() resource in _CRS starting from zero, the index of the target
76line in that resource starting from zero, and the active-low flag for that line,
77respectively, in analogy with the _DSD GPIO property format specified above.
78
79For the example Bluetooth device discussed previously the data structures in
80question would look like this:
81
82static const struct acpi_gpio_params reset_gpio = { 1, 1, false };
83static const struct acpi_gpio_params shutdown_gpio = { 0, 0, false };
84
85static const struct acpi_gpio_mapping bluetooth_acpi_gpios[] = {
86 { "reset-gpio", &reset_gpio, 1 },
87 { "shutdown-gpio", &shutdown_gpio, 1 },
88 { },
89};
90
91Next, the mapping table needs to be passed as the second argument to
92acpi_dev_add_driver_gpios() that will register it with the ACPI device object
93pointed to by its first argument. That should be done in the driver's .probe()
94routine. On removal, the driver should unregister its GPIO mapping table by
95calling acpi_dev_remove_driver_gpios() on the ACPI device object where that
96table was previously registered.
diff --git a/Documentation/cpu-freq/intel-pstate.txt b/Documentation/cpu-freq/intel-pstate.txt
index a69ffe1d54d5..765d7fc0e692 100644
--- a/Documentation/cpu-freq/intel-pstate.txt
+++ b/Documentation/cpu-freq/intel-pstate.txt
@@ -1,17 +1,28 @@
1Intel P-state driver 1Intel P-state driver
2-------------------- 2--------------------
3 3
4This driver implements a scaling driver with an internal governor for 4This driver provides an interface to control the P state selection for
5Intel Core processors. The driver follows the same model as the 5SandyBridge+ Intel processors. The driver can operate two different
6Transmeta scaling driver (longrun.c) and implements the setpolicy() 6modes based on the processor model legacy and Hardware P state (HWP)
7instead of target(). Scaling drivers that implement setpolicy() are 7mode.
8assumed to implement internal governors by the cpufreq core. All the 8
9logic for selecting the current P state is contained within the 9In legacy mode the driver implements a scaling driver with an internal
10driver; no external governor is used by the cpufreq core. 10governor for Intel Core processors. The driver follows the same model
11 11as the Transmeta scaling driver (longrun.c) and implements the
12Intel SandyBridge+ processors are supported. 12setpolicy() instead of target(). Scaling drivers that implement
13 13setpolicy() are assumed to implement internal governors by the cpufreq
14New sysfs files for controlling P state selection have been added to 14core. All the logic for selecting the current P state is contained
15within the driver; no external governor is used by the cpufreq core.
16
17In HWP mode P state selection is implemented in the processor
18itself. The driver provides the interfaces between the cpufreq core and
19the processor to control P state selection based on user preferences
20and reporting frequency to the cpufreq core. In this mode the
21internal governor code is disabled.
22
23In addtion to the interfaces provided by the cpufreq core for
24controlling frequency the driver provides sysfs files for
25controlling P state selection. These files have been added to
15/sys/devices/system/cpu/intel_pstate/ 26/sys/devices/system/cpu/intel_pstate/
16 27
17 max_perf_pct: limits the maximum P state that will be requested by 28 max_perf_pct: limits the maximum P state that will be requested by
@@ -33,7 +44,9 @@ frequency is fiction for Intel Core processors. Even if the scaling
33driver selects a single P state the actual frequency the processor 44driver selects a single P state the actual frequency the processor
34will run at is selected by the processor itself. 45will run at is selected by the processor itself.
35 46
36New debugfs files have also been added to /sys/kernel/debug/pstate_snb/ 47For legacy mode debugfs files have also been added to allow tuning of
48the internal governor algorythm. These files are located at
49/sys/kernel/debug/pstate_snb/ These files are NOT present in HWP mode.
37 50
38 deadband 51 deadband
39 d_gain_pct 52 d_gain_pct
diff --git a/Documentation/devicetree/bindings/arm/idle-states.txt b/Documentation/devicetree/bindings/arm/idle-states.txt
index 37375c7f3ccc..a8274eabae2e 100644
--- a/Documentation/devicetree/bindings/arm/idle-states.txt
+++ b/Documentation/devicetree/bindings/arm/idle-states.txt
@@ -317,6 +317,26 @@ follows:
317 In such systems entry-latency-us + exit-latency-us 317 In such systems entry-latency-us + exit-latency-us
318 will exceed wakeup-latency-us by this duration. 318 will exceed wakeup-latency-us by this duration.
319 319
320 - status:
321 Usage: Optional
322 Value type: <string>
323 Definition: A standard device tree property [5] that indicates
324 the operational status of an idle-state.
325 If present, it shall be:
326 "okay": to indicate that the idle state is
327 operational.
328 "disabled": to indicate that the idle state has
329 been disabled in firmware so it is not
330 operational.
331 If the property is not present the idle-state must
332 be considered operational.
333
334 - idle-state-name:
335 Usage: Optional
336 Value type: <string>
337 Definition: A string used as a descriptive name for the idle
338 state.
339
320 In addition to the properties listed above, a state node may require 340 In addition to the properties listed above, a state node may require
321 additional properties specifics to the entry-method defined in the 341 additional properties specifics to the entry-method defined in the
322 idle-states node, please refer to the entry-method bindings 342 idle-states node, please refer to the entry-method bindings
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index 6ce544191ca6..859918db36b8 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -219,6 +219,24 @@ part of the IRQ interface, e.g. IRQF_TRIGGER_FALLING, as are system wakeup
219capabilities. 219capabilities.
220 220
221 221
222GPIOs and ACPI
223==============
224
225On ACPI systems, GPIOs are described by GpioIo()/GpioInt() resources listed by
226the _CRS configuration objects of devices. Those resources do not provide
227connection IDs (names) for GPIOs, so it is necessary to use an additional
228mechanism for this purpose.
229
230Systems compliant with ACPI 5.1 or newer may provide a _DSD configuration object
231which, among other things, may be used to provide connection IDs for specific
232GPIOs described by the GpioIo()/GpioInt() resources in _CRS. If that is the
233case, it will be handled by the GPIO subsystem automatically. However, if the
234_DSD is not present, the mappings between GpioIo()/GpioInt() resources and GPIO
235connection IDs need to be provided by device drivers.
236
237For details refer to Documentation/acpi/gpio-properties.txt
238
239
222Interacting With the Legacy GPIO Subsystem 240Interacting With the Legacy GPIO Subsystem
223========================================== 241==========================================
224Many kernel subsystems still handle GPIOs using the legacy integer-based 242Many kernel subsystems still handle GPIOs using the legacy integer-based
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 32ba9ea5934a..eacb2e0397ae 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1446,6 +1446,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1446 disable 1446 disable
1447 Do not enable intel_pstate as the default 1447 Do not enable intel_pstate as the default
1448 scaling driver for the supported processors 1448 scaling driver for the supported processors
1449 no_hwp
1450 Do not enable hardware P state control (HWP)
1451 if available.
1449 1452
1450 intremap= [X86-64, Intel-IOMMU] 1453 intremap= [X86-64, Intel-IOMMU]
1451 on enable Interrupt Remapping (default) 1454 on enable Interrupt Remapping (default)
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt
index 7b90fe034c4b..b5f83911732a 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -47,14 +47,15 @@ dynamic PM is implemented in the USB subsystem, although system PM is
47covered to some extent (see Documentation/power/*.txt for more 47covered to some extent (see Documentation/power/*.txt for more
48information about system PM). 48information about system PM).
49 49
50Note: Dynamic PM support for USB is present only if the kernel was 50System PM support is present only if the kernel was built with CONFIG_SUSPEND
51built with CONFIG_USB_SUSPEND enabled (which depends on 51or CONFIG_HIBERNATION enabled. Dynamic PM support for USB is present whenever
52CONFIG_PM_RUNTIME). System PM support is present only if the kernel 52the kernel was built with CONFIG_PM enabled.
53was built with CONFIG_SUSPEND or CONFIG_HIBERNATION enabled. 53
54 54[Historically, dynamic PM support for USB was present only if the
55(Starting with the 3.10 kernel release, dynamic PM support for USB is 55kernel had been built with CONFIG_USB_SUSPEND enabled (which depended on
56present whenever the kernel was built with CONFIG_PM_RUNTIME enabled. 56CONFIG_PM_RUNTIME). Starting with the 3.10 kernel release, dynamic PM support
57The CONFIG_USB_SUSPEND option has been eliminated.) 57for USB was present whenever the kernel was built with CONFIG_PM_RUNTIME
58enabled. The CONFIG_USB_SUSPEND option had been eliminated.]
58 59
59 60
60 What is Remote Wakeup? 61 What is Remote Wakeup?
diff --git a/MAINTAINERS b/MAINTAINERS
index 47d64dcaa433..c8927bc7748e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2655,6 +2655,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
2655S: Maintained 2655S: Maintained
2656F: drivers/cpuidle/cpuidle-big_little.c 2656F: drivers/cpuidle/cpuidle-big_little.c
2657 2657
2658CPUIDLE DRIVER - ARM EXYNOS
2659M: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
2660M: Daniel Lezcano <daniel.lezcano@linaro.org>
2661M: Kukjin Kim <kgene@kernel.org>
2662L: linux-pm@vger.kernel.org
2663L: linux-samsung-soc@vger.kernel.org
2664S: Supported
2665F: drivers/cpuidle/cpuidle-exynos.c
2666F: arch/arm/mach-exynos/pm.c
2667
2658CPUIDLE DRIVERS 2668CPUIDLE DRIVERS
2659M: Rafael J. Wysocki <rjw@rjwysocki.net> 2669M: Rafael J. Wysocki <rjw@rjwysocki.net>
2660M: Daniel Lezcano <daniel.lezcano@linaro.org> 2670M: Daniel Lezcano <daniel.lezcano@linaro.org>
diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h
index 2fca60ab513a..af319ac4960c 100644
--- a/arch/arm/include/asm/cpuidle.h
+++ b/arch/arm/include/asm/cpuidle.h
@@ -15,7 +15,6 @@ static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
15 .exit_latency = 1,\ 15 .exit_latency = 1,\
16 .target_residency = 1,\ 16 .target_residency = 1,\
17 .power_usage = p,\ 17 .power_usage = p,\
18 .flags = CPUIDLE_FLAG_TIME_VALID,\
19 .name = "WFI",\ 18 .name = "WFI",\
20 .desc = "ARM WFI",\ 19 .desc = "ARM WFI",\
21} 20}
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index f1ac1c94ac0f..b4675fc28f83 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -66,7 +66,6 @@ static struct cpuidle_driver davinci_idle_driver = {
66 .enter = davinci_enter_idle, 66 .enter = davinci_enter_idle,
67 .exit_latency = 10, 67 .exit_latency = 10,
68 .target_residency = 10000, 68 .target_residency = 10000,
69 .flags = CPUIDLE_FLAG_TIME_VALID,
70 .name = "DDR SR", 69 .name = "DDR SR",
71 .desc = "WFI and DDR Self Refresh", 70 .desc = "WFI and DDR Self Refresh",
72 }, 71 },
diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
index 5a47e3c6172f..3feca526d16b 100644
--- a/arch/arm/mach-imx/cpuidle-imx5.c
+++ b/arch/arm/mach-imx/cpuidle-imx5.c
@@ -24,7 +24,6 @@ static struct cpuidle_driver imx5_cpuidle_driver = {
24 .enter = imx5_cpuidle_enter, 24 .enter = imx5_cpuidle_enter,
25 .exit_latency = 2, 25 .exit_latency = 2,
26 .target_residency = 1, 26 .target_residency = 1,
27 .flags = CPUIDLE_FLAG_TIME_VALID,
28 .name = "IMX5 SRPG", 27 .name = "IMX5 SRPG",
29 .desc = "CPU state retained,powered off", 28 .desc = "CPU state retained,powered off",
30 }, 29 },
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index aa935787b743..d76d08623f9f 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -53,8 +53,7 @@ static struct cpuidle_driver imx6q_cpuidle_driver = {
53 { 53 {
54 .exit_latency = 50, 54 .exit_latency = 50,
55 .target_residency = 75, 55 .target_residency = 75,
56 .flags = CPUIDLE_FLAG_TIME_VALID | 56 .flags = CPUIDLE_FLAG_TIMER_STOP,
57 CPUIDLE_FLAG_TIMER_STOP,
58 .enter = imx6q_enter_wait, 57 .enter = imx6q_enter_wait,
59 .name = "WAIT", 58 .name = "WAIT",
60 .desc = "Clock off", 59 .desc = "Clock off",
diff --git a/arch/arm/mach-imx/cpuidle-imx6sl.c b/arch/arm/mach-imx/cpuidle-imx6sl.c
index d4b6b8171fa9..7d92e6584551 100644
--- a/arch/arm/mach-imx/cpuidle-imx6sl.c
+++ b/arch/arm/mach-imx/cpuidle-imx6sl.c
@@ -40,8 +40,7 @@ static struct cpuidle_driver imx6sl_cpuidle_driver = {
40 { 40 {
41 .exit_latency = 50, 41 .exit_latency = 50,
42 .target_residency = 75, 42 .target_residency = 75,
43 .flags = CPUIDLE_FLAG_TIME_VALID | 43 .flags = CPUIDLE_FLAG_TIMER_STOP,
44 CPUIDLE_FLAG_TIMER_STOP,
45 .enter = imx6sl_enter_wait, 44 .enter = imx6sl_enter_wait,
46 .name = "WAIT", 45 .name = "WAIT",
47 .desc = "Clock off", 46 .desc = "Clock off",
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index e18709d3b95d..aa7b379e2661 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -265,7 +265,6 @@ static struct cpuidle_driver omap3_idle_driver = {
265 .enter = omap3_enter_idle_bm, 265 .enter = omap3_enter_idle_bm,
266 .exit_latency = 2 + 2, 266 .exit_latency = 2 + 2,
267 .target_residency = 5, 267 .target_residency = 5,
268 .flags = CPUIDLE_FLAG_TIME_VALID,
269 .name = "C1", 268 .name = "C1",
270 .desc = "MPU ON + CORE ON", 269 .desc = "MPU ON + CORE ON",
271 }, 270 },
@@ -273,7 +272,6 @@ static struct cpuidle_driver omap3_idle_driver = {
273 .enter = omap3_enter_idle_bm, 272 .enter = omap3_enter_idle_bm,
274 .exit_latency = 10 + 10, 273 .exit_latency = 10 + 10,
275 .target_residency = 30, 274 .target_residency = 30,
276 .flags = CPUIDLE_FLAG_TIME_VALID,
277 .name = "C2", 275 .name = "C2",
278 .desc = "MPU ON + CORE ON", 276 .desc = "MPU ON + CORE ON",
279 }, 277 },
@@ -281,7 +279,6 @@ static struct cpuidle_driver omap3_idle_driver = {
281 .enter = omap3_enter_idle_bm, 279 .enter = omap3_enter_idle_bm,
282 .exit_latency = 50 + 50, 280 .exit_latency = 50 + 50,
283 .target_residency = 300, 281 .target_residency = 300,
284 .flags = CPUIDLE_FLAG_TIME_VALID,
285 .name = "C3", 282 .name = "C3",
286 .desc = "MPU RET + CORE ON", 283 .desc = "MPU RET + CORE ON",
287 }, 284 },
@@ -289,7 +286,6 @@ static struct cpuidle_driver omap3_idle_driver = {
289 .enter = omap3_enter_idle_bm, 286 .enter = omap3_enter_idle_bm,
290 .exit_latency = 1500 + 1800, 287 .exit_latency = 1500 + 1800,
291 .target_residency = 4000, 288 .target_residency = 4000,
292 .flags = CPUIDLE_FLAG_TIME_VALID,
293 .name = "C4", 289 .name = "C4",
294 .desc = "MPU OFF + CORE ON", 290 .desc = "MPU OFF + CORE ON",
295 }, 291 },
@@ -297,7 +293,6 @@ static struct cpuidle_driver omap3_idle_driver = {
297 .enter = omap3_enter_idle_bm, 293 .enter = omap3_enter_idle_bm,
298 .exit_latency = 2500 + 7500, 294 .exit_latency = 2500 + 7500,
299 .target_residency = 12000, 295 .target_residency = 12000,
300 .flags = CPUIDLE_FLAG_TIME_VALID,
301 .name = "C5", 296 .name = "C5",
302 .desc = "MPU RET + CORE RET", 297 .desc = "MPU RET + CORE RET",
303 }, 298 },
@@ -305,7 +300,6 @@ static struct cpuidle_driver omap3_idle_driver = {
305 .enter = omap3_enter_idle_bm, 300 .enter = omap3_enter_idle_bm,
306 .exit_latency = 3000 + 8500, 301 .exit_latency = 3000 + 8500,
307 .target_residency = 15000, 302 .target_residency = 15000,
308 .flags = CPUIDLE_FLAG_TIME_VALID,
309 .name = "C6", 303 .name = "C6",
310 .desc = "MPU OFF + CORE RET", 304 .desc = "MPU OFF + CORE RET",
311 }, 305 },
@@ -313,7 +307,6 @@ static struct cpuidle_driver omap3_idle_driver = {
313 .enter = omap3_enter_idle_bm, 307 .enter = omap3_enter_idle_bm,
314 .exit_latency = 10000 + 30000, 308 .exit_latency = 10000 + 30000,
315 .target_residency = 30000, 309 .target_residency = 30000,
316 .flags = CPUIDLE_FLAG_TIME_VALID,
317 .name = "C7", 310 .name = "C7",
318 .desc = "MPU OFF + CORE OFF", 311 .desc = "MPU OFF + CORE OFF",
319 }, 312 },
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index 2498ab025fa2..01e398a868bc 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -196,7 +196,6 @@ static struct cpuidle_driver omap4_idle_driver = {
196 /* C1 - CPU0 ON + CPU1 ON + MPU ON */ 196 /* C1 - CPU0 ON + CPU1 ON + MPU ON */
197 .exit_latency = 2 + 2, 197 .exit_latency = 2 + 2,
198 .target_residency = 5, 198 .target_residency = 5,
199 .flags = CPUIDLE_FLAG_TIME_VALID,
200 .enter = omap_enter_idle_simple, 199 .enter = omap_enter_idle_simple,
201 .name = "C1", 200 .name = "C1",
202 .desc = "CPUx ON, MPUSS ON" 201 .desc = "CPUx ON, MPUSS ON"
@@ -205,7 +204,7 @@ static struct cpuidle_driver omap4_idle_driver = {
205 /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */ 204 /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
206 .exit_latency = 328 + 440, 205 .exit_latency = 328 + 440,
207 .target_residency = 960, 206 .target_residency = 960,
208 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED, 207 .flags = CPUIDLE_FLAG_COUPLED,
209 .enter = omap_enter_idle_coupled, 208 .enter = omap_enter_idle_coupled,
210 .name = "C2", 209 .name = "C2",
211 .desc = "CPUx OFF, MPUSS CSWR", 210 .desc = "CPUx OFF, MPUSS CSWR",
@@ -214,7 +213,7 @@ static struct cpuidle_driver omap4_idle_driver = {
214 /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */ 213 /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
215 .exit_latency = 460 + 518, 214 .exit_latency = 460 + 518,
216 .target_residency = 1100, 215 .target_residency = 1100,
217 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED, 216 .flags = CPUIDLE_FLAG_COUPLED,
218 .enter = omap_enter_idle_coupled, 217 .enter = omap_enter_idle_coupled,
219 .name = "C3", 218 .name = "C3",
220 .desc = "CPUx OFF, MPUSS OSWR", 219 .desc = "CPUx OFF, MPUSS OSWR",
diff --git a/arch/arm/mach-s3c24xx/h1940-bluetooth.c b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
index b4d14b864367..9c8b1279a4ba 100644
--- a/arch/arm/mach-s3c24xx/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
@@ -41,7 +41,7 @@ static void h1940bt_enable(int on)
41 mdelay(10); 41 mdelay(10);
42 gpio_set_value(S3C2410_GPH(1), 0); 42 gpio_set_value(S3C2410_GPH(1), 0);
43 43
44 h1940_led_blink_set(-EINVAL, GPIO_LED_BLINK, NULL, NULL); 44 h1940_led_blink_set(NULL, GPIO_LED_BLINK, NULL, NULL);
45 } 45 }
46 else { 46 else {
47 gpio_set_value(S3C2410_GPH(1), 1); 47 gpio_set_value(S3C2410_GPH(1), 1);
@@ -50,7 +50,7 @@ static void h1940bt_enable(int on)
50 mdelay(10); 50 mdelay(10);
51 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); 51 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
52 52
53 h1940_led_blink_set(-EINVAL, GPIO_LED_NO_BLINK_LOW, NULL, NULL); 53 h1940_led_blink_set(NULL, GPIO_LED_NO_BLINK_LOW, NULL, NULL);
54 } 54 }
55} 55}
56 56
diff --git a/arch/arm/mach-s3c24xx/h1940.h b/arch/arm/mach-s3c24xx/h1940.h
index 2950cc466840..596d9f64c5b6 100644
--- a/arch/arm/mach-s3c24xx/h1940.h
+++ b/arch/arm/mach-s3c24xx/h1940.h
@@ -19,8 +19,10 @@
19#define H1940_SUSPEND_RESUMEAT (0x30081000) 19#define H1940_SUSPEND_RESUMEAT (0x30081000)
20#define H1940_SUSPEND_CHECK (0x30080000) 20#define H1940_SUSPEND_CHECK (0x30080000)
21 21
22struct gpio_desc;
23
22extern void h1940_pm_return(void); 24extern void h1940_pm_return(void);
23extern int h1940_led_blink_set(unsigned gpio, int state, 25extern int h1940_led_blink_set(struct gpio_desc *desc, int state,
24 unsigned long *delay_on, 26 unsigned long *delay_on,
25 unsigned long *delay_off); 27 unsigned long *delay_off);
26 28
diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
index d35ddc1d9991..d40d4f5244c6 100644
--- a/arch/arm/mach-s3c24xx/mach-h1940.c
+++ b/arch/arm/mach-s3c24xx/mach-h1940.c
@@ -359,10 +359,11 @@ static struct platform_device h1940_battery = {
359 359
360static DEFINE_SPINLOCK(h1940_blink_spin); 360static DEFINE_SPINLOCK(h1940_blink_spin);
361 361
362int h1940_led_blink_set(unsigned gpio, int state, 362int h1940_led_blink_set(struct gpio_desc *desc, int state,
363 unsigned long *delay_on, unsigned long *delay_off) 363 unsigned long *delay_on, unsigned long *delay_off)
364{ 364{
365 int blink_gpio, check_gpio1, check_gpio2; 365 int blink_gpio, check_gpio1, check_gpio2;
366 int gpio = desc ? desc_to_gpio(desc) : -EINVAL;
366 367
367 switch (gpio) { 368 switch (gpio) {
368 case H1940_LATCH_LED_GREEN: 369 case H1940_LATCH_LED_GREEN:
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index c3f2682d0c62..1d35ff375a01 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -250,9 +250,10 @@ static void rx1950_disable_charger(void)
250 250
251static DEFINE_SPINLOCK(rx1950_blink_spin); 251static DEFINE_SPINLOCK(rx1950_blink_spin);
252 252
253static int rx1950_led_blink_set(unsigned gpio, int state, 253static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
254 unsigned long *delay_on, unsigned long *delay_off) 254 unsigned long *delay_on, unsigned long *delay_off)
255{ 255{
256 int gpio = desc_to_gpio(desc);
256 int blink_gpio, check_gpio; 257 int blink_gpio, check_gpio;
257 258
258 switch (gpio) { 259 switch (gpio) {
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index 3c8ab07c2012..2eb072440dfa 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -48,7 +48,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = {
48 .enter = s3c64xx_enter_idle, 48 .enter = s3c64xx_enter_idle,
49 .exit_latency = 1, 49 .exit_latency = 1,
50 .target_residency = 1, 50 .target_residency = 1,
51 .flags = CPUIDLE_FLAG_TIME_VALID,
52 .name = "IDLE", 51 .name = "IDLE",
53 .desc = "System active, ARM gated", 52 .desc = "System active, ARM gated",
54 }, 53 },
diff --git a/arch/arm/mach-shmobile/pm-r8a7779.c b/arch/arm/mach-shmobile/pm-r8a7779.c
index 82fe3d7f9662..44a74c4c5a01 100644
--- a/arch/arm/mach-shmobile/pm-r8a7779.c
+++ b/arch/arm/mach-shmobile/pm-r8a7779.c
@@ -83,9 +83,8 @@ static void r8a7779_init_pm_domain(struct r8a7779_pm_domain *r8a7779_pd)
83{ 83{
84 struct generic_pm_domain *genpd = &r8a7779_pd->genpd; 84 struct generic_pm_domain *genpd = &r8a7779_pd->genpd;
85 85
86 genpd->flags = GENPD_FLAG_PM_CLK;
86 pm_genpd_init(genpd, NULL, false); 87 pm_genpd_init(genpd, NULL, false);
87 genpd->dev_ops.stop = pm_clk_suspend;
88 genpd->dev_ops.start = pm_clk_resume;
89 genpd->dev_ops.active_wakeup = pd_active_wakeup; 88 genpd->dev_ops.active_wakeup = pd_active_wakeup;
90 genpd->power_off = pd_power_down; 89 genpd->power_off = pd_power_down;
91 genpd->power_on = pd_power_up; 90 genpd->power_on = pd_power_up;
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index 717e6413d29c..6f7d56ecf969 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -106,9 +106,8 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
106 struct generic_pm_domain *genpd = &rmobile_pd->genpd; 106 struct generic_pm_domain *genpd = &rmobile_pd->genpd;
107 struct dev_power_governor *gov = rmobile_pd->gov; 107 struct dev_power_governor *gov = rmobile_pd->gov;
108 108
109 genpd->flags = GENPD_FLAG_PM_CLK;
109 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false); 110 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
110 genpd->dev_ops.stop = pm_clk_suspend;
111 genpd->dev_ops.start = pm_clk_resume;
112 genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup; 111 genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup;
113 genpd->power_off = rmobile_pd_power_down; 112 genpd->power_off = rmobile_pd_power_down;
114 genpd->power_on = rmobile_pd_power_up; 113 genpd->power_on = rmobile_pd_power_up;
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index 7e5c2676c489..0e37da654ed5 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -423,7 +423,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
423 .desc = "Core Standby Mode", 423 .desc = "Core Standby Mode",
424 .exit_latency = 10, 424 .exit_latency = 10,
425 .target_residency = 20 + 10, 425 .target_residency = 20 + 10,
426 .flags = CPUIDLE_FLAG_TIME_VALID,
427 .enter = sh7372_enter_core_standby, 426 .enter = sh7372_enter_core_standby,
428 }, 427 },
429 .states[2] = { 428 .states[2] = {
@@ -431,7 +430,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
431 .desc = "A3SM PLL ON", 430 .desc = "A3SM PLL ON",
432 .exit_latency = 20, 431 .exit_latency = 20,
433 .target_residency = 30 + 20, 432 .target_residency = 30 + 20,
434 .flags = CPUIDLE_FLAG_TIME_VALID,
435 .enter = sh7372_enter_a3sm_pll_on, 433 .enter = sh7372_enter_a3sm_pll_on,
436 }, 434 },
437 .states[3] = { 435 .states[3] = {
@@ -439,7 +437,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
439 .desc = "A3SM PLL OFF", 437 .desc = "A3SM PLL OFF",
440 .exit_latency = 120, 438 .exit_latency = 120,
441 .target_residency = 30 + 120, 439 .target_residency = 30 + 120,
442 .flags = CPUIDLE_FLAG_TIME_VALID,
443 .enter = sh7372_enter_a3sm_pll_off, 440 .enter = sh7372_enter_a3sm_pll_off,
444 }, 441 },
445 .states[4] = { 442 .states[4] = {
@@ -447,7 +444,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
447 .desc = "A4S PLL OFF", 444 .desc = "A4S PLL OFF",
448 .exit_latency = 240, 445 .exit_latency = 240,
449 .target_residency = 30 + 240, 446 .target_residency = 30 + 240,
450 .flags = CPUIDLE_FLAG_TIME_VALID,
451 .enter = sh7372_enter_a4s, 447 .enter = sh7372_enter_a4s,
452 .disabled = true, 448 .disabled = true,
453 }, 449 },
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index 425b6c8f0cb0..f2b586d7b15d 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -75,7 +75,6 @@ static struct cpuidle_driver tegra_idle_driver = {
75 .exit_latency = 500, 75 .exit_latency = 500,
76 .target_residency = 1000, 76 .target_residency = 1000,
77 .power_usage = 0, 77 .power_usage = 0,
78 .flags = CPUIDLE_FLAG_TIME_VALID,
79 .name = "powered-down", 78 .name = "powered-down",
80 .desc = "CPU power gated", 79 .desc = "CPU power gated",
81 }, 80 },
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index b30bf5cba65b..4f25a7c7ca0f 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -59,8 +59,7 @@ static struct cpuidle_driver tegra_idle_driver = {
59 .exit_latency = 5000, 59 .exit_latency = 5000,
60 .target_residency = 10000, 60 .target_residency = 10000,
61 .power_usage = 0, 61 .power_usage = 0,
62 .flags = CPUIDLE_FLAG_TIME_VALID | 62 .flags = CPUIDLE_FLAG_COUPLED,
63 CPUIDLE_FLAG_COUPLED,
64 .name = "powered-down", 63 .name = "powered-down",
65 .desc = "CPU power gated", 64 .desc = "CPU power gated",
66 }, 65 },
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index 35561274f6cf..f8815ed65d9d 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -56,7 +56,6 @@ static struct cpuidle_driver tegra_idle_driver = {
56 .exit_latency = 2000, 56 .exit_latency = 2000,
57 .target_residency = 2200, 57 .target_residency = 2200,
58 .power_usage = 0, 58 .power_usage = 0,
59 .flags = CPUIDLE_FLAG_TIME_VALID,
60 .name = "powered-down", 59 .name = "powered-down",
61 .desc = "CPU power gated", 60 .desc = "CPU power gated",
62 }, 61 },
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 14f6e647c739..5168a52a17f9 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -306,9 +306,10 @@ EXPORT_SYMBOL(orion_gpio_set_blink);
306 306
307#define ORION_BLINK_HALF_PERIOD 100 /* ms */ 307#define ORION_BLINK_HALF_PERIOD 100 /* ms */
308 308
309int orion_gpio_led_blink_set(unsigned gpio, int state, 309int orion_gpio_led_blink_set(struct gpio_desc *desc, int state,
310 unsigned long *delay_on, unsigned long *delay_off) 310 unsigned long *delay_on, unsigned long *delay_off)
311{ 311{
312 unsigned gpio = desc_to_gpio(desc);
312 313
313 if (delay_on && delay_off && !*delay_on && !*delay_off) 314 if (delay_on && delay_off && !*delay_on && !*delay_off)
314 *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD; 315 *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD;
diff --git a/arch/arm/plat-orion/include/plat/orion-gpio.h b/arch/arm/plat-orion/include/plat/orion-gpio.h
index e763988b04b9..e856b073a9c8 100644
--- a/arch/arm/plat-orion/include/plat/orion-gpio.h
+++ b/arch/arm/plat-orion/include/plat/orion-gpio.h
@@ -14,12 +14,15 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/irqdomain.h> 16#include <linux/irqdomain.h>
17
18struct gpio_desc;
19
17/* 20/*
18 * Orion-specific GPIO API extensions. 21 * Orion-specific GPIO API extensions.
19 */ 22 */
20void orion_gpio_set_unused(unsigned pin); 23void orion_gpio_set_unused(unsigned pin);
21void orion_gpio_set_blink(unsigned pin, int blink); 24void orion_gpio_set_blink(unsigned pin, int blink);
22int orion_gpio_led_blink_set(unsigned gpio, int state, 25int orion_gpio_led_blink_set(struct gpio_desc *desc, int state,
23 unsigned long *delay_on, unsigned long *delay_off); 26 unsigned long *delay_on, unsigned long *delay_off);
24 27
25#define GPIO_INPUT_OK (1 << 0) 28#define GPIO_INPUT_OK (1 << 0)
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index c84c88bbbbd7..536d13b0bea6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -11,7 +11,6 @@ config IA64
11 select PCI if (!IA64_HP_SIM) 11 select PCI if (!IA64_HP_SIM)
12 select ACPI if (!IA64_HP_SIM) 12 select ACPI if (!IA64_HP_SIM)
13 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 13 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
14 select PM if (!IA64_HP_SIM)
15 select HAVE_UNSTABLE_SCHED_CLOCK 14 select HAVE_UNSTABLE_SCHED_CLOCK
16 select HAVE_IDE 15 select HAVE_IDE
17 select HAVE_OPROFILE 16 select HAVE_OPROFILE
@@ -233,6 +232,7 @@ config IA64_SGI_UV
233config IA64_HP_SIM 232config IA64_HP_SIM
234 bool "Ski-simulator" 233 bool "Ski-simulator"
235 select SWIOTLB 234 select SWIOTLB
235 depends on !PM_RUNTIME
236 236
237endchoice 237endchoice
238 238
diff --git a/arch/mips/include/asm/idle.h b/arch/mips/include/asm/idle.h
index 1c967abd545c..a2d18ab57ac6 100644
--- a/arch/mips/include/asm/idle.h
+++ b/arch/mips/include/asm/idle.h
@@ -22,7 +22,6 @@ extern int mips_cpuidle_wait_enter(struct cpuidle_device *dev,
22 .exit_latency = 1,\ 22 .exit_latency = 1,\
23 .target_residency = 1,\ 23 .target_residency = 1,\
24 .power_usage = UINT_MAX,\ 24 .power_usage = UINT_MAX,\
25 .flags = CPUIDLE_FLAG_TIME_VALID,\
26 .name = "wait",\ 25 .name = "wait",\
27 .desc = "MIPS wait",\ 26 .desc = "MIPS wait",\
28} 27}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 244fb4c81e25..a1403470f80e 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -222,7 +222,6 @@ config CPU_SHX3
222config ARCH_SHMOBILE 222config ARCH_SHMOBILE
223 bool 223 bool
224 select ARCH_SUSPEND_POSSIBLE 224 select ARCH_SUSPEND_POSSIBLE
225 select PM
226 select PM_RUNTIME 225 select PM_RUNTIME
227 226
228config CPU_HAS_PMU 227config CPU_HAS_PMU
diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c
index e3abfd4277e2..53b8eeb1db20 100644
--- a/arch/sh/kernel/cpu/shmobile/cpuidle.c
+++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c
@@ -59,7 +59,6 @@ static struct cpuidle_driver cpuidle_driver = {
59 .exit_latency = 1, 59 .exit_latency = 1,
60 .target_residency = 1 * 2, 60 .target_residency = 1 * 2,
61 .power_usage = 3, 61 .power_usage = 3,
62 .flags = CPUIDLE_FLAG_TIME_VALID,
63 .enter = cpuidle_sleep_enter, 62 .enter = cpuidle_sleep_enter,
64 .name = "C1", 63 .name = "C1",
65 .desc = "SuperH Sleep Mode", 64 .desc = "SuperH Sleep Mode",
@@ -68,7 +67,6 @@ static struct cpuidle_driver cpuidle_driver = {
68 .exit_latency = 100, 67 .exit_latency = 100,
69 .target_residency = 1 * 2, 68 .target_residency = 1 * 2,
70 .power_usage = 1, 69 .power_usage = 1,
71 .flags = CPUIDLE_FLAG_TIME_VALID,
72 .enter = cpuidle_sleep_enter, 70 .enter = cpuidle_sleep_enter,
73 .name = "C2", 71 .name = "C2",
74 .desc = "SuperH Sleep Mode [SF]", 72 .desc = "SuperH Sleep Mode [SF]",
@@ -78,7 +76,6 @@ static struct cpuidle_driver cpuidle_driver = {
78 .exit_latency = 2300, 76 .exit_latency = 2300,
79 .target_residency = 1 * 2, 77 .target_residency = 1 * 2,
80 .power_usage = 1, 78 .power_usage = 1,
81 .flags = CPUIDLE_FLAG_TIME_VALID,
82 .enter = cpuidle_sleep_enter, 79 .enter = cpuidle_sleep_enter,
83 .name = "C3", 80 .name = "C3",
84 .desc = "SuperH Mobile Standby Mode [SF]", 81 .desc = "SuperH Mobile Standby Mode [SF]",
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 0bb1335313b2..aede2c347bde 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -189,6 +189,11 @@
189#define X86_FEATURE_DTHERM ( 7*32+ 7) /* Digital Thermal Sensor */ 189#define X86_FEATURE_DTHERM ( 7*32+ 7) /* Digital Thermal Sensor */
190#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */ 190#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */
191#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 191#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
192#define X86_FEATURE_HWP ( 7*32+ 10) /* "hwp" Intel HWP */
193#define X86_FEATURE_HWP_NOITFY ( 7*32+ 11) /* Intel HWP_NOTIFY */
194#define X86_FEATURE_HWP_ACT_WINDOW ( 7*32+ 12) /* Intel HWP_ACT_WINDOW */
195#define X86_FEATURE_HWP_EPP ( 7*32+13) /* Intel HWP_EPP */
196#define X86_FEATURE_HWP_PKG_REQ ( 7*32+14) /* Intel HWP_PKG_REQ */
192 197
193/* Virtualization flags: Linux defined, word 8 */ 198/* Virtualization flags: Linux defined, word 8 */
194#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 199#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h
index 8f02f6990759..c8aa65d56027 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -152,6 +152,45 @@
152#define MSR_CC6_DEMOTION_POLICY_CONFIG 0x00000668 152#define MSR_CC6_DEMOTION_POLICY_CONFIG 0x00000668
153#define MSR_MC6_DEMOTION_POLICY_CONFIG 0x00000669 153#define MSR_MC6_DEMOTION_POLICY_CONFIG 0x00000669
154 154
155/* Hardware P state interface */
156#define MSR_PPERF 0x0000064e
157#define MSR_PERF_LIMIT_REASONS 0x0000064f
158#define MSR_PM_ENABLE 0x00000770
159#define MSR_HWP_CAPABILITIES 0x00000771
160#define MSR_HWP_REQUEST_PKG 0x00000772
161#define MSR_HWP_INTERRUPT 0x00000773
162#define MSR_HWP_REQUEST 0x00000774
163#define MSR_HWP_STATUS 0x00000777
164
165/* CPUID.6.EAX */
166#define HWP_BASE_BIT (1<<7)
167#define HWP_NOTIFICATIONS_BIT (1<<8)
168#define HWP_ACTIVITY_WINDOW_BIT (1<<9)
169#define HWP_ENERGY_PERF_PREFERENCE_BIT (1<<10)
170#define HWP_PACKAGE_LEVEL_REQUEST_BIT (1<<11)
171
172/* IA32_HWP_CAPABILITIES */
173#define HWP_HIGHEST_PERF(x) (x & 0xff)
174#define HWP_GUARANTEED_PERF(x) ((x & (0xff << 8)) >>8)
175#define HWP_MOSTEFFICIENT_PERF(x) ((x & (0xff << 16)) >>16)
176#define HWP_LOWEST_PERF(x) ((x & (0xff << 24)) >>24)
177
178/* IA32_HWP_REQUEST */
179#define HWP_MIN_PERF(x) (x & 0xff)
180#define HWP_MAX_PERF(x) ((x & 0xff) << 8)
181#define HWP_DESIRED_PERF(x) ((x & 0xff) << 16)
182#define HWP_ENERGY_PERF_PREFERENCE(x) ((x & 0xff) << 24)
183#define HWP_ACTIVITY_WINDOW(x) ((x & 0xff3) << 32)
184#define HWP_PACKAGE_CONTROL(x) ((x & 0x1) << 42)
185
186/* IA32_HWP_STATUS */
187#define HWP_GUARANTEED_CHANGE(x) (x & 0x1)
188#define HWP_EXCURSION_TO_MINIMUM(x) (x & 0x4)
189
190/* IA32_HWP_INTERRUPT */
191#define HWP_CHANGE_TO_GUARANTEED_INT(x) (x & 0x1)
192#define HWP_EXCURSION_TO_MINIMUM_INT(x) (x & 0x2)
193
155#define MSR_AMD64_MC0_MASK 0xc0010044 194#define MSR_AMD64_MC0_MASK 0xc0010044
156 195
157#define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4*(x)) 196#define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4*(x))
@@ -346,6 +385,8 @@
346 385
347#define MSR_IA32_TEMPERATURE_TARGET 0x000001a2 386#define MSR_IA32_TEMPERATURE_TARGET 0x000001a2
348 387
388#define MSR_MISC_PWR_MGMT 0x000001aa
389
349#define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0 390#define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0
350#define ENERGY_PERF_BIAS_PERFORMANCE 0 391#define ENERGY_PERF_BIAS_PERFORMANCE 0
351#define ENERGY_PERF_BIAS_NORMAL 6 392#define ENERGY_PERF_BIAS_NORMAL 6
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 584874451414..927ec9235947 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -378,7 +378,6 @@ static struct cpuidle_driver apm_idle_driver = {
378 { /* entry 1 is for APM idle */ 378 { /* entry 1 is for APM idle */
379 .name = "APM", 379 .name = "APM",
380 .desc = "APM idle", 380 .desc = "APM idle",
381 .flags = CPUIDLE_FLAG_TIME_VALID,
382 .exit_latency = 250, /* WAG */ 381 .exit_latency = 250, /* WAG */
383 .target_residency = 500, /* WAG */ 382 .target_residency = 500, /* WAG */
384 .enter = &apm_cpu_idle 383 .enter = &apm_cpu_idle
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index 4a8013d55947..60639093d536 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -36,6 +36,11 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
36 { X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006, 0 }, 36 { X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006, 0 },
37 { X86_FEATURE_PLN, CR_EAX, 4, 0x00000006, 0 }, 37 { X86_FEATURE_PLN, CR_EAX, 4, 0x00000006, 0 },
38 { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 }, 38 { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 },
39 { X86_FEATURE_HWP, CR_EAX, 7, 0x00000006, 0 },
40 { X86_FEATURE_HWP_NOITFY, CR_EAX, 8, 0x00000006, 0 },
41 { X86_FEATURE_HWP_ACT_WINDOW, CR_EAX, 9, 0x00000006, 0 },
42 { X86_FEATURE_HWP_EPP, CR_EAX,10, 0x00000006, 0 },
43 { X86_FEATURE_HWP_PKG_REQ, CR_EAX,11, 0x00000006, 0 },
39 { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, 44 { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 },
40 { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, 45 { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 },
41 { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, 46 { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 },
diff --git a/block/blk-core.c b/block/blk-core.c
index 2e7424b42947..ea1c4d0d7a44 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1325,7 +1325,7 @@ void part_round_stats(int cpu, struct hd_struct *part)
1325} 1325}
1326EXPORT_SYMBOL_GPL(part_round_stats); 1326EXPORT_SYMBOL_GPL(part_round_stats);
1327 1327
1328#ifdef CONFIG_PM_RUNTIME 1328#ifdef CONFIG_PM
1329static void blk_pm_put_request(struct request *rq) 1329static void blk_pm_put_request(struct request *rq)
1330{ 1330{
1331 if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && !--rq->q->nr_pending) 1331 if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && !--rq->q->nr_pending)
@@ -2134,7 +2134,7 @@ void blk_account_io_done(struct request *req)
2134 } 2134 }
2135} 2135}
2136 2136
2137#ifdef CONFIG_PM_RUNTIME 2137#ifdef CONFIG_PM
2138/* 2138/*
2139 * Don't process normal requests when queue is suspended 2139 * Don't process normal requests when queue is suspended
2140 * or in the process of suspending/resuming 2140 * or in the process of suspending/resuming
@@ -3159,7 +3159,7 @@ void blk_finish_plug(struct blk_plug *plug)
3159} 3159}
3160EXPORT_SYMBOL(blk_finish_plug); 3160EXPORT_SYMBOL(blk_finish_plug);
3161 3161
3162#ifdef CONFIG_PM_RUNTIME 3162#ifdef CONFIG_PM
3163/** 3163/**
3164 * blk_pm_runtime_init - Block layer runtime PM initialization routine 3164 * blk_pm_runtime_init - Block layer runtime PM initialization routine
3165 * @q: the queue of the device 3165 * @q: the queue of the device
diff --git a/block/elevator.c b/block/elevator.c
index afa3b037a17c..59794d0d38e3 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -539,7 +539,7 @@ void elv_bio_merged(struct request_queue *q, struct request *rq,
539 e->type->ops.elevator_bio_merged_fn(q, rq, bio); 539 e->type->ops.elevator_bio_merged_fn(q, rq, bio);
540} 540}
541 541
542#ifdef CONFIG_PM_RUNTIME 542#ifdef CONFIG_PM
543static void blk_pm_requeue_request(struct request *rq) 543static void blk_pm_requeue_request(struct request *rq)
544{ 544{
545 if (rq->q->dev && !(rq->cmd_flags & REQ_PM)) 545 if (rq->q->dev && !(rq->cmd_flags & REQ_PM))
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index b23fe37f67c0..8951cefb0a96 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -360,15 +360,14 @@ config ACPI_BGRT
360config ACPI_REDUCED_HARDWARE_ONLY 360config ACPI_REDUCED_HARDWARE_ONLY
361 bool "Hardware-reduced ACPI support only" if EXPERT 361 bool "Hardware-reduced ACPI support only" if EXPERT
362 def_bool n 362 def_bool n
363 depends on ACPI
364 help 363 help
365 This config item changes the way the ACPI code is built. When this 364 This config item changes the way the ACPI code is built. When this
366 option is selected, the kernel will use a specialized version of 365 option is selected, the kernel will use a specialized version of
367 ACPICA that ONLY supports the ACPI "reduced hardware" mode. The 366 ACPICA that ONLY supports the ACPI "reduced hardware" mode. The
368 resulting kernel will be smaller but it will also be restricted to 367 resulting kernel will be smaller but it will also be restricted to
369 running in ACPI reduced hardware mode ONLY. 368 running in ACPI reduced hardware mode ONLY.
370 369
371 If you are unsure what to do, do not enable this option. 370 If you are unsure what to do, do not enable this option.
372 371
373source "drivers/acpi/apei/Kconfig" 372source "drivers/acpi/apei/Kconfig"
374 373
@@ -394,4 +393,27 @@ config ACPI_EXTLOG
394 driver adds support for that functionality with corresponding 393 driver adds support for that functionality with corresponding
395 tracepoint which carries that information to userspace. 394 tracepoint which carries that information to userspace.
396 395
396menuconfig PMIC_OPREGION
397 bool "PMIC (Power Management Integrated Circuit) operation region support"
398 help
399 Select this option to enable support for ACPI operation
400 region of the PMIC chip. The operation region can be used
401 to control power rails and sensor reading/writing on the
402 PMIC chip.
403
404if PMIC_OPREGION
405config CRC_PMIC_OPREGION
406 bool "ACPI operation region support for CrystalCove PMIC"
407 depends on INTEL_SOC_PMIC
408 help
409 This config adds ACPI operation region support for CrystalCove PMIC.
410
411config XPOWER_PMIC_OPREGION
412 bool "ACPI operation region support for XPower AXP288 PMIC"
413 depends on AXP288_ADC = y
414 help
415 This config adds ACPI operation region support for XPower AXP288 PMIC.
416
417endif
418
397endif # ACPI 419endif # ACPI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c3b2fcb729f3..f74317cc1ca9 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -47,6 +47,7 @@ acpi-y += int340x_thermal.o
47acpi-y += power.o 47acpi-y += power.o
48acpi-y += event.o 48acpi-y += event.o
49acpi-y += sysfs.o 49acpi-y += sysfs.o
50acpi-y += property.o
50acpi-$(CONFIG_X86) += acpi_cmos_rtc.o 51acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
51acpi-$(CONFIG_DEBUG_FS) += debugfs.o 52acpi-$(CONFIG_DEBUG_FS) += debugfs.o
52acpi-$(CONFIG_ACPI_NUMA) += numa.o 53acpi-$(CONFIG_ACPI_NUMA) += numa.o
@@ -87,3 +88,7 @@ obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
87obj-$(CONFIG_ACPI_APEI) += apei/ 88obj-$(CONFIG_ACPI_APEI) += apei/
88 89
89obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o 90obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o
91
92obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o
93obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
94obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 93d160661f4c..4f3febf8a589 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ACPI support for Intel Lynxpoint LPSS. 2 * ACPI support for Intel Lynxpoint LPSS.
3 * 3 *
4 * Copyright (C) 2013, Intel Corporation 4 * Copyright (C) 2013, 2014, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> 5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Rafael J. Wysocki <rafael.j.wysocki@intel.com> 6 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 * 7 *
@@ -60,6 +60,8 @@ ACPI_MODULE_NAME("acpi_lpss");
60#define LPSS_CLK_DIVIDER BIT(2) 60#define LPSS_CLK_DIVIDER BIT(2)
61#define LPSS_LTR BIT(3) 61#define LPSS_LTR BIT(3)
62#define LPSS_SAVE_CTX BIT(4) 62#define LPSS_SAVE_CTX BIT(4)
63#define LPSS_DEV_PROXY BIT(5)
64#define LPSS_PROXY_REQ BIT(6)
63 65
64struct lpss_private_data; 66struct lpss_private_data;
65 67
@@ -70,8 +72,10 @@ struct lpss_device_desc {
70 void (*setup)(struct lpss_private_data *pdata); 72 void (*setup)(struct lpss_private_data *pdata);
71}; 73};
72 74
75static struct device *proxy_device;
76
73static struct lpss_device_desc lpss_dma_desc = { 77static struct lpss_device_desc lpss_dma_desc = {
74 .flags = LPSS_CLK, 78 .flags = LPSS_CLK | LPSS_PROXY_REQ,
75}; 79};
76 80
77struct lpss_private_data { 81struct lpss_private_data {
@@ -146,22 +150,24 @@ static struct lpss_device_desc byt_pwm_dev_desc = {
146}; 150};
147 151
148static struct lpss_device_desc byt_uart_dev_desc = { 152static struct lpss_device_desc byt_uart_dev_desc = {
149 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX, 153 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX |
154 LPSS_DEV_PROXY,
150 .prv_offset = 0x800, 155 .prv_offset = 0x800,
151 .setup = lpss_uart_setup, 156 .setup = lpss_uart_setup,
152}; 157};
153 158
154static struct lpss_device_desc byt_spi_dev_desc = { 159static struct lpss_device_desc byt_spi_dev_desc = {
155 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX, 160 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX |
161 LPSS_DEV_PROXY,
156 .prv_offset = 0x400, 162 .prv_offset = 0x400,
157}; 163};
158 164
159static struct lpss_device_desc byt_sdio_dev_desc = { 165static struct lpss_device_desc byt_sdio_dev_desc = {
160 .flags = LPSS_CLK, 166 .flags = LPSS_CLK | LPSS_DEV_PROXY,
161}; 167};
162 168
163static struct lpss_device_desc byt_i2c_dev_desc = { 169static struct lpss_device_desc byt_i2c_dev_desc = {
164 .flags = LPSS_CLK | LPSS_SAVE_CTX, 170 .flags = LPSS_CLK | LPSS_SAVE_CTX | LPSS_DEV_PROXY,
165 .prv_offset = 0x800, 171 .prv_offset = 0x800,
166 .setup = byt_i2c_setup, 172 .setup = byt_i2c_setup,
167}; 173};
@@ -368,6 +374,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
368 adev->driver_data = pdata; 374 adev->driver_data = pdata;
369 pdev = acpi_create_platform_device(adev); 375 pdev = acpi_create_platform_device(adev);
370 if (!IS_ERR_OR_NULL(pdev)) { 376 if (!IS_ERR_OR_NULL(pdev)) {
377 if (!proxy_device && dev_desc->flags & LPSS_DEV_PROXY)
378 proxy_device = &pdev->dev;
371 return 1; 379 return 1;
372 } 380 }
373 381
@@ -499,14 +507,15 @@ static void acpi_lpss_set_ltr(struct device *dev, s32 val)
499/** 507/**
500 * acpi_lpss_save_ctx() - Save the private registers of LPSS device 508 * acpi_lpss_save_ctx() - Save the private registers of LPSS device
501 * @dev: LPSS device 509 * @dev: LPSS device
510 * @pdata: pointer to the private data of the LPSS device
502 * 511 *
503 * Most LPSS devices have private registers which may loose their context when 512 * Most LPSS devices have private registers which may loose their context when
504 * the device is powered down. acpi_lpss_save_ctx() saves those registers into 513 * the device is powered down. acpi_lpss_save_ctx() saves those registers into
505 * prv_reg_ctx array. 514 * prv_reg_ctx array.
506 */ 515 */
507static void acpi_lpss_save_ctx(struct device *dev) 516static void acpi_lpss_save_ctx(struct device *dev,
517 struct lpss_private_data *pdata)
508{ 518{
509 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
510 unsigned int i; 519 unsigned int i;
511 520
512 for (i = 0; i < LPSS_PRV_REG_COUNT; i++) { 521 for (i = 0; i < LPSS_PRV_REG_COUNT; i++) {
@@ -521,12 +530,13 @@ static void acpi_lpss_save_ctx(struct device *dev)
521/** 530/**
522 * acpi_lpss_restore_ctx() - Restore the private registers of LPSS device 531 * acpi_lpss_restore_ctx() - Restore the private registers of LPSS device
523 * @dev: LPSS device 532 * @dev: LPSS device
533 * @pdata: pointer to the private data of the LPSS device
524 * 534 *
525 * Restores the registers that were previously stored with acpi_lpss_save_ctx(). 535 * Restores the registers that were previously stored with acpi_lpss_save_ctx().
526 */ 536 */
527static void acpi_lpss_restore_ctx(struct device *dev) 537static void acpi_lpss_restore_ctx(struct device *dev,
538 struct lpss_private_data *pdata)
528{ 539{
529 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
530 unsigned int i; 540 unsigned int i;
531 541
532 /* 542 /*
@@ -549,54 +559,82 @@ static void acpi_lpss_restore_ctx(struct device *dev)
549#ifdef CONFIG_PM_SLEEP 559#ifdef CONFIG_PM_SLEEP
550static int acpi_lpss_suspend_late(struct device *dev) 560static int acpi_lpss_suspend_late(struct device *dev)
551{ 561{
552 int ret = pm_generic_suspend_late(dev); 562 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
563 int ret;
553 564
565 ret = pm_generic_suspend_late(dev);
554 if (ret) 566 if (ret)
555 return ret; 567 return ret;
556 568
557 acpi_lpss_save_ctx(dev); 569 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
570 acpi_lpss_save_ctx(dev, pdata);
571
558 return acpi_dev_suspend_late(dev); 572 return acpi_dev_suspend_late(dev);
559} 573}
560 574
561static int acpi_lpss_resume_early(struct device *dev) 575static int acpi_lpss_resume_early(struct device *dev)
562{ 576{
563 int ret = acpi_dev_resume_early(dev); 577 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
578 int ret;
564 579
580 ret = acpi_dev_resume_early(dev);
565 if (ret) 581 if (ret)
566 return ret; 582 return ret;
567 583
568 acpi_lpss_restore_ctx(dev); 584 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
585 acpi_lpss_restore_ctx(dev, pdata);
586
569 return pm_generic_resume_early(dev); 587 return pm_generic_resume_early(dev);
570} 588}
571#endif /* CONFIG_PM_SLEEP */ 589#endif /* CONFIG_PM_SLEEP */
572 590
573#ifdef CONFIG_PM_RUNTIME
574static int acpi_lpss_runtime_suspend(struct device *dev) 591static int acpi_lpss_runtime_suspend(struct device *dev)
575{ 592{
576 int ret = pm_generic_runtime_suspend(dev); 593 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
594 int ret;
595
596 ret = pm_generic_runtime_suspend(dev);
597 if (ret)
598 return ret;
577 599
600 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
601 acpi_lpss_save_ctx(dev, pdata);
602
603 ret = acpi_dev_runtime_suspend(dev);
578 if (ret) 604 if (ret)
579 return ret; 605 return ret;
580 606
581 acpi_lpss_save_ctx(dev); 607 if (pdata->dev_desc->flags & LPSS_PROXY_REQ && proxy_device)
582 return acpi_dev_runtime_suspend(dev); 608 return pm_runtime_put_sync_suspend(proxy_device);
609
610 return 0;
583} 611}
584 612
585static int acpi_lpss_runtime_resume(struct device *dev) 613static int acpi_lpss_runtime_resume(struct device *dev)
586{ 614{
587 int ret = acpi_dev_runtime_resume(dev); 615 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
616 int ret;
617
618 if (pdata->dev_desc->flags & LPSS_PROXY_REQ && proxy_device) {
619 ret = pm_runtime_get_sync(proxy_device);
620 if (ret)
621 return ret;
622 }
588 623
624 ret = acpi_dev_runtime_resume(dev);
589 if (ret) 625 if (ret)
590 return ret; 626 return ret;
591 627
592 acpi_lpss_restore_ctx(dev); 628 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
629 acpi_lpss_restore_ctx(dev, pdata);
630
593 return pm_generic_runtime_resume(dev); 631 return pm_generic_runtime_resume(dev);
594} 632}
595#endif /* CONFIG_PM_RUNTIME */
596#endif /* CONFIG_PM */ 633#endif /* CONFIG_PM */
597 634
598static struct dev_pm_domain acpi_lpss_pm_domain = { 635static struct dev_pm_domain acpi_lpss_pm_domain = {
599 .ops = { 636 .ops = {
637#ifdef CONFIG_PM
600#ifdef CONFIG_PM_SLEEP 638#ifdef CONFIG_PM_SLEEP
601 .prepare = acpi_subsys_prepare, 639 .prepare = acpi_subsys_prepare,
602 .complete = acpi_subsys_complete, 640 .complete = acpi_subsys_complete,
@@ -608,7 +646,6 @@ static struct dev_pm_domain acpi_lpss_pm_domain = {
608 .poweroff_late = acpi_lpss_suspend_late, 646 .poweroff_late = acpi_lpss_suspend_late,
609 .restore_early = acpi_lpss_resume_early, 647 .restore_early = acpi_lpss_resume_early,
610#endif 648#endif
611#ifdef CONFIG_PM_RUNTIME
612 .runtime_suspend = acpi_lpss_runtime_suspend, 649 .runtime_suspend = acpi_lpss_runtime_suspend,
613 .runtime_resume = acpi_lpss_runtime_resume, 650 .runtime_resume = acpi_lpss_runtime_resume,
614#endif 651#endif
@@ -631,30 +668,27 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb,
631 return 0; 668 return 0;
632 669
633 pdata = acpi_driver_data(adev); 670 pdata = acpi_driver_data(adev);
634 if (!pdata || !pdata->mmio_base) 671 if (!pdata)
635 return 0; 672 return 0;
636 673
637 if (pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) { 674 if (pdata->mmio_base &&
675 pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) {
638 dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n"); 676 dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n");
639 return 0; 677 return 0;
640 } 678 }
641 679
642 switch (action) { 680 switch (action) {
643 case BUS_NOTIFY_BOUND_DRIVER:
644 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
645 pdev->dev.pm_domain = &acpi_lpss_pm_domain;
646 break;
647 case BUS_NOTIFY_UNBOUND_DRIVER:
648 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
649 pdev->dev.pm_domain = NULL;
650 break;
651 case BUS_NOTIFY_ADD_DEVICE: 681 case BUS_NOTIFY_ADD_DEVICE:
682 pdev->dev.pm_domain = &acpi_lpss_pm_domain;
652 if (pdata->dev_desc->flags & LPSS_LTR) 683 if (pdata->dev_desc->flags & LPSS_LTR)
653 return sysfs_create_group(&pdev->dev.kobj, 684 return sysfs_create_group(&pdev->dev.kobj,
654 &lpss_attr_group); 685 &lpss_attr_group);
686 break;
655 case BUS_NOTIFY_DEL_DEVICE: 687 case BUS_NOTIFY_DEL_DEVICE:
656 if (pdata->dev_desc->flags & LPSS_LTR) 688 if (pdata->dev_desc->flags & LPSS_LTR)
657 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); 689 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
690 pdev->dev.pm_domain = NULL;
691 break;
658 default: 692 default:
659 break; 693 break;
660 } 694 }
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index ebf02cc10a43..7f60582d0c8c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -305,6 +305,7 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_db_output_flags, ACPI_DB_CONSOLE_OUTPUT);
305 305
306ACPI_INIT_GLOBAL(u8, acpi_gbl_no_resource_disassembly, FALSE); 306ACPI_INIT_GLOBAL(u8, acpi_gbl_no_resource_disassembly, FALSE);
307ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE); 307ACPI_INIT_GLOBAL(u8, acpi_gbl_ignore_noop_operator, FALSE);
308ACPI_INIT_GLOBAL(u8, acpi_gbl_cstyle_disassembly, TRUE);
308 309
309ACPI_GLOBAL(u8, acpi_gbl_db_opt_disasm); 310ACPI_GLOBAL(u8, acpi_gbl_db_opt_disasm);
310ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose); 311ACPI_GLOBAL(u8, acpi_gbl_db_opt_verbose);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index c00e7e41ad75..680d23bbae7c 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -454,6 +454,7 @@ struct acpi_gpe_register_info {
454 u16 base_gpe_number; /* Base GPE number for this register */ 454 u16 base_gpe_number; /* Base GPE number for this register */
455 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */ 455 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
456 u8 enable_for_run; /* GPEs to keep enabled when running */ 456 u8 enable_for_run; /* GPEs to keep enabled when running */
457 u8 enable_mask; /* Current mask of enabled GPEs */
457}; 458};
458 459
459/* 460/*
@@ -722,6 +723,7 @@ union acpi_parse_value {
722 ACPI_DISASM_ONLY_MEMBERS (\ 723 ACPI_DISASM_ONLY_MEMBERS (\
723 u8 disasm_flags; /* Used during AML disassembly */\ 724 u8 disasm_flags; /* Used during AML disassembly */\
724 u8 disasm_opcode; /* Subtype used for disassembly */\ 725 u8 disasm_opcode; /* Subtype used for disassembly */\
726 char *operator_symbol;/* Used for C-style operator name strings */\
725 char aml_op_name[16]) /* Op name (debug only) */ 727 char aml_op_name[16]) /* Op name (debug only) */
726 728
727/* Flags for disasm_flags field above */ 729/* Flags for disasm_flags field above */
@@ -827,6 +829,8 @@ struct acpi_parse_state {
827#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 829#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
828#define ACPI_PARSEOP_PREDEF_CHECKED 0x08 830#define ACPI_PARSEOP_PREDEF_CHECKED 0x08
829#define ACPI_PARSEOP_SPECIAL 0x10 831#define ACPI_PARSEOP_SPECIAL 0x10
832#define ACPI_PARSEOP_COMPOUND 0x20
833#define ACPI_PARSEOP_ASSIGNMENT 0x40
830 834
831/***************************************************************************** 835/*****************************************************************************
832 * 836 *
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 2095dfb72bcb..aa70154cf4fa 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -134,7 +134,7 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
134 134
135 /* Enable the requested GPE */ 135 /* Enable the requested GPE */
136 136
137 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); 137 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE_SAVE);
138 return_ACPI_STATUS(status); 138 return_ACPI_STATUS(status);
139} 139}
140 140
@@ -213,7 +213,7 @@ acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
213 if (ACPI_SUCCESS(status)) { 213 if (ACPI_SUCCESS(status)) {
214 status = 214 status =
215 acpi_hw_low_set_gpe(gpe_event_info, 215 acpi_hw_low_set_gpe(gpe_event_info,
216 ACPI_GPE_DISABLE); 216 ACPI_GPE_DISABLE_SAVE);
217 } 217 }
218 218
219 if (ACPI_FAILURE(status)) { 219 if (ACPI_FAILURE(status)) {
@@ -616,8 +616,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
616static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context) 616static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context)
617{ 617{
618 struct acpi_gpe_event_info *gpe_event_info = context; 618 struct acpi_gpe_event_info *gpe_event_info = context;
619 acpi_cpu_flags flags;
619 620
621 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
620 (void)acpi_ev_finish_gpe(gpe_event_info); 622 (void)acpi_ev_finish_gpe(gpe_event_info);
623 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
621 624
622 ACPI_FREE(gpe_event_info); 625 ACPI_FREE(gpe_event_info);
623 return; 626 return;
@@ -655,7 +658,7 @@ acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info * gpe_event_info)
655 658
656 /* 659 /*
657 * Enable this GPE, conditionally. This means that the GPE will 660 * Enable this GPE, conditionally. This means that the GPE will
658 * only be physically enabled if the enable_for_run bit is set 661 * only be physically enabled if the enable_mask bit is set
659 * in the event_info. 662 * in the event_info.
660 */ 663 */
661 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_CONDITIONAL_ENABLE); 664 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_CONDITIONAL_ENABLE);
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 48ac7b7b59cd..494027f5c067 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -115,12 +115,12 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
115 /* Set or clear just the bit that corresponds to this GPE */ 115 /* Set or clear just the bit that corresponds to this GPE */
116 116
117 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 117 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
118 switch (action) { 118 switch (action & ~ACPI_GPE_SAVE_MASK) {
119 case ACPI_GPE_CONDITIONAL_ENABLE: 119 case ACPI_GPE_CONDITIONAL_ENABLE:
120 120
121 /* Only enable if the enable_for_run bit is set */ 121 /* Only enable if the corresponding enable_mask bit is set */
122 122
123 if (!(register_bit & gpe_register_info->enable_for_run)) { 123 if (!(register_bit & gpe_register_info->enable_mask)) {
124 return (AE_BAD_PARAMETER); 124 return (AE_BAD_PARAMETER);
125 } 125 }
126 126
@@ -145,6 +145,9 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
145 /* Write the updated enable mask */ 145 /* Write the updated enable mask */
146 146
147 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address); 147 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
148 if (ACPI_SUCCESS(status) && (action & ACPI_GPE_SAVE_MASK)) {
149 gpe_register_info->enable_mask = enable_mask;
150 }
148 return (status); 151 return (status);
149} 152}
150 153
@@ -262,6 +265,32 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
262 265
263/****************************************************************************** 266/******************************************************************************
264 * 267 *
268 * FUNCTION: acpi_hw_gpe_enable_write
269 *
270 * PARAMETERS: enable_mask - Bit mask to write to the GPE register
271 * gpe_register_info - Gpe Register info
272 *
273 * RETURN: Status
274 *
275 * DESCRIPTION: Write the enable mask byte to the given GPE register.
276 *
277 ******************************************************************************/
278
279static acpi_status
280acpi_hw_gpe_enable_write(u8 enable_mask,
281 struct acpi_gpe_register_info *gpe_register_info)
282{
283 acpi_status status;
284
285 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
286 if (ACPI_SUCCESS(status)) {
287 gpe_register_info->enable_mask = enable_mask;
288 }
289 return (status);
290}
291
292/******************************************************************************
293 *
265 * FUNCTION: acpi_hw_disable_gpe_block 294 * FUNCTION: acpi_hw_disable_gpe_block
266 * 295 *
267 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info 296 * PARAMETERS: gpe_xrupt_info - GPE Interrupt info
@@ -287,8 +316,8 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
287 /* Disable all GPEs in this register */ 316 /* Disable all GPEs in this register */
288 317
289 status = 318 status =
290 acpi_hw_write(0x00, 319 acpi_hw_gpe_enable_write(0x00,
291 &gpe_block->register_info[i].enable_address); 320 &gpe_block->register_info[i]);
292 if (ACPI_FAILURE(status)) { 321 if (ACPI_FAILURE(status)) {
293 return (status); 322 return (status);
294 } 323 }
@@ -355,21 +384,23 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
355{ 384{
356 u32 i; 385 u32 i;
357 acpi_status status; 386 acpi_status status;
387 struct acpi_gpe_register_info *gpe_register_info;
358 388
359 /* NOTE: assumes that all GPEs are currently disabled */ 389 /* NOTE: assumes that all GPEs are currently disabled */
360 390
361 /* Examine each GPE Register within the block */ 391 /* Examine each GPE Register within the block */
362 392
363 for (i = 0; i < gpe_block->register_count; i++) { 393 for (i = 0; i < gpe_block->register_count; i++) {
364 if (!gpe_block->register_info[i].enable_for_run) { 394 gpe_register_info = &gpe_block->register_info[i];
395 if (!gpe_register_info->enable_for_run) {
365 continue; 396 continue;
366 } 397 }
367 398
368 /* Enable all "runtime" GPEs in this register */ 399 /* Enable all "runtime" GPEs in this register */
369 400
370 status = 401 status =
371 acpi_hw_write(gpe_block->register_info[i].enable_for_run, 402 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_run,
372 &gpe_block->register_info[i].enable_address); 403 gpe_register_info);
373 if (ACPI_FAILURE(status)) { 404 if (ACPI_FAILURE(status)) {
374 return (status); 405 return (status);
375 } 406 }
@@ -399,10 +430,12 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
399{ 430{
400 u32 i; 431 u32 i;
401 acpi_status status; 432 acpi_status status;
433 struct acpi_gpe_register_info *gpe_register_info;
402 434
403 /* Examine each GPE Register within the block */ 435 /* Examine each GPE Register within the block */
404 436
405 for (i = 0; i < gpe_block->register_count; i++) { 437 for (i = 0; i < gpe_block->register_count; i++) {
438 gpe_register_info = &gpe_block->register_info[i];
406 439
407 /* 440 /*
408 * Enable all "wake" GPEs in this register and disable the 441 * Enable all "wake" GPEs in this register and disable the
@@ -410,8 +443,8 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
410 */ 443 */
411 444
412 status = 445 status =
413 acpi_hw_write(gpe_block->register_info[i].enable_for_wake, 446 acpi_hw_gpe_enable_write(gpe_register_info->enable_for_wake,
414 &gpe_block->register_info[i].enable_address); 447 gpe_register_info);
415 if (ACPI_FAILURE(status)) { 448 if (ACPI_FAILURE(status)) {
416 return (status); 449 return (status);
417 } 450 }
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 5cd017c7ac0e..bc1ff820c7dd 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -263,7 +263,7 @@ const char *acpi_gbl_bpb_decode[] = {
263/* UART serial bus stop bits */ 263/* UART serial bus stop bits */
264 264
265const char *acpi_gbl_sb_decode[] = { 265const char *acpi_gbl_sb_decode[] = {
266 "StopBitsNone", 266 "StopBitsZero",
267 "StopBitsOne", 267 "StopBitsOne",
268 "StopBitsOnePlusHalf", 268 "StopBitsOnePlusHalf",
269 "StopBitsTwo" 269 "StopBitsTwo"
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 502a8492dc83..49c873c68756 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -531,7 +531,9 @@ acpi_decode_pld_buffer(u8 *in_buffer,
531 ACPI_MOVE_32_TO_32(&dword, &buffer[0]); 531 ACPI_MOVE_32_TO_32(&dword, &buffer[0]);
532 pld_info->revision = ACPI_PLD_GET_REVISION(&dword); 532 pld_info->revision = ACPI_PLD_GET_REVISION(&dword);
533 pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword); 533 pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword);
534 pld_info->color = ACPI_PLD_GET_COLOR(&dword); 534 pld_info->red = ACPI_PLD_GET_RED(&dword);
535 pld_info->green = ACPI_PLD_GET_GREEN(&dword);
536 pld_info->blue = ACPI_PLD_GET_BLUE(&dword);
535 537
536 /* Second 32-bit DWord */ 538 /* Second 32-bit DWord */
537 539
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 13380d818462..b1fd6886e439 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -53,6 +53,9 @@
53#define _COMPONENT ACPI_UTILITIES 53#define _COMPONENT ACPI_UTILITIES
54ACPI_MODULE_NAME("utxfinit") 54ACPI_MODULE_NAME("utxfinit")
55 55
56/* For acpi_exec only */
57void ae_do_object_overrides(void);
58
56/******************************************************************************* 59/*******************************************************************************
57 * 60 *
58 * FUNCTION: acpi_initialize_subsystem 61 * FUNCTION: acpi_initialize_subsystem
@@ -65,6 +68,7 @@ ACPI_MODULE_NAME("utxfinit")
65 * called, so any early initialization belongs here. 68 * called, so any early initialization belongs here.
66 * 69 *
67 ******************************************************************************/ 70 ******************************************************************************/
71
68acpi_status __init acpi_initialize_subsystem(void) 72acpi_status __init acpi_initialize_subsystem(void)
69{ 73{
70 acpi_status status; 74 acpi_status status;
@@ -275,6 +279,13 @@ acpi_status __init acpi_initialize_objects(u32 flags)
275 return_ACPI_STATUS(status); 279 return_ACPI_STATUS(status);
276 } 280 }
277 } 281 }
282#ifdef ACPI_EXEC_APP
283 /*
284 * This call implements the "initialization file" option for acpi_exec.
285 * This is the precise point that we want to perform the overrides.
286 */
287 ae_do_object_overrides();
288#endif
278 289
279 /* 290 /*
280 * Execute any module-level code that was detected during the table load 291 * Execute any module-level code that was detected during the table load
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 8ec8a89a20ab..d98ba4355819 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1180,6 +1180,10 @@ static int acpi_battery_add(struct acpi_device *device)
1180 1180
1181 if (!device) 1181 if (!device)
1182 return -EINVAL; 1182 return -EINVAL;
1183
1184 if (device->dep_unmet)
1185 return -EPROBE_DEFER;
1186
1183 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); 1187 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
1184 if (!battery) 1188 if (!battery)
1185 return -ENOMEM; 1189 return -ENOMEM;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 7db193160766..897640188acd 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -201,7 +201,7 @@ int acpi_device_set_power(struct acpi_device *device, int state)
201 * Transition Power 201 * Transition Power
202 * ---------------- 202 * ----------------
203 * In accordance with the ACPI specification first apply power (via 203 * In accordance with the ACPI specification first apply power (via
204 * power resources) and then evalute _PSx. 204 * power resources) and then evaluate _PSx.
205 */ 205 */
206 if (device->power.flags.power_resources) { 206 if (device->power.flags.power_resources) {
207 result = acpi_power_transition(device, state); 207 result = acpi_power_transition(device, state);
@@ -692,7 +692,6 @@ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state,
692 return 0; 692 return 0;
693} 693}
694 694
695#ifdef CONFIG_PM_RUNTIME
696/** 695/**
697 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device. 696 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device.
698 * @dev: Device to enable/disable the platform to wake up. 697 * @dev: Device to enable/disable the platform to wake up.
@@ -714,7 +713,6 @@ int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
714 return acpi_device_wakeup(adev, ACPI_STATE_S0, enable); 713 return acpi_device_wakeup(adev, ACPI_STATE_S0, enable);
715} 714}
716EXPORT_SYMBOL(acpi_pm_device_run_wake); 715EXPORT_SYMBOL(acpi_pm_device_run_wake);
717#endif /* CONFIG_PM_RUNTIME */
718 716
719#ifdef CONFIG_PM_SLEEP 717#ifdef CONFIG_PM_SLEEP
720/** 718/**
@@ -773,7 +771,6 @@ static int acpi_dev_pm_full_power(struct acpi_device *adev)
773 acpi_device_set_power(adev, ACPI_STATE_D0) : 0; 771 acpi_device_set_power(adev, ACPI_STATE_D0) : 0;
774} 772}
775 773
776#ifdef CONFIG_PM_RUNTIME
777/** 774/**
778 * acpi_dev_runtime_suspend - Put device into a low-power state using ACPI. 775 * acpi_dev_runtime_suspend - Put device into a low-power state using ACPI.
779 * @dev: Device to put into a low-power state. 776 * @dev: Device to put into a low-power state.
@@ -855,7 +852,6 @@ int acpi_subsys_runtime_resume(struct device *dev)
855 return ret ? ret : pm_generic_runtime_resume(dev); 852 return ret ? ret : pm_generic_runtime_resume(dev);
856} 853}
857EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); 854EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
858#endif /* CONFIG_PM_RUNTIME */
859 855
860#ifdef CONFIG_PM_SLEEP 856#ifdef CONFIG_PM_SLEEP
861/** 857/**
@@ -1023,10 +1019,9 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
1023 1019
1024static struct dev_pm_domain acpi_general_pm_domain = { 1020static struct dev_pm_domain acpi_general_pm_domain = {
1025 .ops = { 1021 .ops = {
1026#ifdef CONFIG_PM_RUNTIME 1022#ifdef CONFIG_PM
1027 .runtime_suspend = acpi_subsys_runtime_suspend, 1023 .runtime_suspend = acpi_subsys_runtime_suspend,
1028 .runtime_resume = acpi_subsys_runtime_resume, 1024 .runtime_resume = acpi_subsys_runtime_resume,
1029#endif
1030#ifdef CONFIG_PM_SLEEP 1025#ifdef CONFIG_PM_SLEEP
1031 .prepare = acpi_subsys_prepare, 1026 .prepare = acpi_subsys_prepare,
1032 .complete = acpi_subsys_complete, 1027 .complete = acpi_subsys_complete,
@@ -1038,6 +1033,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
1038 .poweroff_late = acpi_subsys_suspend_late, 1033 .poweroff_late = acpi_subsys_suspend_late,
1039 .restore_early = acpi_subsys_resume_early, 1034 .restore_early = acpi_subsys_resume_early,
1040#endif 1035#endif
1036#endif
1041 }, 1037 },
1042}; 1038};
1043 1039
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 447f6d679b29..163e82f536fa 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -173,4 +173,10 @@ static inline void suspend_nvs_restore(void) {}
173bool acpi_osi_is_win8(void); 173bool acpi_osi_is_win8(void);
174#endif 174#endif
175 175
176/*--------------------------------------------------------------------------
177 Device properties
178 -------------------------------------------------------------------------- */
179void acpi_init_properties(struct acpi_device *adev);
180void acpi_free_properties(struct acpi_device *adev);
181
176#endif /* _ACPI_INTERNAL_H_ */ 182#endif /* _ACPI_INTERNAL_H_ */
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 9964f70be98d..f9eeae871593 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -436,7 +436,7 @@ static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
436static void acpi_os_map_cleanup(struct acpi_ioremap *map) 436static void acpi_os_map_cleanup(struct acpi_ioremap *map)
437{ 437{
438 if (!map->refcount) { 438 if (!map->refcount) {
439 synchronize_rcu(); 439 synchronize_rcu_expedited();
440 acpi_unmap(map->phys, map->virt); 440 acpi_unmap(map->phys, map->virt);
441 kfree(map); 441 kfree(map);
442 } 442 }
@@ -1188,6 +1188,12 @@ EXPORT_SYMBOL(acpi_os_execute);
1188 1188
1189void acpi_os_wait_events_complete(void) 1189void acpi_os_wait_events_complete(void)
1190{ 1190{
1191 /*
1192 * Make sure the GPE handler or the fixed event handler is not used
1193 * on another CPU after removal.
1194 */
1195 if (acpi_irq_handler)
1196 synchronize_hardirq(acpi_gbl_FADT.sci_interrupt);
1191 flush_workqueue(kacpid_wq); 1197 flush_workqueue(kacpid_wq);
1192 flush_workqueue(kacpi_notify_wq); 1198 flush_workqueue(kacpi_notify_wq);
1193} 1199}
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 6e6b80eb0bba..7cc4e33179f9 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -484,7 +484,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
484 /* Keep IOAPIC pin configuration when suspending */ 484 /* Keep IOAPIC pin configuration when suspending */
485 if (dev->dev.power.is_prepared) 485 if (dev->dev.power.is_prepared)
486 return; 486 return;
487#ifdef CONFIG_PM_RUNTIME 487#ifdef CONFIG_PM
488 if (dev->dev.power.runtime_status == RPM_SUSPENDING) 488 if (dev->dev.power.runtime_status == RPM_SUSPENDING)
489 return; 489 return;
490#endif 490#endif
diff --git a/drivers/acpi/pmic/intel_pmic.c b/drivers/acpi/pmic/intel_pmic.c
new file mode 100644
index 000000000000..a732e5d7e322
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic.c
@@ -0,0 +1,354 @@
1/*
2 * intel_pmic.c - Intel PMIC operation region driver
3 *
4 * Copyright (C) 2014 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/acpi.h>
18#include <linux/regmap.h>
19#include "intel_pmic.h"
20
21#define PMIC_POWER_OPREGION_ID 0x8d
22#define PMIC_THERMAL_OPREGION_ID 0x8c
23
24struct acpi_lpat {
25 int temp;
26 int raw;
27};
28
29struct intel_pmic_opregion {
30 struct mutex lock;
31 struct acpi_lpat *lpat;
32 int lpat_count;
33 struct regmap *regmap;
34 struct intel_pmic_opregion_data *data;
35};
36
37static int pmic_get_reg_bit(int address, struct pmic_table *table,
38 int count, int *reg, int *bit)
39{
40 int i;
41
42 for (i = 0; i < count; i++) {
43 if (table[i].address == address) {
44 *reg = table[i].reg;
45 if (bit)
46 *bit = table[i].bit;
47 return 0;
48 }
49 }
50 return -ENOENT;
51}
52
53/**
54 * raw_to_temp(): Return temperature from raw value through LPAT table
55 *
56 * @lpat: the temperature_raw mapping table
57 * @count: the count of the above mapping table
58 * @raw: the raw value, used as a key to get the temerature from the
59 * above mapping table
60 *
61 * A positive value will be returned on success, a negative errno will
62 * be returned in error cases.
63 */
64static int raw_to_temp(struct acpi_lpat *lpat, int count, int raw)
65{
66 int i, delta_temp, delta_raw, temp;
67
68 for (i = 0; i < count - 1; i++) {
69 if ((raw >= lpat[i].raw && raw <= lpat[i+1].raw) ||
70 (raw <= lpat[i].raw && raw >= lpat[i+1].raw))
71 break;
72 }
73
74 if (i == count - 1)
75 return -ENOENT;
76
77 delta_temp = lpat[i+1].temp - lpat[i].temp;
78 delta_raw = lpat[i+1].raw - lpat[i].raw;
79 temp = lpat[i].temp + (raw - lpat[i].raw) * delta_temp / delta_raw;
80
81 return temp;
82}
83
84/**
85 * temp_to_raw(): Return raw value from temperature through LPAT table
86 *
87 * @lpat: the temperature_raw mapping table
88 * @count: the count of the above mapping table
89 * @temp: the temperature, used as a key to get the raw value from the
90 * above mapping table
91 *
92 * A positive value will be returned on success, a negative errno will
93 * be returned in error cases.
94 */
95static int temp_to_raw(struct acpi_lpat *lpat, int count, int temp)
96{
97 int i, delta_temp, delta_raw, raw;
98
99 for (i = 0; i < count - 1; i++) {
100 if (temp >= lpat[i].temp && temp <= lpat[i+1].temp)
101 break;
102 }
103
104 if (i == count - 1)
105 return -ENOENT;
106
107 delta_temp = lpat[i+1].temp - lpat[i].temp;
108 delta_raw = lpat[i+1].raw - lpat[i].raw;
109 raw = lpat[i].raw + (temp - lpat[i].temp) * delta_raw / delta_temp;
110
111 return raw;
112}
113
114static void pmic_thermal_lpat(struct intel_pmic_opregion *opregion,
115 acpi_handle handle, struct device *dev)
116{
117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
118 union acpi_object *obj_p, *obj_e;
119 int *lpat, i;
120 acpi_status status;
121
122 status = acpi_evaluate_object(handle, "LPAT", NULL, &buffer);
123 if (ACPI_FAILURE(status))
124 return;
125
126 obj_p = (union acpi_object *)buffer.pointer;
127 if (!obj_p || (obj_p->type != ACPI_TYPE_PACKAGE) ||
128 (obj_p->package.count % 2) || (obj_p->package.count < 4))
129 goto out;
130
131 lpat = devm_kmalloc(dev, sizeof(int) * obj_p->package.count,
132 GFP_KERNEL);
133 if (!lpat)
134 goto out;
135
136 for (i = 0; i < obj_p->package.count; i++) {
137 obj_e = &obj_p->package.elements[i];
138 if (obj_e->type != ACPI_TYPE_INTEGER) {
139 devm_kfree(dev, lpat);
140 goto out;
141 }
142 lpat[i] = (s64)obj_e->integer.value;
143 }
144
145 opregion->lpat = (struct acpi_lpat *)lpat;
146 opregion->lpat_count = obj_p->package.count / 2;
147
148out:
149 kfree(buffer.pointer);
150}
151
152static acpi_status intel_pmic_power_handler(u32 function,
153 acpi_physical_address address, u32 bits, u64 *value64,
154 void *handler_context, void *region_context)
155{
156 struct intel_pmic_opregion *opregion = region_context;
157 struct regmap *regmap = opregion->regmap;
158 struct intel_pmic_opregion_data *d = opregion->data;
159 int reg, bit, result;
160
161 if (bits != 32 || !value64)
162 return AE_BAD_PARAMETER;
163
164 if (function == ACPI_WRITE && !(*value64 == 0 || *value64 == 1))
165 return AE_BAD_PARAMETER;
166
167 result = pmic_get_reg_bit(address, d->power_table,
168 d->power_table_count, &reg, &bit);
169 if (result == -ENOENT)
170 return AE_BAD_PARAMETER;
171
172 mutex_lock(&opregion->lock);
173
174 result = function == ACPI_READ ?
175 d->get_power(regmap, reg, bit, value64) :
176 d->update_power(regmap, reg, bit, *value64 == 1);
177
178 mutex_unlock(&opregion->lock);
179
180 return result ? AE_ERROR : AE_OK;
181}
182
183static int pmic_read_temp(struct intel_pmic_opregion *opregion,
184 int reg, u64 *value)
185{
186 int raw_temp, temp;
187
188 if (!opregion->data->get_raw_temp)
189 return -ENXIO;
190
191 raw_temp = opregion->data->get_raw_temp(opregion->regmap, reg);
192 if (raw_temp < 0)
193 return raw_temp;
194
195 if (!opregion->lpat) {
196 *value = raw_temp;
197 return 0;
198 }
199
200 temp = raw_to_temp(opregion->lpat, opregion->lpat_count, raw_temp);
201 if (temp < 0)
202 return temp;
203
204 *value = temp;
205 return 0;
206}
207
208static int pmic_thermal_temp(struct intel_pmic_opregion *opregion, int reg,
209 u32 function, u64 *value)
210{
211 return function == ACPI_READ ?
212 pmic_read_temp(opregion, reg, value) : -EINVAL;
213}
214
215static int pmic_thermal_aux(struct intel_pmic_opregion *opregion, int reg,
216 u32 function, u64 *value)
217{
218 int raw_temp;
219
220 if (function == ACPI_READ)
221 return pmic_read_temp(opregion, reg, value);
222
223 if (!opregion->data->update_aux)
224 return -ENXIO;
225
226 if (opregion->lpat) {
227 raw_temp = temp_to_raw(opregion->lpat, opregion->lpat_count,
228 *value);
229 if (raw_temp < 0)
230 return raw_temp;
231 } else {
232 raw_temp = *value;
233 }
234
235 return opregion->data->update_aux(opregion->regmap, reg, raw_temp);
236}
237
238static int pmic_thermal_pen(struct intel_pmic_opregion *opregion, int reg,
239 u32 function, u64 *value)
240{
241 struct intel_pmic_opregion_data *d = opregion->data;
242 struct regmap *regmap = opregion->regmap;
243
244 if (!d->get_policy || !d->update_policy)
245 return -ENXIO;
246
247 if (function == ACPI_READ)
248 return d->get_policy(regmap, reg, value);
249
250 if (*value != 0 && *value != 1)
251 return -EINVAL;
252
253 return d->update_policy(regmap, reg, *value);
254}
255
256static bool pmic_thermal_is_temp(int address)
257{
258 return (address <= 0x3c) && !(address % 12);
259}
260
261static bool pmic_thermal_is_aux(int address)
262{
263 return (address >= 4 && address <= 0x40 && !((address - 4) % 12)) ||
264 (address >= 8 && address <= 0x44 && !((address - 8) % 12));
265}
266
267static bool pmic_thermal_is_pen(int address)
268{
269 return address >= 0x48 && address <= 0x5c;
270}
271
272static acpi_status intel_pmic_thermal_handler(u32 function,
273 acpi_physical_address address, u32 bits, u64 *value64,
274 void *handler_context, void *region_context)
275{
276 struct intel_pmic_opregion *opregion = region_context;
277 struct intel_pmic_opregion_data *d = opregion->data;
278 int reg, result;
279
280 if (bits != 32 || !value64)
281 return AE_BAD_PARAMETER;
282
283 result = pmic_get_reg_bit(address, d->thermal_table,
284 d->thermal_table_count, &reg, NULL);
285 if (result == -ENOENT)
286 return AE_BAD_PARAMETER;
287
288 mutex_lock(&opregion->lock);
289
290 if (pmic_thermal_is_temp(address))
291 result = pmic_thermal_temp(opregion, reg, function, value64);
292 else if (pmic_thermal_is_aux(address))
293 result = pmic_thermal_aux(opregion, reg, function, value64);
294 else if (pmic_thermal_is_pen(address))
295 result = pmic_thermal_pen(opregion, reg, function, value64);
296 else
297 result = -EINVAL;
298
299 mutex_unlock(&opregion->lock);
300
301 if (result < 0) {
302 if (result == -EINVAL)
303 return AE_BAD_PARAMETER;
304 else
305 return AE_ERROR;
306 }
307
308 return AE_OK;
309}
310
311int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
312 struct regmap *regmap,
313 struct intel_pmic_opregion_data *d)
314{
315 acpi_status status;
316 struct intel_pmic_opregion *opregion;
317
318 if (!dev || !regmap || !d)
319 return -EINVAL;
320
321 if (!handle)
322 return -ENODEV;
323
324 opregion = devm_kzalloc(dev, sizeof(*opregion), GFP_KERNEL);
325 if (!opregion)
326 return -ENOMEM;
327
328 mutex_init(&opregion->lock);
329 opregion->regmap = regmap;
330 pmic_thermal_lpat(opregion, handle, dev);
331
332 status = acpi_install_address_space_handler(handle,
333 PMIC_POWER_OPREGION_ID,
334 intel_pmic_power_handler,
335 NULL, opregion);
336 if (ACPI_FAILURE(status))
337 return -ENODEV;
338
339 status = acpi_install_address_space_handler(handle,
340 PMIC_THERMAL_OPREGION_ID,
341 intel_pmic_thermal_handler,
342 NULL, opregion);
343 if (ACPI_FAILURE(status)) {
344 acpi_remove_address_space_handler(handle, PMIC_POWER_OPREGION_ID,
345 intel_pmic_power_handler);
346 return -ENODEV;
347 }
348
349 opregion->data = d;
350 return 0;
351}
352EXPORT_SYMBOL_GPL(intel_pmic_install_opregion_handler);
353
354MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/pmic/intel_pmic.h b/drivers/acpi/pmic/intel_pmic.h
new file mode 100644
index 000000000000..d4e90af8f0dd
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic.h
@@ -0,0 +1,25 @@
1#ifndef __INTEL_PMIC_H
2#define __INTEL_PMIC_H
3
4struct pmic_table {
5 int address; /* operation region address */
6 int reg; /* corresponding thermal register */
7 int bit; /* control bit for power */
8};
9
10struct intel_pmic_opregion_data {
11 int (*get_power)(struct regmap *r, int reg, int bit, u64 *value);
12 int (*update_power)(struct regmap *r, int reg, int bit, bool on);
13 int (*get_raw_temp)(struct regmap *r, int reg);
14 int (*update_aux)(struct regmap *r, int reg, int raw_temp);
15 int (*get_policy)(struct regmap *r, int reg, u64 *value);
16 int (*update_policy)(struct regmap *r, int reg, int enable);
17 struct pmic_table *power_table;
18 int power_table_count;
19 struct pmic_table *thermal_table;
20 int thermal_table_count;
21};
22
23int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle, struct regmap *regmap, struct intel_pmic_opregion_data *d);
24
25#endif
diff --git a/drivers/acpi/pmic/intel_pmic_crc.c b/drivers/acpi/pmic/intel_pmic_crc.c
new file mode 100644
index 000000000000..ef7d8ff95abe
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_crc.c
@@ -0,0 +1,211 @@
1/*
2 * intel_pmic_crc.c - Intel CrystalCove PMIC operation region driver
3 *
4 * Copyright (C) 2014 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/acpi.h>
18#include <linux/mfd/intel_soc_pmic.h>
19#include <linux/regmap.h>
20#include <linux/platform_device.h>
21#include "intel_pmic.h"
22
23#define PWR_SOURCE_SELECT BIT(1)
24
25#define PMIC_A0LOCK_REG 0xc5
26
27static struct pmic_table power_table[] = {
28 {
29 .address = 0x24,
30 .reg = 0x66,
31 .bit = 0x00,
32 },
33 {
34 .address = 0x48,
35 .reg = 0x5d,
36 .bit = 0x00,
37 },
38};
39
40static struct pmic_table thermal_table[] = {
41 {
42 .address = 0x00,
43 .reg = 0x75
44 },
45 {
46 .address = 0x04,
47 .reg = 0x95
48 },
49 {
50 .address = 0x08,
51 .reg = 0x97
52 },
53 {
54 .address = 0x0c,
55 .reg = 0x77
56 },
57 {
58 .address = 0x10,
59 .reg = 0x9a
60 },
61 {
62 .address = 0x14,
63 .reg = 0x9c
64 },
65 {
66 .address = 0x18,
67 .reg = 0x79
68 },
69 {
70 .address = 0x1c,
71 .reg = 0x9f
72 },
73 {
74 .address = 0x20,
75 .reg = 0xa1
76 },
77 {
78 .address = 0x48,
79 .reg = 0x94
80 },
81 {
82 .address = 0x4c,
83 .reg = 0x99
84 },
85 {
86 .address = 0x50,
87 .reg = 0x9e
88 },
89};
90
91static int intel_crc_pmic_get_power(struct regmap *regmap, int reg,
92 int bit, u64 *value)
93{
94 int data;
95
96 if (regmap_read(regmap, reg, &data))
97 return -EIO;
98
99 *value = (data & PWR_SOURCE_SELECT) && (data & BIT(bit)) ? 1 : 0;
100 return 0;
101}
102
103static int intel_crc_pmic_update_power(struct regmap *regmap, int reg,
104 int bit, bool on)
105{
106 int data;
107
108 if (regmap_read(regmap, reg, &data))
109 return -EIO;
110
111 if (on) {
112 data |= PWR_SOURCE_SELECT | BIT(bit);
113 } else {
114 data &= ~BIT(bit);
115 data |= PWR_SOURCE_SELECT;
116 }
117
118 if (regmap_write(regmap, reg, data))
119 return -EIO;
120 return 0;
121}
122
123static int intel_crc_pmic_get_raw_temp(struct regmap *regmap, int reg)
124{
125 int temp_l, temp_h;
126
127 /*
128 * Raw temperature value is 10bits: 8bits in reg
129 * and 2bits in reg-1: bit0,1
130 */
131 if (regmap_read(regmap, reg, &temp_l) ||
132 regmap_read(regmap, reg - 1, &temp_h))
133 return -EIO;
134
135 return temp_l | (temp_h & 0x3) << 8;
136}
137
138static int intel_crc_pmic_update_aux(struct regmap *regmap, int reg, int raw)
139{
140 return regmap_write(regmap, reg, raw) ||
141 regmap_update_bits(regmap, reg - 1, 0x3, raw >> 8) ? -EIO : 0;
142}
143
144static int intel_crc_pmic_get_policy(struct regmap *regmap, int reg, u64 *value)
145{
146 int pen;
147
148 if (regmap_read(regmap, reg, &pen))
149 return -EIO;
150 *value = pen >> 7;
151 return 0;
152}
153
154static int intel_crc_pmic_update_policy(struct regmap *regmap,
155 int reg, int enable)
156{
157 int alert0;
158
159 /* Update to policy enable bit requires unlocking a0lock */
160 if (regmap_read(regmap, PMIC_A0LOCK_REG, &alert0))
161 return -EIO;
162
163 if (regmap_update_bits(regmap, PMIC_A0LOCK_REG, 0x01, 0))
164 return -EIO;
165
166 if (regmap_update_bits(regmap, reg, 0x80, enable << 7))
167 return -EIO;
168
169 /* restore alert0 */
170 if (regmap_write(regmap, PMIC_A0LOCK_REG, alert0))
171 return -EIO;
172
173 return 0;
174}
175
176static struct intel_pmic_opregion_data intel_crc_pmic_opregion_data = {
177 .get_power = intel_crc_pmic_get_power,
178 .update_power = intel_crc_pmic_update_power,
179 .get_raw_temp = intel_crc_pmic_get_raw_temp,
180 .update_aux = intel_crc_pmic_update_aux,
181 .get_policy = intel_crc_pmic_get_policy,
182 .update_policy = intel_crc_pmic_update_policy,
183 .power_table = power_table,
184 .power_table_count= ARRAY_SIZE(power_table),
185 .thermal_table = thermal_table,
186 .thermal_table_count = ARRAY_SIZE(thermal_table),
187};
188
189static int intel_crc_pmic_opregion_probe(struct platform_device *pdev)
190{
191 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
192 return intel_pmic_install_opregion_handler(&pdev->dev,
193 ACPI_HANDLE(pdev->dev.parent), pmic->regmap,
194 &intel_crc_pmic_opregion_data);
195}
196
197static struct platform_driver intel_crc_pmic_opregion_driver = {
198 .probe = intel_crc_pmic_opregion_probe,
199 .driver = {
200 .name = "crystal_cove_pmic",
201 },
202};
203
204static int __init intel_crc_pmic_opregion_driver_init(void)
205{
206 return platform_driver_register(&intel_crc_pmic_opregion_driver);
207}
208module_init(intel_crc_pmic_opregion_driver_init);
209
210MODULE_DESCRIPTION("CrystalCove ACPI opration region driver");
211MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
new file mode 100644
index 000000000000..6a082d4de12c
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -0,0 +1,268 @@
1/*
2 * intel_pmic_xpower.c - XPower AXP288 PMIC operation region driver
3 *
4 * Copyright (C) 2014 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/acpi.h>
18#include <linux/mfd/axp20x.h>
19#include <linux/regmap.h>
20#include <linux/platform_device.h>
21#include <linux/iio/consumer.h>
22#include "intel_pmic.h"
23
24#define XPOWER_GPADC_LOW 0x5b
25
26static struct pmic_table power_table[] = {
27 {
28 .address = 0x00,
29 .reg = 0x13,
30 .bit = 0x05,
31 },
32 {
33 .address = 0x04,
34 .reg = 0x13,
35 .bit = 0x06,
36 },
37 {
38 .address = 0x08,
39 .reg = 0x13,
40 .bit = 0x07,
41 },
42 {
43 .address = 0x0c,
44 .reg = 0x12,
45 .bit = 0x03,
46 },
47 {
48 .address = 0x10,
49 .reg = 0x12,
50 .bit = 0x04,
51 },
52 {
53 .address = 0x14,
54 .reg = 0x12,
55 .bit = 0x05,
56 },
57 {
58 .address = 0x18,
59 .reg = 0x12,
60 .bit = 0x06,
61 },
62 {
63 .address = 0x1c,
64 .reg = 0x12,
65 .bit = 0x00,
66 },
67 {
68 .address = 0x20,
69 .reg = 0x12,
70 .bit = 0x01,
71 },
72 {
73 .address = 0x24,
74 .reg = 0x12,
75 .bit = 0x02,
76 },
77 {
78 .address = 0x28,
79 .reg = 0x13,
80 .bit = 0x02,
81 },
82 {
83 .address = 0x2c,
84 .reg = 0x13,
85 .bit = 0x03,
86 },
87 {
88 .address = 0x30,
89 .reg = 0x13,
90 .bit = 0x04,
91 },
92 {
93 .address = 0x38,
94 .reg = 0x10,
95 .bit = 0x03,
96 },
97 {
98 .address = 0x3c,
99 .reg = 0x10,
100 .bit = 0x06,
101 },
102 {
103 .address = 0x40,
104 .reg = 0x10,
105 .bit = 0x05,
106 },
107 {
108 .address = 0x44,
109 .reg = 0x10,
110 .bit = 0x04,
111 },
112 {
113 .address = 0x48,
114 .reg = 0x10,
115 .bit = 0x01,
116 },
117 {
118 .address = 0x4c,
119 .reg = 0x10,
120 .bit = 0x00
121 },
122};
123
124/* TMP0 - TMP5 are the same, all from GPADC */
125static struct pmic_table thermal_table[] = {
126 {
127 .address = 0x00,
128 .reg = XPOWER_GPADC_LOW
129 },
130 {
131 .address = 0x0c,
132 .reg = XPOWER_GPADC_LOW
133 },
134 {
135 .address = 0x18,
136 .reg = XPOWER_GPADC_LOW
137 },
138 {
139 .address = 0x24,
140 .reg = XPOWER_GPADC_LOW
141 },
142 {
143 .address = 0x30,
144 .reg = XPOWER_GPADC_LOW
145 },
146 {
147 .address = 0x3c,
148 .reg = XPOWER_GPADC_LOW
149 },
150};
151
152static int intel_xpower_pmic_get_power(struct regmap *regmap, int reg,
153 int bit, u64 *value)
154{
155 int data;
156
157 if (regmap_read(regmap, reg, &data))
158 return -EIO;
159
160 *value = (data & BIT(bit)) ? 1 : 0;
161 return 0;
162}
163
164static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
165 int bit, bool on)
166{
167 int data;
168
169 if (regmap_read(regmap, reg, &data))
170 return -EIO;
171
172 if (on)
173 data |= BIT(bit);
174 else
175 data &= ~BIT(bit);
176
177 if (regmap_write(regmap, reg, data))
178 return -EIO;
179
180 return 0;
181}
182
183/**
184 * intel_xpower_pmic_get_raw_temp(): Get raw temperature reading from the PMIC
185 *
186 * @regmap: regmap of the PMIC device
187 * @reg: register to get the reading
188 *
189 * We could get the sensor value by manipulating the HW regs here, but since
190 * the axp288 IIO driver may also access the same regs at the same time, the
191 * APIs provided by IIO subsystem are used here instead to avoid problems. As
192 * a result, the two passed in params are of no actual use.
193 *
194 * Return a positive value on success, errno on failure.
195 */
196static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
197{
198 struct iio_channel *gpadc_chan;
199 int ret, val;
200
201 gpadc_chan = iio_channel_get(NULL, "axp288-system-temp");
202 if (IS_ERR_OR_NULL(gpadc_chan))
203 return -EACCES;
204
205 ret = iio_read_channel_raw(gpadc_chan, &val);
206 if (ret < 0)
207 val = ret;
208
209 iio_channel_release(gpadc_chan);
210 return val;
211}
212
213static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
214 .get_power = intel_xpower_pmic_get_power,
215 .update_power = intel_xpower_pmic_update_power,
216 .get_raw_temp = intel_xpower_pmic_get_raw_temp,
217 .power_table = power_table,
218 .power_table_count = ARRAY_SIZE(power_table),
219 .thermal_table = thermal_table,
220 .thermal_table_count = ARRAY_SIZE(thermal_table),
221};
222
223static acpi_status intel_xpower_pmic_gpio_handler(u32 function,
224 acpi_physical_address address, u32 bit_width, u64 *value,
225 void *handler_context, void *region_context)
226{
227 return AE_OK;
228}
229
230static int intel_xpower_pmic_opregion_probe(struct platform_device *pdev)
231{
232 struct device *parent = pdev->dev.parent;
233 struct axp20x_dev *axp20x = dev_get_drvdata(parent);
234 acpi_status status;
235 int result;
236
237 status = acpi_install_address_space_handler(ACPI_HANDLE(parent),
238 ACPI_ADR_SPACE_GPIO, intel_xpower_pmic_gpio_handler,
239 NULL, NULL);
240 if (ACPI_FAILURE(status))
241 return -ENODEV;
242
243 result = intel_pmic_install_opregion_handler(&pdev->dev,
244 ACPI_HANDLE(parent), axp20x->regmap,
245 &intel_xpower_pmic_opregion_data);
246 if (result)
247 acpi_remove_address_space_handler(ACPI_HANDLE(parent),
248 ACPI_ADR_SPACE_GPIO,
249 intel_xpower_pmic_gpio_handler);
250
251 return result;
252}
253
254static struct platform_driver intel_xpower_pmic_opregion_driver = {
255 .probe = intel_xpower_pmic_opregion_probe,
256 .driver = {
257 .name = "axp288_pmic_acpi",
258 },
259};
260
261static int __init intel_xpower_pmic_opregion_driver_init(void)
262{
263 return platform_driver_register(&intel_xpower_pmic_opregion_driver);
264}
265module_init(intel_xpower_pmic_opregion_driver_init);
266
267MODULE_DESCRIPTION("XPower AXP288 ACPI operation region driver");
268MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 17f9ec501972..499536504698 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -334,10 +334,10 @@ static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
334 334
335static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 335static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
336{ 336{
337 acpi_status status = 0; 337 acpi_status status;
338 u64 count; 338 u64 count;
339 int current_count; 339 int current_count;
340 int i; 340 int i, ret = 0;
341 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 341 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
342 union acpi_object *cst; 342 union acpi_object *cst;
343 343
@@ -358,7 +358,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
358 /* There must be at least 2 elements */ 358 /* There must be at least 2 elements */
359 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { 359 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
360 printk(KERN_ERR PREFIX "not enough elements in _CST\n"); 360 printk(KERN_ERR PREFIX "not enough elements in _CST\n");
361 status = -EFAULT; 361 ret = -EFAULT;
362 goto end; 362 goto end;
363 } 363 }
364 364
@@ -367,7 +367,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
367 /* Validate number of power states. */ 367 /* Validate number of power states. */
368 if (count < 1 || count != cst->package.count - 1) { 368 if (count < 1 || count != cst->package.count - 1) {
369 printk(KERN_ERR PREFIX "count given by _CST is not valid\n"); 369 printk(KERN_ERR PREFIX "count given by _CST is not valid\n");
370 status = -EFAULT; 370 ret = -EFAULT;
371 goto end; 371 goto end;
372 } 372 }
373 373
@@ -489,12 +489,12 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
489 489
490 /* Validate number of power states discovered */ 490 /* Validate number of power states discovered */
491 if (current_count < 2) 491 if (current_count < 2)
492 status = -EFAULT; 492 ret = -EFAULT;
493 493
494 end: 494 end:
495 kfree(buffer.pointer); 495 kfree(buffer.pointer);
496 496
497 return status; 497 return ret;
498} 498}
499 499
500static void acpi_processor_power_verify_c3(struct acpi_processor *pr, 500static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
@@ -985,8 +985,8 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
985 state->flags = 0; 985 state->flags = 0;
986 switch (cx->type) { 986 switch (cx->type) {
987 case ACPI_STATE_C1: 987 case ACPI_STATE_C1:
988 if (cx->entry_method == ACPI_CSTATE_FFH) 988 if (cx->entry_method != ACPI_CSTATE_FFH)
989 state->flags |= CPUIDLE_FLAG_TIME_VALID; 989 state->flags |= CPUIDLE_FLAG_TIME_INVALID;
990 990
991 state->enter = acpi_idle_enter_c1; 991 state->enter = acpi_idle_enter_c1;
992 state->enter_dead = acpi_idle_play_dead; 992 state->enter_dead = acpi_idle_play_dead;
@@ -994,14 +994,12 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
994 break; 994 break;
995 995
996 case ACPI_STATE_C2: 996 case ACPI_STATE_C2:
997 state->flags |= CPUIDLE_FLAG_TIME_VALID;
998 state->enter = acpi_idle_enter_simple; 997 state->enter = acpi_idle_enter_simple;
999 state->enter_dead = acpi_idle_play_dead; 998 state->enter_dead = acpi_idle_play_dead;
1000 drv->safe_state_index = count; 999 drv->safe_state_index = count;
1001 break; 1000 break;
1002 1001
1003 case ACPI_STATE_C3: 1002 case ACPI_STATE_C3:
1004 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1005 state->enter = pr->flags.bm_check ? 1003 state->enter = pr->flags.bm_check ?
1006 acpi_idle_enter_bm : 1004 acpi_idle_enter_bm :
1007 acpi_idle_enter_simple; 1005 acpi_idle_enter_simple;
@@ -1111,7 +1109,7 @@ static int acpi_processor_registered;
1111 1109
1112int acpi_processor_power_init(struct acpi_processor *pr) 1110int acpi_processor_power_init(struct acpi_processor *pr)
1113{ 1111{
1114 acpi_status status = 0; 1112 acpi_status status;
1115 int retval; 1113 int retval;
1116 struct cpuidle_device *dev; 1114 struct cpuidle_device *dev;
1117 static int first_run; 1115 static int first_run;
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
new file mode 100644
index 000000000000..0d083736e25b
--- /dev/null
+++ b/drivers/acpi/property.c
@@ -0,0 +1,551 @@
1/*
2 * ACPI device specific properties support.
3 *
4 * Copyright (C) 2014, Intel Corporation
5 * All rights reserved.
6 *
7 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
8 * Darren Hart <dvhart@linux.intel.com>
9 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/acpi.h>
17#include <linux/device.h>
18#include <linux/export.h>
19
20#include "internal.h"
21
22/* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
23static const u8 prp_uuid[16] = {
24 0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d,
25 0x8a, 0x91, 0xbc, 0x9b, 0xbf, 0x4a, 0xa3, 0x01
26};
27
28static bool acpi_property_value_ok(const union acpi_object *value)
29{
30 int j;
31
32 /*
33 * The value must be an integer, a string, a reference, or a package
34 * whose every element must be an integer, a string, or a reference.
35 */
36 switch (value->type) {
37 case ACPI_TYPE_INTEGER:
38 case ACPI_TYPE_STRING:
39 case ACPI_TYPE_LOCAL_REFERENCE:
40 return true;
41
42 case ACPI_TYPE_PACKAGE:
43 for (j = 0; j < value->package.count; j++)
44 switch (value->package.elements[j].type) {
45 case ACPI_TYPE_INTEGER:
46 case ACPI_TYPE_STRING:
47 case ACPI_TYPE_LOCAL_REFERENCE:
48 continue;
49
50 default:
51 return false;
52 }
53
54 return true;
55 }
56 return false;
57}
58
59static bool acpi_properties_format_valid(const union acpi_object *properties)
60{
61 int i;
62
63 for (i = 0; i < properties->package.count; i++) {
64 const union acpi_object *property;
65
66 property = &properties->package.elements[i];
67 /*
68 * Only two elements allowed, the first one must be a string and
69 * the second one has to satisfy certain conditions.
70 */
71 if (property->package.count != 2
72 || property->package.elements[0].type != ACPI_TYPE_STRING
73 || !acpi_property_value_ok(&property->package.elements[1]))
74 return false;
75 }
76 return true;
77}
78
79static void acpi_init_of_compatible(struct acpi_device *adev)
80{
81 const union acpi_object *of_compatible;
82 struct acpi_hardware_id *hwid;
83 bool acpi_of = false;
84 int ret;
85
86 /*
87 * Check if the special PRP0001 ACPI ID is present and in that
88 * case we fill in Device Tree compatible properties for this
89 * device.
90 */
91 list_for_each_entry(hwid, &adev->pnp.ids, list) {
92 if (!strcmp(hwid->id, "PRP0001")) {
93 acpi_of = true;
94 break;
95 }
96 }
97
98 if (!acpi_of)
99 return;
100
101 ret = acpi_dev_get_property_array(adev, "compatible", ACPI_TYPE_STRING,
102 &of_compatible);
103 if (ret) {
104 ret = acpi_dev_get_property(adev, "compatible",
105 ACPI_TYPE_STRING, &of_compatible);
106 if (ret) {
107 acpi_handle_warn(adev->handle,
108 "PRP0001 requires compatible property\n");
109 return;
110 }
111 }
112 adev->data.of_compatible = of_compatible;
113}
114
115void acpi_init_properties(struct acpi_device *adev)
116{
117 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
118 const union acpi_object *desc;
119 acpi_status status;
120 int i;
121
122 status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL, &buf,
123 ACPI_TYPE_PACKAGE);
124 if (ACPI_FAILURE(status))
125 return;
126
127 desc = buf.pointer;
128 if (desc->package.count % 2)
129 goto fail;
130
131 /* Look for the device properties UUID. */
132 for (i = 0; i < desc->package.count; i += 2) {
133 const union acpi_object *uuid, *properties;
134
135 uuid = &desc->package.elements[i];
136 properties = &desc->package.elements[i + 1];
137
138 /*
139 * The first element must be a UUID and the second one must be
140 * a package.
141 */
142 if (uuid->type != ACPI_TYPE_BUFFER || uuid->buffer.length != 16
143 || properties->type != ACPI_TYPE_PACKAGE)
144 break;
145
146 if (memcmp(uuid->buffer.pointer, prp_uuid, sizeof(prp_uuid)))
147 continue;
148
149 /*
150 * We found the matching UUID. Now validate the format of the
151 * package immediately following it.
152 */
153 if (!acpi_properties_format_valid(properties))
154 break;
155
156 adev->data.pointer = buf.pointer;
157 adev->data.properties = properties;
158
159 acpi_init_of_compatible(adev);
160 return;
161 }
162
163 fail:
164 dev_warn(&adev->dev, "Returned _DSD data is not valid, skipping\n");
165 ACPI_FREE(buf.pointer);
166}
167
168void acpi_free_properties(struct acpi_device *adev)
169{
170 ACPI_FREE((void *)adev->data.pointer);
171 adev->data.of_compatible = NULL;
172 adev->data.pointer = NULL;
173 adev->data.properties = NULL;
174}
175
176/**
177 * acpi_dev_get_property - return an ACPI property with given name
178 * @adev: ACPI device to get property
179 * @name: Name of the property
180 * @type: Expected property type
181 * @obj: Location to store the property value (if not %NULL)
182 *
183 * Look up a property with @name and store a pointer to the resulting ACPI
184 * object at the location pointed to by @obj if found.
185 *
186 * Callers must not attempt to free the returned objects. These objects will be
187 * freed by the ACPI core automatically during the removal of @adev.
188 *
189 * Return: %0 if property with @name has been found (success),
190 * %-EINVAL if the arguments are invalid,
191 * %-ENODATA if the property doesn't exist,
192 * %-EPROTO if the property value type doesn't match @type.
193 */
194int acpi_dev_get_property(struct acpi_device *adev, const char *name,
195 acpi_object_type type, const union acpi_object **obj)
196{
197 const union acpi_object *properties;
198 int i;
199
200 if (!adev || !name)
201 return -EINVAL;
202
203 if (!adev->data.pointer || !adev->data.properties)
204 return -ENODATA;
205
206 properties = adev->data.properties;
207 for (i = 0; i < properties->package.count; i++) {
208 const union acpi_object *propname, *propvalue;
209 const union acpi_object *property;
210
211 property = &properties->package.elements[i];
212
213 propname = &property->package.elements[0];
214 propvalue = &property->package.elements[1];
215
216 if (!strcmp(name, propname->string.pointer)) {
217 if (type != ACPI_TYPE_ANY && propvalue->type != type)
218 return -EPROTO;
219 else if (obj)
220 *obj = propvalue;
221
222 return 0;
223 }
224 }
225 return -ENODATA;
226}
227EXPORT_SYMBOL_GPL(acpi_dev_get_property);
228
229/**
230 * acpi_dev_get_property_array - return an ACPI array property with given name
231 * @adev: ACPI device to get property
232 * @name: Name of the property
233 * @type: Expected type of array elements
234 * @obj: Location to store a pointer to the property value (if not NULL)
235 *
236 * Look up an array property with @name and store a pointer to the resulting
237 * ACPI object at the location pointed to by @obj if found.
238 *
239 * Callers must not attempt to free the returned objects. Those objects will be
240 * freed by the ACPI core automatically during the removal of @adev.
241 *
242 * Return: %0 if array property (package) with @name has been found (success),
243 * %-EINVAL if the arguments are invalid,
244 * %-ENODATA if the property doesn't exist,
245 * %-EPROTO if the property is not a package or the type of its elements
246 * doesn't match @type.
247 */
248int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
249 acpi_object_type type,
250 const union acpi_object **obj)
251{
252 const union acpi_object *prop;
253 int ret, i;
254
255 ret = acpi_dev_get_property(adev, name, ACPI_TYPE_PACKAGE, &prop);
256 if (ret)
257 return ret;
258
259 if (type != ACPI_TYPE_ANY) {
260 /* Check that all elements are of correct type. */
261 for (i = 0; i < prop->package.count; i++)
262 if (prop->package.elements[i].type != type)
263 return -EPROTO;
264 }
265 if (obj)
266 *obj = prop;
267
268 return 0;
269}
270EXPORT_SYMBOL_GPL(acpi_dev_get_property_array);
271
272/**
273 * acpi_dev_get_property_reference - returns handle to the referenced object
274 * @adev: ACPI device to get property
275 * @name: Name of the property
276 * @index: Index of the reference to return
277 * @args: Location to store the returned reference with optional arguments
278 *
279 * Find property with @name, verifify that it is a package containing at least
280 * one object reference and if so, store the ACPI device object pointer to the
281 * target object in @args->adev. If the reference includes arguments, store
282 * them in the @args->args[] array.
283 *
284 * If there's more than one reference in the property value package, @index is
285 * used to select the one to return.
286 *
287 * Return: %0 on success, negative error code on failure.
288 */
289int acpi_dev_get_property_reference(struct acpi_device *adev,
290 const char *name, size_t index,
291 struct acpi_reference_args *args)
292{
293 const union acpi_object *element, *end;
294 const union acpi_object *obj;
295 struct acpi_device *device;
296 int ret, idx = 0;
297
298 ret = acpi_dev_get_property(adev, name, ACPI_TYPE_ANY, &obj);
299 if (ret)
300 return ret;
301
302 /*
303 * The simplest case is when the value is a single reference. Just
304 * return that reference then.
305 */
306 if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) {
307 if (index)
308 return -EINVAL;
309
310 ret = acpi_bus_get_device(obj->reference.handle, &device);
311 if (ret)
312 return ret;
313
314 args->adev = device;
315 args->nargs = 0;
316 return 0;
317 }
318
319 /*
320 * If it is not a single reference, then it is a package of
321 * references followed by number of ints as follows:
322 *
323 * Package () { REF, INT, REF, INT, INT }
324 *
325 * The index argument is then used to determine which reference
326 * the caller wants (along with the arguments).
327 */
328 if (obj->type != ACPI_TYPE_PACKAGE || index >= obj->package.count)
329 return -EPROTO;
330
331 element = obj->package.elements;
332 end = element + obj->package.count;
333
334 while (element < end) {
335 u32 nargs, i;
336
337 if (element->type != ACPI_TYPE_LOCAL_REFERENCE)
338 return -EPROTO;
339
340 ret = acpi_bus_get_device(element->reference.handle, &device);
341 if (ret)
342 return -ENODEV;
343
344 element++;
345 nargs = 0;
346
347 /* assume following integer elements are all args */
348 for (i = 0; element + i < end; i++) {
349 int type = element[i].type;
350
351 if (type == ACPI_TYPE_INTEGER)
352 nargs++;
353 else if (type == ACPI_TYPE_LOCAL_REFERENCE)
354 break;
355 else
356 return -EPROTO;
357 }
358
359 if (idx++ == index) {
360 args->adev = device;
361 args->nargs = nargs;
362 for (i = 0; i < nargs; i++)
363 args->args[i] = element[i].integer.value;
364
365 return 0;
366 }
367
368 element += nargs;
369 }
370
371 return -EPROTO;
372}
373EXPORT_SYMBOL_GPL(acpi_dev_get_property_reference);
374
375int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
376 void **valptr)
377{
378 return acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY,
379 (const union acpi_object **)valptr);
380}
381
382int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
383 enum dev_prop_type proptype, void *val)
384{
385 const union acpi_object *obj;
386 int ret;
387
388 if (!val)
389 return -EINVAL;
390
391 if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) {
392 ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_INTEGER, &obj);
393 if (ret)
394 return ret;
395
396 switch (proptype) {
397 case DEV_PROP_U8:
398 if (obj->integer.value > U8_MAX)
399 return -EOVERFLOW;
400 *(u8 *)val = obj->integer.value;
401 break;
402 case DEV_PROP_U16:
403 if (obj->integer.value > U16_MAX)
404 return -EOVERFLOW;
405 *(u16 *)val = obj->integer.value;
406 break;
407 case DEV_PROP_U32:
408 if (obj->integer.value > U32_MAX)
409 return -EOVERFLOW;
410 *(u32 *)val = obj->integer.value;
411 break;
412 default:
413 *(u64 *)val = obj->integer.value;
414 break;
415 }
416 } else if (proptype == DEV_PROP_STRING) {
417 ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_STRING, &obj);
418 if (ret)
419 return ret;
420
421 *(char **)val = obj->string.pointer;
422 } else {
423 ret = -EINVAL;
424 }
425 return ret;
426}
427
428static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val,
429 size_t nval)
430{
431 int i;
432
433 for (i = 0; i < nval; i++) {
434 if (items[i].type != ACPI_TYPE_INTEGER)
435 return -EPROTO;
436 if (items[i].integer.value > U8_MAX)
437 return -EOVERFLOW;
438
439 val[i] = items[i].integer.value;
440 }
441 return 0;
442}
443
444static int acpi_copy_property_array_u16(const union acpi_object *items,
445 u16 *val, size_t nval)
446{
447 int i;
448
449 for (i = 0; i < nval; i++) {
450 if (items[i].type != ACPI_TYPE_INTEGER)
451 return -EPROTO;
452 if (items[i].integer.value > U16_MAX)
453 return -EOVERFLOW;
454
455 val[i] = items[i].integer.value;
456 }
457 return 0;
458}
459
460static int acpi_copy_property_array_u32(const union acpi_object *items,
461 u32 *val, size_t nval)
462{
463 int i;
464
465 for (i = 0; i < nval; i++) {
466 if (items[i].type != ACPI_TYPE_INTEGER)
467 return -EPROTO;
468 if (items[i].integer.value > U32_MAX)
469 return -EOVERFLOW;
470
471 val[i] = items[i].integer.value;
472 }
473 return 0;
474}
475
476static int acpi_copy_property_array_u64(const union acpi_object *items,
477 u64 *val, size_t nval)
478{
479 int i;
480
481 for (i = 0; i < nval; i++) {
482 if (items[i].type != ACPI_TYPE_INTEGER)
483 return -EPROTO;
484
485 val[i] = items[i].integer.value;
486 }
487 return 0;
488}
489
490static int acpi_copy_property_array_string(const union acpi_object *items,
491 char **val, size_t nval)
492{
493 int i;
494
495 for (i = 0; i < nval; i++) {
496 if (items[i].type != ACPI_TYPE_STRING)
497 return -EPROTO;
498
499 val[i] = items[i].string.pointer;
500 }
501 return 0;
502}
503
504int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
505 enum dev_prop_type proptype, void *val, size_t nval)
506{
507 const union acpi_object *obj;
508 const union acpi_object *items;
509 int ret;
510
511 if (val && nval == 1) {
512 ret = acpi_dev_prop_read_single(adev, propname, proptype, val);
513 if (!ret)
514 return ret;
515 }
516
517 ret = acpi_dev_get_property_array(adev, propname, ACPI_TYPE_ANY, &obj);
518 if (ret)
519 return ret;
520
521 if (!val)
522 return obj->package.count;
523 else if (nval <= 0)
524 return -EINVAL;
525
526 if (nval > obj->package.count)
527 return -EOVERFLOW;
528
529 items = obj->package.elements;
530 switch (proptype) {
531 case DEV_PROP_U8:
532 ret = acpi_copy_property_array_u8(items, (u8 *)val, nval);
533 break;
534 case DEV_PROP_U16:
535 ret = acpi_copy_property_array_u16(items, (u16 *)val, nval);
536 break;
537 case DEV_PROP_U32:
538 ret = acpi_copy_property_array_u32(items, (u32 *)val, nval);
539 break;
540 case DEV_PROP_U64:
541 ret = acpi_copy_property_array_u64(items, (u64 *)val, nval);
542 break;
543 case DEV_PROP_STRING:
544 ret = acpi_copy_property_array_string(items, (char **)val, nval);
545 break;
546 default:
547 ret = -EINVAL;
548 break;
549 }
550 return ret;
551}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 0476e90b2091..1b1cf558d3d3 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -36,6 +36,8 @@ bool acpi_force_hot_remove;
36 36
37static const char *dummy_hid = "device"; 37static const char *dummy_hid = "device";
38 38
39static LIST_HEAD(acpi_dep_list);
40static DEFINE_MUTEX(acpi_dep_list_lock);
39static LIST_HEAD(acpi_bus_id_list); 41static LIST_HEAD(acpi_bus_id_list);
40static DEFINE_MUTEX(acpi_scan_lock); 42static DEFINE_MUTEX(acpi_scan_lock);
41static LIST_HEAD(acpi_scan_handlers_list); 43static LIST_HEAD(acpi_scan_handlers_list);
@@ -43,6 +45,12 @@ DEFINE_MUTEX(acpi_device_lock);
43LIST_HEAD(acpi_wakeup_device_list); 45LIST_HEAD(acpi_wakeup_device_list);
44static DEFINE_MUTEX(acpi_hp_context_lock); 46static DEFINE_MUTEX(acpi_hp_context_lock);
45 47
48struct acpi_dep_data {
49 struct list_head node;
50 acpi_handle master;
51 acpi_handle slave;
52};
53
46struct acpi_device_bus_id{ 54struct acpi_device_bus_id{
47 char bus_id[15]; 55 char bus_id[15];
48 unsigned int instance_no; 56 unsigned int instance_no;
@@ -124,17 +132,56 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
124 if (list_empty(&acpi_dev->pnp.ids)) 132 if (list_empty(&acpi_dev->pnp.ids))
125 return 0; 133 return 0;
126 134
127 len = snprintf(modalias, size, "acpi:"); 135 /*
128 size -= len; 136 * If the device has PRP0001 we expose DT compatible modalias
129 137 * instead in form of of:NnameTCcompatible.
130 list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 138 */
131 count = snprintf(&modalias[len], size, "%s:", id->id); 139 if (acpi_dev->data.of_compatible) {
132 if (count < 0) 140 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
133 return -EINVAL; 141 const union acpi_object *of_compatible, *obj;
134 if (count >= size) 142 int i, nval;
135 return -ENOMEM; 143 char *c;
136 len += count; 144
137 size -= count; 145 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
146 /* DT strings are all in lower case */
147 for (c = buf.pointer; *c != '\0'; c++)
148 *c = tolower(*c);
149
150 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
151 ACPI_FREE(buf.pointer);
152
153 of_compatible = acpi_dev->data.of_compatible;
154 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
155 nval = of_compatible->package.count;
156 obj = of_compatible->package.elements;
157 } else { /* Must be ACPI_TYPE_STRING. */
158 nval = 1;
159 obj = of_compatible;
160 }
161 for (i = 0; i < nval; i++, obj++) {
162 count = snprintf(&modalias[len], size, "C%s",
163 obj->string.pointer);
164 if (count < 0)
165 return -EINVAL;
166 if (count >= size)
167 return -ENOMEM;
168
169 len += count;
170 size -= count;
171 }
172 } else {
173 len = snprintf(modalias, size, "acpi:");
174 size -= len;
175
176 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
177 count = snprintf(&modalias[len], size, "%s:", id->id);
178 if (count < 0)
179 return -EINVAL;
180 if (count >= size)
181 return -ENOMEM;
182 len += count;
183 size -= count;
184 }
138 } 185 }
139 186
140 modalias[len] = '\0'; 187 modalias[len] = '\0';
@@ -902,6 +949,51 @@ int acpi_match_device_ids(struct acpi_device *device,
902} 949}
903EXPORT_SYMBOL(acpi_match_device_ids); 950EXPORT_SYMBOL(acpi_match_device_ids);
904 951
952/* Performs match against special "PRP0001" shoehorn ACPI ID */
953static bool acpi_of_driver_match_device(struct device *dev,
954 const struct device_driver *drv)
955{
956 const union acpi_object *of_compatible, *obj;
957 struct acpi_device *adev;
958 int i, nval;
959
960 adev = ACPI_COMPANION(dev);
961 if (!adev)
962 return false;
963
964 of_compatible = adev->data.of_compatible;
965 if (!drv->of_match_table || !of_compatible)
966 return false;
967
968 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
969 nval = of_compatible->package.count;
970 obj = of_compatible->package.elements;
971 } else { /* Must be ACPI_TYPE_STRING. */
972 nval = 1;
973 obj = of_compatible;
974 }
975 /* Now we can look for the driver DT compatible strings */
976 for (i = 0; i < nval; i++, obj++) {
977 const struct of_device_id *id;
978
979 for (id = drv->of_match_table; id->compatible[0]; id++)
980 if (!strcasecmp(obj->string.pointer, id->compatible))
981 return true;
982 }
983
984 return false;
985}
986
987bool acpi_driver_match_device(struct device *dev,
988 const struct device_driver *drv)
989{
990 if (!drv->acpi_match_table)
991 return acpi_of_driver_match_device(dev, drv);
992
993 return !!acpi_match_device(drv->acpi_match_table, dev);
994}
995EXPORT_SYMBOL_GPL(acpi_driver_match_device);
996
905static void acpi_free_power_resources_lists(struct acpi_device *device) 997static void acpi_free_power_resources_lists(struct acpi_device *device)
906{ 998{
907 int i; 999 int i;
@@ -922,6 +1014,7 @@ static void acpi_device_release(struct device *dev)
922{ 1014{
923 struct acpi_device *acpi_dev = to_acpi_device(dev); 1015 struct acpi_device *acpi_dev = to_acpi_device(dev);
924 1016
1017 acpi_free_properties(acpi_dev);
925 acpi_free_pnp_ids(&acpi_dev->pnp); 1018 acpi_free_pnp_ids(&acpi_dev->pnp);
926 acpi_free_power_resources_lists(acpi_dev); 1019 acpi_free_power_resources_lists(acpi_dev);
927 kfree(acpi_dev); 1020 kfree(acpi_dev);
@@ -1304,6 +1397,26 @@ int acpi_device_add(struct acpi_device *device,
1304 return result; 1397 return result;
1305} 1398}
1306 1399
1400struct acpi_device *acpi_get_next_child(struct device *dev,
1401 struct acpi_device *child)
1402{
1403 struct acpi_device *adev = ACPI_COMPANION(dev);
1404 struct list_head *head, *next;
1405
1406 if (!adev)
1407 return NULL;
1408
1409 head = &adev->children;
1410 if (list_empty(head))
1411 return NULL;
1412
1413 if (!child)
1414 return list_first_entry(head, struct acpi_device, node);
1415
1416 next = child->node.next;
1417 return next == head ? NULL : list_entry(next, struct acpi_device, node);
1418}
1419
1307/* -------------------------------------------------------------------------- 1420/* --------------------------------------------------------------------------
1308 Driver Management 1421 Driver Management
1309 -------------------------------------------------------------------------- */ 1422 -------------------------------------------------------------------------- */
@@ -1923,9 +2036,11 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1923 device->device_type = type; 2036 device->device_type = type;
1924 device->handle = handle; 2037 device->handle = handle;
1925 device->parent = acpi_bus_get_parent(handle); 2038 device->parent = acpi_bus_get_parent(handle);
2039 device->fwnode.type = FWNODE_ACPI;
1926 acpi_set_device_status(device, sta); 2040 acpi_set_device_status(device, sta);
1927 acpi_device_get_busid(device); 2041 acpi_device_get_busid(device);
1928 acpi_set_pnp_ids(handle, &device->pnp, type); 2042 acpi_set_pnp_ids(handle, &device->pnp, type);
2043 acpi_init_properties(device);
1929 acpi_bus_get_flags(device); 2044 acpi_bus_get_flags(device);
1930 device->flags.match_driver = false; 2045 device->flags.match_driver = false;
1931 device->flags.initialized = true; 2046 device->flags.initialized = true;
@@ -2086,6 +2201,59 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
2086 } 2201 }
2087} 2202}
2088 2203
2204static void acpi_device_dep_initialize(struct acpi_device *adev)
2205{
2206 struct acpi_dep_data *dep;
2207 struct acpi_handle_list dep_devices;
2208 acpi_status status;
2209 int i;
2210
2211 if (!acpi_has_method(adev->handle, "_DEP"))
2212 return;
2213
2214 status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
2215 &dep_devices);
2216 if (ACPI_FAILURE(status)) {
2217 dev_err(&adev->dev, "Failed to evaluate _DEP.\n");
2218 return;
2219 }
2220
2221 for (i = 0; i < dep_devices.count; i++) {
2222 struct acpi_device_info *info;
2223 int skip;
2224
2225 status = acpi_get_object_info(dep_devices.handles[i], &info);
2226 if (ACPI_FAILURE(status)) {
2227 dev_err(&adev->dev, "Error reading device info\n");
2228 continue;
2229 }
2230
2231 /*
2232 * Skip the dependency of Windows System Power
2233 * Management Controller
2234 */
2235 skip = info->valid & ACPI_VALID_HID &&
2236 !strcmp(info->hardware_id.string, "INT3396");
2237
2238 kfree(info);
2239
2240 if (skip)
2241 continue;
2242
2243 dep = kzalloc(sizeof(struct acpi_dep_data), GFP_KERNEL);
2244 if (!dep)
2245 return;
2246
2247 dep->master = dep_devices.handles[i];
2248 dep->slave = adev->handle;
2249 adev->dep_unmet++;
2250
2251 mutex_lock(&acpi_dep_list_lock);
2252 list_add_tail(&dep->node , &acpi_dep_list);
2253 mutex_unlock(&acpi_dep_list_lock);
2254 }
2255}
2256
2089static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, 2257static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
2090 void *not_used, void **return_value) 2258 void *not_used, void **return_value)
2091{ 2259{
@@ -2112,6 +2280,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
2112 return AE_CTRL_DEPTH; 2280 return AE_CTRL_DEPTH;
2113 2281
2114 acpi_scan_init_hotplug(device); 2282 acpi_scan_init_hotplug(device);
2283 acpi_device_dep_initialize(device);
2115 2284
2116 out: 2285 out:
2117 if (!*return_value) 2286 if (!*return_value)
@@ -2232,6 +2401,29 @@ static void acpi_bus_attach(struct acpi_device *device)
2232 device->handler->hotplug.notify_online(device); 2401 device->handler->hotplug.notify_online(device);
2233} 2402}
2234 2403
2404void acpi_walk_dep_device_list(acpi_handle handle)
2405{
2406 struct acpi_dep_data *dep, *tmp;
2407 struct acpi_device *adev;
2408
2409 mutex_lock(&acpi_dep_list_lock);
2410 list_for_each_entry_safe(dep, tmp, &acpi_dep_list, node) {
2411 if (dep->master == handle) {
2412 acpi_bus_get_device(dep->slave, &adev);
2413 if (!adev)
2414 continue;
2415
2416 adev->dep_unmet--;
2417 if (!adev->dep_unmet)
2418 acpi_bus_attach(adev);
2419 list_del(&dep->node);
2420 kfree(dep);
2421 }
2422 }
2423 mutex_unlock(&acpi_dep_list_lock);
2424}
2425EXPORT_SYMBOL_GPL(acpi_walk_dep_device_list);
2426
2235/** 2427/**
2236 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. 2428 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
2237 * @handle: Root of the namespace scope to scan. 2429 * @handle: Root of the namespace scope to scan.
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 05a31b573fc3..8aa9254a387f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -630,6 +630,7 @@ static int acpi_freeze_begin(void)
630static int acpi_freeze_prepare(void) 630static int acpi_freeze_prepare(void)
631{ 631{
632 acpi_enable_all_wakeup_gpes(); 632 acpi_enable_all_wakeup_gpes();
633 acpi_os_wait_events_complete();
633 enable_irq_wake(acpi_gbl_FADT.sci_interrupt); 634 enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
634 return 0; 635 return 0;
635} 636}
@@ -825,6 +826,7 @@ static void acpi_power_off_prepare(void)
825 /* Prepare to power off the system */ 826 /* Prepare to power off the system */
826 acpi_sleep_prepare(ACPI_STATE_S5); 827 acpi_sleep_prepare(ACPI_STATE_S5);
827 acpi_disable_all_gpes(); 828 acpi_disable_all_gpes();
829 acpi_os_wait_events_complete();
828} 830}
829 831
830static void acpi_power_off(void) 832static void acpi_power_off(void)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 6d5a6cda0734..93b81523a2fe 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -190,30 +190,24 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
190 } 190 }
191} 191}
192 192
193
194int __init 193int __init
195acpi_table_parse_entries(char *id, 194acpi_parse_entries(char *id, unsigned long table_size,
196 unsigned long table_size, 195 acpi_tbl_entry_handler handler,
197 int entry_id, 196 struct acpi_table_header *table_header,
198 acpi_tbl_entry_handler handler, 197 int entry_id, unsigned int max_entries)
199 unsigned int max_entries)
200{ 198{
201 struct acpi_table_header *table_header = NULL;
202 struct acpi_subtable_header *entry; 199 struct acpi_subtable_header *entry;
203 unsigned int count = 0; 200 int count = 0;
204 unsigned long table_end; 201 unsigned long table_end;
205 acpi_size tbl_size;
206 202
207 if (acpi_disabled) 203 if (acpi_disabled)
208 return -ENODEV; 204 return -ENODEV;
209 205
210 if (!handler) 206 if (!id || !handler)
211 return -EINVAL; 207 return -EINVAL;
212 208
213 if (strncmp(id, ACPI_SIG_MADT, 4) == 0) 209 if (!table_size)
214 acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size); 210 return -EINVAL;
215 else
216 acpi_get_table_with_size(id, 0, &table_header, &tbl_size);
217 211
218 if (!table_header) { 212 if (!table_header) {
219 pr_warn("%4.4s not present\n", id); 213 pr_warn("%4.4s not present\n", id);
@@ -230,9 +224,12 @@ acpi_table_parse_entries(char *id,
230 while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < 224 while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
231 table_end) { 225 table_end) {
232 if (entry->type == entry_id 226 if (entry->type == entry_id
233 && (!max_entries || count++ < max_entries)) 227 && (!max_entries || count < max_entries)) {
234 if (handler(entry, table_end)) 228 if (handler(entry, table_end))
235 goto err; 229 return -EINVAL;
230
231 count++;
232 }
236 233
237 /* 234 /*
238 * If entry->length is 0, break from this loop to avoid 235 * If entry->length is 0, break from this loop to avoid
@@ -240,22 +237,53 @@ acpi_table_parse_entries(char *id,
240 */ 237 */
241 if (entry->length == 0) { 238 if (entry->length == 0) {
242 pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id); 239 pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
243 goto err; 240 return -EINVAL;
244 } 241 }
245 242
246 entry = (struct acpi_subtable_header *) 243 entry = (struct acpi_subtable_header *)
247 ((unsigned long)entry + entry->length); 244 ((unsigned long)entry + entry->length);
248 } 245 }
246
249 if (max_entries && count > max_entries) { 247 if (max_entries && count > max_entries) {
250 pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n", 248 pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n",
251 id, entry_id, count - max_entries, count); 249 id, entry_id, count - max_entries, count);
252 } 250 }
253 251
254 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
255 return count; 252 return count;
256err: 253}
254
255int __init
256acpi_table_parse_entries(char *id,
257 unsigned long table_size,
258 int entry_id,
259 acpi_tbl_entry_handler handler,
260 unsigned int max_entries)
261{
262 struct acpi_table_header *table_header = NULL;
263 acpi_size tbl_size;
264 int count;
265 u32 instance = 0;
266
267 if (acpi_disabled)
268 return -ENODEV;
269
270 if (!id || !handler)
271 return -EINVAL;
272
273 if (!strncmp(id, ACPI_SIG_MADT, 4))
274 instance = acpi_apic_instance;
275
276 acpi_get_table_with_size(id, instance, &table_header, &tbl_size);
277 if (!table_header) {
278 pr_warn("%4.4s not present\n", id);
279 return -ENODEV;
280 }
281
282 count = acpi_parse_entries(id, table_size, handler, table_header,
283 entry_id, max_entries);
284
257 early_acpi_os_unmap_memory((char *)table_header, tbl_size); 285 early_acpi_os_unmap_memory((char *)table_header, tbl_size);
258 return -EINVAL; 286 return count;
259} 287}
260 288
261int __init 289int __init
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 371ac12d25b1..dd8ff63ee2b4 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -136,8 +136,7 @@ acpi_extract_package(union acpi_object *package,
136 break; 136 break;
137 case 'B': 137 case 'B':
138 size_required += 138 size_required +=
139 sizeof(u8 *) + 139 sizeof(u8 *) + element->buffer.length;
140 (element->buffer.length * sizeof(u8));
141 tail_offset += sizeof(u8 *); 140 tail_offset += sizeof(u8 *);
142 break; 141 break;
143 default: 142 default:
@@ -255,7 +254,7 @@ acpi_extract_package(union acpi_object *package,
255 memcpy(tail, element->buffer.pointer, 254 memcpy(tail, element->buffer.pointer,
256 element->buffer.length); 255 element->buffer.length);
257 head += sizeof(u8 *); 256 head += sizeof(u8 *);
258 tail += element->buffer.length * sizeof(u8); 257 tail += element->buffer.length;
259 break; 258 break;
260 default: 259 default:
261 /* Should never get here */ 260 /* Should never get here */
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 9d75ead2a1f9..185a57d13723 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1681,6 +1681,19 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
1681 printk(KERN_ERR PREFIX "Create sysfs link\n"); 1681 printk(KERN_ERR PREFIX "Create sysfs link\n");
1682} 1682}
1683 1683
1684static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video)
1685{
1686 struct acpi_video_device *dev;
1687 union acpi_object *levels;
1688
1689 mutex_lock(&video->device_list_lock);
1690 list_for_each_entry(dev, &video->video_device_list, entry) {
1691 if (!acpi_video_device_lcd_query_levels(dev, &levels))
1692 kfree(levels);
1693 }
1694 mutex_unlock(&video->device_list_lock);
1695}
1696
1684static int acpi_video_bus_register_backlight(struct acpi_video_bus *video) 1697static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)
1685{ 1698{
1686 struct acpi_video_device *dev; 1699 struct acpi_video_device *dev;
@@ -1688,6 +1701,8 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)
1688 if (video->backlight_registered) 1701 if (video->backlight_registered)
1689 return 0; 1702 return 0;
1690 1703
1704 acpi_video_run_bcl_for_osi(video);
1705
1691 if (!acpi_video_verify_backlight_support()) 1706 if (!acpi_video_verify_backlight_support())
1692 return 0; 1707 return 0;
1693 1708
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 47bbdc1b5be3..973a3332a85f 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -124,7 +124,7 @@ static const struct dev_pm_ops amba_pm = {
124 .thaw = pm_generic_thaw, 124 .thaw = pm_generic_thaw,
125 .poweroff = pm_generic_poweroff, 125 .poweroff = pm_generic_poweroff,
126 .restore = pm_generic_restore, 126 .restore = pm_generic_restore,
127 SET_PM_RUNTIME_PM_OPS( 127 SET_RUNTIME_PM_OPS(
128 amba_pm_runtime_suspend, 128 amba_pm_runtime_suspend,
129 amba_pm_runtime_resume, 129 amba_pm_runtime_resume,
130 NULL 130 NULL
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 6922cd6850a2..53c3fe1aeb29 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -4,7 +4,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
4 driver.o class.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o devres.o \ 5 cpu.o firmware.o init.o map.o devres.o \
6 attribute_container.o transport_class.o \ 6 attribute_container.o transport_class.o \
7 topology.o container.o 7 topology.o container.o property.o
8obj-$(CONFIG_DEVTMPFS) += devtmpfs.o 8obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
9obj-$(CONFIG_DMA_CMA) += dma-contiguous.o 9obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
10obj-y += power/ 10obj-y += power/
diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index 78369305e069..d626576a4f75 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -12,6 +12,7 @@
12#include <linux/pm.h> 12#include <linux/pm.h>
13#include <linux/pm_clock.h> 13#include <linux/pm_clock.h>
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/clkdev.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/err.h> 17#include <linux/err.h>
17 18
@@ -34,14 +35,20 @@ struct pm_clock_entry {
34/** 35/**
35 * pm_clk_enable - Enable a clock, reporting any errors 36 * pm_clk_enable - Enable a clock, reporting any errors
36 * @dev: The device for the given clock 37 * @dev: The device for the given clock
37 * @clk: The clock being enabled. 38 * @ce: PM clock entry corresponding to the clock.
38 */ 39 */
39static inline int __pm_clk_enable(struct device *dev, struct clk *clk) 40static inline int __pm_clk_enable(struct device *dev, struct pm_clock_entry *ce)
40{ 41{
41 int ret = clk_enable(clk); 42 int ret;
42 if (ret) 43
43 dev_err(dev, "%s: failed to enable clk %p, error %d\n", 44 if (ce->status < PCE_STATUS_ERROR) {
44 __func__, clk, ret); 45 ret = clk_enable(ce->clk);
46 if (!ret)
47 ce->status = PCE_STATUS_ENABLED;
48 else
49 dev_err(dev, "%s: failed to enable clk %p, error %d\n",
50 __func__, ce->clk, ret);
51 }
45 52
46 return ret; 53 return ret;
47} 54}
@@ -53,7 +60,8 @@ static inline int __pm_clk_enable(struct device *dev, struct clk *clk)
53 */ 60 */
54static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce) 61static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
55{ 62{
56 ce->clk = clk_get(dev, ce->con_id); 63 if (!ce->clk)
64 ce->clk = clk_get(dev, ce->con_id);
57 if (IS_ERR(ce->clk)) { 65 if (IS_ERR(ce->clk)) {
58 ce->status = PCE_STATUS_ERROR; 66 ce->status = PCE_STATUS_ERROR;
59 } else { 67 } else {
@@ -63,15 +71,8 @@ static void pm_clk_acquire(struct device *dev, struct pm_clock_entry *ce)
63 } 71 }
64} 72}
65 73
66/** 74static int __pm_clk_add(struct device *dev, const char *con_id,
67 * pm_clk_add - Start using a device clock for power management. 75 struct clk *clk)
68 * @dev: Device whose clock is going to be used for power management.
69 * @con_id: Connection ID of the clock.
70 *
71 * Add the clock represented by @con_id to the list of clocks used for
72 * the power management of @dev.
73 */
74int pm_clk_add(struct device *dev, const char *con_id)
75{ 76{
76 struct pm_subsys_data *psd = dev_to_psd(dev); 77 struct pm_subsys_data *psd = dev_to_psd(dev);
77 struct pm_clock_entry *ce; 78 struct pm_clock_entry *ce;
@@ -93,6 +94,12 @@ int pm_clk_add(struct device *dev, const char *con_id)
93 kfree(ce); 94 kfree(ce);
94 return -ENOMEM; 95 return -ENOMEM;
95 } 96 }
97 } else {
98 if (IS_ERR(ce->clk) || !__clk_get(clk)) {
99 kfree(ce);
100 return -ENOENT;
101 }
102 ce->clk = clk;
96 } 103 }
97 104
98 pm_clk_acquire(dev, ce); 105 pm_clk_acquire(dev, ce);
@@ -104,6 +111,32 @@ int pm_clk_add(struct device *dev, const char *con_id)
104} 111}
105 112
106/** 113/**
114 * pm_clk_add - Start using a device clock for power management.
115 * @dev: Device whose clock is going to be used for power management.
116 * @con_id: Connection ID of the clock.
117 *
118 * Add the clock represented by @con_id to the list of clocks used for
119 * the power management of @dev.
120 */
121int pm_clk_add(struct device *dev, const char *con_id)
122{
123 return __pm_clk_add(dev, con_id, NULL);
124}
125
126/**
127 * pm_clk_add_clk - Start using a device clock for power management.
128 * @dev: Device whose clock is going to be used for power management.
129 * @clk: Clock pointer
130 *
131 * Add the clock to the list of clocks used for the power management of @dev.
132 * It will increment refcount on clock pointer, use clk_put() on it when done.
133 */
134int pm_clk_add_clk(struct device *dev, struct clk *clk)
135{
136 return __pm_clk_add(dev, NULL, clk);
137}
138
139/**
107 * __pm_clk_remove - Destroy PM clock entry. 140 * __pm_clk_remove - Destroy PM clock entry.
108 * @ce: PM clock entry to destroy. 141 * @ce: PM clock entry to destroy.
109 */ 142 */
@@ -223,10 +256,6 @@ void pm_clk_destroy(struct device *dev)
223 } 256 }
224} 257}
225 258
226#endif /* CONFIG_PM */
227
228#ifdef CONFIG_PM_RUNTIME
229
230/** 259/**
231 * pm_clk_suspend - Disable clocks in a device's PM clock list. 260 * pm_clk_suspend - Disable clocks in a device's PM clock list.
232 * @dev: Device to disable the clocks for. 261 * @dev: Device to disable the clocks for.
@@ -266,7 +295,6 @@ int pm_clk_resume(struct device *dev)
266 struct pm_subsys_data *psd = dev_to_psd(dev); 295 struct pm_subsys_data *psd = dev_to_psd(dev);
267 struct pm_clock_entry *ce; 296 struct pm_clock_entry *ce;
268 unsigned long flags; 297 unsigned long flags;
269 int ret;
270 298
271 dev_dbg(dev, "%s()\n", __func__); 299 dev_dbg(dev, "%s()\n", __func__);
272 300
@@ -275,13 +303,8 @@ int pm_clk_resume(struct device *dev)
275 303
276 spin_lock_irqsave(&psd->lock, flags); 304 spin_lock_irqsave(&psd->lock, flags);
277 305
278 list_for_each_entry(ce, &psd->clock_list, node) { 306 list_for_each_entry(ce, &psd->clock_list, node)
279 if (ce->status < PCE_STATUS_ERROR) { 307 __pm_clk_enable(dev, ce);
280 ret = __pm_clk_enable(dev, ce->clk);
281 if (!ret)
282 ce->status = PCE_STATUS_ENABLED;
283 }
284 }
285 308
286 spin_unlock_irqrestore(&psd->lock, flags); 309 spin_unlock_irqrestore(&psd->lock, flags);
287 310
@@ -346,74 +369,7 @@ static int pm_clk_notify(struct notifier_block *nb,
346 return 0; 369 return 0;
347} 370}
348 371
349#else /* !CONFIG_PM_RUNTIME */ 372#else /* !CONFIG_PM */
350
351#ifdef CONFIG_PM
352
353/**
354 * pm_clk_suspend - Disable clocks in a device's PM clock list.
355 * @dev: Device to disable the clocks for.
356 */
357int pm_clk_suspend(struct device *dev)
358{
359 struct pm_subsys_data *psd = dev_to_psd(dev);
360 struct pm_clock_entry *ce;
361 unsigned long flags;
362
363 dev_dbg(dev, "%s()\n", __func__);
364
365 /* If there is no driver, the clocks are already disabled. */
366 if (!psd || !dev->driver)
367 return 0;
368
369 spin_lock_irqsave(&psd->lock, flags);
370
371 list_for_each_entry_reverse(ce, &psd->clock_list, node) {
372 if (ce->status < PCE_STATUS_ERROR) {
373 if (ce->status == PCE_STATUS_ENABLED)
374 clk_disable(ce->clk);
375 ce->status = PCE_STATUS_ACQUIRED;
376 }
377 }
378
379 spin_unlock_irqrestore(&psd->lock, flags);
380
381 return 0;
382}
383
384/**
385 * pm_clk_resume - Enable clocks in a device's PM clock list.
386 * @dev: Device to enable the clocks for.
387 */
388int pm_clk_resume(struct device *dev)
389{
390 struct pm_subsys_data *psd = dev_to_psd(dev);
391 struct pm_clock_entry *ce;
392 unsigned long flags;
393 int ret;
394
395 dev_dbg(dev, "%s()\n", __func__);
396
397 /* If there is no driver, the clocks should remain disabled. */
398 if (!psd || !dev->driver)
399 return 0;
400
401 spin_lock_irqsave(&psd->lock, flags);
402
403 list_for_each_entry(ce, &psd->clock_list, node) {
404 if (ce->status < PCE_STATUS_ERROR) {
405 ret = __pm_clk_enable(dev, ce->clk);
406 if (!ret)
407 ce->status = PCE_STATUS_ENABLED;
408 }
409 }
410
411 spin_unlock_irqrestore(&psd->lock, flags);
412
413 return 0;
414}
415
416#endif /* CONFIG_PM */
417 373
418/** 374/**
419 * enable_clock - Enable a device clock. 375 * enable_clock - Enable a device clock.
@@ -493,7 +449,7 @@ static int pm_clk_notify(struct notifier_block *nb,
493 return 0; 449 return 0;
494} 450}
495 451
496#endif /* !CONFIG_PM_RUNTIME */ 452#endif /* !CONFIG_PM */
497 453
498/** 454/**
499 * pm_clk_add_notifier - Add bus type notifier for power management clocks. 455 * pm_clk_add_notifier - Add bus type notifier for power management clocks.
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index fb83d4acd400..6a103a35ea9b 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -12,6 +12,7 @@
12#include <linux/pm_runtime.h> 12#include <linux/pm_runtime.h>
13#include <linux/pm_domain.h> 13#include <linux/pm_domain.h>
14#include <linux/pm_qos.h> 14#include <linux/pm_qos.h>
15#include <linux/pm_clock.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <linux/sched.h> 18#include <linux/sched.h>
@@ -151,6 +152,59 @@ static void genpd_recalc_cpu_exit_latency(struct generic_pm_domain *genpd)
151 genpd->cpuidle_data->idle_state->exit_latency = usecs64; 152 genpd->cpuidle_data->idle_state->exit_latency = usecs64;
152} 153}
153 154
155static int genpd_power_on(struct generic_pm_domain *genpd)
156{
157 ktime_t time_start;
158 s64 elapsed_ns;
159 int ret;
160
161 if (!genpd->power_on)
162 return 0;
163
164 time_start = ktime_get();
165 ret = genpd->power_on(genpd);
166 if (ret)
167 return ret;
168
169 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
170 if (elapsed_ns <= genpd->power_on_latency_ns)
171 return ret;
172
173 genpd->power_on_latency_ns = elapsed_ns;
174 genpd->max_off_time_changed = true;
175 genpd_recalc_cpu_exit_latency(genpd);
176 pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n",
177 genpd->name, "on", elapsed_ns);
178
179 return ret;
180}
181
182static int genpd_power_off(struct generic_pm_domain *genpd)
183{
184 ktime_t time_start;
185 s64 elapsed_ns;
186 int ret;
187
188 if (!genpd->power_off)
189 return 0;
190
191 time_start = ktime_get();
192 ret = genpd->power_off(genpd);
193 if (ret == -EBUSY)
194 return ret;
195
196 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
197 if (elapsed_ns <= genpd->power_off_latency_ns)
198 return ret;
199
200 genpd->power_off_latency_ns = elapsed_ns;
201 genpd->max_off_time_changed = true;
202 pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n",
203 genpd->name, "off", elapsed_ns);
204
205 return ret;
206}
207
154/** 208/**
155 * __pm_genpd_poweron - Restore power to a given PM domain and its masters. 209 * __pm_genpd_poweron - Restore power to a given PM domain and its masters.
156 * @genpd: PM domain to power up. 210 * @genpd: PM domain to power up.
@@ -222,25 +276,9 @@ static int __pm_genpd_poweron(struct generic_pm_domain *genpd)
222 } 276 }
223 } 277 }
224 278
225 if (genpd->power_on) { 279 ret = genpd_power_on(genpd);
226 ktime_t time_start = ktime_get(); 280 if (ret)
227 s64 elapsed_ns; 281 goto err;
228
229 ret = genpd->power_on(genpd);
230 if (ret)
231 goto err;
232
233 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
234 if (elapsed_ns > genpd->power_on_latency_ns) {
235 genpd->power_on_latency_ns = elapsed_ns;
236 genpd->max_off_time_changed = true;
237 genpd_recalc_cpu_exit_latency(genpd);
238 if (genpd->name)
239 pr_warning("%s: Power-on latency exceeded, "
240 "new value %lld ns\n", genpd->name,
241 elapsed_ns);
242 }
243 }
244 282
245 out: 283 out:
246 genpd_set_active(genpd); 284 genpd_set_active(genpd);
@@ -280,8 +318,6 @@ int pm_genpd_name_poweron(const char *domain_name)
280 return genpd ? pm_genpd_poweron(genpd) : -EINVAL; 318 return genpd ? pm_genpd_poweron(genpd) : -EINVAL;
281} 319}
282 320
283#ifdef CONFIG_PM_RUNTIME
284
285static int genpd_start_dev_no_timing(struct generic_pm_domain *genpd, 321static int genpd_start_dev_no_timing(struct generic_pm_domain *genpd,
286 struct device *dev) 322 struct device *dev)
287{ 323{
@@ -544,16 +580,11 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd)
544 } 580 }
545 581
546 if (genpd->power_off) { 582 if (genpd->power_off) {
547 ktime_t time_start;
548 s64 elapsed_ns;
549
550 if (atomic_read(&genpd->sd_count) > 0) { 583 if (atomic_read(&genpd->sd_count) > 0) {
551 ret = -EBUSY; 584 ret = -EBUSY;
552 goto out; 585 goto out;
553 } 586 }
554 587
555 time_start = ktime_get();
556
557 /* 588 /*
558 * If sd_count > 0 at this point, one of the subdomains hasn't 589 * If sd_count > 0 at this point, one of the subdomains hasn't
559 * managed to call pm_genpd_poweron() for the master yet after 590 * managed to call pm_genpd_poweron() for the master yet after
@@ -562,21 +593,11 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd)
562 * the pm_genpd_poweron() restore power for us (this shouldn't 593 * the pm_genpd_poweron() restore power for us (this shouldn't
563 * happen very often). 594 * happen very often).
564 */ 595 */
565 ret = genpd->power_off(genpd); 596 ret = genpd_power_off(genpd);
566 if (ret == -EBUSY) { 597 if (ret == -EBUSY) {
567 genpd_set_active(genpd); 598 genpd_set_active(genpd);
568 goto out; 599 goto out;
569 } 600 }
570
571 elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
572 if (elapsed_ns > genpd->power_off_latency_ns) {
573 genpd->power_off_latency_ns = elapsed_ns;
574 genpd->max_off_time_changed = true;
575 if (genpd->name)
576 pr_warning("%s: Power-off latency exceeded, "
577 "new value %lld ns\n", genpd->name,
578 elapsed_ns);
579 }
580 } 601 }
581 602
582 genpd->status = GPD_STATE_POWER_OFF; 603 genpd->status = GPD_STATE_POWER_OFF;
@@ -755,33 +776,15 @@ static int __init genpd_poweroff_unused(void)
755} 776}
756late_initcall(genpd_poweroff_unused); 777late_initcall(genpd_poweroff_unused);
757 778
758#else
759
760static inline int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
761 unsigned long val, void *ptr)
762{
763 return NOTIFY_DONE;
764}
765
766static inline void
767genpd_queue_power_off_work(struct generic_pm_domain *genpd) {}
768
769static inline void genpd_power_off_work_fn(struct work_struct *work) {}
770
771#define pm_genpd_runtime_suspend NULL
772#define pm_genpd_runtime_resume NULL
773
774#endif /* CONFIG_PM_RUNTIME */
775
776#ifdef CONFIG_PM_SLEEP 779#ifdef CONFIG_PM_SLEEP
777 780
778/** 781/**
779 * pm_genpd_present - Check if the given PM domain has been initialized. 782 * pm_genpd_present - Check if the given PM domain has been initialized.
780 * @genpd: PM domain to check. 783 * @genpd: PM domain to check.
781 */ 784 */
782static bool pm_genpd_present(struct generic_pm_domain *genpd) 785static bool pm_genpd_present(const struct generic_pm_domain *genpd)
783{ 786{
784 struct generic_pm_domain *gpd; 787 const struct generic_pm_domain *gpd;
785 788
786 if (IS_ERR_OR_NULL(genpd)) 789 if (IS_ERR_OR_NULL(genpd))
787 return false; 790 return false;
@@ -822,8 +825,7 @@ static void pm_genpd_sync_poweroff(struct generic_pm_domain *genpd)
822 || atomic_read(&genpd->sd_count) > 0) 825 || atomic_read(&genpd->sd_count) > 0)
823 return; 826 return;
824 827
825 if (genpd->power_off) 828 genpd_power_off(genpd);
826 genpd->power_off(genpd);
827 829
828 genpd->status = GPD_STATE_POWER_OFF; 830 genpd->status = GPD_STATE_POWER_OFF;
829 831
@@ -854,8 +856,7 @@ static void pm_genpd_sync_poweron(struct generic_pm_domain *genpd)
854 genpd_sd_counter_inc(link->master); 856 genpd_sd_counter_inc(link->master);
855 } 857 }
856 858
857 if (genpd->power_on) 859 genpd_power_on(genpd);
858 genpd->power_on(genpd);
859 860
860 genpd->status = GPD_STATE_ACTIVE; 861 genpd->status = GPD_STATE_ACTIVE;
861} 862}
@@ -1277,8 +1278,7 @@ static int pm_genpd_restore_noirq(struct device *dev)
1277 * If the domain was off before the hibernation, make 1278 * If the domain was off before the hibernation, make
1278 * sure it will be off going forward. 1279 * sure it will be off going forward.
1279 */ 1280 */
1280 if (genpd->power_off) 1281 genpd_power_off(genpd);
1281 genpd->power_off(genpd);
1282 1282
1283 return 0; 1283 return 0;
1284 } 1284 }
@@ -1364,7 +1364,7 @@ void pm_genpd_syscore_poweron(struct device *dev)
1364} 1364}
1365EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron); 1365EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
1366 1366
1367#else 1367#else /* !CONFIG_PM_SLEEP */
1368 1368
1369#define pm_genpd_prepare NULL 1369#define pm_genpd_prepare NULL
1370#define pm_genpd_suspend NULL 1370#define pm_genpd_suspend NULL
@@ -1929,6 +1929,12 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
1929 genpd->domain.ops.complete = pm_genpd_complete; 1929 genpd->domain.ops.complete = pm_genpd_complete;
1930 genpd->dev_ops.save_state = pm_genpd_default_save_state; 1930 genpd->dev_ops.save_state = pm_genpd_default_save_state;
1931 genpd->dev_ops.restore_state = pm_genpd_default_restore_state; 1931 genpd->dev_ops.restore_state = pm_genpd_default_restore_state;
1932
1933 if (genpd->flags & GENPD_FLAG_PM_CLK) {
1934 genpd->dev_ops.stop = pm_clk_suspend;
1935 genpd->dev_ops.start = pm_clk_resume;
1936 }
1937
1932 mutex_lock(&gpd_list_lock); 1938 mutex_lock(&gpd_list_lock);
1933 list_add(&genpd->gpd_list_node, &gpd_list); 1939 list_add(&genpd->gpd_list_node, &gpd_list);
1934 mutex_unlock(&gpd_list_lock); 1940 mutex_unlock(&gpd_list_lock);
@@ -2216,11 +2222,12 @@ int genpd_dev_pm_attach(struct device *dev)
2216 } 2222 }
2217 2223
2218 dev->pm_domain->detach = genpd_dev_pm_detach; 2224 dev->pm_domain->detach = genpd_dev_pm_detach;
2225 pm_genpd_poweron(pd);
2219 2226
2220 return 0; 2227 return 0;
2221} 2228}
2222EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); 2229EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
2223#endif 2230#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
2224 2231
2225 2232
2226/*** debugfs support ***/ 2233/*** debugfs support ***/
@@ -2236,10 +2243,8 @@ static struct dentry *pm_genpd_debugfs_dir;
2236 2243
2237/* 2244/*
2238 * TODO: This function is a slightly modified version of rtpm_status_show 2245 * TODO: This function is a slightly modified version of rtpm_status_show
2239 * from sysfs.c, but dependencies between PM_GENERIC_DOMAINS and PM_RUNTIME 2246 * from sysfs.c, so generalize it.
2240 * are too loose to generalize it.
2241 */ 2247 */
2242#ifdef CONFIG_PM_RUNTIME
2243static void rtpm_status_str(struct seq_file *s, struct device *dev) 2248static void rtpm_status_str(struct seq_file *s, struct device *dev)
2244{ 2249{
2245 static const char * const status_lookup[] = { 2250 static const char * const status_lookup[] = {
@@ -2261,12 +2266,6 @@ static void rtpm_status_str(struct seq_file *s, struct device *dev)
2261 2266
2262 seq_puts(s, p); 2267 seq_puts(s, p);
2263} 2268}
2264#else
2265static void rtpm_status_str(struct seq_file *s, struct device *dev)
2266{
2267 seq_puts(s, "active");
2268}
2269#endif
2270 2269
2271static int pm_genpd_summary_one(struct seq_file *s, 2270static int pm_genpd_summary_one(struct seq_file *s,
2272 struct generic_pm_domain *gpd) 2271 struct generic_pm_domain *gpd)
diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c
index d88a62e104d4..2a4154a09e4d 100644
--- a/drivers/base/power/domain_governor.c
+++ b/drivers/base/power/domain_governor.c
@@ -11,8 +11,6 @@
11#include <linux/pm_qos.h> 11#include <linux/pm_qos.h>
12#include <linux/hrtimer.h> 12#include <linux/hrtimer.h>
13 13
14#ifdef CONFIG_PM_RUNTIME
15
16static int dev_update_qos_constraint(struct device *dev, void *data) 14static int dev_update_qos_constraint(struct device *dev, void *data)
17{ 15{
18 s64 *constraint_ns_p = data; 16 s64 *constraint_ns_p = data;
@@ -227,15 +225,6 @@ static bool always_on_power_down_ok(struct dev_pm_domain *domain)
227 return false; 225 return false;
228} 226}
229 227
230#else /* !CONFIG_PM_RUNTIME */
231
232static inline bool default_stop_ok(struct device *dev) { return false; }
233
234#define default_power_down_ok NULL
235#define always_on_power_down_ok NULL
236
237#endif /* !CONFIG_PM_RUNTIME */
238
239struct dev_power_governor simple_qos_governor = { 228struct dev_power_governor simple_qos_governor = {
240 .stop_ok = default_stop_ok, 229 .stop_ok = default_stop_ok,
241 .power_down_ok = default_power_down_ok, 230 .power_down_ok = default_power_down_ok,
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 89ced955fafa..2d195f3a1998 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -49,11 +49,12 @@
49 * are protected by the dev_opp_list_lock for integrity. 49 * are protected by the dev_opp_list_lock for integrity.
50 * IMPORTANT: the opp nodes should be maintained in increasing 50 * IMPORTANT: the opp nodes should be maintained in increasing
51 * order. 51 * order.
52 * @dynamic: not-created from static DT entries.
52 * @available: true/false - marks if this OPP as available or not 53 * @available: true/false - marks if this OPP as available or not
53 * @rate: Frequency in hertz 54 * @rate: Frequency in hertz
54 * @u_volt: Nominal voltage in microvolts corresponding to this OPP 55 * @u_volt: Nominal voltage in microvolts corresponding to this OPP
55 * @dev_opp: points back to the device_opp struct this opp belongs to 56 * @dev_opp: points back to the device_opp struct this opp belongs to
56 * @head: RCU callback head used for deferred freeing 57 * @rcu_head: RCU callback head used for deferred freeing
57 * 58 *
58 * This structure stores the OPP information for a given device. 59 * This structure stores the OPP information for a given device.
59 */ 60 */
@@ -61,11 +62,12 @@ struct dev_pm_opp {
61 struct list_head node; 62 struct list_head node;
62 63
63 bool available; 64 bool available;
65 bool dynamic;
64 unsigned long rate; 66 unsigned long rate;
65 unsigned long u_volt; 67 unsigned long u_volt;
66 68
67 struct device_opp *dev_opp; 69 struct device_opp *dev_opp;
68 struct rcu_head head; 70 struct rcu_head rcu_head;
69}; 71};
70 72
71/** 73/**
@@ -76,7 +78,8 @@ struct dev_pm_opp {
76 * RCU usage: nodes are not modified in the list of device_opp, 78 * RCU usage: nodes are not modified in the list of device_opp,
77 * however addition is possible and is secured by dev_opp_list_lock 79 * however addition is possible and is secured by dev_opp_list_lock
78 * @dev: device pointer 80 * @dev: device pointer
79 * @head: notifier head to notify the OPP availability changes. 81 * @srcu_head: notifier head to notify the OPP availability changes.
82 * @rcu_head: RCU callback head used for deferred freeing
80 * @opp_list: list of opps 83 * @opp_list: list of opps
81 * 84 *
82 * This is an internal data structure maintaining the link to opps attached to 85 * This is an internal data structure maintaining the link to opps attached to
@@ -87,7 +90,8 @@ struct device_opp {
87 struct list_head node; 90 struct list_head node;
88 91
89 struct device *dev; 92 struct device *dev;
90 struct srcu_notifier_head head; 93 struct srcu_notifier_head srcu_head;
94 struct rcu_head rcu_head;
91 struct list_head opp_list; 95 struct list_head opp_list;
92}; 96};
93 97
@@ -378,30 +382,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
378} 382}
379EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); 383EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor);
380 384
381/** 385static int dev_pm_opp_add_dynamic(struct device *dev, unsigned long freq,
382 * dev_pm_opp_add() - Add an OPP table from a table definitions 386 unsigned long u_volt, bool dynamic)
383 * @dev: device for which we do this operation
384 * @freq: Frequency in Hz for this OPP
385 * @u_volt: Voltage in uVolts for this OPP
386 *
387 * This function adds an opp definition to the opp list and returns status.
388 * The opp is made available by default and it can be controlled using
389 * dev_pm_opp_enable/disable functions.
390 *
391 * Locking: The internal device_opp and opp structures are RCU protected.
392 * Hence this function internally uses RCU updater strategy with mutex locks
393 * to keep the integrity of the internal data structures. Callers should ensure
394 * that this function is *NOT* called under RCU protection or in contexts where
395 * mutex cannot be locked.
396 *
397 * Return:
398 * 0: On success OR
399 * Duplicate OPPs (both freq and volt are same) and opp->available
400 * -EEXIST: Freq are same and volt are different OR
401 * Duplicate OPPs (both freq and volt are same) and !opp->available
402 * -ENOMEM: Memory allocation failure
403 */
404int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
405{ 387{
406 struct device_opp *dev_opp = NULL; 388 struct device_opp *dev_opp = NULL;
407 struct dev_pm_opp *opp, *new_opp; 389 struct dev_pm_opp *opp, *new_opp;
@@ -417,6 +399,13 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
417 /* Hold our list modification lock here */ 399 /* Hold our list modification lock here */
418 mutex_lock(&dev_opp_list_lock); 400 mutex_lock(&dev_opp_list_lock);
419 401
402 /* populate the opp table */
403 new_opp->dev_opp = dev_opp;
404 new_opp->rate = freq;
405 new_opp->u_volt = u_volt;
406 new_opp->available = true;
407 new_opp->dynamic = dynamic;
408
420 /* Check for existing list for 'dev' */ 409 /* Check for existing list for 'dev' */
421 dev_opp = find_device_opp(dev); 410 dev_opp = find_device_opp(dev);
422 if (IS_ERR(dev_opp)) { 411 if (IS_ERR(dev_opp)) {
@@ -436,19 +425,15 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
436 } 425 }
437 426
438 dev_opp->dev = dev; 427 dev_opp->dev = dev;
439 srcu_init_notifier_head(&dev_opp->head); 428 srcu_init_notifier_head(&dev_opp->srcu_head);
440 INIT_LIST_HEAD(&dev_opp->opp_list); 429 INIT_LIST_HEAD(&dev_opp->opp_list);
441 430
442 /* Secure the device list modification */ 431 /* Secure the device list modification */
443 list_add_rcu(&dev_opp->node, &dev_opp_list); 432 list_add_rcu(&dev_opp->node, &dev_opp_list);
433 head = &dev_opp->opp_list;
434 goto list_add;
444 } 435 }
445 436
446 /* populate the opp table */
447 new_opp->dev_opp = dev_opp;
448 new_opp->rate = freq;
449 new_opp->u_volt = u_volt;
450 new_opp->available = true;
451
452 /* 437 /*
453 * Insert new OPP in order of increasing frequency 438 * Insert new OPP in order of increasing frequency
454 * and discard if already present 439 * and discard if already present
@@ -474,6 +459,7 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
474 return ret; 459 return ret;
475 } 460 }
476 461
462list_add:
477 list_add_rcu(&new_opp->node, head); 463 list_add_rcu(&new_opp->node, head);
478 mutex_unlock(&dev_opp_list_lock); 464 mutex_unlock(&dev_opp_list_lock);
479 465
@@ -481,11 +467,109 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
481 * Notify the changes in the availability of the operable 467 * Notify the changes in the availability of the operable
482 * frequency/voltage list. 468 * frequency/voltage list.
483 */ 469 */
484 srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp); 470 srcu_notifier_call_chain(&dev_opp->srcu_head, OPP_EVENT_ADD, new_opp);
485 return 0; 471 return 0;
486} 472}
473
474/**
475 * dev_pm_opp_add() - Add an OPP table from a table definitions
476 * @dev: device for which we do this operation
477 * @freq: Frequency in Hz for this OPP
478 * @u_volt: Voltage in uVolts for this OPP
479 *
480 * This function adds an opp definition to the opp list and returns status.
481 * The opp is made available by default and it can be controlled using
482 * dev_pm_opp_enable/disable functions.
483 *
484 * Locking: The internal device_opp and opp structures are RCU protected.
485 * Hence this function internally uses RCU updater strategy with mutex locks
486 * to keep the integrity of the internal data structures. Callers should ensure
487 * that this function is *NOT* called under RCU protection or in contexts where
488 * mutex cannot be locked.
489 *
490 * Return:
491 * 0: On success OR
492 * Duplicate OPPs (both freq and volt are same) and opp->available
493 * -EEXIST: Freq are same and volt are different OR
494 * Duplicate OPPs (both freq and volt are same) and !opp->available
495 * -ENOMEM: Memory allocation failure
496 */
497int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
498{
499 return dev_pm_opp_add_dynamic(dev, freq, u_volt, true);
500}
487EXPORT_SYMBOL_GPL(dev_pm_opp_add); 501EXPORT_SYMBOL_GPL(dev_pm_opp_add);
488 502
503static void kfree_opp_rcu(struct rcu_head *head)
504{
505 struct dev_pm_opp *opp = container_of(head, struct dev_pm_opp, rcu_head);
506
507 kfree_rcu(opp, rcu_head);
508}
509
510static void kfree_device_rcu(struct rcu_head *head)
511{
512 struct device_opp *device_opp = container_of(head, struct device_opp, rcu_head);
513
514 kfree(device_opp);
515}
516
517void __dev_pm_opp_remove(struct device_opp *dev_opp, struct dev_pm_opp *opp)
518{
519 /*
520 * Notify the changes in the availability of the operable
521 * frequency/voltage list.
522 */
523 srcu_notifier_call_chain(&dev_opp->srcu_head, OPP_EVENT_REMOVE, opp);
524 list_del_rcu(&opp->node);
525 call_srcu(&dev_opp->srcu_head.srcu, &opp->rcu_head, kfree_opp_rcu);
526
527 if (list_empty(&dev_opp->opp_list)) {
528 list_del_rcu(&dev_opp->node);
529 call_srcu(&dev_opp->srcu_head.srcu, &dev_opp->rcu_head,
530 kfree_device_rcu);
531 }
532}
533
534/**
535 * dev_pm_opp_remove() - Remove an OPP from OPP list
536 * @dev: device for which we do this operation
537 * @freq: OPP to remove with matching 'freq'
538 *
539 * This function removes an opp from the opp list.
540 */
541void dev_pm_opp_remove(struct device *dev, unsigned long freq)
542{
543 struct dev_pm_opp *opp;
544 struct device_opp *dev_opp;
545 bool found = false;
546
547 /* Hold our list modification lock here */
548 mutex_lock(&dev_opp_list_lock);
549
550 dev_opp = find_device_opp(dev);
551 if (IS_ERR(dev_opp))
552 goto unlock;
553
554 list_for_each_entry(opp, &dev_opp->opp_list, node) {
555 if (opp->rate == freq) {
556 found = true;
557 break;
558 }
559 }
560
561 if (!found) {
562 dev_warn(dev, "%s: Couldn't find OPP with freq: %lu\n",
563 __func__, freq);
564 goto unlock;
565 }
566
567 __dev_pm_opp_remove(dev_opp, opp);
568unlock:
569 mutex_unlock(&dev_opp_list_lock);
570}
571EXPORT_SYMBOL_GPL(dev_pm_opp_remove);
572
489/** 573/**
490 * opp_set_availability() - helper to set the availability of an opp 574 * opp_set_availability() - helper to set the availability of an opp
491 * @dev: device for which we do this operation 575 * @dev: device for which we do this operation
@@ -557,14 +641,14 @@ static int opp_set_availability(struct device *dev, unsigned long freq,
557 641
558 list_replace_rcu(&opp->node, &new_opp->node); 642 list_replace_rcu(&opp->node, &new_opp->node);
559 mutex_unlock(&dev_opp_list_lock); 643 mutex_unlock(&dev_opp_list_lock);
560 kfree_rcu(opp, head); 644 call_srcu(&dev_opp->srcu_head.srcu, &opp->rcu_head, kfree_opp_rcu);
561 645
562 /* Notify the change of the OPP availability */ 646 /* Notify the change of the OPP availability */
563 if (availability_req) 647 if (availability_req)
564 srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ENABLE, 648 srcu_notifier_call_chain(&dev_opp->srcu_head, OPP_EVENT_ENABLE,
565 new_opp); 649 new_opp);
566 else 650 else
567 srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_DISABLE, 651 srcu_notifier_call_chain(&dev_opp->srcu_head, OPP_EVENT_DISABLE,
568 new_opp); 652 new_opp);
569 653
570 return 0; 654 return 0;
@@ -629,7 +713,7 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
629 if (IS_ERR(dev_opp)) 713 if (IS_ERR(dev_opp))
630 return ERR_CAST(dev_opp); /* matching type */ 714 return ERR_CAST(dev_opp); /* matching type */
631 715
632 return &dev_opp->head; 716 return &dev_opp->srcu_head;
633} 717}
634 718
635#ifdef CONFIG_OF 719#ifdef CONFIG_OF
@@ -666,7 +750,7 @@ int of_init_opp_table(struct device *dev)
666 unsigned long freq = be32_to_cpup(val++) * 1000; 750 unsigned long freq = be32_to_cpup(val++) * 1000;
667 unsigned long volt = be32_to_cpup(val++); 751 unsigned long volt = be32_to_cpup(val++);
668 752
669 if (dev_pm_opp_add(dev, freq, volt)) 753 if (dev_pm_opp_add_dynamic(dev, freq, volt, false))
670 dev_warn(dev, "%s: Failed to add OPP %ld\n", 754 dev_warn(dev, "%s: Failed to add OPP %ld\n",
671 __func__, freq); 755 __func__, freq);
672 nr -= 2; 756 nr -= 2;
@@ -675,4 +759,34 @@ int of_init_opp_table(struct device *dev)
675 return 0; 759 return 0;
676} 760}
677EXPORT_SYMBOL_GPL(of_init_opp_table); 761EXPORT_SYMBOL_GPL(of_init_opp_table);
762
763/**
764 * of_free_opp_table() - Free OPP table entries created from static DT entries
765 * @dev: device pointer used to lookup device OPPs.
766 *
767 * Free OPPs created using static entries present in DT.
768 */
769void of_free_opp_table(struct device *dev)
770{
771 struct device_opp *dev_opp = find_device_opp(dev);
772 struct dev_pm_opp *opp, *tmp;
773
774 /* Check for existing list for 'dev' */
775 dev_opp = find_device_opp(dev);
776 if (WARN(IS_ERR(dev_opp), "%s: dev_opp: %ld\n", dev_name(dev),
777 PTR_ERR(dev_opp)))
778 return;
779
780 /* Hold our list modification lock here */
781 mutex_lock(&dev_opp_list_lock);
782
783 /* Free static OPPs */
784 list_for_each_entry_safe(opp, tmp, &dev_opp->opp_list, node) {
785 if (!opp->dynamic)
786 __dev_pm_opp_remove(dev_opp, opp);
787 }
788
789 mutex_unlock(&dev_opp_list_lock);
790}
791EXPORT_SYMBOL_GPL(of_free_opp_table);
678#endif 792#endif
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index a21223d95926..b6b8a273c5da 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -9,7 +9,7 @@ static inline void device_pm_init_common(struct device *dev)
9 } 9 }
10} 10}
11 11
12#ifdef CONFIG_PM_RUNTIME 12#ifdef CONFIG_PM
13 13
14static inline void pm_runtime_early_init(struct device *dev) 14static inline void pm_runtime_early_init(struct device *dev)
15{ 15{
@@ -20,7 +20,21 @@ static inline void pm_runtime_early_init(struct device *dev)
20extern void pm_runtime_init(struct device *dev); 20extern void pm_runtime_init(struct device *dev);
21extern void pm_runtime_remove(struct device *dev); 21extern void pm_runtime_remove(struct device *dev);
22 22
23#else /* !CONFIG_PM_RUNTIME */ 23/*
24 * sysfs.c
25 */
26
27extern int dpm_sysfs_add(struct device *dev);
28extern void dpm_sysfs_remove(struct device *dev);
29extern void rpm_sysfs_remove(struct device *dev);
30extern int wakeup_sysfs_add(struct device *dev);
31extern void wakeup_sysfs_remove(struct device *dev);
32extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
33extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
34extern int pm_qos_sysfs_add_flags(struct device *dev);
35extern void pm_qos_sysfs_remove_flags(struct device *dev);
36
37#else /* CONFIG_PM */
24 38
25static inline void pm_runtime_early_init(struct device *dev) 39static inline void pm_runtime_early_init(struct device *dev)
26{ 40{
@@ -30,7 +44,15 @@ static inline void pm_runtime_early_init(struct device *dev)
30static inline void pm_runtime_init(struct device *dev) {} 44static inline void pm_runtime_init(struct device *dev) {}
31static inline void pm_runtime_remove(struct device *dev) {} 45static inline void pm_runtime_remove(struct device *dev) {}
32 46
33#endif /* !CONFIG_PM_RUNTIME */ 47static inline int dpm_sysfs_add(struct device *dev) { return 0; }
48static inline void dpm_sysfs_remove(struct device *dev) {}
49static inline void rpm_sysfs_remove(struct device *dev) {}
50static inline int wakeup_sysfs_add(struct device *dev) { return 0; }
51static inline void wakeup_sysfs_remove(struct device *dev) {}
52static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
53static inline void pm_qos_sysfs_remove(struct device *dev) {}
54
55#endif
34 56
35#ifdef CONFIG_PM_SLEEP 57#ifdef CONFIG_PM_SLEEP
36 58
@@ -77,31 +99,3 @@ static inline void device_pm_init(struct device *dev)
77 device_pm_sleep_init(dev); 99 device_pm_sleep_init(dev);
78 pm_runtime_init(dev); 100 pm_runtime_init(dev);
79} 101}
80
81#ifdef CONFIG_PM
82
83/*
84 * sysfs.c
85 */
86
87extern int dpm_sysfs_add(struct device *dev);
88extern void dpm_sysfs_remove(struct device *dev);
89extern void rpm_sysfs_remove(struct device *dev);
90extern int wakeup_sysfs_add(struct device *dev);
91extern void wakeup_sysfs_remove(struct device *dev);
92extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
93extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
94extern int pm_qos_sysfs_add_flags(struct device *dev);
95extern void pm_qos_sysfs_remove_flags(struct device *dev);
96
97#else /* CONFIG_PM */
98
99static inline int dpm_sysfs_add(struct device *dev) { return 0; }
100static inline void dpm_sysfs_remove(struct device *dev) {}
101static inline void rpm_sysfs_remove(struct device *dev) {}
102static inline int wakeup_sysfs_add(struct device *dev) { return 0; }
103static inline void wakeup_sysfs_remove(struct device *dev) {}
104static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
105static inline void pm_qos_sysfs_remove(struct device *dev) {}
106
107#endif
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 36b9eb4862cb..a8fe4c1a8d07 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -599,7 +599,6 @@ int dev_pm_qos_add_ancestor_request(struct device *dev,
599} 599}
600EXPORT_SYMBOL_GPL(dev_pm_qos_add_ancestor_request); 600EXPORT_SYMBOL_GPL(dev_pm_qos_add_ancestor_request);
601 601
602#ifdef CONFIG_PM_RUNTIME
603static void __dev_pm_qos_drop_user_request(struct device *dev, 602static void __dev_pm_qos_drop_user_request(struct device *dev,
604 enum dev_pm_qos_req_type type) 603 enum dev_pm_qos_req_type type)
605{ 604{
@@ -880,7 +879,3 @@ int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
880 mutex_unlock(&dev_pm_qos_mtx); 879 mutex_unlock(&dev_pm_qos_mtx);
881 return ret; 880 return ret;
882} 881}
883#else /* !CONFIG_PM_RUNTIME */
884static void __dev_pm_qos_hide_latency_limit(struct device *dev) {}
885static void __dev_pm_qos_hide_flags(struct device *dev) {}
886#endif /* CONFIG_PM_RUNTIME */
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 67c7938e430b..5070c4fe8542 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -13,43 +13,38 @@
13#include <trace/events/rpm.h> 13#include <trace/events/rpm.h>
14#include "power.h" 14#include "power.h"
15 15
16#define RPM_GET_CALLBACK(dev, cb) \ 16typedef int (*pm_callback_t)(struct device *);
17({ \
18 int (*__rpm_cb)(struct device *__d); \
19 \
20 if (dev->pm_domain) \
21 __rpm_cb = dev->pm_domain->ops.cb; \
22 else if (dev->type && dev->type->pm) \
23 __rpm_cb = dev->type->pm->cb; \
24 else if (dev->class && dev->class->pm) \
25 __rpm_cb = dev->class->pm->cb; \
26 else if (dev->bus && dev->bus->pm) \
27 __rpm_cb = dev->bus->pm->cb; \
28 else \
29 __rpm_cb = NULL; \
30 \
31 if (!__rpm_cb && dev->driver && dev->driver->pm) \
32 __rpm_cb = dev->driver->pm->cb; \
33 \
34 __rpm_cb; \
35})
36
37static int (*rpm_get_suspend_cb(struct device *dev))(struct device *)
38{
39 return RPM_GET_CALLBACK(dev, runtime_suspend);
40}
41 17
42static int (*rpm_get_resume_cb(struct device *dev))(struct device *) 18static pm_callback_t __rpm_get_callback(struct device *dev, size_t cb_offset)
43{ 19{
44 return RPM_GET_CALLBACK(dev, runtime_resume); 20 pm_callback_t cb;
45} 21 const struct dev_pm_ops *ops;
22
23 if (dev->pm_domain)
24 ops = &dev->pm_domain->ops;
25 else if (dev->type && dev->type->pm)
26 ops = dev->type->pm;
27 else if (dev->class && dev->class->pm)
28 ops = dev->class->pm;
29 else if (dev->bus && dev->bus->pm)
30 ops = dev->bus->pm;
31 else
32 ops = NULL;
46 33
47#ifdef CONFIG_PM_RUNTIME 34 if (ops)
48static int (*rpm_get_idle_cb(struct device *dev))(struct device *) 35 cb = *(pm_callback_t *)((void *)ops + cb_offset);
49{ 36 else
50 return RPM_GET_CALLBACK(dev, runtime_idle); 37 cb = NULL;
38
39 if (!cb && dev->driver && dev->driver->pm)
40 cb = *(pm_callback_t *)((void *)dev->driver->pm + cb_offset);
41
42 return cb;
51} 43}
52 44
45#define RPM_GET_CALLBACK(dev, callback) \
46 __rpm_get_callback(dev, offsetof(struct dev_pm_ops, callback))
47
53static int rpm_resume(struct device *dev, int rpmflags); 48static int rpm_resume(struct device *dev, int rpmflags);
54static int rpm_suspend(struct device *dev, int rpmflags); 49static int rpm_suspend(struct device *dev, int rpmflags);
55 50
@@ -347,7 +342,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
347 342
348 dev->power.idle_notification = true; 343 dev->power.idle_notification = true;
349 344
350 callback = rpm_get_idle_cb(dev); 345 callback = RPM_GET_CALLBACK(dev, runtime_idle);
351 346
352 if (callback) 347 if (callback)
353 retval = __rpm_callback(callback, dev); 348 retval = __rpm_callback(callback, dev);
@@ -517,7 +512,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
517 512
518 __update_runtime_status(dev, RPM_SUSPENDING); 513 __update_runtime_status(dev, RPM_SUSPENDING);
519 514
520 callback = rpm_get_suspend_cb(dev); 515 callback = RPM_GET_CALLBACK(dev, runtime_suspend);
521 516
522 retval = rpm_callback(callback, dev); 517 retval = rpm_callback(callback, dev);
523 if (retval) 518 if (retval)
@@ -737,7 +732,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
737 732
738 __update_runtime_status(dev, RPM_RESUMING); 733 __update_runtime_status(dev, RPM_RESUMING);
739 734
740 callback = rpm_get_resume_cb(dev); 735 callback = RPM_GET_CALLBACK(dev, runtime_resume);
741 736
742 retval = rpm_callback(callback, dev); 737 retval = rpm_callback(callback, dev);
743 if (retval) { 738 if (retval) {
@@ -1402,7 +1397,6 @@ void pm_runtime_remove(struct device *dev)
1402 if (dev->power.irq_safe && dev->parent) 1397 if (dev->power.irq_safe && dev->parent)
1403 pm_runtime_put(dev->parent); 1398 pm_runtime_put(dev->parent);
1404} 1399}
1405#endif
1406 1400
1407/** 1401/**
1408 * pm_runtime_force_suspend - Force a device into suspend state if needed. 1402 * pm_runtime_force_suspend - Force a device into suspend state if needed.
@@ -1422,16 +1416,10 @@ int pm_runtime_force_suspend(struct device *dev)
1422 int ret = 0; 1416 int ret = 0;
1423 1417
1424 pm_runtime_disable(dev); 1418 pm_runtime_disable(dev);
1425
1426 /*
1427 * Note that pm_runtime_status_suspended() returns false while
1428 * !CONFIG_PM_RUNTIME, which means the device will be put into low
1429 * power state.
1430 */
1431 if (pm_runtime_status_suspended(dev)) 1419 if (pm_runtime_status_suspended(dev))
1432 return 0; 1420 return 0;
1433 1421
1434 callback = rpm_get_suspend_cb(dev); 1422 callback = RPM_GET_CALLBACK(dev, runtime_suspend);
1435 1423
1436 if (!callback) { 1424 if (!callback) {
1437 ret = -ENOSYS; 1425 ret = -ENOSYS;
@@ -1467,7 +1455,7 @@ int pm_runtime_force_resume(struct device *dev)
1467 int (*callback)(struct device *); 1455 int (*callback)(struct device *);
1468 int ret = 0; 1456 int ret = 0;
1469 1457
1470 callback = rpm_get_resume_cb(dev); 1458 callback = RPM_GET_CALLBACK(dev, runtime_resume);
1471 1459
1472 if (!callback) { 1460 if (!callback) {
1473 ret = -ENOSYS; 1461 ret = -ENOSYS;
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index a9d26ed11bf4..d2be3f9c211c 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -95,7 +95,6 @@
95const char power_group_name[] = "power"; 95const char power_group_name[] = "power";
96EXPORT_SYMBOL_GPL(power_group_name); 96EXPORT_SYMBOL_GPL(power_group_name);
97 97
98#ifdef CONFIG_PM_RUNTIME
99static const char ctrl_auto[] = "auto"; 98static const char ctrl_auto[] = "auto";
100static const char ctrl_on[] = "on"; 99static const char ctrl_on[] = "on";
101 100
@@ -330,7 +329,6 @@ static ssize_t pm_qos_remote_wakeup_store(struct device *dev,
330 329
331static DEVICE_ATTR(pm_qos_remote_wakeup, 0644, 330static DEVICE_ATTR(pm_qos_remote_wakeup, 0644,
332 pm_qos_remote_wakeup_show, pm_qos_remote_wakeup_store); 331 pm_qos_remote_wakeup_show, pm_qos_remote_wakeup_store);
333#endif /* CONFIG_PM_RUNTIME */
334 332
335#ifdef CONFIG_PM_SLEEP 333#ifdef CONFIG_PM_SLEEP
336static const char _enabled[] = "enabled"; 334static const char _enabled[] = "enabled";
@@ -531,8 +529,6 @@ static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444,
531#endif /* CONFIG_PM_SLEEP */ 529#endif /* CONFIG_PM_SLEEP */
532 530
533#ifdef CONFIG_PM_ADVANCED_DEBUG 531#ifdef CONFIG_PM_ADVANCED_DEBUG
534#ifdef CONFIG_PM_RUNTIME
535
536static ssize_t rtpm_usagecount_show(struct device *dev, 532static ssize_t rtpm_usagecount_show(struct device *dev,
537 struct device_attribute *attr, char *buf) 533 struct device_attribute *attr, char *buf)
538{ 534{
@@ -562,10 +558,7 @@ static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
562static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL); 558static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
563static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL); 559static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
564 560
565#endif
566
567#ifdef CONFIG_PM_SLEEP 561#ifdef CONFIG_PM_SLEEP
568
569static ssize_t async_show(struct device *dev, struct device_attribute *attr, 562static ssize_t async_show(struct device *dev, struct device_attribute *attr,
570 char *buf) 563 char *buf)
571{ 564{
@@ -595,7 +588,7 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
595 588
596static DEVICE_ATTR(async, 0644, async_show, async_store); 589static DEVICE_ATTR(async, 0644, async_show, async_store);
597 590
598#endif 591#endif /* CONFIG_PM_SLEEP */
599#endif /* CONFIG_PM_ADVANCED_DEBUG */ 592#endif /* CONFIG_PM_ADVANCED_DEBUG */
600 593
601static struct attribute *power_attrs[] = { 594static struct attribute *power_attrs[] = {
@@ -603,12 +596,10 @@ static struct attribute *power_attrs[] = {
603#ifdef CONFIG_PM_SLEEP 596#ifdef CONFIG_PM_SLEEP
604 &dev_attr_async.attr, 597 &dev_attr_async.attr,
605#endif 598#endif
606#ifdef CONFIG_PM_RUNTIME
607 &dev_attr_runtime_status.attr, 599 &dev_attr_runtime_status.attr,
608 &dev_attr_runtime_usage.attr, 600 &dev_attr_runtime_usage.attr,
609 &dev_attr_runtime_active_kids.attr, 601 &dev_attr_runtime_active_kids.attr,
610 &dev_attr_runtime_enabled.attr, 602 &dev_attr_runtime_enabled.attr,
611#endif
612#endif /* CONFIG_PM_ADVANCED_DEBUG */ 603#endif /* CONFIG_PM_ADVANCED_DEBUG */
613 NULL, 604 NULL,
614}; 605};
@@ -640,7 +631,6 @@ static struct attribute_group pm_wakeup_attr_group = {
640}; 631};
641 632
642static struct attribute *runtime_attrs[] = { 633static struct attribute *runtime_attrs[] = {
643#ifdef CONFIG_PM_RUNTIME
644#ifndef CONFIG_PM_ADVANCED_DEBUG 634#ifndef CONFIG_PM_ADVANCED_DEBUG
645 &dev_attr_runtime_status.attr, 635 &dev_attr_runtime_status.attr,
646#endif 636#endif
@@ -648,7 +638,6 @@ static struct attribute *runtime_attrs[] = {
648 &dev_attr_runtime_suspended_time.attr, 638 &dev_attr_runtime_suspended_time.attr,
649 &dev_attr_runtime_active_time.attr, 639 &dev_attr_runtime_active_time.attr,
650 &dev_attr_autosuspend_delay_ms.attr, 640 &dev_attr_autosuspend_delay_ms.attr,
651#endif /* CONFIG_PM_RUNTIME */
652 NULL, 641 NULL,
653}; 642};
654static struct attribute_group pm_runtime_attr_group = { 643static struct attribute_group pm_runtime_attr_group = {
@@ -657,9 +646,7 @@ static struct attribute_group pm_runtime_attr_group = {
657}; 646};
658 647
659static struct attribute *pm_qos_resume_latency_attrs[] = { 648static struct attribute *pm_qos_resume_latency_attrs[] = {
660#ifdef CONFIG_PM_RUNTIME
661 &dev_attr_pm_qos_resume_latency_us.attr, 649 &dev_attr_pm_qos_resume_latency_us.attr,
662#endif /* CONFIG_PM_RUNTIME */
663 NULL, 650 NULL,
664}; 651};
665static struct attribute_group pm_qos_resume_latency_attr_group = { 652static struct attribute_group pm_qos_resume_latency_attr_group = {
@@ -668,9 +655,7 @@ static struct attribute_group pm_qos_resume_latency_attr_group = {
668}; 655};
669 656
670static struct attribute *pm_qos_latency_tolerance_attrs[] = { 657static struct attribute *pm_qos_latency_tolerance_attrs[] = {
671#ifdef CONFIG_PM_RUNTIME
672 &dev_attr_pm_qos_latency_tolerance_us.attr, 658 &dev_attr_pm_qos_latency_tolerance_us.attr,
673#endif /* CONFIG_PM_RUNTIME */
674 NULL, 659 NULL,
675}; 660};
676static struct attribute_group pm_qos_latency_tolerance_attr_group = { 661static struct attribute_group pm_qos_latency_tolerance_attr_group = {
@@ -679,10 +664,8 @@ static struct attribute_group pm_qos_latency_tolerance_attr_group = {
679}; 664};
680 665
681static struct attribute *pm_qos_flags_attrs[] = { 666static struct attribute *pm_qos_flags_attrs[] = {
682#ifdef CONFIG_PM_RUNTIME
683 &dev_attr_pm_qos_no_power_off.attr, 667 &dev_attr_pm_qos_no_power_off.attr,
684 &dev_attr_pm_qos_remote_wakeup.attr, 668 &dev_attr_pm_qos_remote_wakeup.attr,
685#endif /* CONFIG_PM_RUNTIME */
686 NULL, 669 NULL,
687}; 670};
688static struct attribute_group pm_qos_flags_attr_group = { 671static struct attribute_group pm_qos_flags_attr_group = {
diff --git a/drivers/base/property.c b/drivers/base/property.c
new file mode 100644
index 000000000000..c45845874d4f
--- /dev/null
+++ b/drivers/base/property.c
@@ -0,0 +1,431 @@
1/*
2 * property.c - Unified device property interface.
3 *
4 * Copyright (C) 2014, Intel Corporation
5 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 * Mika Westerberg <mika.westerberg@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/property.h>
14#include <linux/export.h>
15#include <linux/acpi.h>
16#include <linux/of.h>
17
18/**
19 * device_property_present - check if a property of a device is present
20 * @dev: Device whose property is being checked
21 * @propname: Name of the property
22 *
23 * Check if property @propname is present in the device firmware description.
24 */
25bool device_property_present(struct device *dev, const char *propname)
26{
27 if (IS_ENABLED(CONFIG_OF) && dev->of_node)
28 return of_property_read_bool(dev->of_node, propname);
29
30 return !acpi_dev_prop_get(ACPI_COMPANION(dev), propname, NULL);
31}
32EXPORT_SYMBOL_GPL(device_property_present);
33
34/**
35 * fwnode_property_present - check if a property of a firmware node is present
36 * @fwnode: Firmware node whose property to check
37 * @propname: Name of the property
38 */
39bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
40{
41 if (is_of_node(fwnode))
42 return of_property_read_bool(of_node(fwnode), propname);
43 else if (is_acpi_node(fwnode))
44 return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL);
45
46 return false;
47}
48EXPORT_SYMBOL_GPL(fwnode_property_present);
49
50#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
51 (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
52 : of_property_count_elems_of_size((node), (propname), sizeof(type))
53
54#define DEV_PROP_READ_ARRAY(_dev_, _propname_, _type_, _proptype_, _val_, _nval_) \
55 IS_ENABLED(CONFIG_OF) && _dev_->of_node ? \
56 (OF_DEV_PROP_READ_ARRAY(_dev_->of_node, _propname_, _type_, \
57 _val_, _nval_)) : \
58 acpi_dev_prop_read(ACPI_COMPANION(_dev_), _propname_, \
59 _proptype_, _val_, _nval_)
60
61/**
62 * device_property_read_u8_array - return a u8 array property of a device
63 * @dev: Device to get the property of
64 * @propname: Name of the property
65 * @val: The values are stored here
66 * @nval: Size of the @val array
67 *
68 * Function reads an array of u8 properties with @propname from the device
69 * firmware description and stores them to @val if found.
70 *
71 * Return: %0 if the property was found (success),
72 * %-EINVAL if given arguments are not valid,
73 * %-ENODATA if the property does not have a value,
74 * %-EPROTO if the property is not an array of numbers,
75 * %-EOVERFLOW if the size of the property is not as expected.
76 */
77int device_property_read_u8_array(struct device *dev, const char *propname,
78 u8 *val, size_t nval)
79{
80 return DEV_PROP_READ_ARRAY(dev, propname, u8, DEV_PROP_U8, val, nval);
81}
82EXPORT_SYMBOL_GPL(device_property_read_u8_array);
83
84/**
85 * device_property_read_u16_array - return a u16 array property of a device
86 * @dev: Device to get the property of
87 * @propname: Name of the property
88 * @val: The values are stored here
89 * @nval: Size of the @val array
90 *
91 * Function reads an array of u16 properties with @propname from the device
92 * firmware description and stores them to @val if found.
93 *
94 * Return: %0 if the property was found (success),
95 * %-EINVAL if given arguments are not valid,
96 * %-ENODATA if the property does not have a value,
97 * %-EPROTO if the property is not an array of numbers,
98 * %-EOVERFLOW if the size of the property is not as expected.
99 */
100int device_property_read_u16_array(struct device *dev, const char *propname,
101 u16 *val, size_t nval)
102{
103 return DEV_PROP_READ_ARRAY(dev, propname, u16, DEV_PROP_U16, val, nval);
104}
105EXPORT_SYMBOL_GPL(device_property_read_u16_array);
106
107/**
108 * device_property_read_u32_array - return a u32 array property of a device
109 * @dev: Device to get the property of
110 * @propname: Name of the property
111 * @val: The values are stored here
112 * @nval: Size of the @val array
113 *
114 * Function reads an array of u32 properties with @propname from the device
115 * firmware description and stores them to @val if found.
116 *
117 * Return: %0 if the property was found (success),
118 * %-EINVAL if given arguments are not valid,
119 * %-ENODATA if the property does not have a value,
120 * %-EPROTO if the property is not an array of numbers,
121 * %-EOVERFLOW if the size of the property is not as expected.
122 */
123int device_property_read_u32_array(struct device *dev, const char *propname,
124 u32 *val, size_t nval)
125{
126 return DEV_PROP_READ_ARRAY(dev, propname, u32, DEV_PROP_U32, val, nval);
127}
128EXPORT_SYMBOL_GPL(device_property_read_u32_array);
129
130/**
131 * device_property_read_u64_array - return a u64 array property of a device
132 * @dev: Device to get the property of
133 * @propname: Name of the property
134 * @val: The values are stored here
135 * @nval: Size of the @val array
136 *
137 * Function reads an array of u64 properties with @propname from the device
138 * firmware description and stores them to @val if found.
139 *
140 * Return: %0 if the property was found (success),
141 * %-EINVAL if given arguments are not valid,
142 * %-ENODATA if the property does not have a value,
143 * %-EPROTO if the property is not an array of numbers,
144 * %-EOVERFLOW if the size of the property is not as expected.
145 */
146int device_property_read_u64_array(struct device *dev, const char *propname,
147 u64 *val, size_t nval)
148{
149 return DEV_PROP_READ_ARRAY(dev, propname, u64, DEV_PROP_U64, val, nval);
150}
151EXPORT_SYMBOL_GPL(device_property_read_u64_array);
152
153/**
154 * device_property_read_string_array - return a string array property of device
155 * @dev: Device to get the property of
156 * @propname: Name of the property
157 * @val: The values are stored here
158 * @nval: Size of the @val array
159 *
160 * Function reads an array of string properties with @propname from the device
161 * firmware description and stores them to @val if found.
162 *
163 * Return: %0 if the property was found (success),
164 * %-EINVAL if given arguments are not valid,
165 * %-ENODATA if the property does not have a value,
166 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
167 * %-EOVERFLOW if the size of the property is not as expected.
168 */
169int device_property_read_string_array(struct device *dev, const char *propname,
170 const char **val, size_t nval)
171{
172 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
173 of_property_read_string_array(dev->of_node, propname, val, nval) :
174 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
175 DEV_PROP_STRING, val, nval);
176}
177EXPORT_SYMBOL_GPL(device_property_read_string_array);
178
179/**
180 * device_property_read_string - return a string property of a device
181 * @dev: Device to get the property of
182 * @propname: Name of the property
183 * @val: The value is stored here
184 *
185 * Function reads property @propname from the device firmware description and
186 * stores the value into @val if found. The value is checked to be a string.
187 *
188 * Return: %0 if the property was found (success),
189 * %-EINVAL if given arguments are not valid,
190 * %-ENODATA if the property does not have a value,
191 * %-EPROTO or %-EILSEQ if the property type is not a string.
192 */
193int device_property_read_string(struct device *dev, const char *propname,
194 const char **val)
195{
196 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
197 of_property_read_string(dev->of_node, propname, val) :
198 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
199 DEV_PROP_STRING, val, 1);
200}
201EXPORT_SYMBOL_GPL(device_property_read_string);
202
203#define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \
204({ \
205 int _ret_; \
206 if (is_of_node(_fwnode_)) \
207 _ret_ = OF_DEV_PROP_READ_ARRAY(of_node(_fwnode_), _propname_, \
208 _type_, _val_, _nval_); \
209 else if (is_acpi_node(_fwnode_)) \
210 _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \
211 _proptype_, _val_, _nval_); \
212 else \
213 _ret_ = -ENXIO; \
214 _ret_; \
215})
216
217/**
218 * fwnode_property_read_u8_array - return a u8 array property of firmware node
219 * @fwnode: Firmware node to get the property of
220 * @propname: Name of the property
221 * @val: The values are stored here
222 * @nval: Size of the @val array
223 *
224 * Read an array of u8 properties with @propname from @fwnode and stores them to
225 * @val if found.
226 *
227 * Return: %0 if the property was found (success),
228 * %-EINVAL if given arguments are not valid,
229 * %-ENODATA if the property does not have a value,
230 * %-EPROTO if the property is not an array of numbers,
231 * %-EOVERFLOW if the size of the property is not as expected,
232 * %-ENXIO if no suitable firmware interface is present.
233 */
234int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
235 const char *propname, u8 *val, size_t nval)
236{
237 return FWNODE_PROP_READ_ARRAY(fwnode, propname, u8, DEV_PROP_U8,
238 val, nval);
239}
240EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
241
242/**
243 * fwnode_property_read_u16_array - return a u16 array property of firmware node
244 * @fwnode: Firmware node to get the property of
245 * @propname: Name of the property
246 * @val: The values are stored here
247 * @nval: Size of the @val array
248 *
249 * Read an array of u16 properties with @propname from @fwnode and store them to
250 * @val if found.
251 *
252 * Return: %0 if the property was found (success),
253 * %-EINVAL if given arguments are not valid,
254 * %-ENODATA if the property does not have a value,
255 * %-EPROTO if the property is not an array of numbers,
256 * %-EOVERFLOW if the size of the property is not as expected,
257 * %-ENXIO if no suitable firmware interface is present.
258 */
259int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
260 const char *propname, u16 *val, size_t nval)
261{
262 return FWNODE_PROP_READ_ARRAY(fwnode, propname, u16, DEV_PROP_U16,
263 val, nval);
264}
265EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
266
267/**
268 * fwnode_property_read_u32_array - return a u32 array property of firmware node
269 * @fwnode: Firmware node to get the property of
270 * @propname: Name of the property
271 * @val: The values are stored here
272 * @nval: Size of the @val array
273 *
274 * Read an array of u32 properties with @propname from @fwnode store them to
275 * @val if found.
276 *
277 * Return: %0 if the property was found (success),
278 * %-EINVAL if given arguments are not valid,
279 * %-ENODATA if the property does not have a value,
280 * %-EPROTO if the property is not an array of numbers,
281 * %-EOVERFLOW if the size of the property is not as expected,
282 * %-ENXIO if no suitable firmware interface is present.
283 */
284int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
285 const char *propname, u32 *val, size_t nval)
286{
287 return FWNODE_PROP_READ_ARRAY(fwnode, propname, u32, DEV_PROP_U32,
288 val, nval);
289}
290EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
291
292/**
293 * fwnode_property_read_u64_array - return a u64 array property firmware node
294 * @fwnode: Firmware node to get the property of
295 * @propname: Name of the property
296 * @val: The values are stored here
297 * @nval: Size of the @val array
298 *
299 * Read an array of u64 properties with @propname from @fwnode and store them to
300 * @val if found.
301 *
302 * Return: %0 if the property was found (success),
303 * %-EINVAL if given arguments are not valid,
304 * %-ENODATA if the property does not have a value,
305 * %-EPROTO if the property is not an array of numbers,
306 * %-EOVERFLOW if the size of the property is not as expected,
307 * %-ENXIO if no suitable firmware interface is present.
308 */
309int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
310 const char *propname, u64 *val, size_t nval)
311{
312 return FWNODE_PROP_READ_ARRAY(fwnode, propname, u64, DEV_PROP_U64,
313 val, nval);
314}
315EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
316
317/**
318 * fwnode_property_read_string_array - return string array property of a node
319 * @fwnode: Firmware node to get the property of
320 * @propname: Name of the property
321 * @val: The values are stored here
322 * @nval: Size of the @val array
323 *
324 * Read an string list property @propname from the given firmware node and store
325 * them to @val if found.
326 *
327 * Return: %0 if the property was found (success),
328 * %-EINVAL if given arguments are not valid,
329 * %-ENODATA if the property does not have a value,
330 * %-EPROTO if the property is not an array of strings,
331 * %-EOVERFLOW if the size of the property is not as expected,
332 * %-ENXIO if no suitable firmware interface is present.
333 */
334int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
335 const char *propname, const char **val,
336 size_t nval)
337{
338 if (is_of_node(fwnode))
339 return of_property_read_string_array(of_node(fwnode), propname,
340 val, nval);
341 else if (is_acpi_node(fwnode))
342 return acpi_dev_prop_read(acpi_node(fwnode), propname,
343 DEV_PROP_STRING, val, nval);
344
345 return -ENXIO;
346}
347EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
348
349/**
350 * fwnode_property_read_string - return a string property of a firmware node
351 * @fwnode: Firmware node to get the property of
352 * @propname: Name of the property
353 * @val: The value is stored here
354 *
355 * Read property @propname from the given firmware node and store the value into
356 * @val if found. The value is checked to be a string.
357 *
358 * Return: %0 if the property was found (success),
359 * %-EINVAL if given arguments are not valid,
360 * %-ENODATA if the property does not have a value,
361 * %-EPROTO or %-EILSEQ if the property is not a string,
362 * %-ENXIO if no suitable firmware interface is present.
363 */
364int fwnode_property_read_string(struct fwnode_handle *fwnode,
365 const char *propname, const char **val)
366{
367 if (is_of_node(fwnode))
368 return of_property_read_string(of_node(fwnode),propname, val);
369 else if (is_acpi_node(fwnode))
370 return acpi_dev_prop_read(acpi_node(fwnode), propname,
371 DEV_PROP_STRING, val, 1);
372
373 return -ENXIO;
374}
375EXPORT_SYMBOL_GPL(fwnode_property_read_string);
376
377/**
378 * device_get_next_child_node - Return the next child node handle for a device
379 * @dev: Device to find the next child node for.
380 * @child: Handle to one of the device's child nodes or a null handle.
381 */
382struct fwnode_handle *device_get_next_child_node(struct device *dev,
383 struct fwnode_handle *child)
384{
385 if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
386 struct device_node *node;
387
388 node = of_get_next_available_child(dev->of_node, of_node(child));
389 if (node)
390 return &node->fwnode;
391 } else if (IS_ENABLED(CONFIG_ACPI)) {
392 struct acpi_device *node;
393
394 node = acpi_get_next_child(dev, acpi_node(child));
395 if (node)
396 return acpi_fwnode_handle(node);
397 }
398 return NULL;
399}
400EXPORT_SYMBOL_GPL(device_get_next_child_node);
401
402/**
403 * fwnode_handle_put - Drop reference to a device node
404 * @fwnode: Pointer to the device node to drop the reference to.
405 *
406 * This has to be used when terminating device_for_each_child_node() iteration
407 * with break or return to prevent stale device node references from being left
408 * behind.
409 */
410void fwnode_handle_put(struct fwnode_handle *fwnode)
411{
412 if (is_of_node(fwnode))
413 of_node_put(of_node(fwnode));
414}
415EXPORT_SYMBOL_GPL(fwnode_handle_put);
416
417/**
418 * device_get_child_node_count - return the number of child nodes for device
419 * @dev: Device to cound the child nodes for
420 */
421unsigned int device_get_child_node_count(struct device *dev)
422{
423 struct fwnode_handle *child;
424 unsigned int count = 0;
425
426 device_for_each_child_node(dev, child)
427 count++;
428
429 return count;
430}
431EXPORT_SYMBOL_GPL(device_get_child_node_count);
diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c
index 9f8277cc44b4..993efd7f6c7e 100644
--- a/drivers/char/hw_random/exynos-rng.c
+++ b/drivers/char/hw_random/exynos-rng.c
@@ -143,7 +143,7 @@ static int exynos_rng_remove(struct platform_device *pdev)
143 return 0; 143 return 0;
144} 144}
145 145
146#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME) 146#ifdef CONFIG_PM
147static int exynos_rng_runtime_suspend(struct device *dev) 147static int exynos_rng_runtime_suspend(struct device *dev)
148{ 148{
149 struct platform_device *pdev = to_platform_device(dev); 149 struct platform_device *pdev = to_platform_device(dev);
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 3489f8f5fada..29b2ef5a68b9 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -63,7 +63,6 @@ config CPU_FREQ_DEFAULT_GOV_PERFORMANCE
63 63
64config CPU_FREQ_DEFAULT_GOV_POWERSAVE 64config CPU_FREQ_DEFAULT_GOV_POWERSAVE
65 bool "powersave" 65 bool "powersave"
66 depends on EXPERT
67 select CPU_FREQ_GOV_POWERSAVE 66 select CPU_FREQ_GOV_POWERSAVE
68 help 67 help
69 Use the CPUFreq governor 'powersave' as default. This sets 68 Use the CPUFreq governor 'powersave' as default. This sets
@@ -183,6 +182,8 @@ config CPU_FREQ_GOV_CONSERVATIVE
183 182
184 If in doubt, say N. 183 If in doubt, say N.
185 184
185comment "CPU frequency scaling drivers"
186
186config CPUFREQ_DT 187config CPUFREQ_DT
187 tristate "Generic DT based cpufreq driver" 188 tristate "Generic DT based cpufreq driver"
188 depends on HAVE_CLK && OF 189 depends on HAVE_CLK && OF
@@ -196,19 +197,19 @@ config CPUFREQ_DT
196 197
197 If in doubt, say N. 198 If in doubt, say N.
198 199
199menu "x86 CPU frequency scaling drivers" 200if X86
200depends on X86
201source "drivers/cpufreq/Kconfig.x86" 201source "drivers/cpufreq/Kconfig.x86"
202endmenu 202endif
203 203
204menu "ARM CPU frequency scaling drivers" 204if ARM || ARM64
205depends on ARM || ARM64
206source "drivers/cpufreq/Kconfig.arm" 205source "drivers/cpufreq/Kconfig.arm"
207endmenu 206endif
208 207
209menu "AVR32 CPU frequency scaling drivers" 208if PPC32 || PPC64
210depends on AVR32 209source "drivers/cpufreq/Kconfig.powerpc"
210endif
211 211
212if AVR32
212config AVR32_AT32AP_CPUFREQ 213config AVR32_AT32AP_CPUFREQ
213 bool "CPU frequency driver for AT32AP" 214 bool "CPU frequency driver for AT32AP"
214 depends on PLATFORM_AT32AP 215 depends on PLATFORM_AT32AP
@@ -216,12 +217,9 @@ config AVR32_AT32AP_CPUFREQ
216 help 217 help
217 This enables the CPU frequency driver for AT32AP processors. 218 This enables the CPU frequency driver for AT32AP processors.
218 If in doubt, say N. 219 If in doubt, say N.
220endif
219 221
220endmenu 222if IA64
221
222menu "CPUFreq processor drivers"
223depends on IA64
224
225config IA64_ACPI_CPUFREQ 223config IA64_ACPI_CPUFREQ
226 tristate "ACPI Processor P-States driver" 224 tristate "ACPI Processor P-States driver"
227 depends on ACPI_PROCESSOR 225 depends on ACPI_PROCESSOR
@@ -232,12 +230,9 @@ config IA64_ACPI_CPUFREQ
232 For details, take a look at <file:Documentation/cpu-freq/>. 230 For details, take a look at <file:Documentation/cpu-freq/>.
233 231
234 If in doubt, say N. 232 If in doubt, say N.
233endif
235 234
236endmenu 235if MIPS
237
238menu "MIPS CPUFreq processor drivers"
239depends on MIPS
240
241config LOONGSON2_CPUFREQ 236config LOONGSON2_CPUFREQ
242 tristate "Loongson2 CPUFreq Driver" 237 tristate "Loongson2 CPUFreq Driver"
243 help 238 help
@@ -250,15 +245,18 @@ config LOONGSON2_CPUFREQ
250 245
251 If in doubt, say N. 246 If in doubt, say N.
252 247
253endmenu 248config LOONGSON1_CPUFREQ
249 tristate "Loongson1 CPUFreq Driver"
250 help
251 This option adds a CPUFreq driver for loongson1 processors which
252 support software configurable cpu frequency.
254 253
255menu "PowerPC CPU frequency scaling drivers" 254 For details, take a look at <file:Documentation/cpu-freq/>.
256depends on PPC32 || PPC64
257source "drivers/cpufreq/Kconfig.powerpc"
258endmenu
259 255
260menu "SPARC CPU frequency scaling drivers" 256 If in doubt, say N.
261depends on SPARC64 257endif
258
259if SPARC64
262config SPARC_US3_CPUFREQ 260config SPARC_US3_CPUFREQ
263 tristate "UltraSPARC-III CPU Frequency driver" 261 tristate "UltraSPARC-III CPU Frequency driver"
264 help 262 help
@@ -276,10 +274,9 @@ config SPARC_US2E_CPUFREQ
276 For details, take a look at <file:Documentation/cpu-freq>. 274 For details, take a look at <file:Documentation/cpu-freq>.
277 275
278 If in doubt, say N. 276 If in doubt, say N.
279endmenu 277endif
280 278
281menu "SH CPU Frequency scaling" 279if SUPERH
282depends on SUPERH
283config SH_CPU_FREQ 280config SH_CPU_FREQ
284 tristate "SuperH CPU Frequency driver" 281 tristate "SuperH CPU Frequency driver"
285 help 282 help
@@ -293,7 +290,7 @@ config SH_CPU_FREQ
293 For details, take a look at <file:Documentation/cpu-freq>. 290 For details, take a look at <file:Documentation/cpu-freq>.
294 291
295 If unsure, say N. 292 If unsure, say N.
296endmenu 293endif
297 294
298endif 295endif
299endmenu 296endmenu
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 83a75dc84761..0f9a2c3c0e0d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -247,3 +247,11 @@ config ARM_TEGRA_CPUFREQ
247 default y 247 default y
248 help 248 help
249 This adds the CPUFreq driver support for TEGRA SOCs. 249 This adds the CPUFreq driver support for TEGRA SOCs.
250
251config ARM_PXA2xx_CPUFREQ
252 tristate "Intel PXA2xx CPUfreq driver"
253 depends on PXA27x || PXA25x
254 help
255 This add the CPUFreq driver support for Intel PXA2xx SOCs.
256
257 If in doubt, say N.
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 40c53dc1937e..b3ca7b0b2c33 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -61,8 +61,7 @@ obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
61obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o 61obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o
62obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o 62obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
63obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o 63obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
64obj-$(CONFIG_PXA25x) += pxa2xx-cpufreq.o 64obj-$(CONFIG_ARM_PXA2xx_CPUFREQ) += pxa2xx-cpufreq.o
65obj-$(CONFIG_PXA27x) += pxa2xx-cpufreq.o
66obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o 65obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o
67obj-$(CONFIG_ARM_S3C24XX_CPUFREQ) += s3c24xx-cpufreq.o 66obj-$(CONFIG_ARM_S3C24XX_CPUFREQ) += s3c24xx-cpufreq.o
68obj-$(CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS) += s3c24xx-cpufreq-debugfs.o 67obj-$(CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS) += s3c24xx-cpufreq-debugfs.o
@@ -98,6 +97,7 @@ obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o
98obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o 97obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o
99obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o 98obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o
100obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o 99obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o
100obj-$(CONFIG_LOONGSON1_CPUFREQ) += ls1x-cpufreq.o
101obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o 101obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o
102obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o 102obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o
103obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o 103obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
index a46c223c2506..e1a6ba66a7f5 100644
--- a/drivers/cpufreq/arm_big_little.c
+++ b/drivers/cpufreq/arm_big_little.c
@@ -289,6 +289,8 @@ static void _put_cluster_clk_and_freq_table(struct device *cpu_dev)
289 289
290 clk_put(clk[cluster]); 290 clk_put(clk[cluster]);
291 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); 291 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]);
292 if (arm_bL_ops->free_opp_table)
293 arm_bL_ops->free_opp_table(cpu_dev);
292 dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); 294 dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster);
293} 295}
294 296
@@ -337,7 +339,7 @@ static int _get_cluster_clk_and_freq_table(struct device *cpu_dev)
337 if (ret) { 339 if (ret) {
338 dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, err: %d\n", 340 dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, err: %d\n",
339 __func__, cpu_dev->id, ret); 341 __func__, cpu_dev->id, ret);
340 goto out; 342 goto free_opp_table;
341 } 343 }
342 344
343 name[12] = cluster + '0'; 345 name[12] = cluster + '0';
@@ -354,6 +356,9 @@ static int _get_cluster_clk_and_freq_table(struct device *cpu_dev)
354 ret = PTR_ERR(clk[cluster]); 356 ret = PTR_ERR(clk[cluster]);
355 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); 357 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]);
356 358
359free_opp_table:
360 if (arm_bL_ops->free_opp_table)
361 arm_bL_ops->free_opp_table(cpu_dev);
357out: 362out:
358 dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, 363 dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__,
359 cluster); 364 cluster);
diff --git a/drivers/cpufreq/arm_big_little.h b/drivers/cpufreq/arm_big_little.h
index 70f18fc12d4a..a211f7db9d32 100644
--- a/drivers/cpufreq/arm_big_little.h
+++ b/drivers/cpufreq/arm_big_little.h
@@ -25,13 +25,16 @@
25 25
26struct cpufreq_arm_bL_ops { 26struct cpufreq_arm_bL_ops {
27 char name[CPUFREQ_NAME_LEN]; 27 char name[CPUFREQ_NAME_LEN];
28 int (*get_transition_latency)(struct device *cpu_dev);
29 28
30 /* 29 /*
31 * This must set opp table for cpu_dev in a similar way as done by 30 * This must set opp table for cpu_dev in a similar way as done by
32 * of_init_opp_table(). 31 * of_init_opp_table().
33 */ 32 */
34 int (*init_opp_table)(struct device *cpu_dev); 33 int (*init_opp_table)(struct device *cpu_dev);
34
35 /* Optional */
36 int (*get_transition_latency)(struct device *cpu_dev);
37 void (*free_opp_table)(struct device *cpu_dev);
35}; 38};
36 39
37int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); 40int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops);
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c
index 4550f6976768..ef0b3f1324d5 100644
--- a/drivers/cpufreq/arm_big_little_dt.c
+++ b/drivers/cpufreq/arm_big_little_dt.c
@@ -82,6 +82,7 @@ static struct cpufreq_arm_bL_ops dt_bL_ops = {
82 .name = "dt-bl", 82 .name = "dt-bl",
83 .get_transition_latency = dt_get_transition_latency, 83 .get_transition_latency = dt_get_transition_latency,
84 .init_opp_table = dt_init_opp_table, 84 .init_opp_table = dt_init_opp_table,
85 .free_opp_table = of_free_opp_table,
85}; 86};
86 87
87static int generic_bL_probe(struct platform_device *pdev) 88static int generic_bL_probe(struct platform_device *pdev)
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index f657c571b18e..9bc2720628a4 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -58,6 +58,8 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
58 old_freq = clk_get_rate(cpu_clk) / 1000; 58 old_freq = clk_get_rate(cpu_clk) / 1000;
59 59
60 if (!IS_ERR(cpu_reg)) { 60 if (!IS_ERR(cpu_reg)) {
61 unsigned long opp_freq;
62
61 rcu_read_lock(); 63 rcu_read_lock();
62 opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_Hz); 64 opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_Hz);
63 if (IS_ERR(opp)) { 65 if (IS_ERR(opp)) {
@@ -67,13 +69,16 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
67 return PTR_ERR(opp); 69 return PTR_ERR(opp);
68 } 70 }
69 volt = dev_pm_opp_get_voltage(opp); 71 volt = dev_pm_opp_get_voltage(opp);
72 opp_freq = dev_pm_opp_get_freq(opp);
70 rcu_read_unlock(); 73 rcu_read_unlock();
71 tol = volt * priv->voltage_tolerance / 100; 74 tol = volt * priv->voltage_tolerance / 100;
72 volt_old = regulator_get_voltage(cpu_reg); 75 volt_old = regulator_get_voltage(cpu_reg);
76 dev_dbg(cpu_dev, "Found OPP: %ld kHz, %ld uV\n",
77 opp_freq / 1000, volt);
73 } 78 }
74 79
75 dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n", 80 dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
76 old_freq / 1000, volt_old ? volt_old / 1000 : -1, 81 old_freq / 1000, (volt_old > 0) ? volt_old / 1000 : -1,
77 new_freq / 1000, volt ? volt / 1000 : -1); 82 new_freq / 1000, volt ? volt / 1000 : -1);
78 83
79 /* scaling up? scale voltage before frequency */ 84 /* scaling up? scale voltage before frequency */
@@ -89,7 +94,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
89 ret = clk_set_rate(cpu_clk, freq_exact); 94 ret = clk_set_rate(cpu_clk, freq_exact);
90 if (ret) { 95 if (ret) {
91 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); 96 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
92 if (!IS_ERR(cpu_reg)) 97 if (!IS_ERR(cpu_reg) && volt_old > 0)
93 regulator_set_voltage_tol(cpu_reg, volt_old, tol); 98 regulator_set_voltage_tol(cpu_reg, volt_old, tol);
94 return ret; 99 return ret;
95 } 100 }
@@ -181,7 +186,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
181{ 186{
182 struct cpufreq_dt_platform_data *pd; 187 struct cpufreq_dt_platform_data *pd;
183 struct cpufreq_frequency_table *freq_table; 188 struct cpufreq_frequency_table *freq_table;
184 struct thermal_cooling_device *cdev;
185 struct device_node *np; 189 struct device_node *np;
186 struct private_data *priv; 190 struct private_data *priv;
187 struct device *cpu_dev; 191 struct device *cpu_dev;
@@ -210,7 +214,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
210 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 214 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
211 if (!priv) { 215 if (!priv) {
212 ret = -ENOMEM; 216 ret = -ENOMEM;
213 goto out_put_node; 217 goto out_free_opp;
214 } 218 }
215 219
216 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); 220 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
@@ -264,20 +268,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
264 goto out_free_priv; 268 goto out_free_priv;
265 } 269 }
266 270
267 /*
268 * For now, just loading the cooling device;
269 * thermal DT code takes care of matching them.
270 */
271 if (of_find_property(np, "#cooling-cells", NULL)) {
272 cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
273 if (IS_ERR(cdev))
274 dev_err(cpu_dev,
275 "running cpufreq without cooling device: %ld\n",
276 PTR_ERR(cdev));
277 else
278 priv->cdev = cdev;
279 }
280
281 priv->cpu_dev = cpu_dev; 271 priv->cpu_dev = cpu_dev;
282 priv->cpu_reg = cpu_reg; 272 priv->cpu_reg = cpu_reg;
283 policy->driver_data = priv; 273 policy->driver_data = priv;
@@ -287,7 +277,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
287 if (ret) { 277 if (ret) {
288 dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__, 278 dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__,
289 ret); 279 ret);
290 goto out_cooling_unregister; 280 goto out_free_cpufreq_table;
291 } 281 }
292 282
293 policy->cpuinfo.transition_latency = transition_latency; 283 policy->cpuinfo.transition_latency = transition_latency;
@@ -300,12 +290,12 @@ static int cpufreq_init(struct cpufreq_policy *policy)
300 290
301 return 0; 291 return 0;
302 292
303out_cooling_unregister: 293out_free_cpufreq_table:
304 cpufreq_cooling_unregister(priv->cdev);
305 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 294 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
306out_free_priv: 295out_free_priv:
307 kfree(priv); 296 kfree(priv);
308out_put_node: 297out_free_opp:
298 of_free_opp_table(cpu_dev);
309 of_node_put(np); 299 of_node_put(np);
310out_put_reg_clk: 300out_put_reg_clk:
311 clk_put(cpu_clk); 301 clk_put(cpu_clk);
@@ -319,8 +309,10 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
319{ 309{
320 struct private_data *priv = policy->driver_data; 310 struct private_data *priv = policy->driver_data;
321 311
322 cpufreq_cooling_unregister(priv->cdev); 312 if (priv->cdev)
313 cpufreq_cooling_unregister(priv->cdev);
323 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); 314 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
315 of_free_opp_table(priv->cpu_dev);
324 clk_put(policy->clk); 316 clk_put(policy->clk);
325 if (!IS_ERR(priv->cpu_reg)) 317 if (!IS_ERR(priv->cpu_reg))
326 regulator_put(priv->cpu_reg); 318 regulator_put(priv->cpu_reg);
@@ -329,6 +321,33 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
329 return 0; 321 return 0;
330} 322}
331 323
324static void cpufreq_ready(struct cpufreq_policy *policy)
325{
326 struct private_data *priv = policy->driver_data;
327 struct device_node *np = of_node_get(priv->cpu_dev->of_node);
328
329 if (WARN_ON(!np))
330 return;
331
332 /*
333 * For now, just loading the cooling device;
334 * thermal DT code takes care of matching them.
335 */
336 if (of_find_property(np, "#cooling-cells", NULL)) {
337 priv->cdev = of_cpufreq_cooling_register(np,
338 policy->related_cpus);
339 if (IS_ERR(priv->cdev)) {
340 dev_err(priv->cpu_dev,
341 "running cpufreq without cooling device: %ld\n",
342 PTR_ERR(priv->cdev));
343
344 priv->cdev = NULL;
345 }
346 }
347
348 of_node_put(np);
349}
350
332static struct cpufreq_driver dt_cpufreq_driver = { 351static struct cpufreq_driver dt_cpufreq_driver = {
333 .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, 352 .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
334 .verify = cpufreq_generic_frequency_table_verify, 353 .verify = cpufreq_generic_frequency_table_verify,
@@ -336,6 +355,7 @@ static struct cpufreq_driver dt_cpufreq_driver = {
336 .get = cpufreq_generic_get, 355 .get = cpufreq_generic_get,
337 .init = cpufreq_init, 356 .init = cpufreq_init,
338 .exit = cpufreq_exit, 357 .exit = cpufreq_exit,
358 .ready = cpufreq_ready,
339 .name = "cpufreq-dt", 359 .name = "cpufreq-dt",
340 .attr = cpufreq_generic_attr, 360 .attr = cpufreq_generic_attr,
341}; 361};
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4473eba1d6b0..a09a29c312a9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -535,7 +535,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
535static ssize_t store_##file_name \ 535static ssize_t store_##file_name \
536(struct cpufreq_policy *policy, const char *buf, size_t count) \ 536(struct cpufreq_policy *policy, const char *buf, size_t count) \
537{ \ 537{ \
538 int ret; \ 538 int ret, temp; \
539 struct cpufreq_policy new_policy; \ 539 struct cpufreq_policy new_policy; \
540 \ 540 \
541 ret = cpufreq_get_policy(&new_policy, policy->cpu); \ 541 ret = cpufreq_get_policy(&new_policy, policy->cpu); \
@@ -546,8 +546,10 @@ static ssize_t store_##file_name \
546 if (ret != 1) \ 546 if (ret != 1) \
547 return -EINVAL; \ 547 return -EINVAL; \
548 \ 548 \
549 temp = new_policy.object; \
549 ret = cpufreq_set_policy(policy, &new_policy); \ 550 ret = cpufreq_set_policy(policy, &new_policy); \
550 policy->user_policy.object = policy->object; \ 551 if (!ret) \
552 policy->user_policy.object = temp; \
551 \ 553 \
552 return ret ? ret : count; \ 554 return ret ? ret : count; \
553} 555}
@@ -898,46 +900,31 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy,
898 struct freq_attr **drv_attr; 900 struct freq_attr **drv_attr;
899 int ret = 0; 901 int ret = 0;
900 902
901 /* prepare interface data */
902 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
903 &dev->kobj, "cpufreq");
904 if (ret)
905 return ret;
906
907 /* set up files for this cpu device */ 903 /* set up files for this cpu device */
908 drv_attr = cpufreq_driver->attr; 904 drv_attr = cpufreq_driver->attr;
909 while ((drv_attr) && (*drv_attr)) { 905 while ((drv_attr) && (*drv_attr)) {
910 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); 906 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
911 if (ret) 907 if (ret)
912 goto err_out_kobj_put; 908 return ret;
913 drv_attr++; 909 drv_attr++;
914 } 910 }
915 if (cpufreq_driver->get) { 911 if (cpufreq_driver->get) {
916 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 912 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
917 if (ret) 913 if (ret)
918 goto err_out_kobj_put; 914 return ret;
919 } 915 }
920 916
921 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 917 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
922 if (ret) 918 if (ret)
923 goto err_out_kobj_put; 919 return ret;
924 920
925 if (cpufreq_driver->bios_limit) { 921 if (cpufreq_driver->bios_limit) {
926 ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); 922 ret = sysfs_create_file(&policy->kobj, &bios_limit.attr);
927 if (ret) 923 if (ret)
928 goto err_out_kobj_put; 924 return ret;
929 } 925 }
930 926
931 ret = cpufreq_add_dev_symlink(policy); 927 return cpufreq_add_dev_symlink(policy);
932 if (ret)
933 goto err_out_kobj_put;
934
935 return ret;
936
937err_out_kobj_put:
938 kobject_put(&policy->kobj);
939 wait_for_completion(&policy->kobj_unregister);
940 return ret;
941} 928}
942 929
943static void cpufreq_init_policy(struct cpufreq_policy *policy) 930static void cpufreq_init_policy(struct cpufreq_policy *policy)
@@ -1196,6 +1183,8 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1196 goto err_set_policy_cpu; 1183 goto err_set_policy_cpu;
1197 } 1184 }
1198 1185
1186 down_write(&policy->rwsem);
1187
1199 /* related cpus should atleast have policy->cpus */ 1188 /* related cpus should atleast have policy->cpus */
1200 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus); 1189 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
1201 1190
@@ -1208,9 +1197,17 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1208 if (!recover_policy) { 1197 if (!recover_policy) {
1209 policy->user_policy.min = policy->min; 1198 policy->user_policy.min = policy->min;
1210 policy->user_policy.max = policy->max; 1199 policy->user_policy.max = policy->max;
1200
1201 /* prepare interface data */
1202 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
1203 &dev->kobj, "cpufreq");
1204 if (ret) {
1205 pr_err("%s: failed to init policy->kobj: %d\n",
1206 __func__, ret);
1207 goto err_init_policy_kobj;
1208 }
1211 } 1209 }
1212 1210
1213 down_write(&policy->rwsem);
1214 write_lock_irqsave(&cpufreq_driver_lock, flags); 1211 write_lock_irqsave(&cpufreq_driver_lock, flags);
1215 for_each_cpu(j, policy->cpus) 1212 for_each_cpu(j, policy->cpus)
1216 per_cpu(cpufreq_cpu_data, j) = policy; 1213 per_cpu(cpufreq_cpu_data, j) = policy;
@@ -1288,8 +1285,13 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1288 up_write(&policy->rwsem); 1285 up_write(&policy->rwsem);
1289 1286
1290 kobject_uevent(&policy->kobj, KOBJ_ADD); 1287 kobject_uevent(&policy->kobj, KOBJ_ADD);
1288
1291 up_read(&cpufreq_rwsem); 1289 up_read(&cpufreq_rwsem);
1292 1290
1291 /* Callback for handling stuff after policy is ready */
1292 if (cpufreq_driver->ready)
1293 cpufreq_driver->ready(policy);
1294
1293 pr_debug("initialization complete\n"); 1295 pr_debug("initialization complete\n");
1294 1296
1295 return 0; 1297 return 0;
@@ -1301,6 +1303,11 @@ err_get_freq:
1301 per_cpu(cpufreq_cpu_data, j) = NULL; 1303 per_cpu(cpufreq_cpu_data, j) = NULL;
1302 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1304 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1303 1305
1306 if (!recover_policy) {
1307 kobject_put(&policy->kobj);
1308 wait_for_completion(&policy->kobj_unregister);
1309 }
1310err_init_policy_kobj:
1304 up_write(&policy->rwsem); 1311 up_write(&policy->rwsem);
1305 1312
1306 if (cpufreq_driver->exit) 1313 if (cpufreq_driver->exit)
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index f33f25b483ca..27a57ed9eb2c 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -371,7 +371,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
371 if (ret) { 371 if (ret) {
372 dev_err(dvfs_info->dev, 372 dev_err(dvfs_info->dev,
373 "failed to init cpufreq table: %d\n", ret); 373 "failed to init cpufreq table: %d\n", ret);
374 goto err_put_node; 374 goto err_free_opp;
375 } 375 }
376 dvfs_info->freq_count = dev_pm_opp_get_opp_count(dvfs_info->dev); 376 dvfs_info->freq_count = dev_pm_opp_get_opp_count(dvfs_info->dev);
377 exynos_sort_descend_freq_table(); 377 exynos_sort_descend_freq_table();
@@ -423,6 +423,8 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
423 423
424err_free_table: 424err_free_table:
425 dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table); 425 dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
426err_free_opp:
427 of_free_opp_table(dvfs_info->dev);
426err_put_node: 428err_put_node:
427 of_node_put(np); 429 of_node_put(np);
428 dev_err(&pdev->dev, "%s: failed initialization\n", __func__); 430 dev_err(&pdev->dev, "%s: failed initialization\n", __func__);
@@ -433,6 +435,7 @@ static int exynos_cpufreq_remove(struct platform_device *pdev)
433{ 435{
434 cpufreq_unregister_driver(&exynos_driver); 436 cpufreq_unregister_driver(&exynos_driver);
435 dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table); 437 dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
438 of_free_opp_table(dvfs_info->dev);
436 return 0; 439 return 0;
437} 440}
438 441
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index c2d30765bf3d..5da1d131f770 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -31,6 +31,7 @@ static struct clk *step_clk;
31static struct clk *pll2_pfd2_396m_clk; 31static struct clk *pll2_pfd2_396m_clk;
32 32
33static struct device *cpu_dev; 33static struct device *cpu_dev;
34static bool free_opp;
34static struct cpufreq_frequency_table *freq_table; 35static struct cpufreq_frequency_table *freq_table;
35static unsigned int transition_latency; 36static unsigned int transition_latency;
36 37
@@ -207,11 +208,14 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
207 goto put_reg; 208 goto put_reg;
208 } 209 }
209 210
211 /* Because we have added the OPPs here, we must free them */
212 free_opp = true;
213
210 num = dev_pm_opp_get_opp_count(cpu_dev); 214 num = dev_pm_opp_get_opp_count(cpu_dev);
211 if (num < 0) { 215 if (num < 0) {
212 ret = num; 216 ret = num;
213 dev_err(cpu_dev, "no OPP table is found: %d\n", ret); 217 dev_err(cpu_dev, "no OPP table is found: %d\n", ret);
214 goto put_reg; 218 goto out_free_opp;
215 } 219 }
216 } 220 }
217 221
@@ -306,6 +310,9 @@ soc_opp_out:
306 310
307free_freq_table: 311free_freq_table:
308 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 312 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
313out_free_opp:
314 if (free_opp)
315 of_free_opp_table(cpu_dev);
309put_reg: 316put_reg:
310 if (!IS_ERR(arm_reg)) 317 if (!IS_ERR(arm_reg))
311 regulator_put(arm_reg); 318 regulator_put(arm_reg);
@@ -332,6 +339,8 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
332{ 339{
333 cpufreq_unregister_driver(&imx6q_cpufreq_driver); 340 cpufreq_unregister_driver(&imx6q_cpufreq_driver);
334 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 341 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
342 if (free_opp)
343 of_free_opp_table(cpu_dev);
335 regulator_put(arm_reg); 344 regulator_put(arm_reg);
336 if (!IS_ERR(pu_reg)) 345 if (!IS_ERR(pu_reg))
337 regulator_put(pu_reg); 346 regulator_put(pu_reg);
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 27bb6d3877ed..1405b393c93d 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -137,6 +137,7 @@ struct cpu_defaults {
137 137
138static struct pstate_adjust_policy pid_params; 138static struct pstate_adjust_policy pid_params;
139static struct pstate_funcs pstate_funcs; 139static struct pstate_funcs pstate_funcs;
140static int hwp_active;
140 141
141struct perf_limits { 142struct perf_limits {
142 int no_turbo; 143 int no_turbo;
@@ -244,6 +245,34 @@ static inline void update_turbo_state(void)
244 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); 245 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate);
245} 246}
246 247
248#define PCT_TO_HWP(x) (x * 255 / 100)
249static void intel_pstate_hwp_set(void)
250{
251 int min, max, cpu;
252 u64 value, freq;
253
254 get_online_cpus();
255
256 for_each_online_cpu(cpu) {
257 rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value);
258 min = PCT_TO_HWP(limits.min_perf_pct);
259 value &= ~HWP_MIN_PERF(~0L);
260 value |= HWP_MIN_PERF(min);
261
262 max = PCT_TO_HWP(limits.max_perf_pct);
263 if (limits.no_turbo) {
264 rdmsrl( MSR_HWP_CAPABILITIES, freq);
265 max = HWP_GUARANTEED_PERF(freq);
266 }
267
268 value &= ~HWP_MAX_PERF(~0L);
269 value |= HWP_MAX_PERF(max);
270 wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
271 }
272
273 put_online_cpus();
274}
275
247/************************** debugfs begin ************************/ 276/************************** debugfs begin ************************/
248static int pid_param_set(void *data, u64 val) 277static int pid_param_set(void *data, u64 val)
249{ 278{
@@ -279,6 +308,8 @@ static void __init intel_pstate_debug_expose_params(void)
279 struct dentry *debugfs_parent; 308 struct dentry *debugfs_parent;
280 int i = 0; 309 int i = 0;
281 310
311 if (hwp_active)
312 return;
282 debugfs_parent = debugfs_create_dir("pstate_snb", NULL); 313 debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
283 if (IS_ERR_OR_NULL(debugfs_parent)) 314 if (IS_ERR_OR_NULL(debugfs_parent))
284 return; 315 return;
@@ -329,8 +360,12 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
329 pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); 360 pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
330 return -EPERM; 361 return -EPERM;
331 } 362 }
363
332 limits.no_turbo = clamp_t(int, input, 0, 1); 364 limits.no_turbo = clamp_t(int, input, 0, 1);
333 365
366 if (hwp_active)
367 intel_pstate_hwp_set();
368
334 return count; 369 return count;
335} 370}
336 371
@@ -348,6 +383,8 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
348 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 383 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
349 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 384 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
350 385
386 if (hwp_active)
387 intel_pstate_hwp_set();
351 return count; 388 return count;
352} 389}
353 390
@@ -363,6 +400,8 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
363 limits.min_perf_pct = clamp_t(int, input, 0 , 100); 400 limits.min_perf_pct = clamp_t(int, input, 0 , 100);
364 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 401 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
365 402
403 if (hwp_active)
404 intel_pstate_hwp_set();
366 return count; 405 return count;
367} 406}
368 407
@@ -395,8 +434,16 @@ static void __init intel_pstate_sysfs_expose_params(void)
395 rc = sysfs_create_group(intel_pstate_kobject, &intel_pstate_attr_group); 434 rc = sysfs_create_group(intel_pstate_kobject, &intel_pstate_attr_group);
396 BUG_ON(rc); 435 BUG_ON(rc);
397} 436}
398
399/************************** sysfs end ************************/ 437/************************** sysfs end ************************/
438
439static void intel_pstate_hwp_enable(void)
440{
441 hwp_active++;
442 pr_info("intel_pstate HWP enabled\n");
443
444 wrmsrl( MSR_PM_ENABLE, 0x1);
445}
446
400static int byt_get_min_pstate(void) 447static int byt_get_min_pstate(void)
401{ 448{
402 u64 value; 449 u64 value;
@@ -648,6 +695,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
648 cpu->prev_mperf = mperf; 695 cpu->prev_mperf = mperf;
649} 696}
650 697
698static inline void intel_hwp_set_sample_time(struct cpudata *cpu)
699{
700 int delay;
701
702 delay = msecs_to_jiffies(50);
703 mod_timer_pinned(&cpu->timer, jiffies + delay);
704}
705
651static inline void intel_pstate_set_sample_time(struct cpudata *cpu) 706static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
652{ 707{
653 int delay; 708 int delay;
@@ -694,6 +749,14 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
694 intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl); 749 intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl);
695} 750}
696 751
752static void intel_hwp_timer_func(unsigned long __data)
753{
754 struct cpudata *cpu = (struct cpudata *) __data;
755
756 intel_pstate_sample(cpu);
757 intel_hwp_set_sample_time(cpu);
758}
759
697static void intel_pstate_timer_func(unsigned long __data) 760static void intel_pstate_timer_func(unsigned long __data)
698{ 761{
699 struct cpudata *cpu = (struct cpudata *) __data; 762 struct cpudata *cpu = (struct cpudata *) __data;
@@ -730,6 +793,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
730 ICPU(0x3f, core_params), 793 ICPU(0x3f, core_params),
731 ICPU(0x45, core_params), 794 ICPU(0x45, core_params),
732 ICPU(0x46, core_params), 795 ICPU(0x46, core_params),
796 ICPU(0x47, core_params),
733 ICPU(0x4c, byt_params), 797 ICPU(0x4c, byt_params),
734 ICPU(0x4f, core_params), 798 ICPU(0x4f, core_params),
735 ICPU(0x56, core_params), 799 ICPU(0x56, core_params),
@@ -737,6 +801,11 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
737}; 801};
738MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); 802MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);
739 803
804static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] = {
805 ICPU(0x56, core_params),
806 {}
807};
808
740static int intel_pstate_init_cpu(unsigned int cpunum) 809static int intel_pstate_init_cpu(unsigned int cpunum)
741{ 810{
742 struct cpudata *cpu; 811 struct cpudata *cpu;
@@ -753,9 +822,14 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
753 intel_pstate_get_cpu_pstates(cpu); 822 intel_pstate_get_cpu_pstates(cpu);
754 823
755 init_timer_deferrable(&cpu->timer); 824 init_timer_deferrable(&cpu->timer);
756 cpu->timer.function = intel_pstate_timer_func;
757 cpu->timer.data = (unsigned long)cpu; 825 cpu->timer.data = (unsigned long)cpu;
758 cpu->timer.expires = jiffies + HZ/100; 826 cpu->timer.expires = jiffies + HZ/100;
827
828 if (!hwp_active)
829 cpu->timer.function = intel_pstate_timer_func;
830 else
831 cpu->timer.function = intel_hwp_timer_func;
832
759 intel_pstate_busy_pid_reset(cpu); 833 intel_pstate_busy_pid_reset(cpu);
760 intel_pstate_sample(cpu); 834 intel_pstate_sample(cpu);
761 835
@@ -792,6 +866,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
792 limits.no_turbo = 0; 866 limits.no_turbo = 0;
793 return 0; 867 return 0;
794 } 868 }
869
795 limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; 870 limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
796 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); 871 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100);
797 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 872 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
@@ -801,6 +876,9 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
801 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 876 limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
802 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 877 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
803 878
879 if (hwp_active)
880 intel_pstate_hwp_set();
881
804 return 0; 882 return 0;
805} 883}
806 884
@@ -823,6 +901,9 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
823 pr_info("intel_pstate CPU %d exiting\n", cpu_num); 901 pr_info("intel_pstate CPU %d exiting\n", cpu_num);
824 902
825 del_timer_sync(&all_cpu_data[cpu_num]->timer); 903 del_timer_sync(&all_cpu_data[cpu_num]->timer);
904 if (hwp_active)
905 return;
906
826 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); 907 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
827} 908}
828 909
@@ -866,6 +947,7 @@ static struct cpufreq_driver intel_pstate_driver = {
866}; 947};
867 948
868static int __initdata no_load; 949static int __initdata no_load;
950static int __initdata no_hwp;
869 951
870static int intel_pstate_msrs_not_valid(void) 952static int intel_pstate_msrs_not_valid(void)
871{ 953{
@@ -943,15 +1025,46 @@ static bool intel_pstate_no_acpi_pss(void)
943 return true; 1025 return true;
944} 1026}
945 1027
1028static bool intel_pstate_has_acpi_ppc(void)
1029{
1030 int i;
1031
1032 for_each_possible_cpu(i) {
1033 struct acpi_processor *pr = per_cpu(processors, i);
1034
1035 if (!pr)
1036 continue;
1037 if (acpi_has_method(pr->handle, "_PPC"))
1038 return true;
1039 }
1040 return false;
1041}
1042
1043enum {
1044 PSS,
1045 PPC,
1046};
1047
946struct hw_vendor_info { 1048struct hw_vendor_info {
947 u16 valid; 1049 u16 valid;
948 char oem_id[ACPI_OEM_ID_SIZE]; 1050 char oem_id[ACPI_OEM_ID_SIZE];
949 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; 1051 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE];
1052 int oem_pwr_table;
950}; 1053};
951 1054
952/* Hardware vendor-specific info that has its own power management modes */ 1055/* Hardware vendor-specific info that has its own power management modes */
953static struct hw_vendor_info vendor_info[] = { 1056static struct hw_vendor_info vendor_info[] = {
954 {1, "HP ", "ProLiant"}, 1057 {1, "HP ", "ProLiant", PSS},
1058 {1, "ORACLE", "X4-2 ", PPC},
1059 {1, "ORACLE", "X4-2L ", PPC},
1060 {1, "ORACLE", "X4-2B ", PPC},
1061 {1, "ORACLE", "X3-2 ", PPC},
1062 {1, "ORACLE", "X3-2L ", PPC},
1063 {1, "ORACLE", "X3-2B ", PPC},
1064 {1, "ORACLE", "X4470M2 ", PPC},
1065 {1, "ORACLE", "X4270M3 ", PPC},
1066 {1, "ORACLE", "X4270M2 ", PPC},
1067 {1, "ORACLE", "X4170M2 ", PPC},
955 {0, "", ""}, 1068 {0, "", ""},
956}; 1069};
957 1070
@@ -959,6 +1072,15 @@ static bool intel_pstate_platform_pwr_mgmt_exists(void)
959{ 1072{
960 struct acpi_table_header hdr; 1073 struct acpi_table_header hdr;
961 struct hw_vendor_info *v_info; 1074 struct hw_vendor_info *v_info;
1075 const struct x86_cpu_id *id;
1076 u64 misc_pwr;
1077
1078 id = x86_match_cpu(intel_pstate_cpu_oob_ids);
1079 if (id) {
1080 rdmsrl(MSR_MISC_PWR_MGMT, misc_pwr);
1081 if ( misc_pwr & (1 << 8))
1082 return true;
1083 }
962 1084
963 if (acpi_disabled || 1085 if (acpi_disabled ||
964 ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) 1086 ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr)))
@@ -966,15 +1088,21 @@ static bool intel_pstate_platform_pwr_mgmt_exists(void)
966 1088
967 for (v_info = vendor_info; v_info->valid; v_info++) { 1089 for (v_info = vendor_info; v_info->valid; v_info++) {
968 if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) && 1090 if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) &&
969 !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && 1091 !strncmp(hdr.oem_table_id, v_info->oem_table_id,
970 intel_pstate_no_acpi_pss()) 1092 ACPI_OEM_TABLE_ID_SIZE))
971 return true; 1093 switch (v_info->oem_pwr_table) {
1094 case PSS:
1095 return intel_pstate_no_acpi_pss();
1096 case PPC:
1097 return intel_pstate_has_acpi_ppc();
1098 }
972 } 1099 }
973 1100
974 return false; 1101 return false;
975} 1102}
976#else /* CONFIG_ACPI not enabled */ 1103#else /* CONFIG_ACPI not enabled */
977static inline bool intel_pstate_platform_pwr_mgmt_exists(void) { return false; } 1104static inline bool intel_pstate_platform_pwr_mgmt_exists(void) { return false; }
1105static inline bool intel_pstate_has_acpi_ppc(void) { return false; }
978#endif /* CONFIG_ACPI */ 1106#endif /* CONFIG_ACPI */
979 1107
980static int __init intel_pstate_init(void) 1108static int __init intel_pstate_init(void)
@@ -982,6 +1110,7 @@ static int __init intel_pstate_init(void)
982 int cpu, rc = 0; 1110 int cpu, rc = 0;
983 const struct x86_cpu_id *id; 1111 const struct x86_cpu_id *id;
984 struct cpu_defaults *cpu_info; 1112 struct cpu_defaults *cpu_info;
1113 struct cpuinfo_x86 *c = &boot_cpu_data;
985 1114
986 if (no_load) 1115 if (no_load)
987 return -ENODEV; 1116 return -ENODEV;
@@ -1011,6 +1140,9 @@ static int __init intel_pstate_init(void)
1011 if (!all_cpu_data) 1140 if (!all_cpu_data)
1012 return -ENOMEM; 1141 return -ENOMEM;
1013 1142
1143 if (cpu_has(c,X86_FEATURE_HWP) && !no_hwp)
1144 intel_pstate_hwp_enable();
1145
1014 rc = cpufreq_register_driver(&intel_pstate_driver); 1146 rc = cpufreq_register_driver(&intel_pstate_driver);
1015 if (rc) 1147 if (rc)
1016 goto out; 1148 goto out;
@@ -1041,6 +1173,8 @@ static int __init intel_pstate_setup(char *str)
1041 1173
1042 if (!strcmp(str, "disable")) 1174 if (!strcmp(str, "disable"))
1043 no_load = 1; 1175 no_load = 1;
1176 if (!strcmp(str, "no_hwp"))
1177 no_hwp = 1;
1044 return 0; 1178 return 0;
1045} 1179}
1046early_param("intel_pstate", intel_pstate_setup); 1180early_param("intel_pstate", intel_pstate_setup);
diff --git a/drivers/cpufreq/ls1x-cpufreq.c b/drivers/cpufreq/ls1x-cpufreq.c
new file mode 100644
index 000000000000..25fbd6a1374f
--- /dev/null
+++ b/drivers/cpufreq/ls1x-cpufreq.c
@@ -0,0 +1,223 @@
1/*
2 * CPU Frequency Scaling for Loongson 1 SoC
3 *
4 * Copyright (C) 2014 Zhang, Keguang <keguang.zhang@gmail.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <linux/clk.h>
12#include <linux/clk-provider.h>
13#include <linux/cpu.h>
14#include <linux/cpufreq.h>
15#include <linux/delay.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18#include <linux/slab.h>
19
20#include <asm/mach-loongson1/cpufreq.h>
21#include <asm/mach-loongson1/loongson1.h>
22
23static struct {
24 struct device *dev;
25 struct clk *clk; /* CPU clk */
26 struct clk *mux_clk; /* MUX of CPU clk */
27 struct clk *pll_clk; /* PLL clk */
28 struct clk *osc_clk; /* OSC clk */
29 unsigned int max_freq;
30 unsigned int min_freq;
31} ls1x_cpufreq;
32
33static int ls1x_cpufreq_notifier(struct notifier_block *nb,
34 unsigned long val, void *data)
35{
36 if (val == CPUFREQ_POSTCHANGE)
37 current_cpu_data.udelay_val = loops_per_jiffy;
38
39 return NOTIFY_OK;
40}
41
42static struct notifier_block ls1x_cpufreq_notifier_block = {
43 .notifier_call = ls1x_cpufreq_notifier
44};
45
46static int ls1x_cpufreq_target(struct cpufreq_policy *policy,
47 unsigned int index)
48{
49 unsigned int old_freq, new_freq;
50
51 old_freq = policy->cur;
52 new_freq = policy->freq_table[index].frequency;
53
54 /*
55 * The procedure of reconfiguring CPU clk is as below.
56 *
57 * - Reparent CPU clk to OSC clk
58 * - Reset CPU clock (very important)
59 * - Reconfigure CPU DIV
60 * - Reparent CPU clk back to CPU DIV clk
61 */
62
63 dev_dbg(ls1x_cpufreq.dev, "%u KHz --> %u KHz\n", old_freq, new_freq);
64 clk_set_parent(policy->clk, ls1x_cpufreq.osc_clk);
65 __raw_writel(__raw_readl(LS1X_CLK_PLL_DIV) | RST_CPU_EN | RST_CPU,
66 LS1X_CLK_PLL_DIV);
67 __raw_writel(__raw_readl(LS1X_CLK_PLL_DIV) & ~(RST_CPU_EN | RST_CPU),
68 LS1X_CLK_PLL_DIV);
69 clk_set_rate(ls1x_cpufreq.mux_clk, new_freq * 1000);
70 clk_set_parent(policy->clk, ls1x_cpufreq.mux_clk);
71
72 return 0;
73}
74
75static int ls1x_cpufreq_init(struct cpufreq_policy *policy)
76{
77 struct cpufreq_frequency_table *freq_tbl;
78 unsigned int pll_freq, freq;
79 int steps, i, ret;
80
81 pll_freq = clk_get_rate(ls1x_cpufreq.pll_clk) / 1000;
82
83 steps = 1 << DIV_CPU_WIDTH;
84 freq_tbl = kzalloc(sizeof(*freq_tbl) * steps, GFP_KERNEL);
85 if (!freq_tbl) {
86 dev_err(ls1x_cpufreq.dev,
87 "failed to alloc cpufreq_frequency_table\n");
88 ret = -ENOMEM;
89 goto out;
90 }
91
92 for (i = 0; i < (steps - 1); i++) {
93 freq = pll_freq / (i + 1);
94 if ((freq < ls1x_cpufreq.min_freq) ||
95 (freq > ls1x_cpufreq.max_freq))
96 freq_tbl[i].frequency = CPUFREQ_ENTRY_INVALID;
97 else
98 freq_tbl[i].frequency = freq;
99 dev_dbg(ls1x_cpufreq.dev,
100 "cpufreq table: index %d: frequency %d\n", i,
101 freq_tbl[i].frequency);
102 }
103 freq_tbl[i].frequency = CPUFREQ_TABLE_END;
104
105 policy->clk = ls1x_cpufreq.clk;
106 ret = cpufreq_generic_init(policy, freq_tbl, 0);
107 if (ret)
108 kfree(freq_tbl);
109out:
110 return ret;
111}
112
113static int ls1x_cpufreq_exit(struct cpufreq_policy *policy)
114{
115 kfree(policy->freq_table);
116 return 0;
117}
118
119static struct cpufreq_driver ls1x_cpufreq_driver = {
120 .name = "cpufreq-ls1x",
121 .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
122 .verify = cpufreq_generic_frequency_table_verify,
123 .target_index = ls1x_cpufreq_target,
124 .get = cpufreq_generic_get,
125 .init = ls1x_cpufreq_init,
126 .exit = ls1x_cpufreq_exit,
127 .attr = cpufreq_generic_attr,
128};
129
130static int ls1x_cpufreq_remove(struct platform_device *pdev)
131{
132 cpufreq_unregister_notifier(&ls1x_cpufreq_notifier_block,
133 CPUFREQ_TRANSITION_NOTIFIER);
134 cpufreq_unregister_driver(&ls1x_cpufreq_driver);
135
136 return 0;
137}
138
139static int ls1x_cpufreq_probe(struct platform_device *pdev)
140{
141 struct plat_ls1x_cpufreq *pdata = pdev->dev.platform_data;
142 struct clk *clk;
143 int ret;
144
145 if (!pdata || !pdata->clk_name || !pdata->osc_clk_name)
146 return -EINVAL;
147
148 ls1x_cpufreq.dev = &pdev->dev;
149
150 clk = devm_clk_get(&pdev->dev, pdata->clk_name);
151 if (IS_ERR(clk)) {
152 dev_err(ls1x_cpufreq.dev, "unable to get %s clock\n",
153 pdata->clk_name);
154 ret = PTR_ERR(clk);
155 goto out;
156 }
157 ls1x_cpufreq.clk = clk;
158
159 clk = clk_get_parent(clk);
160 if (IS_ERR(clk)) {
161 dev_err(ls1x_cpufreq.dev, "unable to get parent of %s clock\n",
162 __clk_get_name(ls1x_cpufreq.clk));
163 ret = PTR_ERR(clk);
164 goto out;
165 }
166 ls1x_cpufreq.mux_clk = clk;
167
168 clk = clk_get_parent(clk);
169 if (IS_ERR(clk)) {
170 dev_err(ls1x_cpufreq.dev, "unable to get parent of %s clock\n",
171 __clk_get_name(ls1x_cpufreq.mux_clk));
172 ret = PTR_ERR(clk);
173 goto out;
174 }
175 ls1x_cpufreq.pll_clk = clk;
176
177 clk = devm_clk_get(&pdev->dev, pdata->osc_clk_name);
178 if (IS_ERR(clk)) {
179 dev_err(ls1x_cpufreq.dev, "unable to get %s clock\n",
180 pdata->osc_clk_name);
181 ret = PTR_ERR(clk);
182 goto out;
183 }
184 ls1x_cpufreq.osc_clk = clk;
185
186 ls1x_cpufreq.max_freq = pdata->max_freq;
187 ls1x_cpufreq.min_freq = pdata->min_freq;
188
189 ret = cpufreq_register_driver(&ls1x_cpufreq_driver);
190 if (ret) {
191 dev_err(ls1x_cpufreq.dev,
192 "failed to register cpufreq driver: %d\n", ret);
193 goto out;
194 }
195
196 ret = cpufreq_register_notifier(&ls1x_cpufreq_notifier_block,
197 CPUFREQ_TRANSITION_NOTIFIER);
198
199 if (!ret)
200 goto out;
201
202 dev_err(ls1x_cpufreq.dev, "failed to register cpufreq notifier: %d\n",
203 ret);
204
205 cpufreq_unregister_driver(&ls1x_cpufreq_driver);
206out:
207 return ret;
208}
209
210static struct platform_driver ls1x_cpufreq_platdrv = {
211 .driver = {
212 .name = "ls1x-cpufreq",
213 .owner = THIS_MODULE,
214 },
215 .probe = ls1x_cpufreq_probe,
216 .remove = ls1x_cpufreq_remove,
217};
218
219module_platform_driver(ls1x_cpufreq_platdrv);
220
221MODULE_AUTHOR("Kelvin Cheung <keguang.zhang@gmail.com>");
222MODULE_DESCRIPTION("Loongson 1 CPUFreq driver");
223MODULE_LICENSE("GPL");
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index 4d2c8e861089..2a0d58959acf 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -603,6 +603,13 @@ static void __exit pcc_cpufreq_exit(void)
603 free_percpu(pcc_cpu_info); 603 free_percpu(pcc_cpu_info);
604} 604}
605 605
606static const struct acpi_device_id processor_device_ids[] = {
607 {ACPI_PROCESSOR_OBJECT_HID, },
608 {ACPI_PROCESSOR_DEVICE_HID, },
609 {},
610};
611MODULE_DEVICE_TABLE(acpi, processor_device_ids);
612
606MODULE_AUTHOR("Matthew Garrett, Naga Chumbalkar"); 613MODULE_AUTHOR("Matthew Garrett, Naga Chumbalkar");
607MODULE_VERSION(PCC_VERSION); 614MODULE_VERSION(PCC_VERSION);
608MODULE_DESCRIPTION("Processor Clocking Control interface driver"); 615MODULE_DESCRIPTION("Processor Clocking Control interface driver");
diff --git a/drivers/cpuidle/cpuidle-arm64.c b/drivers/cpuidle/cpuidle-arm64.c
index 50997ea942fc..80704b931ba4 100644
--- a/drivers/cpuidle/cpuidle-arm64.c
+++ b/drivers/cpuidle/cpuidle-arm64.c
@@ -73,7 +73,6 @@ static struct cpuidle_driver arm64_idle_driver = {
73 .exit_latency = 1, 73 .exit_latency = 1,
74 .target_residency = 1, 74 .target_residency = 1,
75 .power_usage = UINT_MAX, 75 .power_usage = UINT_MAX,
76 .flags = CPUIDLE_FLAG_TIME_VALID,
77 .name = "WFI", 76 .name = "WFI",
78 .desc = "ARM64 WFI", 77 .desc = "ARM64 WFI",
79 } 78 }
@@ -104,11 +103,8 @@ static int __init arm64_idle_init(void)
104 * reason to initialize the idle driver if only wfi is supported. 103 * reason to initialize the idle driver if only wfi is supported.
105 */ 104 */
106 ret = dt_init_idle_driver(drv, arm64_idle_state_match, 1); 105 ret = dt_init_idle_driver(drv, arm64_idle_state_match, 1);
107 if (ret <= 0) { 106 if (ret <= 0)
108 if (ret)
109 pr_err("failed to initialize idle states\n");
110 return ret ? : -ENODEV; 107 return ret ? : -ENODEV;
111 }
112 108
113 /* 109 /*
114 * Call arch CPU operations in order to initialize 110 * Call arch CPU operations in order to initialize
@@ -122,12 +118,6 @@ static int __init arm64_idle_init(void)
122 } 118 }
123 } 119 }
124 120
125 ret = cpuidle_register(drv, NULL); 121 return cpuidle_register(drv, NULL);
126 if (ret) {
127 pr_err("failed to register cpuidle driver\n");
128 return ret;
129 }
130
131 return 0;
132} 122}
133device_initcall(arm64_idle_init); 123device_initcall(arm64_idle_init);
diff --git a/drivers/cpuidle/cpuidle-at91.c b/drivers/cpuidle/cpuidle-at91.c
index a0774370c6bc..1964ff07117c 100644
--- a/drivers/cpuidle/cpuidle-at91.c
+++ b/drivers/cpuidle/cpuidle-at91.c
@@ -43,7 +43,6 @@ static struct cpuidle_driver at91_idle_driver = {
43 .enter = at91_enter_idle, 43 .enter = at91_enter_idle,
44 .exit_latency = 10, 44 .exit_latency = 10,
45 .target_residency = 10000, 45 .target_residency = 10000,
46 .flags = CPUIDLE_FLAG_TIME_VALID,
47 .name = "RAM_SR", 46 .name = "RAM_SR",
48 .desc = "WFI and DDR Self Refresh", 47 .desc = "WFI and DDR Self Refresh",
49 }, 48 },
diff --git a/drivers/cpuidle/cpuidle-big_little.c b/drivers/cpuidle/cpuidle-big_little.c
index fbc00a1d3c48..e3e225fe6b45 100644
--- a/drivers/cpuidle/cpuidle-big_little.c
+++ b/drivers/cpuidle/cpuidle-big_little.c
@@ -67,8 +67,7 @@ static struct cpuidle_driver bl_idle_little_driver = {
67 .enter = bl_enter_powerdown, 67 .enter = bl_enter_powerdown,
68 .exit_latency = 700, 68 .exit_latency = 700,
69 .target_residency = 2500, 69 .target_residency = 2500,
70 .flags = CPUIDLE_FLAG_TIME_VALID | 70 .flags = CPUIDLE_FLAG_TIMER_STOP,
71 CPUIDLE_FLAG_TIMER_STOP,
72 .name = "C1", 71 .name = "C1",
73 .desc = "ARM little-cluster power down", 72 .desc = "ARM little-cluster power down",
74 }, 73 },
@@ -89,8 +88,7 @@ static struct cpuidle_driver bl_idle_big_driver = {
89 .enter = bl_enter_powerdown, 88 .enter = bl_enter_powerdown,
90 .exit_latency = 500, 89 .exit_latency = 500,
91 .target_residency = 2000, 90 .target_residency = 2000,
92 .flags = CPUIDLE_FLAG_TIME_VALID | 91 .flags = CPUIDLE_FLAG_TIMER_STOP,
93 CPUIDLE_FLAG_TIMER_STOP,
94 .name = "C1", 92 .name = "C1",
95 .desc = "ARM big-cluster power down", 93 .desc = "ARM big-cluster power down",
96 }, 94 },
diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index 6e51114057d0..6541b0bfdfaa 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -55,7 +55,6 @@ static struct cpuidle_driver calxeda_idle_driver = {
55 { 55 {
56 .name = "PG", 56 .name = "PG",
57 .desc = "Power Gate", 57 .desc = "Power Gate",
58 .flags = CPUIDLE_FLAG_TIME_VALID,
59 .exit_latency = 30, 58 .exit_latency = 30,
60 .power_usage = 50, 59 .power_usage = 50,
61 .target_residency = 200, 60 .target_residency = 200,
diff --git a/drivers/cpuidle/cpuidle-cps.c b/drivers/cpuidle/cpuidle-cps.c
index fc7b62720deb..1adb6980b707 100644
--- a/drivers/cpuidle/cpuidle-cps.c
+++ b/drivers/cpuidle/cpuidle-cps.c
@@ -79,7 +79,6 @@ static struct cpuidle_driver cps_driver = {
79 .enter = cps_nc_enter, 79 .enter = cps_nc_enter,
80 .exit_latency = 200, 80 .exit_latency = 200,
81 .target_residency = 450, 81 .target_residency = 450,
82 .flags = CPUIDLE_FLAG_TIME_VALID,
83 .name = "nc-wait", 82 .name = "nc-wait",
84 .desc = "non-coherent MIPS wait", 83 .desc = "non-coherent MIPS wait",
85 }, 84 },
@@ -87,8 +86,7 @@ static struct cpuidle_driver cps_driver = {
87 .enter = cps_nc_enter, 86 .enter = cps_nc_enter,
88 .exit_latency = 300, 87 .exit_latency = 300,
89 .target_residency = 700, 88 .target_residency = 700,
90 .flags = CPUIDLE_FLAG_TIME_VALID | 89 .flags = CPUIDLE_FLAG_TIMER_STOP,
91 CPUIDLE_FLAG_TIMER_STOP,
92 .name = "clock-gated", 90 .name = "clock-gated",
93 .desc = "core clock gated", 91 .desc = "core clock gated",
94 }, 92 },
@@ -96,8 +94,7 @@ static struct cpuidle_driver cps_driver = {
96 .enter = cps_nc_enter, 94 .enter = cps_nc_enter,
97 .exit_latency = 600, 95 .exit_latency = 600,
98 .target_residency = 1000, 96 .target_residency = 1000,
99 .flags = CPUIDLE_FLAG_TIME_VALID | 97 .flags = CPUIDLE_FLAG_TIMER_STOP,
100 CPUIDLE_FLAG_TIMER_STOP,
101 .name = "power-gated", 98 .name = "power-gated",
102 .desc = "core power gated", 99 .desc = "core power gated",
103 }, 100 },
diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c
index ba9b34b579f3..64d12a855ec6 100644
--- a/drivers/cpuidle/cpuidle-exynos.c
+++ b/drivers/cpuidle/cpuidle-exynos.c
@@ -47,7 +47,6 @@ static struct cpuidle_driver exynos_idle_driver = {
47 .enter = exynos_enter_lowpower, 47 .enter = exynos_enter_lowpower,
48 .exit_latency = 300, 48 .exit_latency = 300,
49 .target_residency = 100000, 49 .target_residency = 100000,
50 .flags = CPUIDLE_FLAG_TIME_VALID,
51 .name = "C1", 50 .name = "C1",
52 .desc = "ARM power down", 51 .desc = "ARM power down",
53 }, 52 },
diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 41ba843251b8..d88f8d7c2143 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -47,7 +47,6 @@ static struct cpuidle_driver kirkwood_idle_driver = {
47 .enter = kirkwood_enter_idle, 47 .enter = kirkwood_enter_idle,
48 .exit_latency = 10, 48 .exit_latency = 10,
49 .target_residency = 100000, 49 .target_residency = 100000,
50 .flags = CPUIDLE_FLAG_TIME_VALID,
51 .name = "DDR SR", 50 .name = "DDR SR",
52 .desc = "WFI and DDR Self Refresh", 51 .desc = "WFI and DDR Self Refresh",
53 }, 52 },
diff --git a/drivers/cpuidle/cpuidle-mvebu-v7.c b/drivers/cpuidle/cpuidle-mvebu-v7.c
index 45371bb16214..dd4c176df2a3 100644
--- a/drivers/cpuidle/cpuidle-mvebu-v7.c
+++ b/drivers/cpuidle/cpuidle-mvebu-v7.c
@@ -53,7 +53,6 @@ static struct cpuidle_driver armadaxp_idle_driver = {
53 .exit_latency = 10, 53 .exit_latency = 10,
54 .power_usage = 50, 54 .power_usage = 50,
55 .target_residency = 100, 55 .target_residency = 100,
56 .flags = CPUIDLE_FLAG_TIME_VALID,
57 .name = "MV CPU IDLE", 56 .name = "MV CPU IDLE",
58 .desc = "CPU power down", 57 .desc = "CPU power down",
59 }, 58 },
@@ -62,8 +61,7 @@ static struct cpuidle_driver armadaxp_idle_driver = {
62 .exit_latency = 100, 61 .exit_latency = 100,
63 .power_usage = 5, 62 .power_usage = 5,
64 .target_residency = 1000, 63 .target_residency = 1000,
65 .flags = CPUIDLE_FLAG_TIME_VALID | 64 .flags = MVEBU_V7_FLAG_DEEP_IDLE,
66 MVEBU_V7_FLAG_DEEP_IDLE,
67 .name = "MV CPU DEEP IDLE", 65 .name = "MV CPU DEEP IDLE",
68 .desc = "CPU and L2 Fabric power down", 66 .desc = "CPU and L2 Fabric power down",
69 }, 67 },
@@ -78,8 +76,7 @@ static struct cpuidle_driver armada370_idle_driver = {
78 .exit_latency = 100, 76 .exit_latency = 100,
79 .power_usage = 5, 77 .power_usage = 5,
80 .target_residency = 1000, 78 .target_residency = 1000,
81 .flags = (CPUIDLE_FLAG_TIME_VALID | 79 .flags = MVEBU_V7_FLAG_DEEP_IDLE,
82 MVEBU_V7_FLAG_DEEP_IDLE),
83 .name = "Deep Idle", 80 .name = "Deep Idle",
84 .desc = "CPU and L2 Fabric power down", 81 .desc = "CPU and L2 Fabric power down",
85 }, 82 },
@@ -94,7 +91,6 @@ static struct cpuidle_driver armada38x_idle_driver = {
94 .exit_latency = 10, 91 .exit_latency = 10,
95 .power_usage = 5, 92 .power_usage = 5,
96 .target_residency = 100, 93 .target_residency = 100,
97 .flags = CPUIDLE_FLAG_TIME_VALID,
98 .name = "Idle", 94 .name = "Idle",
99 .desc = "CPU and SCU power down", 95 .desc = "CPU and SCU power down",
100 }, 96 },
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 7d3a3497dd4c..e9248bb9173a 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -93,7 +93,6 @@ static struct cpuidle_state powernv_states[MAX_POWERNV_IDLE_STATES] = {
93 { /* Snooze */ 93 { /* Snooze */
94 .name = "snooze", 94 .name = "snooze",
95 .desc = "snooze", 95 .desc = "snooze",
96 .flags = CPUIDLE_FLAG_TIME_VALID,
97 .exit_latency = 0, 96 .exit_latency = 0,
98 .target_residency = 0, 97 .target_residency = 0,
99 .enter = &snooze_loop }, 98 .enter = &snooze_loop },
@@ -202,7 +201,7 @@ static int powernv_add_idle_states(void)
202 /* Add NAP state */ 201 /* Add NAP state */
203 strcpy(powernv_states[nr_idle_states].name, "Nap"); 202 strcpy(powernv_states[nr_idle_states].name, "Nap");
204 strcpy(powernv_states[nr_idle_states].desc, "Nap"); 203 strcpy(powernv_states[nr_idle_states].desc, "Nap");
205 powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIME_VALID; 204 powernv_states[nr_idle_states].flags = 0;
206 powernv_states[nr_idle_states].exit_latency = 205 powernv_states[nr_idle_states].exit_latency =
207 ((unsigned int)latency_ns) / 1000; 206 ((unsigned int)latency_ns) / 1000;
208 powernv_states[nr_idle_states].target_residency = 207 powernv_states[nr_idle_states].target_residency =
@@ -215,8 +214,7 @@ static int powernv_add_idle_states(void)
215 /* Add FASTSLEEP state */ 214 /* Add FASTSLEEP state */
216 strcpy(powernv_states[nr_idle_states].name, "FastSleep"); 215 strcpy(powernv_states[nr_idle_states].name, "FastSleep");
217 strcpy(powernv_states[nr_idle_states].desc, "FastSleep"); 216 strcpy(powernv_states[nr_idle_states].desc, "FastSleep");
218 powernv_states[nr_idle_states].flags = 217 powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIMER_STOP;
219 CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TIMER_STOP;
220 powernv_states[nr_idle_states].exit_latency = 218 powernv_states[nr_idle_states].exit_latency =
221 ((unsigned int)latency_ns) / 1000; 219 ((unsigned int)latency_ns) / 1000;
222 powernv_states[nr_idle_states].target_residency = 220 powernv_states[nr_idle_states].target_residency =
diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c
index 6f7b01956885..bb9e2b6f3ecc 100644
--- a/drivers/cpuidle/cpuidle-pseries.c
+++ b/drivers/cpuidle/cpuidle-pseries.c
@@ -142,14 +142,12 @@ static struct cpuidle_state dedicated_states[] = {
142 { /* Snooze */ 142 { /* Snooze */
143 .name = "snooze", 143 .name = "snooze",
144 .desc = "snooze", 144 .desc = "snooze",
145 .flags = CPUIDLE_FLAG_TIME_VALID,
146 .exit_latency = 0, 145 .exit_latency = 0,
147 .target_residency = 0, 146 .target_residency = 0,
148 .enter = &snooze_loop }, 147 .enter = &snooze_loop },
149 { /* CEDE */ 148 { /* CEDE */
150 .name = "CEDE", 149 .name = "CEDE",
151 .desc = "CEDE", 150 .desc = "CEDE",
152 .flags = CPUIDLE_FLAG_TIME_VALID,
153 .exit_latency = 10, 151 .exit_latency = 10,
154 .target_residency = 100, 152 .target_residency = 100,
155 .enter = &dedicated_cede_loop }, 153 .enter = &dedicated_cede_loop },
@@ -162,7 +160,6 @@ static struct cpuidle_state shared_states[] = {
162 { /* Shared Cede */ 160 { /* Shared Cede */
163 .name = "Shared Cede", 161 .name = "Shared Cede",
164 .desc = "Shared Cede", 162 .desc = "Shared Cede",
165 .flags = CPUIDLE_FLAG_TIME_VALID,
166 .exit_latency = 0, 163 .exit_latency = 0,
167 .target_residency = 0, 164 .target_residency = 0,
168 .enter = &shared_cede_loop }, 165 .enter = &shared_cede_loop },
diff --git a/drivers/cpuidle/cpuidle-ux500.c b/drivers/cpuidle/cpuidle-ux500.c
index 5e35804b1a95..292e65a90308 100644
--- a/drivers/cpuidle/cpuidle-ux500.c
+++ b/drivers/cpuidle/cpuidle-ux500.c
@@ -101,8 +101,7 @@ static struct cpuidle_driver ux500_idle_driver = {
101 .enter = ux500_enter_idle, 101 .enter = ux500_enter_idle,
102 .exit_latency = 70, 102 .exit_latency = 70,
103 .target_residency = 260, 103 .target_residency = 260,
104 .flags = CPUIDLE_FLAG_TIME_VALID | 104 .flags = CPUIDLE_FLAG_TIMER_STOP,
105 CPUIDLE_FLAG_TIMER_STOP,
106 .name = "ApIdle", 105 .name = "ApIdle",
107 .desc = "ARM Retention", 106 .desc = "ARM Retention",
108 }, 107 },
diff --git a/drivers/cpuidle/cpuidle-zynq.c b/drivers/cpuidle/cpuidle-zynq.c
index c61b8b2a7c77..022dec86de8e 100644
--- a/drivers/cpuidle/cpuidle-zynq.c
+++ b/drivers/cpuidle/cpuidle-zynq.c
@@ -52,7 +52,6 @@ static struct cpuidle_driver zynq_idle_driver = {
52 .enter = zynq_enter_idle, 52 .enter = zynq_enter_idle,
53 .exit_latency = 10, 53 .exit_latency = 10,
54 .target_residency = 10000, 54 .target_residency = 10000,
55 .flags = CPUIDLE_FLAG_TIME_VALID,
56 .name = "RAM_SR", 55 .name = "RAM_SR",
57 .desc = "WFI and RAM Self Refresh", 56 .desc = "WFI and RAM Self Refresh",
58 }, 57 },
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index e431d11abf8d..2697e87d5b34 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -201,7 +201,6 @@ static void poll_idle_init(struct cpuidle_driver *drv)
201 state->exit_latency = 0; 201 state->exit_latency = 0;
202 state->target_residency = 0; 202 state->target_residency = 0;
203 state->power_usage = -1; 203 state->power_usage = -1;
204 state->flags = CPUIDLE_FLAG_TIME_VALID;
205 state->enter = poll_idle; 204 state->enter = poll_idle;
206 state->disabled = false; 205 state->disabled = false;
207} 206}
diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
index 52f4d11bbf3f..a5c111b67f37 100644
--- a/drivers/cpuidle/dt_idle_states.c
+++ b/drivers/cpuidle/dt_idle_states.c
@@ -27,6 +27,7 @@ static int init_state_node(struct cpuidle_state *idle_state,
27{ 27{
28 int err; 28 int err;
29 const struct of_device_id *match_id; 29 const struct of_device_id *match_id;
30 const char *desc;
30 31
31 match_id = of_match_node(matches, state_node); 32 match_id = of_match_node(matches, state_node);
32 if (!match_id) 33 if (!match_id)
@@ -73,7 +74,11 @@ static int init_state_node(struct cpuidle_state *idle_state,
73 return -EINVAL; 74 return -EINVAL;
74 } 75 }
75 76
76 idle_state->flags = CPUIDLE_FLAG_TIME_VALID; 77 err = of_property_read_string(state_node, "idle-state-name", &desc);
78 if (err)
79 desc = state_node->name;
80
81 idle_state->flags = 0;
77 if (of_property_read_bool(state_node, "local-timer-stop")) 82 if (of_property_read_bool(state_node, "local-timer-stop"))
78 idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP; 83 idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP;
79 /* 84 /*
@@ -82,7 +87,7 @@ static int init_state_node(struct cpuidle_state *idle_state,
82 * and desc become string pointers 87 * and desc become string pointers
83 */ 88 */
84 strncpy(idle_state->name, state_node->name, CPUIDLE_NAME_LEN - 1); 89 strncpy(idle_state->name, state_node->name, CPUIDLE_NAME_LEN - 1);
85 strncpy(idle_state->desc, state_node->name, CPUIDLE_DESC_LEN - 1); 90 strncpy(idle_state->desc, desc, CPUIDLE_DESC_LEN - 1);
86 return 0; 91 return 0;
87} 92}
88 93
@@ -169,6 +174,9 @@ int dt_init_idle_driver(struct cpuidle_driver *drv,
169 if (!state_node) 174 if (!state_node)
170 break; 175 break;
171 176
177 if (!of_device_is_available(state_node))
178 continue;
179
172 if (!idle_state_valid(state_node, i, cpumask)) { 180 if (!idle_state_valid(state_node, i, cpumask)) {
173 pr_warn("%s idle state not valid, bailing out\n", 181 pr_warn("%s idle state not valid, bailing out\n",
174 state_node->full_name); 182 state_node->full_name);
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 06b57c4c4d80..37263d9a1051 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -79,7 +79,7 @@ static int ladder_select_state(struct cpuidle_driver *drv,
79 79
80 last_state = &ldev->states[last_idx]; 80 last_state = &ldev->states[last_idx];
81 81
82 if (drv->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) { 82 if (!(drv->states[last_idx].flags & CPUIDLE_FLAG_TIME_INVALID)) {
83 last_residency = cpuidle_get_last_residency(dev) - \ 83 last_residency = cpuidle_get_last_residency(dev) - \
84 drv->states[last_idx].exit_latency; 84 drv->states[last_idx].exit_latency;
85 } 85 }
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 710a233b9b0d..659d7b0c9ebf 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -405,7 +405,7 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
405 * the measured amount of time is less than the exit latency, 405 * the measured amount of time is less than the exit latency,
406 * assume the state was never reached and the exit latency is 0. 406 * assume the state was never reached and the exit latency is 0.
407 */ 407 */
408 if (unlikely(!(target->flags & CPUIDLE_FLAG_TIME_VALID))) { 408 if (unlikely(target->flags & CPUIDLE_FLAG_TIME_INVALID)) {
409 /* Use timer value as is */ 409 /* Use timer value as is */
410 measured_us = data->next_timer_us; 410 measured_us = data->next_timer_us;
411 411
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 244722170410..380478562b7d 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/pm_runtime.h>
25 26
26#include "../dmaengine.h" 27#include "../dmaengine.h"
27#include "internal.h" 28#include "internal.h"
@@ -1504,6 +1505,9 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1504 dw->regs = chip->regs; 1505 dw->regs = chip->regs;
1505 chip->dw = dw; 1506 chip->dw = dw;
1506 1507
1508 pm_runtime_enable(chip->dev);
1509 pm_runtime_get_sync(chip->dev);
1510
1507 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS); 1511 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS);
1508 autocfg = dw_params >> DW_PARAMS_EN & 0x1; 1512 autocfg = dw_params >> DW_PARAMS_EN & 0x1;
1509 1513
@@ -1667,11 +1671,14 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1667 dev_info(chip->dev, "DesignWare DMA Controller, %d channels\n", 1671 dev_info(chip->dev, "DesignWare DMA Controller, %d channels\n",
1668 nr_channels); 1672 nr_channels);
1669 1673
1674 pm_runtime_put_sync_suspend(chip->dev);
1675
1670 return 0; 1676 return 0;
1671 1677
1672err_dma_register: 1678err_dma_register:
1673 free_irq(chip->irq, dw); 1679 free_irq(chip->irq, dw);
1674err_pdata: 1680err_pdata:
1681 pm_runtime_put_sync_suspend(chip->dev);
1675 return err; 1682 return err;
1676} 1683}
1677EXPORT_SYMBOL_GPL(dw_dma_probe); 1684EXPORT_SYMBOL_GPL(dw_dma_probe);
@@ -1681,6 +1688,8 @@ int dw_dma_remove(struct dw_dma_chip *chip)
1681 struct dw_dma *dw = chip->dw; 1688 struct dw_dma *dw = chip->dw;
1682 struct dw_dma_chan *dwc, *_dwc; 1689 struct dw_dma_chan *dwc, *_dwc;
1683 1690
1691 pm_runtime_get_sync(chip->dev);
1692
1684 dw_dma_off(dw); 1693 dw_dma_off(dw);
1685 dma_async_device_unregister(&dw->dma); 1694 dma_async_device_unregister(&dw->dma);
1686 1695
@@ -1693,6 +1702,8 @@ int dw_dma_remove(struct dw_dma_chip *chip)
1693 channel_clear_bit(dw, CH_EN, dwc->mask); 1702 channel_clear_bit(dw, CH_EN, dwc->mask);
1694 } 1703 }
1695 1704
1705 pm_runtime_put_sync_suspend(chip->dev);
1706 pm_runtime_disable(chip->dev);
1696 return 0; 1707 return 0;
1697} 1708}
1698EXPORT_SYMBOL_GPL(dw_dma_remove); 1709EXPORT_SYMBOL_GPL(dw_dma_remove);
diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
index 5aeada56a442..bda20e6e1007 100644
--- a/drivers/dma/nbpfaxi.c
+++ b/drivers/dma/nbpfaxi.c
@@ -1479,7 +1479,7 @@ static struct platform_device_id nbpf_ids[] = {
1479}; 1479};
1480MODULE_DEVICE_TABLE(platform, nbpf_ids); 1480MODULE_DEVICE_TABLE(platform, nbpf_ids);
1481 1481
1482#ifdef CONFIG_PM_RUNTIME 1482#ifdef CONFIG_PM
1483static int nbpf_runtime_suspend(struct device *dev) 1483static int nbpf_runtime_suspend(struct device *dev)
1484{ 1484{
1485 struct nbpf_device *nbpf = platform_get_drvdata(to_platform_device(dev)); 1485 struct nbpf_device *nbpf = platform_get_drvdata(to_platform_device(dev));
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 5fe59335e247..d9ca3e32d748 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3051,7 +3051,7 @@ static int dma40_runtime_resume(struct device *dev)
3051 3051
3052static const struct dev_pm_ops dma40_pm_ops = { 3052static const struct dev_pm_ops dma40_pm_ops = {
3053 SET_LATE_SYSTEM_SLEEP_PM_OPS(dma40_suspend, dma40_resume) 3053 SET_LATE_SYSTEM_SLEEP_PM_OPS(dma40_suspend, dma40_resume)
3054 SET_PM_RUNTIME_PM_OPS(dma40_runtime_suspend, 3054 SET_RUNTIME_PM_OPS(dma40_runtime_suspend,
3055 dma40_runtime_resume, 3055 dma40_runtime_resume,
3056 NULL) 3056 NULL)
3057}; 3057};
diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 16efa603ff65..1c867d0303db 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1587,7 +1587,7 @@ static int tegra_dma_pm_resume(struct device *dev)
1587#endif 1587#endif
1588 1588
1589static const struct dev_pm_ops tegra_dma_dev_pm_ops = { 1589static const struct dev_pm_ops tegra_dma_dev_pm_ops = {
1590#ifdef CONFIG_PM_RUNTIME 1590#ifdef CONFIG_PM
1591 .runtime_suspend = tegra_dma_runtime_suspend, 1591 .runtime_suspend = tegra_dma_runtime_suspend,
1592 .runtime_resume = tegra_dma_runtime_resume, 1592 .runtime_resume = tegra_dma_runtime_resume,
1593#endif 1593#endif
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index 954b9f6b0ef8..13dbd3dfc33a 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -109,6 +109,38 @@ struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev,
109EXPORT_SYMBOL(__devm_gpiod_get_index); 109EXPORT_SYMBOL(__devm_gpiod_get_index);
110 110
111/** 111/**
112 * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
113 * @dev: GPIO consumer
114 * @child: firmware node (child of @dev)
115 *
116 * GPIO descriptors returned from this function are automatically disposed on
117 * driver detach.
118 */
119struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
120 struct fwnode_handle *child)
121{
122 struct gpio_desc **dr;
123 struct gpio_desc *desc;
124
125 dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),
126 GFP_KERNEL);
127 if (!dr)
128 return ERR_PTR(-ENOMEM);
129
130 desc = fwnode_get_named_gpiod(child, "gpios");
131 if (IS_ERR(desc)) {
132 devres_free(dr);
133 return desc;
134 }
135
136 *dr = desc;
137 devres_add(dev, dr);
138
139 return desc;
140}
141EXPORT_SYMBOL(devm_get_gpiod_from_child);
142
143/**
112 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional() 144 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
113 * @dev: GPIO consumer 145 * @dev: GPIO consumer
114 * @con_id: function within the GPIO consumer 146 * @con_id: function within the GPIO consumer
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 415682f69214..3d6b445665ad 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1259,7 +1259,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
1259 1259
1260#ifdef CONFIG_ARCH_OMAP2PLUS 1260#ifdef CONFIG_ARCH_OMAP2PLUS
1261 1261
1262#if defined(CONFIG_PM_RUNTIME) 1262#if defined(CONFIG_PM)
1263static void omap_gpio_restore_context(struct gpio_bank *bank); 1263static void omap_gpio_restore_context(struct gpio_bank *bank);
1264 1264
1265static int omap_gpio_runtime_suspend(struct device *dev) 1265static int omap_gpio_runtime_suspend(struct device *dev)
@@ -1440,7 +1440,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
1440 1440
1441 return 0; 1441 return 0;
1442} 1442}
1443#endif /* CONFIG_PM_RUNTIME */ 1443#endif /* CONFIG_PM */
1444 1444
1445void omap2_gpio_prepare_for_idle(int pwr_mode) 1445void omap2_gpio_prepare_for_idle(int pwr_mode)
1446{ 1446{
@@ -1468,7 +1468,7 @@ void omap2_gpio_resume_after_idle(void)
1468 } 1468 }
1469} 1469}
1470 1470
1471#if defined(CONFIG_PM_RUNTIME) 1471#if defined(CONFIG_PM)
1472static void omap_gpio_init_context(struct gpio_bank *p) 1472static void omap_gpio_init_context(struct gpio_bank *p)
1473{ 1473{
1474 struct omap_gpio_reg_offs *regs = p->regs; 1474 struct omap_gpio_reg_offs *regs = p->regs;
@@ -1525,7 +1525,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank)
1525 writel_relaxed(bank->context.irqenable2, 1525 writel_relaxed(bank->context.irqenable2,
1526 bank->base + bank->regs->irqenable2); 1526 bank->base + bank->regs->irqenable2);
1527} 1527}
1528#endif /* CONFIG_PM_RUNTIME */ 1528#endif /* CONFIG_PM */
1529#else 1529#else
1530#define omap_gpio_runtime_suspend NULL 1530#define omap_gpio_runtime_suspend NULL
1531#define omap_gpio_runtime_resume NULL 1531#define omap_gpio_runtime_resume NULL
diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
index 41e91d70301e..99720c8bc8ed 100644
--- a/drivers/gpio/gpio-sch.c
+++ b/drivers/gpio/gpio-sch.c
@@ -29,290 +29,221 @@
29 29
30#include <linux/gpio.h> 30#include <linux/gpio.h>
31 31
32static DEFINE_SPINLOCK(gpio_lock); 32#define GEN 0x00
33 33#define GIO 0x04
34#define CGEN (0x00) 34#define GLV 0x08
35#define CGIO (0x04) 35
36#define CGLV (0x08) 36struct sch_gpio {
37 37 struct gpio_chip chip;
38#define RGEN (0x20) 38 spinlock_t lock;
39#define RGIO (0x24) 39 unsigned short iobase;
40#define RGLV (0x28) 40 unsigned short core_base;
41 41 unsigned short resume_base;
42static unsigned short gpio_ba; 42};
43
44static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned gpio_num)
45{
46 u8 curr_dirs;
47 unsigned short offset, bit;
48
49 spin_lock(&gpio_lock);
50
51 offset = CGIO + gpio_num / 8;
52 bit = gpio_num % 8;
53
54 curr_dirs = inb(gpio_ba + offset);
55
56 if (!(curr_dirs & (1 << bit)))
57 outb(curr_dirs | (1 << bit), gpio_ba + offset);
58 43
59 spin_unlock(&gpio_lock); 44#define to_sch_gpio(c) container_of(c, struct sch_gpio, chip)
60 return 0;
61}
62 45
63static int sch_gpio_core_get(struct gpio_chip *gc, unsigned gpio_num) 46static unsigned sch_gpio_offset(struct sch_gpio *sch, unsigned gpio,
47 unsigned reg)
64{ 48{
65 int res; 49 unsigned base = 0;
66 unsigned short offset, bit;
67 50
68 offset = CGLV + gpio_num / 8; 51 if (gpio >= sch->resume_base) {
69 bit = gpio_num % 8; 52 gpio -= sch->resume_base;
53 base += 0x20;
54 }
70 55
71 res = !!(inb(gpio_ba + offset) & (1 << bit)); 56 return base + reg + gpio / 8;
72 return res;
73} 57}
74 58
75static void sch_gpio_core_set(struct gpio_chip *gc, unsigned gpio_num, int val) 59static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio)
76{ 60{
77 u8 curr_vals; 61 if (gpio >= sch->resume_base)
78 unsigned short offset, bit; 62 gpio -= sch->resume_base;
79 63 return gpio % 8;
80 spin_lock(&gpio_lock);
81
82 offset = CGLV + gpio_num / 8;
83 bit = gpio_num % 8;
84
85 curr_vals = inb(gpio_ba + offset);
86
87 if (val)
88 outb(curr_vals | (1 << bit), gpio_ba + offset);
89 else
90 outb((curr_vals & ~(1 << bit)), gpio_ba + offset);
91 spin_unlock(&gpio_lock);
92} 64}
93 65
94static int sch_gpio_core_direction_out(struct gpio_chip *gc, 66static void sch_gpio_enable(struct sch_gpio *sch, unsigned gpio)
95 unsigned gpio_num, int val)
96{ 67{
97 u8 curr_dirs;
98 unsigned short offset, bit; 68 unsigned short offset, bit;
69 u8 enable;
99 70
100 spin_lock(&gpio_lock); 71 spin_lock(&sch->lock);
101 72
102 offset = CGIO + gpio_num / 8; 73 offset = sch_gpio_offset(sch, gpio, GEN);
103 bit = gpio_num % 8; 74 bit = sch_gpio_bit(sch, gpio);
104
105 curr_dirs = inb(gpio_ba + offset);
106 if (curr_dirs & (1 << bit))
107 outb(curr_dirs & ~(1 << bit), gpio_ba + offset);
108 75
109 spin_unlock(&gpio_lock); 76 enable = inb(sch->iobase + offset);
77 if (!(enable & (1 << bit)))
78 outb(enable | (1 << bit), sch->iobase + offset);
110 79
111 /* 80 spin_unlock(&sch->lock);
112 * according to the datasheet, writing to the level register has no
113 * effect when GPIO is programmed as input.
114 * Actually the the level register is read-only when configured as input.
115 * Thus presetting the output level before switching to output is _NOT_ possible.
116 * Hence we set the level after configuring the GPIO as output.
117 * But we cannot prevent a short low pulse if direction is set to high
118 * and an external pull-up is connected.
119 */
120 sch_gpio_core_set(gc, gpio_num, val);
121 return 0;
122} 81}
123 82
124static struct gpio_chip sch_gpio_core = { 83static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num)
125 .label = "sch_gpio_core",
126 .owner = THIS_MODULE,
127 .direction_input = sch_gpio_core_direction_in,
128 .get = sch_gpio_core_get,
129 .direction_output = sch_gpio_core_direction_out,
130 .set = sch_gpio_core_set,
131};
132
133static int sch_gpio_resume_direction_in(struct gpio_chip *gc,
134 unsigned gpio_num)
135{ 84{
85 struct sch_gpio *sch = to_sch_gpio(gc);
136 u8 curr_dirs; 86 u8 curr_dirs;
137 unsigned short offset, bit; 87 unsigned short offset, bit;
138 88
139 spin_lock(&gpio_lock); 89 spin_lock(&sch->lock);
140 90
141 offset = RGIO + gpio_num / 8; 91 offset = sch_gpio_offset(sch, gpio_num, GIO);
142 bit = gpio_num % 8; 92 bit = sch_gpio_bit(sch, gpio_num);
143 93
144 curr_dirs = inb(gpio_ba + offset); 94 curr_dirs = inb(sch->iobase + offset);
145 95
146 if (!(curr_dirs & (1 << bit))) 96 if (!(curr_dirs & (1 << bit)))
147 outb(curr_dirs | (1 << bit), gpio_ba + offset); 97 outb(curr_dirs | (1 << bit), sch->iobase + offset);
148 98
149 spin_unlock(&gpio_lock); 99 spin_unlock(&sch->lock);
150 return 0; 100 return 0;
151} 101}
152 102
153static int sch_gpio_resume_get(struct gpio_chip *gc, unsigned gpio_num) 103static int sch_gpio_get(struct gpio_chip *gc, unsigned gpio_num)
154{ 104{
105 struct sch_gpio *sch = to_sch_gpio(gc);
106 int res;
155 unsigned short offset, bit; 107 unsigned short offset, bit;
156 108
157 offset = RGLV + gpio_num / 8; 109 offset = sch_gpio_offset(sch, gpio_num, GLV);
158 bit = gpio_num % 8; 110 bit = sch_gpio_bit(sch, gpio_num);
111
112 res = !!(inb(sch->iobase + offset) & (1 << bit));
159 113
160 return !!(inb(gpio_ba + offset) & (1 << bit)); 114 return res;
161} 115}
162 116
163static void sch_gpio_resume_set(struct gpio_chip *gc, 117static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
164 unsigned gpio_num, int val)
165{ 118{
119 struct sch_gpio *sch = to_sch_gpio(gc);
166 u8 curr_vals; 120 u8 curr_vals;
167 unsigned short offset, bit; 121 unsigned short offset, bit;
168 122
169 spin_lock(&gpio_lock); 123 spin_lock(&sch->lock);
170 124
171 offset = RGLV + gpio_num / 8; 125 offset = sch_gpio_offset(sch, gpio_num, GLV);
172 bit = gpio_num % 8; 126 bit = sch_gpio_bit(sch, gpio_num);
173 127
174 curr_vals = inb(gpio_ba + offset); 128 curr_vals = inb(sch->iobase + offset);
175 129
176 if (val) 130 if (val)
177 outb(curr_vals | (1 << bit), gpio_ba + offset); 131 outb(curr_vals | (1 << bit), sch->iobase + offset);
178 else 132 else
179 outb((curr_vals & ~(1 << bit)), gpio_ba + offset); 133 outb((curr_vals & ~(1 << bit)), sch->iobase + offset);
180 134
181 spin_unlock(&gpio_lock); 135 spin_unlock(&sch->lock);
182} 136}
183 137
184static int sch_gpio_resume_direction_out(struct gpio_chip *gc, 138static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned gpio_num,
185 unsigned gpio_num, int val) 139 int val)
186{ 140{
141 struct sch_gpio *sch = to_sch_gpio(gc);
187 u8 curr_dirs; 142 u8 curr_dirs;
188 unsigned short offset, bit; 143 unsigned short offset, bit;
189 144
190 offset = RGIO + gpio_num / 8; 145 spin_lock(&sch->lock);
191 bit = gpio_num % 8;
192 146
193 spin_lock(&gpio_lock); 147 offset = sch_gpio_offset(sch, gpio_num, GIO);
148 bit = sch_gpio_bit(sch, gpio_num);
194 149
195 curr_dirs = inb(gpio_ba + offset); 150 curr_dirs = inb(sch->iobase + offset);
196 if (curr_dirs & (1 << bit)) 151 if (curr_dirs & (1 << bit))
197 outb(curr_dirs & ~(1 << bit), gpio_ba + offset); 152 outb(curr_dirs & ~(1 << bit), sch->iobase + offset);
198 153
199 spin_unlock(&gpio_lock); 154 spin_unlock(&sch->lock);
200 155
201 /* 156 /*
202 * according to the datasheet, writing to the level register has no 157 * according to the datasheet, writing to the level register has no
203 * effect when GPIO is programmed as input. 158 * effect when GPIO is programmed as input.
204 * Actually the the level register is read-only when configured as input. 159 * Actually the the level register is read-only when configured as input.
205 * Thus presetting the output level before switching to output is _NOT_ possible. 160 * Thus presetting the output level before switching to output is _NOT_ possible.
206 * Hence we set the level after configuring the GPIO as output. 161 * Hence we set the level after configuring the GPIO as output.
207 * But we cannot prevent a short low pulse if direction is set to high 162 * But we cannot prevent a short low pulse if direction is set to high
208 * and an external pull-up is connected. 163 * and an external pull-up is connected.
209 */ 164 */
210 sch_gpio_resume_set(gc, gpio_num, val); 165 sch_gpio_set(gc, gpio_num, val);
211 return 0; 166 return 0;
212} 167}
213 168
214static struct gpio_chip sch_gpio_resume = { 169static struct gpio_chip sch_gpio_chip = {
215 .label = "sch_gpio_resume", 170 .label = "sch_gpio",
216 .owner = THIS_MODULE, 171 .owner = THIS_MODULE,
217 .direction_input = sch_gpio_resume_direction_in, 172 .direction_input = sch_gpio_direction_in,
218 .get = sch_gpio_resume_get, 173 .get = sch_gpio_get,
219 .direction_output = sch_gpio_resume_direction_out, 174 .direction_output = sch_gpio_direction_out,
220 .set = sch_gpio_resume_set, 175 .set = sch_gpio_set,
221}; 176};
222 177
223static int sch_gpio_probe(struct platform_device *pdev) 178static int sch_gpio_probe(struct platform_device *pdev)
224{ 179{
180 struct sch_gpio *sch;
225 struct resource *res; 181 struct resource *res;
226 int err, id;
227 182
228 id = pdev->id; 183 sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL);
229 if (!id) 184 if (!sch)
230 return -ENODEV; 185 return -ENOMEM;
231 186
232 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 187 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
233 if (!res) 188 if (!res)
234 return -EBUSY; 189 return -EBUSY;
235 190
236 if (!request_region(res->start, resource_size(res), pdev->name)) 191 if (!devm_request_region(&pdev->dev, res->start, resource_size(res),
192 pdev->name))
237 return -EBUSY; 193 return -EBUSY;
238 194
239 gpio_ba = res->start; 195 spin_lock_init(&sch->lock);
196 sch->iobase = res->start;
197 sch->chip = sch_gpio_chip;
198 sch->chip.label = dev_name(&pdev->dev);
199 sch->chip.dev = &pdev->dev;
240 200
241 switch (id) { 201 switch (pdev->id) {
242 case PCI_DEVICE_ID_INTEL_SCH_LPC: 202 case PCI_DEVICE_ID_INTEL_SCH_LPC:
243 sch_gpio_core.base = 0; 203 sch->core_base = 0;
244 sch_gpio_core.ngpio = 10; 204 sch->resume_base = 10;
245 sch_gpio_resume.base = 10; 205 sch->chip.ngpio = 14;
246 sch_gpio_resume.ngpio = 4; 206
247 /* 207 /*
248 * GPIO[6:0] enabled by default 208 * GPIO[6:0] enabled by default
249 * GPIO7 is configured by the CMC as SLPIOVR 209 * GPIO7 is configured by the CMC as SLPIOVR
250 * Enable GPIO[9:8] core powered gpios explicitly 210 * Enable GPIO[9:8] core powered gpios explicitly
251 */ 211 */
252 outb(0x3, gpio_ba + CGEN + 1); 212 sch_gpio_enable(sch, 8);
213 sch_gpio_enable(sch, 9);
253 /* 214 /*
254 * SUS_GPIO[2:0] enabled by default 215 * SUS_GPIO[2:0] enabled by default
255 * Enable SUS_GPIO3 resume powered gpio explicitly 216 * Enable SUS_GPIO3 resume powered gpio explicitly
256 */ 217 */
257 outb(0x8, gpio_ba + RGEN); 218 sch_gpio_enable(sch, 13);
258 break; 219 break;
259 220
260 case PCI_DEVICE_ID_INTEL_ITC_LPC: 221 case PCI_DEVICE_ID_INTEL_ITC_LPC:
261 sch_gpio_core.base = 0; 222 sch->core_base = 0;
262 sch_gpio_core.ngpio = 5; 223 sch->resume_base = 5;
263 sch_gpio_resume.base = 5; 224 sch->chip.ngpio = 14;
264 sch_gpio_resume.ngpio = 9;
265 break; 225 break;
266 226
267 case PCI_DEVICE_ID_INTEL_CENTERTON_ILB: 227 case PCI_DEVICE_ID_INTEL_CENTERTON_ILB:
268 sch_gpio_core.base = 0; 228 sch->core_base = 0;
269 sch_gpio_core.ngpio = 21; 229 sch->resume_base = 21;
270 sch_gpio_resume.base = 21; 230 sch->chip.ngpio = 30;
271 sch_gpio_resume.ngpio = 9;
272 break; 231 break;
273 232
274 default: 233 default:
275 err = -ENODEV; 234 return -ENODEV;
276 goto err_sch_gpio_core;
277 } 235 }
278 236
279 sch_gpio_core.dev = &pdev->dev; 237 platform_set_drvdata(pdev, sch);
280 sch_gpio_resume.dev = &pdev->dev;
281
282 err = gpiochip_add(&sch_gpio_core);
283 if (err < 0)
284 goto err_sch_gpio_core;
285 238
286 err = gpiochip_add(&sch_gpio_resume); 239 return gpiochip_add(&sch->chip);
287 if (err < 0)
288 goto err_sch_gpio_resume;
289
290 return 0;
291
292err_sch_gpio_resume:
293 gpiochip_remove(&sch_gpio_core);
294
295err_sch_gpio_core:
296 release_region(res->start, resource_size(res));
297 gpio_ba = 0;
298
299 return err;
300} 240}
301 241
302static int sch_gpio_remove(struct platform_device *pdev) 242static int sch_gpio_remove(struct platform_device *pdev)
303{ 243{
304 struct resource *res; 244 struct sch_gpio *sch = platform_get_drvdata(pdev);
305 if (gpio_ba) {
306
307 gpiochip_remove(&sch_gpio_core);
308 gpiochip_remove(&sch_gpio_resume);
309
310 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
311
312 release_region(res->start, resource_size(res));
313 gpio_ba = 0;
314 }
315 245
246 gpiochip_remove(&sch->chip);
316 return 0; 247 return 0;
317} 248}
318 249
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 74cd480bf8de..184c4b1b2558 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -578,7 +578,7 @@ static void zynq_gpio_free(struct gpio_chip *chip, unsigned offset)
578 578
579static const struct dev_pm_ops zynq_gpio_dev_pm_ops = { 579static const struct dev_pm_ops zynq_gpio_dev_pm_ops = {
580 SET_SYSTEM_SLEEP_PM_OPS(zynq_gpio_suspend, zynq_gpio_resume) 580 SET_SYSTEM_SLEEP_PM_OPS(zynq_gpio_suspend, zynq_gpio_resume)
581 SET_PM_RUNTIME_PM_OPS(zynq_gpio_runtime_suspend, 581 SET_RUNTIME_PM_OPS(zynq_gpio_runtime_suspend,
582 zynq_gpio_runtime_resume, NULL) 582 zynq_gpio_runtime_resume, NULL)
583}; 583};
584 584
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 05c6275da224..ba98bb59a58f 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -287,9 +287,45 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
287 } 287 }
288} 288}
289 289
290int acpi_dev_add_driver_gpios(struct acpi_device *adev,
291 const struct acpi_gpio_mapping *gpios)
292{
293 if (adev && gpios) {
294 adev->driver_gpios = gpios;
295 return 0;
296 }
297 return -EINVAL;
298}
299EXPORT_SYMBOL_GPL(acpi_dev_add_driver_gpios);
300
301static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
302 const char *name, int index,
303 struct acpi_reference_args *args)
304{
305 const struct acpi_gpio_mapping *gm;
306
307 if (!adev->driver_gpios)
308 return false;
309
310 for (gm = adev->driver_gpios; gm->name; gm++)
311 if (!strcmp(name, gm->name) && gm->data && index < gm->size) {
312 const struct acpi_gpio_params *par = gm->data + index;
313
314 args->adev = adev;
315 args->args[0] = par->crs_entry_index;
316 args->args[1] = par->line_index;
317 args->args[2] = par->active_low;
318 args->nargs = 3;
319 return true;
320 }
321
322 return false;
323}
324
290struct acpi_gpio_lookup { 325struct acpi_gpio_lookup {
291 struct acpi_gpio_info info; 326 struct acpi_gpio_info info;
292 int index; 327 int index;
328 int pin_index;
293 struct gpio_desc *desc; 329 struct gpio_desc *desc;
294 int n; 330 int n;
295}; 331};
@@ -303,13 +339,24 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
303 339
304 if (lookup->n++ == lookup->index && !lookup->desc) { 340 if (lookup->n++ == lookup->index && !lookup->desc) {
305 const struct acpi_resource_gpio *agpio = &ares->data.gpio; 341 const struct acpi_resource_gpio *agpio = &ares->data.gpio;
342 int pin_index = lookup->pin_index;
343
344 if (pin_index >= agpio->pin_table_length)
345 return 1;
306 346
307 lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, 347 lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
308 agpio->pin_table[0]); 348 agpio->pin_table[pin_index]);
309 lookup->info.gpioint = 349 lookup->info.gpioint =
310 agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT; 350 agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT;
311 lookup->info.active_low = 351
312 agpio->polarity == ACPI_ACTIVE_LOW; 352 /*
353 * ActiveLow is only specified for GpioInt resource. If
354 * GpioIo is used then the only way to set the flag is
355 * to use _DSD "gpios" property.
356 */
357 if (lookup->info.gpioint)
358 lookup->info.active_low =
359 agpio->polarity == ACPI_ACTIVE_LOW;
313 } 360 }
314 361
315 return 1; 362 return 1;
@@ -317,40 +364,79 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
317 364
318/** 365/**
319 * acpi_get_gpiod_by_index() - get a GPIO descriptor from device resources 366 * acpi_get_gpiod_by_index() - get a GPIO descriptor from device resources
320 * @dev: pointer to a device to get GPIO from 367 * @adev: pointer to a ACPI device to get GPIO from
368 * @propname: Property name of the GPIO (optional)
321 * @index: index of GpioIo/GpioInt resource (starting from %0) 369 * @index: index of GpioIo/GpioInt resource (starting from %0)
322 * @info: info pointer to fill in (optional) 370 * @info: info pointer to fill in (optional)
323 * 371 *
324 * Function goes through ACPI resources for @dev and based on @index looks 372 * Function goes through ACPI resources for @adev and based on @index looks
325 * up a GpioIo/GpioInt resource, translates it to the Linux GPIO descriptor, 373 * up a GpioIo/GpioInt resource, translates it to the Linux GPIO descriptor,
326 * and returns it. @index matches GpioIo/GpioInt resources only so if there 374 * and returns it. @index matches GpioIo/GpioInt resources only so if there
327 * are total %3 GPIO resources, the index goes from %0 to %2. 375 * are total %3 GPIO resources, the index goes from %0 to %2.
328 * 376 *
377 * If @propname is specified the GPIO is looked using device property. In
378 * that case @index is used to select the GPIO entry in the property value
379 * (in case of multiple).
380 *
329 * If the GPIO cannot be translated or there is an error an ERR_PTR is 381 * If the GPIO cannot be translated or there is an error an ERR_PTR is
330 * returned. 382 * returned.
331 * 383 *
332 * Note: if the GPIO resource has multiple entries in the pin list, this 384 * Note: if the GPIO resource has multiple entries in the pin list, this
333 * function only returns the first. 385 * function only returns the first.
334 */ 386 */
335struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, 387struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
388 const char *propname, int index,
336 struct acpi_gpio_info *info) 389 struct acpi_gpio_info *info)
337{ 390{
338 struct acpi_gpio_lookup lookup; 391 struct acpi_gpio_lookup lookup;
339 struct list_head resource_list; 392 struct list_head resource_list;
340 struct acpi_device *adev; 393 bool active_low = false;
341 acpi_handle handle;
342 int ret; 394 int ret;
343 395
344 if (!dev) 396 if (!adev)
345 return ERR_PTR(-EINVAL);
346
347 handle = ACPI_HANDLE(dev);
348 if (!handle || acpi_bus_get_device(handle, &adev))
349 return ERR_PTR(-ENODEV); 397 return ERR_PTR(-ENODEV);
350 398
351 memset(&lookup, 0, sizeof(lookup)); 399 memset(&lookup, 0, sizeof(lookup));
352 lookup.index = index; 400 lookup.index = index;
353 401
402 if (propname) {
403 struct acpi_reference_args args;
404
405 dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
406
407 memset(&args, 0, sizeof(args));
408 ret = acpi_dev_get_property_reference(adev, propname,
409 index, &args);
410 if (ret) {
411 bool found = acpi_get_driver_gpio_data(adev, propname,
412 index, &args);
413 if (!found)
414 return ERR_PTR(ret);
415 }
416
417 /*
418 * The property was found and resolved so need to
419 * lookup the GPIO based on returned args instead.
420 */
421 adev = args.adev;
422 if (args.nargs >= 2) {
423 lookup.index = args.args[0];
424 lookup.pin_index = args.args[1];
425 /*
426 * 3rd argument, if present is used to
427 * specify active_low.
428 */
429 if (args.nargs >= 3)
430 active_low = !!args.args[2];
431 }
432
433 dev_dbg(&adev->dev, "GPIO: _DSD returned %s %zd %llu %llu %llu\n",
434 dev_name(&adev->dev), args.nargs,
435 args.args[0], args.args[1], args.args[2]);
436 } else {
437 dev_dbg(&adev->dev, "GPIO: looking up %d in _CRS\n", index);
438 }
439
354 INIT_LIST_HEAD(&resource_list); 440 INIT_LIST_HEAD(&resource_list);
355 ret = acpi_dev_get_resources(adev, &resource_list, acpi_find_gpio, 441 ret = acpi_dev_get_resources(adev, &resource_list, acpi_find_gpio,
356 &lookup); 442 &lookup);
@@ -359,8 +445,11 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
359 445
360 acpi_dev_free_resource_list(&resource_list); 446 acpi_dev_free_resource_list(&resource_list);
361 447
362 if (lookup.desc && info) 448 if (lookup.desc && info) {
363 *info = lookup.info; 449 *info = lookup.info;
450 if (active_low)
451 info->active_low = active_low;
452 }
364 453
365 return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT); 454 return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT);
366} 455}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e8e98ca25ec7..58659dbe702a 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1505,14 +1505,36 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
1505 unsigned int idx, 1505 unsigned int idx,
1506 enum gpio_lookup_flags *flags) 1506 enum gpio_lookup_flags *flags)
1507{ 1507{
1508 static const char * const suffixes[] = { "gpios", "gpio" };
1509 struct acpi_device *adev = ACPI_COMPANION(dev);
1508 struct acpi_gpio_info info; 1510 struct acpi_gpio_info info;
1509 struct gpio_desc *desc; 1511 struct gpio_desc *desc;
1512 char propname[32];
1513 int i;
1510 1514
1511 desc = acpi_get_gpiod_by_index(dev, idx, &info); 1515 /* Try first from _DSD */
1512 if (IS_ERR(desc)) 1516 for (i = 0; i < ARRAY_SIZE(suffixes); i++) {
1513 return desc; 1517 if (con_id && strcmp(con_id, "gpios")) {
1518 snprintf(propname, sizeof(propname), "%s-%s",
1519 con_id, suffixes[i]);
1520 } else {
1521 snprintf(propname, sizeof(propname), "%s",
1522 suffixes[i]);
1523 }
1524
1525 desc = acpi_get_gpiod_by_index(adev, propname, idx, &info);
1526 if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER))
1527 break;
1528 }
1514 1529
1515 if (info.gpioint && info.active_low) 1530 /* Then from plain _CRS GPIOs */
1531 if (IS_ERR(desc)) {
1532 desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info);
1533 if (IS_ERR(desc))
1534 return desc;
1535 }
1536
1537 if (info.active_low)
1516 *flags |= GPIO_ACTIVE_LOW; 1538 *flags |= GPIO_ACTIVE_LOW;
1517 1539
1518 return desc; 1540 return desc;
@@ -1713,6 +1735,61 @@ struct gpio_desc *__must_check __gpiod_get_index(struct device *dev,
1713EXPORT_SYMBOL_GPL(__gpiod_get_index); 1735EXPORT_SYMBOL_GPL(__gpiod_get_index);
1714 1736
1715/** 1737/**
1738 * fwnode_get_named_gpiod - obtain a GPIO from firmware node
1739 * @fwnode: handle of the firmware node
1740 * @propname: name of the firmware property representing the GPIO
1741 *
1742 * This function can be used for drivers that get their configuration
1743 * from firmware.
1744 *
1745 * Function properly finds the corresponding GPIO using whatever is the
1746 * underlying firmware interface and then makes sure that the GPIO
1747 * descriptor is requested before it is returned to the caller.
1748 *
1749 * In case of error an ERR_PTR() is returned.
1750 */
1751struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
1752 const char *propname)
1753{
1754 struct gpio_desc *desc = ERR_PTR(-ENODEV);
1755 bool active_low = false;
1756 int ret;
1757
1758 if (!fwnode)
1759 return ERR_PTR(-EINVAL);
1760
1761 if (is_of_node(fwnode)) {
1762 enum of_gpio_flags flags;
1763
1764 desc = of_get_named_gpiod_flags(of_node(fwnode), propname, 0,
1765 &flags);
1766 if (!IS_ERR(desc))
1767 active_low = flags & OF_GPIO_ACTIVE_LOW;
1768 } else if (is_acpi_node(fwnode)) {
1769 struct acpi_gpio_info info;
1770
1771 desc = acpi_get_gpiod_by_index(acpi_node(fwnode), propname, 0,
1772 &info);
1773 if (!IS_ERR(desc))
1774 active_low = info.active_low;
1775 }
1776
1777 if (IS_ERR(desc))
1778 return desc;
1779
1780 ret = gpiod_request(desc, NULL);
1781 if (ret)
1782 return ERR_PTR(ret);
1783
1784 /* Only value flag can be set from both DT and ACPI is active_low */
1785 if (active_low)
1786 set_bit(FLAG_ACTIVE_LOW, &desc->flags);
1787
1788 return desc;
1789}
1790EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
1791
1792/**
1716 * gpiod_get_index_optional - obtain an optional GPIO from a multi-index GPIO 1793 * gpiod_get_index_optional - obtain an optional GPIO from a multi-index GPIO
1717 * function 1794 * function
1718 * @dev: GPIO consumer, can be NULL for system-global GPIOs 1795 * @dev: GPIO consumer, can be NULL for system-global GPIOs
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 9db2b6a71c5d..e3a52113a541 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -34,7 +34,8 @@ void acpi_gpiochip_remove(struct gpio_chip *chip);
34void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 34void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
35void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 35void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
36 36
37struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, 37struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
38 const char *propname, int index,
38 struct acpi_gpio_info *info); 39 struct acpi_gpio_info *info);
39#else 40#else
40static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } 41static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
@@ -47,8 +48,8 @@ static inline void
47acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } 48acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
48 49
49static inline struct gpio_desc * 50static inline struct gpio_desc *
50acpi_get_gpiod_by_index(struct device *dev, int index, 51acpi_get_gpiod_by_index(struct acpi_device *adev, const char *propname,
51 struct acpi_gpio_info *info) 52 int index, struct acpi_gpio_info *info)
52{ 53{
53 return ERR_PTR(-ENOSYS); 54 return ERR_PTR(-ENOSYS);
54} 55}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 68d38eb6774d..835b6af00970 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -1817,7 +1817,7 @@ static int fimc_resume(struct device *dev)
1817} 1817}
1818#endif 1818#endif
1819 1819
1820#ifdef CONFIG_PM_RUNTIME 1820#ifdef CONFIG_PM
1821static int fimc_runtime_suspend(struct device *dev) 1821static int fimc_runtime_suspend(struct device *dev)
1822{ 1822{
1823 struct fimc_context *ctx = get_fimc_context(dev); 1823 struct fimc_context *ctx = get_fimc_context(dev);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 6ff8599f6cbf..81a250830808 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -1540,7 +1540,7 @@ static int g2d_resume(struct device *dev)
1540} 1540}
1541#endif 1541#endif
1542 1542
1543#ifdef CONFIG_PM_RUNTIME 1543#ifdef CONFIG_PM
1544static int g2d_runtime_suspend(struct device *dev) 1544static int g2d_runtime_suspend(struct device *dev)
1545{ 1545{
1546 struct g2d_data *g2d = dev_get_drvdata(dev); 1546 struct g2d_data *g2d = dev_get_drvdata(dev);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index c6a013fc321c..0261468c8019 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -1764,7 +1764,7 @@ static int gsc_resume(struct device *dev)
1764} 1764}
1765#endif 1765#endif
1766 1766
1767#ifdef CONFIG_PM_RUNTIME 1767#ifdef CONFIG_PM
1768static int gsc_runtime_suspend(struct device *dev) 1768static int gsc_runtime_suspend(struct device *dev)
1769{ 1769{
1770 struct gsc_context *ctx = get_gsc_context(dev); 1770 struct gsc_context *ctx = get_gsc_context(dev);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index b6a37d4f5b13..425e70625388 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -822,7 +822,7 @@ static int rotator_resume(struct device *dev)
822} 822}
823#endif 823#endif
824 824
825#ifdef CONFIG_PM_RUNTIME 825#ifdef CONFIG_PM
826static int rotator_runtime_suspend(struct device *dev) 826static int rotator_runtime_suspend(struct device *dev)
827{ 827{
828 struct rot_context *rot = dev_get_drvdata(dev); 828 struct rot_context *rot = dev_get_drvdata(dev);
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 747d54421e73..f09e70cafaf1 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -1095,7 +1095,7 @@ static int i2c_hid_resume(struct device *dev)
1095} 1095}
1096#endif 1096#endif
1097 1097
1098#ifdef CONFIG_PM_RUNTIME 1098#ifdef CONFIG_PM
1099static int i2c_hid_runtime_suspend(struct device *dev) 1099static int i2c_hid_runtime_suspend(struct device *dev)
1100{ 1100{
1101 struct i2c_client *client = to_i2c_client(dev); 1101 struct i2c_client *client = to_i2c_client(dev);
diff --git a/drivers/hsi/controllers/omap_ssi.c b/drivers/hsi/controllers/omap_ssi.c
index bf0eace4cb67..4d5b682fc6af 100644
--- a/drivers/hsi/controllers/omap_ssi.c
+++ b/drivers/hsi/controllers/omap_ssi.c
@@ -555,7 +555,7 @@ static int __exit ssi_remove(struct platform_device *pd)
555 return 0; 555 return 0;
556} 556}
557 557
558#ifdef CONFIG_PM_RUNTIME 558#ifdef CONFIG_PM
559static int omap_ssi_runtime_suspend(struct device *dev) 559static int omap_ssi_runtime_suspend(struct device *dev)
560{ 560{
561 struct hsi_controller *ssi = dev_get_drvdata(dev); 561 struct hsi_controller *ssi = dev_get_drvdata(dev);
diff --git a/drivers/hsi/controllers/omap_ssi_port.c b/drivers/hsi/controllers/omap_ssi_port.c
index 4c0b5820581e..d836cfe50513 100644
--- a/drivers/hsi/controllers/omap_ssi_port.c
+++ b/drivers/hsi/controllers/omap_ssi_port.c
@@ -1260,7 +1260,7 @@ static int __exit ssi_port_remove(struct platform_device *pd)
1260 return 0; 1260 return 0;
1261} 1261}
1262 1262
1263#ifdef CONFIG_PM_RUNTIME 1263#ifdef CONFIG_PM
1264static int ssi_save_port_ctx(struct omap_ssi_port *omap_port) 1264static int ssi_save_port_ctx(struct omap_ssi_port *omap_port)
1265{ 1265{
1266 struct hsi_port *port = to_hsi_port(omap_port->dev); 1266 struct hsi_port *port = to_hsi_port(omap_port->dev);
diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
index 9490d0f4255c..8fe78d08e01c 100644
--- a/drivers/i2c/busses/i2c-hix5hd2.c
+++ b/drivers/i2c/busses/i2c-hix5hd2.c
@@ -528,7 +528,7 @@ static int hix5hd2_i2c_runtime_resume(struct device *dev)
528#endif 528#endif
529 529
530static const struct dev_pm_ops hix5hd2_i2c_pm_ops = { 530static const struct dev_pm_ops hix5hd2_i2c_pm_ops = {
531 SET_PM_RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend, 531 SET_RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend,
532 hix5hd2_i2c_runtime_resume, 532 hix5hd2_i2c_runtime_resume,
533 NULL) 533 NULL)
534}; 534};
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 9ad038d223c4..97998946c4f6 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -932,7 +932,7 @@ static int nmk_i2c_runtime_resume(struct device *dev)
932 932
933static const struct dev_pm_ops nmk_i2c_pm = { 933static const struct dev_pm_ops nmk_i2c_pm = {
934 SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early) 934 SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
935 SET_PM_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, 935 SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend,
936 nmk_i2c_runtime_resume, 936 nmk_i2c_runtime_resume,
937 NULL) 937 NULL)
938}; 938};
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 277a2288d4a8..0e650a0d0ad0 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1280,7 +1280,6 @@ static int omap_i2c_remove(struct platform_device *pdev)
1280} 1280}
1281 1281
1282#ifdef CONFIG_PM 1282#ifdef CONFIG_PM
1283#ifdef CONFIG_PM_RUNTIME
1284static int omap_i2c_runtime_suspend(struct device *dev) 1283static int omap_i2c_runtime_suspend(struct device *dev)
1285{ 1284{
1286 struct platform_device *pdev = to_platform_device(dev); 1285 struct platform_device *pdev = to_platform_device(dev);
@@ -1318,7 +1317,6 @@ static int omap_i2c_runtime_resume(struct device *dev)
1318 1317
1319 return 0; 1318 return 0;
1320} 1319}
1321#endif /* CONFIG_PM_RUNTIME */
1322 1320
1323static struct dev_pm_ops omap_i2c_pm_ops = { 1321static struct dev_pm_ops omap_i2c_pm_ops = {
1324 SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, 1322 SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend,
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index f43b4e11647a..68aeb8eedae0 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -403,6 +403,7 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
403 return -ENOMEM; 403 return -ENOMEM;
404 } 404 }
405 405
406 acpi_walk_dep_device_list(handle);
406 return 0; 407 return 0;
407} 408}
408 409
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 9b7ee7e427df..9cceacb92f9d 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -128,28 +128,28 @@ static struct cpuidle_state nehalem_cstates[] = {
128 { 128 {
129 .name = "C1-NHM", 129 .name = "C1-NHM",
130 .desc = "MWAIT 0x00", 130 .desc = "MWAIT 0x00",
131 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 131 .flags = MWAIT2flg(0x00),
132 .exit_latency = 3, 132 .exit_latency = 3,
133 .target_residency = 6, 133 .target_residency = 6,
134 .enter = &intel_idle }, 134 .enter = &intel_idle },
135 { 135 {
136 .name = "C1E-NHM", 136 .name = "C1E-NHM",
137 .desc = "MWAIT 0x01", 137 .desc = "MWAIT 0x01",
138 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 138 .flags = MWAIT2flg(0x01),
139 .exit_latency = 10, 139 .exit_latency = 10,
140 .target_residency = 20, 140 .target_residency = 20,
141 .enter = &intel_idle }, 141 .enter = &intel_idle },
142 { 142 {
143 .name = "C3-NHM", 143 .name = "C3-NHM",
144 .desc = "MWAIT 0x10", 144 .desc = "MWAIT 0x10",
145 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 145 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
146 .exit_latency = 20, 146 .exit_latency = 20,
147 .target_residency = 80, 147 .target_residency = 80,
148 .enter = &intel_idle }, 148 .enter = &intel_idle },
149 { 149 {
150 .name = "C6-NHM", 150 .name = "C6-NHM",
151 .desc = "MWAIT 0x20", 151 .desc = "MWAIT 0x20",
152 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 152 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
153 .exit_latency = 200, 153 .exit_latency = 200,
154 .target_residency = 800, 154 .target_residency = 800,
155 .enter = &intel_idle }, 155 .enter = &intel_idle },
@@ -161,35 +161,35 @@ static struct cpuidle_state snb_cstates[] = {
161 { 161 {
162 .name = "C1-SNB", 162 .name = "C1-SNB",
163 .desc = "MWAIT 0x00", 163 .desc = "MWAIT 0x00",
164 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 164 .flags = MWAIT2flg(0x00),
165 .exit_latency = 2, 165 .exit_latency = 2,
166 .target_residency = 2, 166 .target_residency = 2,
167 .enter = &intel_idle }, 167 .enter = &intel_idle },
168 { 168 {
169 .name = "C1E-SNB", 169 .name = "C1E-SNB",
170 .desc = "MWAIT 0x01", 170 .desc = "MWAIT 0x01",
171 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 171 .flags = MWAIT2flg(0x01),
172 .exit_latency = 10, 172 .exit_latency = 10,
173 .target_residency = 20, 173 .target_residency = 20,
174 .enter = &intel_idle }, 174 .enter = &intel_idle },
175 { 175 {
176 .name = "C3-SNB", 176 .name = "C3-SNB",
177 .desc = "MWAIT 0x10", 177 .desc = "MWAIT 0x10",
178 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 178 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
179 .exit_latency = 80, 179 .exit_latency = 80,
180 .target_residency = 211, 180 .target_residency = 211,
181 .enter = &intel_idle }, 181 .enter = &intel_idle },
182 { 182 {
183 .name = "C6-SNB", 183 .name = "C6-SNB",
184 .desc = "MWAIT 0x20", 184 .desc = "MWAIT 0x20",
185 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 185 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
186 .exit_latency = 104, 186 .exit_latency = 104,
187 .target_residency = 345, 187 .target_residency = 345,
188 .enter = &intel_idle }, 188 .enter = &intel_idle },
189 { 189 {
190 .name = "C7-SNB", 190 .name = "C7-SNB",
191 .desc = "MWAIT 0x30", 191 .desc = "MWAIT 0x30",
192 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 192 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
193 .exit_latency = 109, 193 .exit_latency = 109,
194 .target_residency = 345, 194 .target_residency = 345,
195 .enter = &intel_idle }, 195 .enter = &intel_idle },
@@ -201,42 +201,42 @@ static struct cpuidle_state byt_cstates[] = {
201 { 201 {
202 .name = "C1-BYT", 202 .name = "C1-BYT",
203 .desc = "MWAIT 0x00", 203 .desc = "MWAIT 0x00",
204 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 204 .flags = MWAIT2flg(0x00),
205 .exit_latency = 1, 205 .exit_latency = 1,
206 .target_residency = 1, 206 .target_residency = 1,
207 .enter = &intel_idle }, 207 .enter = &intel_idle },
208 { 208 {
209 .name = "C1E-BYT", 209 .name = "C1E-BYT",
210 .desc = "MWAIT 0x01", 210 .desc = "MWAIT 0x01",
211 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 211 .flags = MWAIT2flg(0x01),
212 .exit_latency = 15, 212 .exit_latency = 15,
213 .target_residency = 30, 213 .target_residency = 30,
214 .enter = &intel_idle }, 214 .enter = &intel_idle },
215 { 215 {
216 .name = "C6N-BYT", 216 .name = "C6N-BYT",
217 .desc = "MWAIT 0x58", 217 .desc = "MWAIT 0x58",
218 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 218 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
219 .exit_latency = 40, 219 .exit_latency = 40,
220 .target_residency = 275, 220 .target_residency = 275,
221 .enter = &intel_idle }, 221 .enter = &intel_idle },
222 { 222 {
223 .name = "C6S-BYT", 223 .name = "C6S-BYT",
224 .desc = "MWAIT 0x52", 224 .desc = "MWAIT 0x52",
225 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 225 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
226 .exit_latency = 140, 226 .exit_latency = 140,
227 .target_residency = 560, 227 .target_residency = 560,
228 .enter = &intel_idle }, 228 .enter = &intel_idle },
229 { 229 {
230 .name = "C7-BYT", 230 .name = "C7-BYT",
231 .desc = "MWAIT 0x60", 231 .desc = "MWAIT 0x60",
232 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 232 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
233 .exit_latency = 1200, 233 .exit_latency = 1200,
234 .target_residency = 1500, 234 .target_residency = 1500,
235 .enter = &intel_idle }, 235 .enter = &intel_idle },
236 { 236 {
237 .name = "C7S-BYT", 237 .name = "C7S-BYT",
238 .desc = "MWAIT 0x64", 238 .desc = "MWAIT 0x64",
239 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 239 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
240 .exit_latency = 10000, 240 .exit_latency = 10000,
241 .target_residency = 20000, 241 .target_residency = 20000,
242 .enter = &intel_idle }, 242 .enter = &intel_idle },
@@ -248,35 +248,35 @@ static struct cpuidle_state ivb_cstates[] = {
248 { 248 {
249 .name = "C1-IVB", 249 .name = "C1-IVB",
250 .desc = "MWAIT 0x00", 250 .desc = "MWAIT 0x00",
251 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 251 .flags = MWAIT2flg(0x00),
252 .exit_latency = 1, 252 .exit_latency = 1,
253 .target_residency = 1, 253 .target_residency = 1,
254 .enter = &intel_idle }, 254 .enter = &intel_idle },
255 { 255 {
256 .name = "C1E-IVB", 256 .name = "C1E-IVB",
257 .desc = "MWAIT 0x01", 257 .desc = "MWAIT 0x01",
258 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 258 .flags = MWAIT2flg(0x01),
259 .exit_latency = 10, 259 .exit_latency = 10,
260 .target_residency = 20, 260 .target_residency = 20,
261 .enter = &intel_idle }, 261 .enter = &intel_idle },
262 { 262 {
263 .name = "C3-IVB", 263 .name = "C3-IVB",
264 .desc = "MWAIT 0x10", 264 .desc = "MWAIT 0x10",
265 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 265 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
266 .exit_latency = 59, 266 .exit_latency = 59,
267 .target_residency = 156, 267 .target_residency = 156,
268 .enter = &intel_idle }, 268 .enter = &intel_idle },
269 { 269 {
270 .name = "C6-IVB", 270 .name = "C6-IVB",
271 .desc = "MWAIT 0x20", 271 .desc = "MWAIT 0x20",
272 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 272 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
273 .exit_latency = 80, 273 .exit_latency = 80,
274 .target_residency = 300, 274 .target_residency = 300,
275 .enter = &intel_idle }, 275 .enter = &intel_idle },
276 { 276 {
277 .name = "C7-IVB", 277 .name = "C7-IVB",
278 .desc = "MWAIT 0x30", 278 .desc = "MWAIT 0x30",
279 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 279 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
280 .exit_latency = 87, 280 .exit_latency = 87,
281 .target_residency = 300, 281 .target_residency = 300,
282 .enter = &intel_idle }, 282 .enter = &intel_idle },
@@ -288,28 +288,28 @@ static struct cpuidle_state ivt_cstates[] = {
288 { 288 {
289 .name = "C1-IVT", 289 .name = "C1-IVT",
290 .desc = "MWAIT 0x00", 290 .desc = "MWAIT 0x00",
291 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 291 .flags = MWAIT2flg(0x00),
292 .exit_latency = 1, 292 .exit_latency = 1,
293 .target_residency = 1, 293 .target_residency = 1,
294 .enter = &intel_idle }, 294 .enter = &intel_idle },
295 { 295 {
296 .name = "C1E-IVT", 296 .name = "C1E-IVT",
297 .desc = "MWAIT 0x01", 297 .desc = "MWAIT 0x01",
298 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 298 .flags = MWAIT2flg(0x01),
299 .exit_latency = 10, 299 .exit_latency = 10,
300 .target_residency = 80, 300 .target_residency = 80,
301 .enter = &intel_idle }, 301 .enter = &intel_idle },
302 { 302 {
303 .name = "C3-IVT", 303 .name = "C3-IVT",
304 .desc = "MWAIT 0x10", 304 .desc = "MWAIT 0x10",
305 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 305 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
306 .exit_latency = 59, 306 .exit_latency = 59,
307 .target_residency = 156, 307 .target_residency = 156,
308 .enter = &intel_idle }, 308 .enter = &intel_idle },
309 { 309 {
310 .name = "C6-IVT", 310 .name = "C6-IVT",
311 .desc = "MWAIT 0x20", 311 .desc = "MWAIT 0x20",
312 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 312 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
313 .exit_latency = 82, 313 .exit_latency = 82,
314 .target_residency = 300, 314 .target_residency = 300,
315 .enter = &intel_idle }, 315 .enter = &intel_idle },
@@ -321,28 +321,28 @@ static struct cpuidle_state ivt_cstates_4s[] = {
321 { 321 {
322 .name = "C1-IVT-4S", 322 .name = "C1-IVT-4S",
323 .desc = "MWAIT 0x00", 323 .desc = "MWAIT 0x00",
324 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 324 .flags = MWAIT2flg(0x00),
325 .exit_latency = 1, 325 .exit_latency = 1,
326 .target_residency = 1, 326 .target_residency = 1,
327 .enter = &intel_idle }, 327 .enter = &intel_idle },
328 { 328 {
329 .name = "C1E-IVT-4S", 329 .name = "C1E-IVT-4S",
330 .desc = "MWAIT 0x01", 330 .desc = "MWAIT 0x01",
331 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 331 .flags = MWAIT2flg(0x01),
332 .exit_latency = 10, 332 .exit_latency = 10,
333 .target_residency = 250, 333 .target_residency = 250,
334 .enter = &intel_idle }, 334 .enter = &intel_idle },
335 { 335 {
336 .name = "C3-IVT-4S", 336 .name = "C3-IVT-4S",
337 .desc = "MWAIT 0x10", 337 .desc = "MWAIT 0x10",
338 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 338 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
339 .exit_latency = 59, 339 .exit_latency = 59,
340 .target_residency = 300, 340 .target_residency = 300,
341 .enter = &intel_idle }, 341 .enter = &intel_idle },
342 { 342 {
343 .name = "C6-IVT-4S", 343 .name = "C6-IVT-4S",
344 .desc = "MWAIT 0x20", 344 .desc = "MWAIT 0x20",
345 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 345 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
346 .exit_latency = 84, 346 .exit_latency = 84,
347 .target_residency = 400, 347 .target_residency = 400,
348 .enter = &intel_idle }, 348 .enter = &intel_idle },
@@ -354,28 +354,28 @@ static struct cpuidle_state ivt_cstates_8s[] = {
354 { 354 {
355 .name = "C1-IVT-8S", 355 .name = "C1-IVT-8S",
356 .desc = "MWAIT 0x00", 356 .desc = "MWAIT 0x00",
357 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 357 .flags = MWAIT2flg(0x00),
358 .exit_latency = 1, 358 .exit_latency = 1,
359 .target_residency = 1, 359 .target_residency = 1,
360 .enter = &intel_idle }, 360 .enter = &intel_idle },
361 { 361 {
362 .name = "C1E-IVT-8S", 362 .name = "C1E-IVT-8S",
363 .desc = "MWAIT 0x01", 363 .desc = "MWAIT 0x01",
364 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 364 .flags = MWAIT2flg(0x01),
365 .exit_latency = 10, 365 .exit_latency = 10,
366 .target_residency = 500, 366 .target_residency = 500,
367 .enter = &intel_idle }, 367 .enter = &intel_idle },
368 { 368 {
369 .name = "C3-IVT-8S", 369 .name = "C3-IVT-8S",
370 .desc = "MWAIT 0x10", 370 .desc = "MWAIT 0x10",
371 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 371 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
372 .exit_latency = 59, 372 .exit_latency = 59,
373 .target_residency = 600, 373 .target_residency = 600,
374 .enter = &intel_idle }, 374 .enter = &intel_idle },
375 { 375 {
376 .name = "C6-IVT-8S", 376 .name = "C6-IVT-8S",
377 .desc = "MWAIT 0x20", 377 .desc = "MWAIT 0x20",
378 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 378 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
379 .exit_latency = 88, 379 .exit_latency = 88,
380 .target_residency = 700, 380 .target_residency = 700,
381 .enter = &intel_idle }, 381 .enter = &intel_idle },
@@ -387,56 +387,56 @@ static struct cpuidle_state hsw_cstates[] = {
387 { 387 {
388 .name = "C1-HSW", 388 .name = "C1-HSW",
389 .desc = "MWAIT 0x00", 389 .desc = "MWAIT 0x00",
390 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 390 .flags = MWAIT2flg(0x00),
391 .exit_latency = 2, 391 .exit_latency = 2,
392 .target_residency = 2, 392 .target_residency = 2,
393 .enter = &intel_idle }, 393 .enter = &intel_idle },
394 { 394 {
395 .name = "C1E-HSW", 395 .name = "C1E-HSW",
396 .desc = "MWAIT 0x01", 396 .desc = "MWAIT 0x01",
397 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 397 .flags = MWAIT2flg(0x01),
398 .exit_latency = 10, 398 .exit_latency = 10,
399 .target_residency = 20, 399 .target_residency = 20,
400 .enter = &intel_idle }, 400 .enter = &intel_idle },
401 { 401 {
402 .name = "C3-HSW", 402 .name = "C3-HSW",
403 .desc = "MWAIT 0x10", 403 .desc = "MWAIT 0x10",
404 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 404 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
405 .exit_latency = 33, 405 .exit_latency = 33,
406 .target_residency = 100, 406 .target_residency = 100,
407 .enter = &intel_idle }, 407 .enter = &intel_idle },
408 { 408 {
409 .name = "C6-HSW", 409 .name = "C6-HSW",
410 .desc = "MWAIT 0x20", 410 .desc = "MWAIT 0x20",
411 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 411 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
412 .exit_latency = 133, 412 .exit_latency = 133,
413 .target_residency = 400, 413 .target_residency = 400,
414 .enter = &intel_idle }, 414 .enter = &intel_idle },
415 { 415 {
416 .name = "C7s-HSW", 416 .name = "C7s-HSW",
417 .desc = "MWAIT 0x32", 417 .desc = "MWAIT 0x32",
418 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 418 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
419 .exit_latency = 166, 419 .exit_latency = 166,
420 .target_residency = 500, 420 .target_residency = 500,
421 .enter = &intel_idle }, 421 .enter = &intel_idle },
422 { 422 {
423 .name = "C8-HSW", 423 .name = "C8-HSW",
424 .desc = "MWAIT 0x40", 424 .desc = "MWAIT 0x40",
425 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 425 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
426 .exit_latency = 300, 426 .exit_latency = 300,
427 .target_residency = 900, 427 .target_residency = 900,
428 .enter = &intel_idle }, 428 .enter = &intel_idle },
429 { 429 {
430 .name = "C9-HSW", 430 .name = "C9-HSW",
431 .desc = "MWAIT 0x50", 431 .desc = "MWAIT 0x50",
432 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 432 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
433 .exit_latency = 600, 433 .exit_latency = 600,
434 .target_residency = 1800, 434 .target_residency = 1800,
435 .enter = &intel_idle }, 435 .enter = &intel_idle },
436 { 436 {
437 .name = "C10-HSW", 437 .name = "C10-HSW",
438 .desc = "MWAIT 0x60", 438 .desc = "MWAIT 0x60",
439 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 439 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
440 .exit_latency = 2600, 440 .exit_latency = 2600,
441 .target_residency = 7700, 441 .target_residency = 7700,
442 .enter = &intel_idle }, 442 .enter = &intel_idle },
@@ -447,56 +447,56 @@ static struct cpuidle_state bdw_cstates[] = {
447 { 447 {
448 .name = "C1-BDW", 448 .name = "C1-BDW",
449 .desc = "MWAIT 0x00", 449 .desc = "MWAIT 0x00",
450 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 450 .flags = MWAIT2flg(0x00),
451 .exit_latency = 2, 451 .exit_latency = 2,
452 .target_residency = 2, 452 .target_residency = 2,
453 .enter = &intel_idle }, 453 .enter = &intel_idle },
454 { 454 {
455 .name = "C1E-BDW", 455 .name = "C1E-BDW",
456 .desc = "MWAIT 0x01", 456 .desc = "MWAIT 0x01",
457 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID, 457 .flags = MWAIT2flg(0x01),
458 .exit_latency = 10, 458 .exit_latency = 10,
459 .target_residency = 20, 459 .target_residency = 20,
460 .enter = &intel_idle }, 460 .enter = &intel_idle },
461 { 461 {
462 .name = "C3-BDW", 462 .name = "C3-BDW",
463 .desc = "MWAIT 0x10", 463 .desc = "MWAIT 0x10",
464 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 464 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
465 .exit_latency = 40, 465 .exit_latency = 40,
466 .target_residency = 100, 466 .target_residency = 100,
467 .enter = &intel_idle }, 467 .enter = &intel_idle },
468 { 468 {
469 .name = "C6-BDW", 469 .name = "C6-BDW",
470 .desc = "MWAIT 0x20", 470 .desc = "MWAIT 0x20",
471 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 471 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
472 .exit_latency = 133, 472 .exit_latency = 133,
473 .target_residency = 400, 473 .target_residency = 400,
474 .enter = &intel_idle }, 474 .enter = &intel_idle },
475 { 475 {
476 .name = "C7s-BDW", 476 .name = "C7s-BDW",
477 .desc = "MWAIT 0x32", 477 .desc = "MWAIT 0x32",
478 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 478 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
479 .exit_latency = 166, 479 .exit_latency = 166,
480 .target_residency = 500, 480 .target_residency = 500,
481 .enter = &intel_idle }, 481 .enter = &intel_idle },
482 { 482 {
483 .name = "C8-BDW", 483 .name = "C8-BDW",
484 .desc = "MWAIT 0x40", 484 .desc = "MWAIT 0x40",
485 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 485 .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
486 .exit_latency = 300, 486 .exit_latency = 300,
487 .target_residency = 900, 487 .target_residency = 900,
488 .enter = &intel_idle }, 488 .enter = &intel_idle },
489 { 489 {
490 .name = "C9-BDW", 490 .name = "C9-BDW",
491 .desc = "MWAIT 0x50", 491 .desc = "MWAIT 0x50",
492 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 492 .flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
493 .exit_latency = 600, 493 .exit_latency = 600,
494 .target_residency = 1800, 494 .target_residency = 1800,
495 .enter = &intel_idle }, 495 .enter = &intel_idle },
496 { 496 {
497 .name = "C10-BDW", 497 .name = "C10-BDW",
498 .desc = "MWAIT 0x60", 498 .desc = "MWAIT 0x60",
499 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 499 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
500 .exit_latency = 2600, 500 .exit_latency = 2600,
501 .target_residency = 7700, 501 .target_residency = 7700,
502 .enter = &intel_idle }, 502 .enter = &intel_idle },
@@ -508,28 +508,28 @@ static struct cpuidle_state atom_cstates[] = {
508 { 508 {
509 .name = "C1E-ATM", 509 .name = "C1E-ATM",
510 .desc = "MWAIT 0x00", 510 .desc = "MWAIT 0x00",
511 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 511 .flags = MWAIT2flg(0x00),
512 .exit_latency = 10, 512 .exit_latency = 10,
513 .target_residency = 20, 513 .target_residency = 20,
514 .enter = &intel_idle }, 514 .enter = &intel_idle },
515 { 515 {
516 .name = "C2-ATM", 516 .name = "C2-ATM",
517 .desc = "MWAIT 0x10", 517 .desc = "MWAIT 0x10",
518 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID, 518 .flags = MWAIT2flg(0x10),
519 .exit_latency = 20, 519 .exit_latency = 20,
520 .target_residency = 80, 520 .target_residency = 80,
521 .enter = &intel_idle }, 521 .enter = &intel_idle },
522 { 522 {
523 .name = "C4-ATM", 523 .name = "C4-ATM",
524 .desc = "MWAIT 0x30", 524 .desc = "MWAIT 0x30",
525 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 525 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,
526 .exit_latency = 100, 526 .exit_latency = 100,
527 .target_residency = 400, 527 .target_residency = 400,
528 .enter = &intel_idle }, 528 .enter = &intel_idle },
529 { 529 {
530 .name = "C6-ATM", 530 .name = "C6-ATM",
531 .desc = "MWAIT 0x52", 531 .desc = "MWAIT 0x52",
532 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 532 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
533 .exit_latency = 140, 533 .exit_latency = 140,
534 .target_residency = 560, 534 .target_residency = 560,
535 .enter = &intel_idle }, 535 .enter = &intel_idle },
@@ -540,14 +540,14 @@ static struct cpuidle_state avn_cstates[] = {
540 { 540 {
541 .name = "C1-AVN", 541 .name = "C1-AVN",
542 .desc = "MWAIT 0x00", 542 .desc = "MWAIT 0x00",
543 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 543 .flags = MWAIT2flg(0x00),
544 .exit_latency = 2, 544 .exit_latency = 2,
545 .target_residency = 2, 545 .target_residency = 2,
546 .enter = &intel_idle }, 546 .enter = &intel_idle },
547 { 547 {
548 .name = "C6-AVN", 548 .name = "C6-AVN",
549 .desc = "MWAIT 0x51", 549 .desc = "MWAIT 0x51",
550 .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 550 .flags = MWAIT2flg(0x51) | CPUIDLE_FLAG_TLB_FLUSHED,
551 .exit_latency = 15, 551 .exit_latency = 15,
552 .target_residency = 45, 552 .target_residency = 45,
553 .enter = &intel_idle }, 553 .enter = &intel_idle },
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 513bd6d14293..066d0c04072c 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -513,7 +513,7 @@ static int bmc150_accel_get_bw(struct bmc150_accel_data *data, int *val,
513 return -EINVAL; 513 return -EINVAL;
514} 514}
515 515
516#ifdef CONFIG_PM_RUNTIME 516#ifdef CONFIG_PM
517static int bmc150_accel_get_startup_times(struct bmc150_accel_data *data) 517static int bmc150_accel_get_startup_times(struct bmc150_accel_data *data)
518{ 518{
519 int i; 519 int i;
@@ -1371,7 +1371,7 @@ static int bmc150_accel_resume(struct device *dev)
1371} 1371}
1372#endif 1372#endif
1373 1373
1374#ifdef CONFIG_PM_RUNTIME 1374#ifdef CONFIG_PM
1375static int bmc150_accel_runtime_suspend(struct device *dev) 1375static int bmc150_accel_runtime_suspend(struct device *dev)
1376{ 1376{
1377 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1377 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 320aa72c0349..da2fe93739a2 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -360,7 +360,7 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
360 return 0; 360 return 0;
361} 361}
362 362
363#ifdef CONFIG_PM_RUNTIME 363#ifdef CONFIG_PM
364static int kxcjk1013_get_startup_times(struct kxcjk1013_data *data) 364static int kxcjk1013_get_startup_times(struct kxcjk1013_data *data)
365{ 365{
366 int i; 366 int i;
@@ -1359,7 +1359,7 @@ static int kxcjk1013_resume(struct device *dev)
1359} 1359}
1360#endif 1360#endif
1361 1361
1362#ifdef CONFIG_PM_RUNTIME 1362#ifdef CONFIG_PM
1363static int kxcjk1013_runtime_suspend(struct device *dev) 1363static int kxcjk1013_runtime_suspend(struct device *dev)
1364{ 1364{
1365 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1365 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index d2fa526740ca..60451b328242 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -256,7 +256,7 @@ static int bmg160_chip_init(struct bmg160_data *data)
256 256
257static int bmg160_set_power_state(struct bmg160_data *data, bool on) 257static int bmg160_set_power_state(struct bmg160_data *data, bool on)
258{ 258{
259#ifdef CONFIG_PM_RUNTIME 259#ifdef CONFIG_PM
260 int ret; 260 int ret;
261 261
262 if (on) 262 if (on)
@@ -1202,7 +1202,7 @@ static int bmg160_resume(struct device *dev)
1202} 1202}
1203#endif 1203#endif
1204 1204
1205#ifdef CONFIG_PM_RUNTIME 1205#ifdef CONFIG_PM
1206static int bmg160_runtime_suspend(struct device *dev) 1206static int bmg160_runtime_suspend(struct device *dev)
1207{ 1207{
1208 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1208 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index 432d36395f35..c9c1c8ca7267 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -23,10 +23,9 @@
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/gpio/consumer.h>
26#include <linux/gpio_keys.h> 27#include <linux/gpio_keys.h>
27#include <linux/of.h> 28#include <linux/property.h>
28#include <linux/of_platform.h>
29#include <linux/of_gpio.h>
30 29
31#define DRV_NAME "gpio-keys-polled" 30#define DRV_NAME "gpio-keys-polled"
32 31
@@ -51,15 +50,14 @@ static void gpio_keys_polled_check_state(struct input_dev *input,
51 int state; 50 int state;
52 51
53 if (bdata->can_sleep) 52 if (bdata->can_sleep)
54 state = !!gpio_get_value_cansleep(button->gpio); 53 state = !!gpiod_get_value_cansleep(button->gpiod);
55 else 54 else
56 state = !!gpio_get_value(button->gpio); 55 state = !!gpiod_get_value(button->gpiod);
57 56
58 if (state != bdata->last_state) { 57 if (state != bdata->last_state) {
59 unsigned int type = button->type ?: EV_KEY; 58 unsigned int type = button->type ?: EV_KEY;
60 59
61 input_event(input, type, button->code, 60 input_event(input, type, button->code, state);
62 !!(state ^ button->active_low));
63 input_sync(input); 61 input_sync(input);
64 bdata->count = 0; 62 bdata->count = 0;
65 bdata->last_state = state; 63 bdata->last_state = state;
@@ -102,21 +100,15 @@ static void gpio_keys_polled_close(struct input_polled_dev *dev)
102 pdata->disable(bdev->dev); 100 pdata->disable(bdev->dev);
103} 101}
104 102
105#ifdef CONFIG_OF
106static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct device *dev) 103static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct device *dev)
107{ 104{
108 struct device_node *node, *pp;
109 struct gpio_keys_platform_data *pdata; 105 struct gpio_keys_platform_data *pdata;
110 struct gpio_keys_button *button; 106 struct gpio_keys_button *button;
107 struct fwnode_handle *child;
111 int error; 108 int error;
112 int nbuttons; 109 int nbuttons;
113 int i;
114
115 node = dev->of_node;
116 if (!node)
117 return NULL;
118 110
119 nbuttons = of_get_child_count(node); 111 nbuttons = device_get_child_node_count(dev);
120 if (nbuttons == 0) 112 if (nbuttons == 0)
121 return NULL; 113 return NULL;
122 114
@@ -126,52 +118,44 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
126 return ERR_PTR(-ENOMEM); 118 return ERR_PTR(-ENOMEM);
127 119
128 pdata->buttons = (struct gpio_keys_button *)(pdata + 1); 120 pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
129 pdata->nbuttons = nbuttons;
130 121
131 pdata->rep = !!of_get_property(node, "autorepeat", NULL); 122 pdata->rep = device_property_present(dev, "autorepeat");
132 of_property_read_u32(node, "poll-interval", &pdata->poll_interval); 123 device_property_read_u32(dev, "poll-interval", &pdata->poll_interval);
133 124
134 i = 0; 125 device_for_each_child_node(dev, child) {
135 for_each_child_of_node(node, pp) { 126 struct gpio_desc *desc;
136 int gpio;
137 enum of_gpio_flags flags;
138 127
139 if (!of_find_property(pp, "gpios", NULL)) { 128 desc = devm_get_gpiod_from_child(dev, child);
140 pdata->nbuttons--; 129 if (IS_ERR(desc)) {
141 dev_warn(dev, "Found button without gpios\n"); 130 error = PTR_ERR(desc);
142 continue;
143 }
144
145 gpio = of_get_gpio_flags(pp, 0, &flags);
146 if (gpio < 0) {
147 error = gpio;
148 if (error != -EPROBE_DEFER) 131 if (error != -EPROBE_DEFER)
149 dev_err(dev, 132 dev_err(dev,
150 "Failed to get gpio flags, error: %d\n", 133 "Failed to get gpio flags, error: %d\n",
151 error); 134 error);
135 fwnode_handle_put(child);
152 return ERR_PTR(error); 136 return ERR_PTR(error);
153 } 137 }
154 138
155 button = &pdata->buttons[i++]; 139 button = &pdata->buttons[pdata->nbuttons++];
156 140 button->gpiod = desc;
157 button->gpio = gpio;
158 button->active_low = flags & OF_GPIO_ACTIVE_LOW;
159 141
160 if (of_property_read_u32(pp, "linux,code", &button->code)) { 142 if (fwnode_property_read_u32(child, "linux,code", &button->code)) {
161 dev_err(dev, "Button without keycode: 0x%x\n", 143 dev_err(dev, "Button without keycode: %d\n",
162 button->gpio); 144 pdata->nbuttons - 1);
145 fwnode_handle_put(child);
163 return ERR_PTR(-EINVAL); 146 return ERR_PTR(-EINVAL);
164 } 147 }
165 148
166 button->desc = of_get_property(pp, "label", NULL); 149 fwnode_property_read_string(child, "label", &button->desc);
167 150
168 if (of_property_read_u32(pp, "linux,input-type", &button->type)) 151 if (fwnode_property_read_u32(child, "linux,input-type",
152 &button->type))
169 button->type = EV_KEY; 153 button->type = EV_KEY;
170 154
171 button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); 155 button->wakeup = fwnode_property_present(child, "gpio-key,wakeup");
172 156
173 if (of_property_read_u32(pp, "debounce-interval", 157 if (fwnode_property_read_u32(child, "debounce-interval",
174 &button->debounce_interval)) 158 &button->debounce_interval))
175 button->debounce_interval = 5; 159 button->debounce_interval = 5;
176 } 160 }
177 161
@@ -187,15 +171,6 @@ static const struct of_device_id gpio_keys_polled_of_match[] = {
187}; 171};
188MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match); 172MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
189 173
190#else
191
192static inline struct gpio_keys_platform_data *
193gpio_keys_polled_get_devtree_pdata(struct device *dev)
194{
195 return NULL;
196}
197#endif
198
199static int gpio_keys_polled_probe(struct platform_device *pdev) 174static int gpio_keys_polled_probe(struct platform_device *pdev)
200{ 175{
201 struct device *dev = &pdev->dev; 176 struct device *dev = &pdev->dev;
@@ -259,7 +234,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
259 for (i = 0; i < pdata->nbuttons; i++) { 234 for (i = 0; i < pdata->nbuttons; i++) {
260 struct gpio_keys_button *button = &pdata->buttons[i]; 235 struct gpio_keys_button *button = &pdata->buttons[i];
261 struct gpio_keys_button_data *bdata = &bdev->data[i]; 236 struct gpio_keys_button_data *bdata = &bdev->data[i];
262 unsigned int gpio = button->gpio;
263 unsigned int type = button->type ?: EV_KEY; 237 unsigned int type = button->type ?: EV_KEY;
264 238
265 if (button->wakeup) { 239 if (button->wakeup) {
@@ -267,15 +241,31 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
267 return -EINVAL; 241 return -EINVAL;
268 } 242 }
269 243
270 error = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_IN, 244 /*
271 button->desc ? : DRV_NAME); 245 * Legacy GPIO number so request the GPIO here and
272 if (error) { 246 * convert it to descriptor.
273 dev_err(dev, "unable to claim gpio %u, err=%d\n", 247 */
274 gpio, error); 248 if (!button->gpiod && gpio_is_valid(button->gpio)) {
275 return error; 249 unsigned flags = 0;
250
251 if (button->active_low)
252 flags |= GPIOF_ACTIVE_LOW;
253
254 error = devm_gpio_request_one(&pdev->dev, button->gpio,
255 flags, button->desc ? : DRV_NAME);
256 if (error) {
257 dev_err(dev, "unable to claim gpio %u, err=%d\n",
258 button->gpio, error);
259 return error;
260 }
261
262 button->gpiod = gpio_to_desc(button->gpio);
276 } 263 }
277 264
278 bdata->can_sleep = gpio_cansleep(gpio); 265 if (IS_ERR(button->gpiod))
266 return PTR_ERR(button->gpiod);
267
268 bdata->can_sleep = gpiod_cansleep(button->gpiod);
279 bdata->last_state = -1; 269 bdata->last_state = -1;
280 bdata->threshold = DIV_ROUND_UP(button->debounce_interval, 270 bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
281 pdata->poll_interval); 271 pdata->poll_interval);
@@ -308,7 +298,7 @@ static struct platform_driver gpio_keys_polled_driver = {
308 .driver = { 298 .driver = {
309 .name = DRV_NAME, 299 .name = DRV_NAME,
310 .owner = THIS_MODULE, 300 .owner = THIS_MODULE,
311 .of_match_table = of_match_ptr(gpio_keys_polled_of_match), 301 .of_match_table = gpio_keys_polled_of_match,
312 }, 302 },
313}; 303};
314module_platform_driver(gpio_keys_polled_driver); 304module_platform_driver(gpio_keys_polled_driver);
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 5e80fbf7b5ed..c994e3bbd776 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -463,7 +463,7 @@ static int samsung_keypad_remove(struct platform_device *pdev)
463 return 0; 463 return 0;
464} 464}
465 465
466#ifdef CONFIG_PM_RUNTIME 466#ifdef CONFIG_PM
467static int samsung_keypad_runtime_suspend(struct device *dev) 467static int samsung_keypad_runtime_suspend(struct device *dev)
468{ 468{
469 struct platform_device *pdev = to_platform_device(dev); 469 struct platform_device *pdev = to_platform_device(dev);
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index a035a390f8e2..568a3d340c8a 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -1716,7 +1716,7 @@ static void cyttsp4_free_si_ptrs(struct cyttsp4 *cd)
1716 kfree(si->btn_rec_data); 1716 kfree(si->btn_rec_data);
1717} 1717}
1718 1718
1719#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME) 1719#ifdef CONFIG_PM
1720static int cyttsp4_core_sleep(struct cyttsp4 *cd) 1720static int cyttsp4_core_sleep(struct cyttsp4 *cd)
1721{ 1721{
1722 int rc; 1722 int rc;
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index b4518c8751c8..868e6fc17cba 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -12,25 +12,23 @@
12 */ 12 */
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/gpio/consumer.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/leds.h> 17#include <linux/leds.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/of.h>
19#include <linux/of_gpio.h>
20#include <linux/of_platform.h>
21#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/property.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/workqueue.h> 22#include <linux/workqueue.h>
24 23
25struct gpio_led_data { 24struct gpio_led_data {
26 struct led_classdev cdev; 25 struct led_classdev cdev;
27 unsigned gpio; 26 struct gpio_desc *gpiod;
28 struct work_struct work; 27 struct work_struct work;
29 u8 new_level; 28 u8 new_level;
30 u8 can_sleep; 29 u8 can_sleep;
31 u8 active_low;
32 u8 blinking; 30 u8 blinking;
33 int (*platform_gpio_blink_set)(unsigned gpio, int state, 31 int (*platform_gpio_blink_set)(struct gpio_desc *desc, int state,
34 unsigned long *delay_on, unsigned long *delay_off); 32 unsigned long *delay_on, unsigned long *delay_off);
35}; 33};
36 34
@@ -40,12 +38,11 @@ static void gpio_led_work(struct work_struct *work)
40 container_of(work, struct gpio_led_data, work); 38 container_of(work, struct gpio_led_data, work);
41 39
42 if (led_dat->blinking) { 40 if (led_dat->blinking) {
43 led_dat->platform_gpio_blink_set(led_dat->gpio, 41 led_dat->platform_gpio_blink_set(led_dat->gpiod,
44 led_dat->new_level, 42 led_dat->new_level, NULL, NULL);
45 NULL, NULL);
46 led_dat->blinking = 0; 43 led_dat->blinking = 0;
47 } else 44 } else
48 gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level); 45 gpiod_set_value_cansleep(led_dat->gpiod, led_dat->new_level);
49} 46}
50 47
51static void gpio_led_set(struct led_classdev *led_cdev, 48static void gpio_led_set(struct led_classdev *led_cdev,
@@ -60,9 +57,6 @@ static void gpio_led_set(struct led_classdev *led_cdev,
60 else 57 else
61 level = 1; 58 level = 1;
62 59
63 if (led_dat->active_low)
64 level = !level;
65
66 /* Setting GPIOs with I2C/etc requires a task context, and we don't 60 /* Setting GPIOs with I2C/etc requires a task context, and we don't
67 * seem to have a reliable way to know if we're already in one; so 61 * seem to have a reliable way to know if we're already in one; so
68 * let's just assume the worst. 62 * let's just assume the worst.
@@ -72,11 +66,11 @@ static void gpio_led_set(struct led_classdev *led_cdev,
72 schedule_work(&led_dat->work); 66 schedule_work(&led_dat->work);
73 } else { 67 } else {
74 if (led_dat->blinking) { 68 if (led_dat->blinking) {
75 led_dat->platform_gpio_blink_set(led_dat->gpio, level, 69 led_dat->platform_gpio_blink_set(led_dat->gpiod, level,
76 NULL, NULL); 70 NULL, NULL);
77 led_dat->blinking = 0; 71 led_dat->blinking = 0;
78 } else 72 } else
79 gpio_set_value(led_dat->gpio, level); 73 gpiod_set_value(led_dat->gpiod, level);
80 } 74 }
81} 75}
82 76
@@ -87,34 +81,49 @@ static int gpio_blink_set(struct led_classdev *led_cdev,
87 container_of(led_cdev, struct gpio_led_data, cdev); 81 container_of(led_cdev, struct gpio_led_data, cdev);
88 82
89 led_dat->blinking = 1; 83 led_dat->blinking = 1;
90 return led_dat->platform_gpio_blink_set(led_dat->gpio, GPIO_LED_BLINK, 84 return led_dat->platform_gpio_blink_set(led_dat->gpiod, GPIO_LED_BLINK,
91 delay_on, delay_off); 85 delay_on, delay_off);
92} 86}
93 87
94static int create_gpio_led(const struct gpio_led *template, 88static int create_gpio_led(const struct gpio_led *template,
95 struct gpio_led_data *led_dat, struct device *parent, 89 struct gpio_led_data *led_dat, struct device *parent,
96 int (*blink_set)(unsigned, int, unsigned long *, unsigned long *)) 90 int (*blink_set)(struct gpio_desc *, int, unsigned long *,
91 unsigned long *))
97{ 92{
98 int ret, state; 93 int ret, state;
99 94
100 led_dat->gpio = -1; 95 led_dat->gpiod = template->gpiod;
96 if (!led_dat->gpiod) {
97 /*
98 * This is the legacy code path for platform code that
99 * still uses GPIO numbers. Ultimately we would like to get
100 * rid of this block completely.
101 */
102 unsigned long flags = 0;
103
104 /* skip leds that aren't available */
105 if (!gpio_is_valid(template->gpio)) {
106 dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n",
107 template->gpio, template->name);
108 return 0;
109 }
101 110
102 /* skip leds that aren't available */ 111 if (template->active_low)
103 if (!gpio_is_valid(template->gpio)) { 112 flags |= GPIOF_ACTIVE_LOW;
104 dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n",
105 template->gpio, template->name);
106 return 0;
107 }
108 113
109 ret = devm_gpio_request(parent, template->gpio, template->name); 114 ret = devm_gpio_request_one(parent, template->gpio, flags,
110 if (ret < 0) 115 template->name);
111 return ret; 116 if (ret < 0)
117 return ret;
118
119 led_dat->gpiod = gpio_to_desc(template->gpio);
120 if (IS_ERR(led_dat->gpiod))
121 return PTR_ERR(led_dat->gpiod);
122 }
112 123
113 led_dat->cdev.name = template->name; 124 led_dat->cdev.name = template->name;
114 led_dat->cdev.default_trigger = template->default_trigger; 125 led_dat->cdev.default_trigger = template->default_trigger;
115 led_dat->gpio = template->gpio; 126 led_dat->can_sleep = gpiod_cansleep(led_dat->gpiod);
116 led_dat->can_sleep = gpio_cansleep(template->gpio);
117 led_dat->active_low = template->active_low;
118 led_dat->blinking = 0; 127 led_dat->blinking = 0;
119 if (blink_set) { 128 if (blink_set) {
120 led_dat->platform_gpio_blink_set = blink_set; 129 led_dat->platform_gpio_blink_set = blink_set;
@@ -122,30 +131,24 @@ static int create_gpio_led(const struct gpio_led *template,
122 } 131 }
123 led_dat->cdev.brightness_set = gpio_led_set; 132 led_dat->cdev.brightness_set = gpio_led_set;
124 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) 133 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP)
125 state = !!gpio_get_value_cansleep(led_dat->gpio) ^ led_dat->active_low; 134 state = !!gpiod_get_value_cansleep(led_dat->gpiod);
126 else 135 else
127 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); 136 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
128 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; 137 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
129 if (!template->retain_state_suspended) 138 if (!template->retain_state_suspended)
130 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 139 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
131 140
132 ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state); 141 ret = gpiod_direction_output(led_dat->gpiod, state);
133 if (ret < 0) 142 if (ret < 0)
134 return ret; 143 return ret;
135 144
136 INIT_WORK(&led_dat->work, gpio_led_work); 145 INIT_WORK(&led_dat->work, gpio_led_work);
137 146
138 ret = led_classdev_register(parent, &led_dat->cdev); 147 return led_classdev_register(parent, &led_dat->cdev);
139 if (ret < 0)
140 return ret;
141
142 return 0;
143} 148}
144 149
145static void delete_gpio_led(struct gpio_led_data *led) 150static void delete_gpio_led(struct gpio_led_data *led)
146{ 151{
147 if (!gpio_is_valid(led->gpio))
148 return;
149 led_classdev_unregister(&led->cdev); 152 led_classdev_unregister(&led->cdev);
150 cancel_work_sync(&led->work); 153 cancel_work_sync(&led->work);
151} 154}
@@ -161,40 +164,47 @@ static inline int sizeof_gpio_leds_priv(int num_leds)
161 (sizeof(struct gpio_led_data) * num_leds); 164 (sizeof(struct gpio_led_data) * num_leds);
162} 165}
163 166
164/* Code to create from OpenFirmware platform devices */ 167static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
165#ifdef CONFIG_OF_GPIO
166static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
167{ 168{
168 struct device_node *np = pdev->dev.of_node, *child; 169 struct device *dev = &pdev->dev;
170 struct fwnode_handle *child;
169 struct gpio_leds_priv *priv; 171 struct gpio_leds_priv *priv;
170 int count, ret; 172 int count, ret;
173 struct device_node *np;
171 174
172 /* count LEDs in this device, so we know how much to allocate */ 175 count = device_get_child_node_count(dev);
173 count = of_get_available_child_count(np);
174 if (!count) 176 if (!count)
175 return ERR_PTR(-ENODEV); 177 return ERR_PTR(-ENODEV);
176 178
177 for_each_available_child_of_node(np, child) 179 priv = devm_kzalloc(dev, sizeof_gpio_leds_priv(count), GFP_KERNEL);
178 if (of_get_gpio(child, 0) == -EPROBE_DEFER)
179 return ERR_PTR(-EPROBE_DEFER);
180
181 priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count),
182 GFP_KERNEL);
183 if (!priv) 180 if (!priv)
184 return ERR_PTR(-ENOMEM); 181 return ERR_PTR(-ENOMEM);
185 182
186 for_each_available_child_of_node(np, child) { 183 device_for_each_child_node(dev, child) {
187 struct gpio_led led = {}; 184 struct gpio_led led = {};
188 enum of_gpio_flags flags; 185 const char *state = NULL;
189 const char *state; 186
190 187 led.gpiod = devm_get_gpiod_from_child(dev, child);
191 led.gpio = of_get_gpio_flags(child, 0, &flags); 188 if (IS_ERR(led.gpiod)) {
192 led.active_low = flags & OF_GPIO_ACTIVE_LOW; 189 fwnode_handle_put(child);
193 led.name = of_get_property(child, "label", NULL) ? : child->name; 190 goto err;
194 led.default_trigger = 191 }
195 of_get_property(child, "linux,default-trigger", NULL); 192
196 state = of_get_property(child, "default-state", NULL); 193 np = of_node(child);
197 if (state) { 194
195 if (fwnode_property_present(child, "label")) {
196 fwnode_property_read_string(child, "label", &led.name);
197 } else {
198 if (IS_ENABLED(CONFIG_OF) && !led.name && np)
199 led.name = np->name;
200 if (!led.name)
201 return ERR_PTR(-EINVAL);
202 }
203 fwnode_property_read_string(child, "linux,default-trigger",
204 &led.default_trigger);
205
206 if (!fwnode_property_read_string(child, "linux,default_state",
207 &state)) {
198 if (!strcmp(state, "keep")) 208 if (!strcmp(state, "keep"))
199 led.default_state = LEDS_GPIO_DEFSTATE_KEEP; 209 led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
200 else if (!strcmp(state, "on")) 210 else if (!strcmp(state, "on"))
@@ -203,13 +213,13 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
203 led.default_state = LEDS_GPIO_DEFSTATE_OFF; 213 led.default_state = LEDS_GPIO_DEFSTATE_OFF;
204 } 214 }
205 215
206 if (of_get_property(child, "retain-state-suspended", NULL)) 216 if (fwnode_property_present(child, "retain-state-suspended"))
207 led.retain_state_suspended = 1; 217 led.retain_state_suspended = 1;
208 218
209 ret = create_gpio_led(&led, &priv->leds[priv->num_leds++], 219 ret = create_gpio_led(&led, &priv->leds[priv->num_leds++],
210 &pdev->dev, NULL); 220 dev, NULL);
211 if (ret < 0) { 221 if (ret < 0) {
212 of_node_put(child); 222 fwnode_handle_put(child);
213 goto err; 223 goto err;
214 } 224 }
215 } 225 }
@@ -228,12 +238,6 @@ static const struct of_device_id of_gpio_leds_match[] = {
228}; 238};
229 239
230MODULE_DEVICE_TABLE(of, of_gpio_leds_match); 240MODULE_DEVICE_TABLE(of, of_gpio_leds_match);
231#else /* CONFIG_OF_GPIO */
232static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
233{
234 return ERR_PTR(-ENODEV);
235}
236#endif /* CONFIG_OF_GPIO */
237 241
238static int gpio_led_probe(struct platform_device *pdev) 242static int gpio_led_probe(struct platform_device *pdev)
239{ 243{
@@ -261,7 +265,7 @@ static int gpio_led_probe(struct platform_device *pdev)
261 } 265 }
262 } 266 }
263 } else { 267 } else {
264 priv = gpio_leds_create_of(pdev); 268 priv = gpio_leds_create(pdev);
265 if (IS_ERR(priv)) 269 if (IS_ERR(priv))
266 return PTR_ERR(priv); 270 return PTR_ERR(priv);
267 } 271 }
@@ -288,7 +292,7 @@ static struct platform_driver gpio_led_driver = {
288 .driver = { 292 .driver = {
289 .name = "leds-gpio", 293 .name = "leds-gpio",
290 .owner = THIS_MODULE, 294 .owner = THIS_MODULE,
291 .of_match_table = of_match_ptr(of_gpio_leds_match), 295 .of_match_table = of_gpio_leds_match,
292 }, 296 },
293}; 297};
294 298
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index ced47609f5ef..5f0cd5cafea2 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1980,7 +1980,7 @@ static int coda_probe(struct platform_device *pdev)
1980 1980
1981 /* 1981 /*
1982 * Start activated so we can directly call coda_hw_init in 1982 * Start activated so we can directly call coda_hw_init in
1983 * coda_fw_callback regardless of whether CONFIG_PM_RUNTIME is 1983 * coda_fw_callback regardless of whether CONFIG_PM is
1984 * enabled or whether the device is associated with a PM domain. 1984 * enabled or whether the device is associated with a PM domain.
1985 */ 1985 */
1986 pm_runtime_get_noresume(&pdev->dev); 1986 pm_runtime_get_noresume(&pdev->dev);
@@ -2013,7 +2013,7 @@ static int coda_remove(struct platform_device *pdev)
2013 return 0; 2013 return 0;
2014} 2014}
2015 2015
2016#ifdef CONFIG_PM_RUNTIME 2016#ifdef CONFIG_PM
2017static int coda_runtime_resume(struct device *dev) 2017static int coda_runtime_resume(struct device *dev)
2018{ 2018{
2019 struct coda_dev *cdev = dev_get_drvdata(dev); 2019 struct coda_dev *cdev = dev_get_drvdata(dev);
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index aee92d908e49..f5d85520caf3 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -832,7 +832,7 @@ err:
832 return -ENXIO; 832 return -ENXIO;
833} 833}
834 834
835#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 835#ifdef CONFIG_PM
836static int fimc_m2m_suspend(struct fimc_dev *fimc) 836static int fimc_m2m_suspend(struct fimc_dev *fimc)
837{ 837{
838 unsigned long flags; 838 unsigned long flags;
@@ -871,7 +871,7 @@ static int fimc_m2m_resume(struct fimc_dev *fimc)
871 871
872 return 0; 872 return 0;
873} 873}
874#endif /* CONFIG_PM_RUNTIME || CONFIG_PM_SLEEP */ 874#endif /* CONFIG_PM */
875 875
876static const struct of_device_id fimc_of_match[]; 876static const struct of_device_id fimc_of_match[];
877 877
@@ -1039,7 +1039,7 @@ err_sclk:
1039 return ret; 1039 return ret;
1040} 1040}
1041 1041
1042#ifdef CONFIG_PM_RUNTIME 1042#ifdef CONFIG_PM
1043static int fimc_runtime_resume(struct device *dev) 1043static int fimc_runtime_resume(struct device *dev)
1044{ 1044{
1045 struct fimc_dev *fimc = dev_get_drvdata(dev); 1045 struct fimc_dev *fimc = dev_get_drvdata(dev);
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
index 371cad4fcce9..d83033170789 100644
--- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -81,7 +81,7 @@ static int fimc_is_i2c_remove(struct platform_device *pdev)
81 return 0; 81 return 0;
82} 82}
83 83
84#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 84#ifdef CONFIG_PM
85static int fimc_is_i2c_runtime_suspend(struct device *dev) 85static int fimc_is_i2c_runtime_suspend(struct device *dev)
86{ 86{
87 struct fimc_is_i2c *isp_i2c = dev_get_drvdata(dev); 87 struct fimc_is_i2c *isp_i2c = dev_get_drvdata(dev);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index a97d2352f1d7..6c1eb308f7b5 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1588,7 +1588,7 @@ err_clk_put:
1588 return ret; 1588 return ret;
1589} 1589}
1590 1590
1591#ifdef CONFIG_PM_RUNTIME 1591#ifdef CONFIG_PM
1592static int fimc_lite_runtime_resume(struct device *dev) 1592static int fimc_lite_runtime_resume(struct device *dev)
1593{ 1593{
1594 struct fimc_lite *fimc = dev_get_drvdata(dev); 1594 struct fimc_lite *fimc = dev_get_drvdata(dev);
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index db6fd14d1936..be5d6fc895cb 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -978,7 +978,7 @@ static int s5pcsis_resume(struct device *dev)
978} 978}
979#endif 979#endif
980 980
981#ifdef CONFIG_PM_RUNTIME 981#ifdef CONFIG_PM
982static int s5pcsis_runtime_suspend(struct device *dev) 982static int s5pcsis_runtime_suspend(struct device *dev)
983{ 983{
984 return s5pcsis_pm_suspend(dev, true); 984 return s5pcsis_pm_suspend(dev, true);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 6fcc7f072ace..fe2727413f3a 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -2632,7 +2632,7 @@ static int s5p_jpeg_remove(struct platform_device *pdev)
2632 return 0; 2632 return 0;
2633} 2633}
2634 2634
2635#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) 2635#ifdef CONFIG_PM
2636static int s5p_jpeg_runtime_suspend(struct device *dev) 2636static int s5p_jpeg_runtime_suspend(struct device *dev)
2637{ 2637{
2638 struct s5p_jpeg *jpeg = dev_get_drvdata(dev); 2638 struct s5p_jpeg *jpeg = dev_get_drvdata(dev);
@@ -2682,7 +2682,7 @@ static int s5p_jpeg_runtime_resume(struct device *dev)
2682 2682
2683 return 0; 2683 return 0;
2684} 2684}
2685#endif /* CONFIG_PM_RUNTIME || CONFIG_PM_SLEEP */ 2685#endif /* CONFIG_PM */
2686 2686
2687#ifdef CONFIG_PM_SLEEP 2687#ifdef CONFIG_PM_SLEEP
2688static int s5p_jpeg_suspend(struct device *dev) 2688static int s5p_jpeg_suspend(struct device *dev)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 165bc86c5962..363fd8c0a699 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1302,7 +1302,7 @@ static int s5p_mfc_resume(struct device *dev)
1302} 1302}
1303#endif 1303#endif
1304 1304
1305#ifdef CONFIG_PM_RUNTIME 1305#ifdef CONFIG_PM
1306static int s5p_mfc_runtime_suspend(struct device *dev) 1306static int s5p_mfc_runtime_suspend(struct device *dev)
1307{ 1307{
1308 struct platform_device *pdev = to_platform_device(dev); 1308 struct platform_device *pdev = to_platform_device(dev);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 826c48945bf5..5f97a3398c11 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -13,9 +13,7 @@
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#ifdef CONFIG_PM_RUNTIME
17#include <linux/pm_runtime.h> 16#include <linux/pm_runtime.h>
18#endif
19#include "s5p_mfc_common.h" 17#include "s5p_mfc_common.h"
20#include "s5p_mfc_debug.h" 18#include "s5p_mfc_debug.h"
21#include "s5p_mfc_pm.h" 19#include "s5p_mfc_pm.h"
@@ -67,7 +65,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
67 } 65 }
68 66
69 atomic_set(&pm->power, 0); 67 atomic_set(&pm->power, 0);
70#ifdef CONFIG_PM_RUNTIME 68#ifdef CONFIG_PM
71 pm->device = &dev->plat_dev->dev; 69 pm->device = &dev->plat_dev->dev;
72 pm_runtime_enable(pm->device); 70 pm_runtime_enable(pm->device);
73#endif 71#endif
@@ -93,7 +91,7 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
93 } 91 }
94 clk_unprepare(pm->clock_gate); 92 clk_unprepare(pm->clock_gate);
95 clk_put(pm->clock_gate); 93 clk_put(pm->clock_gate);
96#ifdef CONFIG_PM_RUNTIME 94#ifdef CONFIG_PM
97 pm_runtime_disable(pm->device); 95 pm_runtime_disable(pm->device);
98#endif 96#endif
99} 97}
@@ -120,7 +118,7 @@ void s5p_mfc_clock_off(void)
120 118
121int s5p_mfc_power_on(void) 119int s5p_mfc_power_on(void)
122{ 120{
123#ifdef CONFIG_PM_RUNTIME 121#ifdef CONFIG_PM
124 return pm_runtime_get_sync(pm->device); 122 return pm_runtime_get_sync(pm->device);
125#else 123#else
126 atomic_set(&pm->power, 1); 124 atomic_set(&pm->power, 1);
@@ -130,7 +128,7 @@ int s5p_mfc_power_on(void)
130 128
131int s5p_mfc_power_off(void) 129int s5p_mfc_power_off(void)
132{ 130{
133#ifdef CONFIG_PM_RUNTIME 131#ifdef CONFIG_PM
134 return pm_runtime_put_sync(pm->device); 132 return pm_runtime_put_sync(pm->device);
135#else 133#else
136 atomic_set(&pm->power, 0); 134 atomic_set(&pm->power, 0);
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 36000f920981..8e3168d160b2 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -867,7 +867,7 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc)
867 gpadc->cal_data[ADC_INPUT_VBAT].offset); 867 gpadc->cal_data[ADC_INPUT_VBAT].offset);
868} 868}
869 869
870#ifdef CONFIG_PM_RUNTIME 870#ifdef CONFIG_PM
871static int ab8500_gpadc_runtime_suspend(struct device *dev) 871static int ab8500_gpadc_runtime_suspend(struct device *dev)
872{ 872{
873 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); 873 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index bce7c0784b6b..09ba8f186e6a 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -330,7 +330,7 @@ err_fll:
330 return err; 330 return err;
331} 331}
332 332
333#ifdef CONFIG_PM_RUNTIME 333#ifdef CONFIG_PM
334static int arizona_runtime_resume(struct device *dev) 334static int arizona_runtime_resume(struct device *dev)
335{ 335{
336 struct arizona *arizona = dev_get_drvdata(dev); 336 struct arizona *arizona = dev_get_drvdata(dev);
@@ -1024,7 +1024,7 @@ int arizona_dev_init(struct arizona *arizona)
1024 goto err_irq; 1024 goto err_irq;
1025 } 1025 }
1026 1026
1027#ifdef CONFIG_PM_RUNTIME 1027#ifdef CONFIG_PM
1028 regulator_disable(arizona->dcvdd); 1028 regulator_disable(arizona->dcvdd);
1029#endif 1029#endif
1030 1030
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index c522ee22b1c0..b1b580a88654 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -354,6 +354,9 @@ static struct mfd_cell axp288_cells[] = {
354 .num_resources = ARRAY_SIZE(axp288_battery_resources), 354 .num_resources = ARRAY_SIZE(axp288_battery_resources),
355 .resources = axp288_battery_resources, 355 .resources = axp288_battery_resources,
356 }, 356 },
357 {
358 .name = "axp288_pmic_acpi",
359 },
357}; 360};
358 361
359static struct axp20x_dev *axp20x_pm_power_off; 362static struct axp20x_dev *axp20x_pm_power_off;
diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c
index 7107cab832e6..c85e2ecb868a 100644
--- a/drivers/mfd/intel_soc_pmic_crc.c
+++ b/drivers/mfd/intel_soc_pmic_crc.c
@@ -106,6 +106,9 @@ static struct mfd_cell crystal_cove_dev[] = {
106 .num_resources = ARRAY_SIZE(gpio_resources), 106 .num_resources = ARRAY_SIZE(gpio_resources),
107 .resources = gpio_resources, 107 .resources = gpio_resources,
108 }, 108 },
109 {
110 .name = "crystal_cove_pmic",
111 },
109}; 112};
110 113
111static struct regmap_config crystal_cove_regmap_config = { 114static struct regmap_config crystal_cove_regmap_config = {
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index e6fab94e2c8a..6ca9d25cc3f0 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -116,7 +116,7 @@ static const char *wm8958_main_supplies[] = {
116 "SPKVDD2", 116 "SPKVDD2",
117}; 117};
118 118
119#ifdef CONFIG_PM_RUNTIME 119#ifdef CONFIG_PM
120static int wm8994_suspend(struct device *dev) 120static int wm8994_suspend(struct device *dev)
121{ 121{
122 struct wm8994 *wm8994 = dev_get_drvdata(dev); 122 struct wm8994 *wm8994 = dev_get_drvdata(dev);
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 868a30a1b417..3739ffa9cdf1 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -609,7 +609,7 @@ static int apds990x_detect(struct apds990x_chip *chip)
609 return ret; 609 return ret;
610} 610}
611 611
612#if defined(CONFIG_PM) || defined(CONFIG_PM_RUNTIME) 612#ifdef CONFIG_PM
613static int apds990x_chip_on(struct apds990x_chip *chip) 613static int apds990x_chip_on(struct apds990x_chip *chip)
614{ 614{
615 int err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), 615 int err = regulator_bulk_enable(ARRAY_SIZE(chip->regs),
@@ -1237,7 +1237,7 @@ static int apds990x_resume(struct device *dev)
1237} 1237}
1238#endif 1238#endif
1239 1239
1240#ifdef CONFIG_PM_RUNTIME 1240#ifdef CONFIG_PM
1241static int apds990x_runtime_suspend(struct device *dev) 1241static int apds990x_runtime_suspend(struct device *dev)
1242{ 1242{
1243 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1243 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index 7b55f8a152d4..b756381b8250 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -1358,7 +1358,7 @@ static int bh1770_resume(struct device *dev)
1358} 1358}
1359#endif 1359#endif
1360 1360
1361#ifdef CONFIG_PM_RUNTIME 1361#ifdef CONFIG_PM
1362static int bh1770_runtime_suspend(struct device *dev) 1362static int bh1770_runtime_suspend(struct device *dev)
1363{ 1363{
1364 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1364 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index 634f72929e12..0a1af93ec638 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -18,7 +18,7 @@
18 18
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/spi/eeprom.h> 20#include <linux/spi/eeprom.h>
21#include <linux/of.h> 21#include <linux/property.h>
22 22
23/* 23/*
24 * NOTE: this is an *EEPROM* driver. The vagaries of product naming 24 * NOTE: this is an *EEPROM* driver. The vagaries of product naming
@@ -301,35 +301,33 @@ static ssize_t at25_mem_write(struct memory_accessor *mem, const char *buf,
301 301
302/*-------------------------------------------------------------------------*/ 302/*-------------------------------------------------------------------------*/
303 303
304static int at25_np_to_chip(struct device *dev, 304static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip)
305 struct device_node *np,
306 struct spi_eeprom *chip)
307{ 305{
308 u32 val; 306 u32 val;
309 307
310 memset(chip, 0, sizeof(*chip)); 308 memset(chip, 0, sizeof(*chip));
311 strncpy(chip->name, np->name, sizeof(chip->name)); 309 strncpy(chip->name, "at25", sizeof(chip->name));
312 310
313 if (of_property_read_u32(np, "size", &val) == 0 || 311 if (device_property_read_u32(dev, "size", &val) == 0 ||
314 of_property_read_u32(np, "at25,byte-len", &val) == 0) { 312 device_property_read_u32(dev, "at25,byte-len", &val) == 0) {
315 chip->byte_len = val; 313 chip->byte_len = val;
316 } else { 314 } else {
317 dev_err(dev, "Error: missing \"size\" property\n"); 315 dev_err(dev, "Error: missing \"size\" property\n");
318 return -ENODEV; 316 return -ENODEV;
319 } 317 }
320 318
321 if (of_property_read_u32(np, "pagesize", &val) == 0 || 319 if (device_property_read_u32(dev, "pagesize", &val) == 0 ||
322 of_property_read_u32(np, "at25,page-size", &val) == 0) { 320 device_property_read_u32(dev, "at25,page-size", &val) == 0) {
323 chip->page_size = (u16)val; 321 chip->page_size = (u16)val;
324 } else { 322 } else {
325 dev_err(dev, "Error: missing \"pagesize\" property\n"); 323 dev_err(dev, "Error: missing \"pagesize\" property\n");
326 return -ENODEV; 324 return -ENODEV;
327 } 325 }
328 326
329 if (of_property_read_u32(np, "at25,addr-mode", &val) == 0) { 327 if (device_property_read_u32(dev, "at25,addr-mode", &val) == 0) {
330 chip->flags = (u16)val; 328 chip->flags = (u16)val;
331 } else { 329 } else {
332 if (of_property_read_u32(np, "address-width", &val)) { 330 if (device_property_read_u32(dev, "address-width", &val)) {
333 dev_err(dev, 331 dev_err(dev,
334 "Error: missing \"address-width\" property\n"); 332 "Error: missing \"address-width\" property\n");
335 return -ENODEV; 333 return -ENODEV;
@@ -350,7 +348,7 @@ static int at25_np_to_chip(struct device *dev,
350 val); 348 val);
351 return -ENODEV; 349 return -ENODEV;
352 } 350 }
353 if (of_find_property(np, "read-only", NULL)) 351 if (device_property_present(dev, "read-only"))
354 chip->flags |= EE_READONLY; 352 chip->flags |= EE_READONLY;
355 } 353 }
356 return 0; 354 return 0;
@@ -360,21 +358,15 @@ static int at25_probe(struct spi_device *spi)
360{ 358{
361 struct at25_data *at25 = NULL; 359 struct at25_data *at25 = NULL;
362 struct spi_eeprom chip; 360 struct spi_eeprom chip;
363 struct device_node *np = spi->dev.of_node;
364 int err; 361 int err;
365 int sr; 362 int sr;
366 int addrlen; 363 int addrlen;
367 364
368 /* Chip description */ 365 /* Chip description */
369 if (!spi->dev.platform_data) { 366 if (!spi->dev.platform_data) {
370 if (np) { 367 err = at25_fw_to_chip(&spi->dev, &chip);
371 err = at25_np_to_chip(&spi->dev, np, &chip); 368 if (err)
372 if (err) 369 return err;
373 return err;
374 } else {
375 dev_err(&spi->dev, "Error: no chip description\n");
376 return -ENODEV;
377 }
378 } else 370 } else
379 chip = *(struct spi_eeprom *)spi->dev.platform_data; 371 chip = *(struct spi_eeprom *)spi->dev.platform_data;
380 372
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
index d324f8a97b88..63fe096d4462 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
@@ -235,7 +235,7 @@ static int lis3lv02d_i2c_resume(struct device *dev)
235} 235}
236#endif /* CONFIG_PM_SLEEP */ 236#endif /* CONFIG_PM_SLEEP */
237 237
238#ifdef CONFIG_PM_RUNTIME 238#ifdef CONFIG_PM
239static int lis3_i2c_runtime_suspend(struct device *dev) 239static int lis3_i2c_runtime_suspend(struct device *dev)
240{ 240{
241 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 241 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
@@ -253,7 +253,7 @@ static int lis3_i2c_runtime_resume(struct device *dev)
253 lis3lv02d_poweron(lis3); 253 lis3lv02d_poweron(lis3);
254 return 0; 254 return 0;
255} 255}
256#endif /* CONFIG_PM_RUNTIME */ 256#endif /* CONFIG_PM */
257 257
258static const struct i2c_device_id lis3lv02d_id[] = { 258static const struct i2c_device_id lis3lv02d_id[] = {
259 {"lis3lv02d", LIS3LV02D}, 259 {"lis3lv02d", LIS3LV02D},
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 71744b16cc8c..61b04d7646f1 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -530,9 +530,9 @@ struct mei_device {
530 * Power Gating support 530 * Power Gating support
531 */ 531 */
532 enum mei_pg_event pg_event; 532 enum mei_pg_event pg_event;
533#ifdef CONFIG_PM_RUNTIME 533#ifdef CONFIG_PM
534 struct dev_pm_domain pg_domain; 534 struct dev_pm_domain pg_domain;
535#endif /* CONFIG_PM_RUNTIME */ 535#endif /* CONFIG_PM */
536 536
537 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; 537 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE];
538 u32 rd_msg_hdr; 538 u32 rd_msg_hdr;
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index f3225b1643ab..cf20d397068a 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -89,13 +89,13 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
89 89
90MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl); 90MODULE_DEVICE_TABLE(pci, mei_me_pci_tbl);
91 91
92#ifdef CONFIG_PM_RUNTIME 92#ifdef CONFIG_PM
93static inline void mei_me_set_pm_domain(struct mei_device *dev); 93static inline void mei_me_set_pm_domain(struct mei_device *dev);
94static inline void mei_me_unset_pm_domain(struct mei_device *dev); 94static inline void mei_me_unset_pm_domain(struct mei_device *dev);
95#else 95#else
96static inline void mei_me_set_pm_domain(struct mei_device *dev) {} 96static inline void mei_me_set_pm_domain(struct mei_device *dev) {}
97static inline void mei_me_unset_pm_domain(struct mei_device *dev) {} 97static inline void mei_me_unset_pm_domain(struct mei_device *dev) {}
98#endif /* CONFIG_PM_RUNTIME */ 98#endif /* CONFIG_PM */
99 99
100/** 100/**
101 * mei_me_quirk_probe - probe for devices that doesn't valid ME interface 101 * mei_me_quirk_probe - probe for devices that doesn't valid ME interface
@@ -357,7 +357,7 @@ static int mei_me_pci_resume(struct device *device)
357} 357}
358#endif /* CONFIG_PM_SLEEP */ 358#endif /* CONFIG_PM_SLEEP */
359 359
360#ifdef CONFIG_PM_RUNTIME 360#ifdef CONFIG_PM
361static int mei_me_pm_runtime_idle(struct device *device) 361static int mei_me_pm_runtime_idle(struct device *device)
362{ 362{
363 struct pci_dev *pdev = to_pci_dev(device); 363 struct pci_dev *pdev = to_pci_dev(device);
@@ -453,9 +453,7 @@ static inline void mei_me_unset_pm_domain(struct mei_device *dev)
453 /* stop using pm callbacks if any */ 453 /* stop using pm callbacks if any */
454 dev->dev->pm_domain = NULL; 454 dev->dev->pm_domain = NULL;
455} 455}
456#endif /* CONFIG_PM_RUNTIME */
457 456
458#ifdef CONFIG_PM
459static const struct dev_pm_ops mei_me_pm_ops = { 457static const struct dev_pm_ops mei_me_pm_ops = {
460 SET_SYSTEM_SLEEP_PM_OPS(mei_me_pci_suspend, 458 SET_SYSTEM_SLEEP_PM_OPS(mei_me_pci_suspend,
461 mei_me_pci_resume) 459 mei_me_pci_resume)
diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
index bee1c6fb7e75..1f572deacf54 100644
--- a/drivers/misc/mei/pci-txe.c
+++ b/drivers/misc/mei/pci-txe.c
@@ -42,13 +42,13 @@ static const struct pci_device_id mei_txe_pci_tbl[] = {
42}; 42};
43MODULE_DEVICE_TABLE(pci, mei_txe_pci_tbl); 43MODULE_DEVICE_TABLE(pci, mei_txe_pci_tbl);
44 44
45#ifdef CONFIG_PM_RUNTIME 45#ifdef CONFIG_PM
46static inline void mei_txe_set_pm_domain(struct mei_device *dev); 46static inline void mei_txe_set_pm_domain(struct mei_device *dev);
47static inline void mei_txe_unset_pm_domain(struct mei_device *dev); 47static inline void mei_txe_unset_pm_domain(struct mei_device *dev);
48#else 48#else
49static inline void mei_txe_set_pm_domain(struct mei_device *dev) {} 49static inline void mei_txe_set_pm_domain(struct mei_device *dev) {}
50static inline void mei_txe_unset_pm_domain(struct mei_device *dev) {} 50static inline void mei_txe_unset_pm_domain(struct mei_device *dev) {}
51#endif /* CONFIG_PM_RUNTIME */ 51#endif /* CONFIG_PM */
52 52
53static void mei_txe_pci_iounmap(struct pci_dev *pdev, struct mei_txe_hw *hw) 53static void mei_txe_pci_iounmap(struct pci_dev *pdev, struct mei_txe_hw *hw)
54{ 54{
@@ -295,7 +295,7 @@ static int mei_txe_pci_resume(struct device *device)
295} 295}
296#endif /* CONFIG_PM_SLEEP */ 296#endif /* CONFIG_PM_SLEEP */
297 297
298#ifdef CONFIG_PM_RUNTIME 298#ifdef CONFIG_PM
299static int mei_txe_pm_runtime_idle(struct device *device) 299static int mei_txe_pm_runtime_idle(struct device *device)
300{ 300{
301 struct pci_dev *pdev = to_pci_dev(device); 301 struct pci_dev *pdev = to_pci_dev(device);
@@ -401,9 +401,7 @@ static inline void mei_txe_unset_pm_domain(struct mei_device *dev)
401 /* stop using pm callbacks if any */ 401 /* stop using pm callbacks if any */
402 dev->dev->pm_domain = NULL; 402 dev->dev->pm_domain = NULL;
403} 403}
404#endif /* CONFIG_PM_RUNTIME */
405 404
406#ifdef CONFIG_PM
407static const struct dev_pm_ops mei_txe_pm_ops = { 405static const struct dev_pm_ops mei_txe_pm_ops = {
408 SET_SYSTEM_SLEEP_PM_OPS(mei_txe_pci_suspend, 406 SET_SYSTEM_SLEEP_PM_OPS(mei_txe_pci_suspend,
409 mei_txe_pci_resume) 407 mei_txe_pci_resume)
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 5ca562ccfcf3..86d271148528 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -152,7 +152,7 @@ static int mmc_bus_resume(struct device *dev)
152} 152}
153#endif 153#endif
154 154
155#ifdef CONFIG_PM_RUNTIME 155#ifdef CONFIG_PM
156static int mmc_runtime_suspend(struct device *dev) 156static int mmc_runtime_suspend(struct device *dev)
157{ 157{
158 struct mmc_card *card = mmc_dev_to_card(dev); 158 struct mmc_card *card = mmc_dev_to_card(dev);
@@ -168,7 +168,7 @@ static int mmc_runtime_resume(struct device *dev)
168 168
169 return host->bus_ops->runtime_resume(host); 169 return host->bus_ops->runtime_resume(host);
170} 170}
171#endif /* !CONFIG_PM_RUNTIME */ 171#endif /* !CONFIG_PM */
172 172
173static const struct dev_pm_ops mmc_bus_pm_ops = { 173static const struct dev_pm_ops mmc_bus_pm_ops = {
174 SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, NULL) 174 SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, NULL)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 53bf7a4b5839..8232e9a02d40 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1850,7 +1850,7 @@ static int mmci_runtime_resume(struct device *dev)
1850static const struct dev_pm_ops mmci_dev_pm_ops = { 1850static const struct dev_pm_ops mmci_dev_pm_ops = {
1851 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1851 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1852 pm_runtime_force_resume) 1852 pm_runtime_force_resume)
1853 SET_PM_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL) 1853 SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
1854}; 1854};
1855 1855
1856static struct amba_id mmci_ids[] = { 1856static struct amba_id mmci_ids[] = {
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index daba49ac1242..c01eac7c8196 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -430,7 +430,7 @@ static int sdhci_acpi_resume(struct device *dev)
430 430
431#endif 431#endif
432 432
433#ifdef CONFIG_PM_RUNTIME 433#ifdef CONFIG_PM
434 434
435static int sdhci_acpi_runtime_suspend(struct device *dev) 435static int sdhci_acpi_runtime_suspend(struct device *dev)
436{ 436{
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 12711ab51aed..af1f7c0f9545 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1108,7 +1108,7 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1108 pm_runtime_dont_use_autosuspend(&pdev->dev); 1108 pm_runtime_dont_use_autosuspend(&pdev->dev);
1109 pm_runtime_disable(&pdev->dev); 1109 pm_runtime_disable(&pdev->dev);
1110 1110
1111 if (!IS_ENABLED(CONFIG_PM_RUNTIME)) { 1111 if (!IS_ENABLED(CONFIG_PM)) {
1112 clk_disable_unprepare(imx_data->clk_per); 1112 clk_disable_unprepare(imx_data->clk_per);
1113 clk_disable_unprepare(imx_data->clk_ipg); 1113 clk_disable_unprepare(imx_data->clk_ipg);
1114 clk_disable_unprepare(imx_data->clk_ahb); 1114 clk_disable_unprepare(imx_data->clk_ahb);
@@ -1119,7 +1119,7 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
1119 return 0; 1119 return 0;
1120} 1120}
1121 1121
1122#ifdef CONFIG_PM_RUNTIME 1122#ifdef CONFIG_PM
1123static int sdhci_esdhc_runtime_suspend(struct device *dev) 1123static int sdhci_esdhc_runtime_suspend(struct device *dev)
1124{ 1124{
1125 struct sdhci_host *host = dev_get_drvdata(dev); 1125 struct sdhci_host *host = dev_get_drvdata(dev);
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 95f73007fccf..03427755b902 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -134,7 +134,7 @@ static int pch_hc_probe_slot(struct sdhci_pci_slot *slot)
134 return 0; 134 return 0;
135} 135}
136 136
137#ifdef CONFIG_PM_RUNTIME 137#ifdef CONFIG_PM
138 138
139static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) 139static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id)
140{ 140{
@@ -1276,15 +1276,6 @@ static int sdhci_pci_resume(struct device *dev)
1276 return 0; 1276 return 0;
1277} 1277}
1278 1278
1279#else /* CONFIG_PM */
1280
1281#define sdhci_pci_suspend NULL
1282#define sdhci_pci_resume NULL
1283
1284#endif /* CONFIG_PM */
1285
1286#ifdef CONFIG_PM_RUNTIME
1287
1288static int sdhci_pci_runtime_suspend(struct device *dev) 1279static int sdhci_pci_runtime_suspend(struct device *dev)
1289{ 1280{
1290 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 1281 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
@@ -1356,7 +1347,12 @@ static int sdhci_pci_runtime_idle(struct device *dev)
1356 return 0; 1347 return 0;
1357} 1348}
1358 1349
1359#endif 1350#else /* CONFIG_PM */
1351
1352#define sdhci_pci_suspend NULL
1353#define sdhci_pci_resume NULL
1354
1355#endif /* CONFIG_PM */
1360 1356
1361static const struct dev_pm_ops sdhci_pci_pm_ops = { 1357static const struct dev_pm_ops sdhci_pci_pm_ops = {
1362 .suspend = sdhci_pci_suspend, 1358 .suspend = sdhci_pci_suspend,
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index ad0badad0ebc..45238871192d 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -452,7 +452,7 @@ static int sdhci_pxav3_resume(struct device *dev)
452} 452}
453#endif 453#endif
454 454
455#ifdef CONFIG_PM_RUNTIME 455#ifdef CONFIG_PM
456static int sdhci_pxav3_runtime_suspend(struct device *dev) 456static int sdhci_pxav3_runtime_suspend(struct device *dev)
457{ 457{
458 struct sdhci_host *host = dev_get_drvdata(dev); 458 struct sdhci_host *host = dev_get_drvdata(dev);
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 4f7a63213b33..c45b8932d843 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -615,7 +615,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
615 goto err_req_regs; 615 goto err_req_regs;
616 } 616 }
617 617
618#ifdef CONFIG_PM_RUNTIME 618#ifdef CONFIG_PM
619 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) 619 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
620 clk_disable_unprepare(sc->clk_io); 620 clk_disable_unprepare(sc->clk_io);
621#endif 621#endif
@@ -641,7 +641,7 @@ static int sdhci_s3c_remove(struct platform_device *pdev)
641 if (sc->ext_cd_irq) 641 if (sc->ext_cd_irq)
642 free_irq(sc->ext_cd_irq, sc); 642 free_irq(sc->ext_cd_irq, sc);
643 643
644#ifdef CONFIG_PM_RUNTIME 644#ifdef CONFIG_PM
645 if (sc->pdata->cd_type != S3C_SDHCI_CD_INTERNAL) 645 if (sc->pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
646 clk_prepare_enable(sc->clk_io); 646 clk_prepare_enable(sc->clk_io);
647#endif 647#endif
@@ -673,7 +673,7 @@ static int sdhci_s3c_resume(struct device *dev)
673} 673}
674#endif 674#endif
675 675
676#ifdef CONFIG_PM_RUNTIME 676#ifdef CONFIG_PM
677static int sdhci_s3c_runtime_suspend(struct device *dev) 677static int sdhci_s3c_runtime_suspend(struct device *dev)
678{ 678{
679 struct sdhci_host *host = dev_get_drvdata(dev); 679 struct sdhci_host *host = dev_get_drvdata(dev);
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 73de62a58d70..cbb245b58538 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -54,7 +54,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
54static void sdhci_tuning_timer(unsigned long data); 54static void sdhci_tuning_timer(unsigned long data);
55static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable); 55static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable);
56 56
57#ifdef CONFIG_PM_RUNTIME 57#ifdef CONFIG_PM
58static int sdhci_runtime_pm_get(struct sdhci_host *host); 58static int sdhci_runtime_pm_get(struct sdhci_host *host);
59static int sdhci_runtime_pm_put(struct sdhci_host *host); 59static int sdhci_runtime_pm_put(struct sdhci_host *host);
60static void sdhci_runtime_pm_bus_on(struct sdhci_host *host); 60static void sdhci_runtime_pm_bus_on(struct sdhci_host *host);
@@ -2697,9 +2697,6 @@ int sdhci_resume_host(struct sdhci_host *host)
2697} 2697}
2698 2698
2699EXPORT_SYMBOL_GPL(sdhci_resume_host); 2699EXPORT_SYMBOL_GPL(sdhci_resume_host);
2700#endif /* CONFIG_PM */
2701
2702#ifdef CONFIG_PM_RUNTIME
2703 2700
2704static int sdhci_runtime_pm_get(struct sdhci_host *host) 2701static int sdhci_runtime_pm_get(struct sdhci_host *host)
2705{ 2702{
@@ -2800,7 +2797,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
2800} 2797}
2801EXPORT_SYMBOL_GPL(sdhci_runtime_resume_host); 2798EXPORT_SYMBOL_GPL(sdhci_runtime_resume_host);
2802 2799
2803#endif 2800#endif /* CONFIG_PM */
2804 2801
2805/*****************************************************************************\ 2802/*****************************************************************************\
2806 * * 2803 * *
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index ddd31cda2370..41a2c34299ed 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -454,9 +454,6 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
454extern int sdhci_suspend_host(struct sdhci_host *host); 454extern int sdhci_suspend_host(struct sdhci_host *host);
455extern int sdhci_resume_host(struct sdhci_host *host); 455extern int sdhci_resume_host(struct sdhci_host *host);
456extern void sdhci_enable_irq_wakeups(struct sdhci_host *host); 456extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
457#endif
458
459#ifdef CONFIG_PM_RUNTIME
460extern int sdhci_runtime_suspend_host(struct sdhci_host *host); 457extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
461extern int sdhci_runtime_resume_host(struct sdhci_host *host); 458extern int sdhci_runtime_resume_host(struct sdhci_host *host);
462#endif 459#endif
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index a2e81a1ea6af..00c8ebdf8ec7 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -375,7 +375,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
375static const struct dev_pm_ops tmio_mmc_dev_pm_ops = { 375static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
376 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 376 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
377 pm_runtime_force_resume) 377 pm_runtime_force_resume)
378 SET_PM_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend, 378 SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
379 tmio_mmc_host_runtime_resume, 379 tmio_mmc_host_runtime_resume,
380 NULL) 380 NULL)
381}; 381};
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 659028ddb8b1..2616fdfdbbeb 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -135,7 +135,7 @@ static int tmio_mmc_remove(struct platform_device *pdev)
135 135
136static const struct dev_pm_ops tmio_mmc_dev_pm_ops = { 136static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
137 SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume) 137 SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume)
138 SET_PM_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend, 138 SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
139 tmio_mmc_host_runtime_resume, 139 tmio_mmc_host_runtime_resume,
140 NULL) 140 NULL)
141}; 141};
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 247335d2c7ec..952ef7c434e8 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -6372,7 +6372,6 @@ static int e1000e_pm_resume(struct device *dev)
6372} 6372}
6373#endif /* CONFIG_PM_SLEEP */ 6373#endif /* CONFIG_PM_SLEEP */
6374 6374
6375#ifdef CONFIG_PM_RUNTIME
6376static int e1000e_pm_runtime_idle(struct device *dev) 6375static int e1000e_pm_runtime_idle(struct device *dev)
6377{ 6376{
6378 struct pci_dev *pdev = to_pci_dev(dev); 6377 struct pci_dev *pdev = to_pci_dev(dev);
@@ -6432,7 +6431,6 @@ static int e1000e_pm_runtime_suspend(struct device *dev)
6432 6431
6433 return 0; 6432 return 0;
6434} 6433}
6435#endif /* CONFIG_PM_RUNTIME */
6436#endif /* CONFIG_PM */ 6434#endif /* CONFIG_PM */
6437 6435
6438static void e1000_shutdown(struct pci_dev *pdev) 6436static void e1000_shutdown(struct pci_dev *pdev)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 487cd9c4ac0d..b85880a6e4c4 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -186,11 +186,9 @@ static int igb_pci_enable_sriov(struct pci_dev *dev, int num_vfs);
186static int igb_suspend(struct device *); 186static int igb_suspend(struct device *);
187#endif 187#endif
188static int igb_resume(struct device *); 188static int igb_resume(struct device *);
189#ifdef CONFIG_PM_RUNTIME
190static int igb_runtime_suspend(struct device *dev); 189static int igb_runtime_suspend(struct device *dev);
191static int igb_runtime_resume(struct device *dev); 190static int igb_runtime_resume(struct device *dev);
192static int igb_runtime_idle(struct device *dev); 191static int igb_runtime_idle(struct device *dev);
193#endif
194static const struct dev_pm_ops igb_pm_ops = { 192static const struct dev_pm_ops igb_pm_ops = {
195 SET_SYSTEM_SLEEP_PM_OPS(igb_suspend, igb_resume) 193 SET_SYSTEM_SLEEP_PM_OPS(igb_suspend, igb_resume)
196 SET_RUNTIME_PM_OPS(igb_runtime_suspend, igb_runtime_resume, 194 SET_RUNTIME_PM_OPS(igb_runtime_suspend, igb_runtime_resume,
@@ -7450,7 +7448,6 @@ static int igb_resume(struct device *dev)
7450 return 0; 7448 return 0;
7451} 7449}
7452 7450
7453#ifdef CONFIG_PM_RUNTIME
7454static int igb_runtime_idle(struct device *dev) 7451static int igb_runtime_idle(struct device *dev)
7455{ 7452{
7456 struct pci_dev *pdev = to_pci_dev(dev); 7453 struct pci_dev *pdev = to_pci_dev(dev);
@@ -7487,8 +7484,7 @@ static int igb_runtime_resume(struct device *dev)
7487{ 7484{
7488 return igb_resume(dev); 7485 return igb_resume(dev);
7489} 7486}
7490#endif /* CONFIG_PM_RUNTIME */ 7487#endif /* CONFIG_PM */
7491#endif
7492 7488
7493static void igb_shutdown(struct pci_dev *pdev) 7489static void igb_shutdown(struct pci_dev *pdev)
7494{ 7490{
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 3823edf2d012..4c2ccde42427 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1250,6 +1250,39 @@ int of_property_read_u64(const struct device_node *np, const char *propname,
1250EXPORT_SYMBOL_GPL(of_property_read_u64); 1250EXPORT_SYMBOL_GPL(of_property_read_u64);
1251 1251
1252/** 1252/**
1253 * of_property_read_u64_array - Find and read an array of 64 bit integers
1254 * from a property.
1255 *
1256 * @np: device node from which the property value is to be read.
1257 * @propname: name of the property to be searched.
1258 * @out_values: pointer to return value, modified only if return value is 0.
1259 * @sz: number of array elements to read
1260 *
1261 * Search for a property in a device node and read 64-bit value(s) from
1262 * it. Returns 0 on success, -EINVAL if the property does not exist,
1263 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1264 * property data isn't large enough.
1265 *
1266 * The out_values is modified only if a valid u64 value can be decoded.
1267 */
1268int of_property_read_u64_array(const struct device_node *np,
1269 const char *propname, u64 *out_values,
1270 size_t sz)
1271{
1272 const __be32 *val = of_find_property_value_of_size(np, propname,
1273 (sz * sizeof(*out_values)));
1274
1275 if (IS_ERR(val))
1276 return PTR_ERR(val);
1277
1278 while (sz--) {
1279 *out_values++ = of_read_number(val, 2);
1280 val += 2;
1281 }
1282 return 0;
1283}
1284
1285/**
1253 * of_property_read_string - Find and read a string from a property 1286 * of_property_read_string - Find and read a string from a property
1254 * @np: device node from which the property value is to be read. 1287 * @np: device node from which the property value is to be read.
1255 * @propname: name of the property to be searched. 1288 * @propname: name of the property to be searched.
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 2b3c89425bb5..887e6bd95af7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1104,7 +1104,7 @@ static int pci_pm_restore(struct device *dev)
1104 1104
1105#endif /* !CONFIG_HIBERNATE_CALLBACKS */ 1105#endif /* !CONFIG_HIBERNATE_CALLBACKS */
1106 1106
1107#ifdef CONFIG_PM_RUNTIME 1107#ifdef CONFIG_PM
1108 1108
1109static int pci_pm_runtime_suspend(struct device *dev) 1109static int pci_pm_runtime_suspend(struct device *dev)
1110{ 1110{
@@ -1200,16 +1200,6 @@ static int pci_pm_runtime_idle(struct device *dev)
1200 return ret; 1200 return ret;
1201} 1201}
1202 1202
1203#else /* !CONFIG_PM_RUNTIME */
1204
1205#define pci_pm_runtime_suspend NULL
1206#define pci_pm_runtime_resume NULL
1207#define pci_pm_runtime_idle NULL
1208
1209#endif /* !CONFIG_PM_RUNTIME */
1210
1211#ifdef CONFIG_PM
1212
1213static const struct dev_pm_ops pci_dev_pm_ops = { 1203static const struct dev_pm_ops pci_dev_pm_ops = {
1214 .prepare = pci_pm_prepare, 1204 .prepare = pci_pm_prepare,
1215 .suspend = pci_pm_suspend, 1205 .suspend = pci_pm_suspend,
@@ -1231,11 +1221,15 @@ static const struct dev_pm_ops pci_dev_pm_ops = {
1231 1221
1232#define PCI_PM_OPS_PTR (&pci_dev_pm_ops) 1222#define PCI_PM_OPS_PTR (&pci_dev_pm_ops)
1233 1223
1234#else /* !COMFIG_PM_OPS */ 1224#else /* !CONFIG_PM */
1225
1226#define pci_pm_runtime_suspend NULL
1227#define pci_pm_runtime_resume NULL
1228#define pci_pm_runtime_idle NULL
1235 1229
1236#define PCI_PM_OPS_PTR NULL 1230#define PCI_PM_OPS_PTR NULL
1237 1231
1238#endif /* !COMFIG_PM_OPS */ 1232#endif /* !CONFIG_PM */
1239 1233
1240/** 1234/**
1241 * __pci_register_driver - register a new pci driver 1235 * __pci_register_driver - register a new pci driver
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a5addbc9c026..a62acc443d5b 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -410,7 +410,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
410} 410}
411static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store); 411static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store);
412 412
413#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 413#if defined(CONFIG_PM) && defined(CONFIG_ACPI)
414static ssize_t d3cold_allowed_store(struct device *dev, 414static ssize_t d3cold_allowed_store(struct device *dev,
415 struct device_attribute *attr, 415 struct device_attribute *attr,
416 const char *buf, size_t count) 416 const char *buf, size_t count)
@@ -591,7 +591,7 @@ static struct attribute *pci_dev_attrs[] = {
591 &dev_attr_enable.attr, 591 &dev_attr_enable.attr,
592 &dev_attr_broken_parity_status.attr, 592 &dev_attr_broken_parity_status.attr,
593 &dev_attr_msi_bus.attr, 593 &dev_attr_msi_bus.attr,
594#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 594#if defined(CONFIG_PM) && defined(CONFIG_ACPI)
595 &dev_attr_d3cold_allowed.attr, 595 &dev_attr_d3cold_allowed.attr,
596#endif 596#endif
597#ifdef CONFIG_OF 597#ifdef CONFIG_OF
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index 7958e59d6077..e294713c8143 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -79,4 +79,4 @@ endchoice
79 79
80config PCIE_PME 80config PCIE_PME
81 def_bool y 81 def_bool y
82 depends on PCIEPORTBUS && PM_RUNTIME 82 depends on PCIEPORTBUS && PM
diff --git a/drivers/powercap/Kconfig b/drivers/powercap/Kconfig
index a7c81b53d88a..85727ef6ce8e 100644
--- a/drivers/powercap/Kconfig
+++ b/drivers/powercap/Kconfig
@@ -17,7 +17,7 @@ if POWERCAP
17# Client driver configurations go here. 17# Client driver configurations go here.
18config INTEL_RAPL 18config INTEL_RAPL
19 tristate "Intel RAPL Support" 19 tristate "Intel RAPL Support"
20 depends on X86 20 depends on X86 && IOSF_MBI
21 default n 21 default n
22 ---help--- 22 ---help---
23 This enables support for the Intel Running Average Power Limit (RAPL) 23 This enables support for the Intel Running Average Power Limit (RAPL)
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index 45e05b32f9b6..c71443c4f265 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -29,6 +29,7 @@
29#include <linux/sysfs.h> 29#include <linux/sysfs.h>
30#include <linux/cpu.h> 30#include <linux/cpu.h>
31#include <linux/powercap.h> 31#include <linux/powercap.h>
32#include <asm/iosf_mbi.h>
32 33
33#include <asm/processor.h> 34#include <asm/processor.h>
34#include <asm/cpu_device_id.h> 35#include <asm/cpu_device_id.h>
@@ -70,11 +71,6 @@
70#define RAPL_PRIMITIVE_DERIVED BIT(1) /* not from raw data */ 71#define RAPL_PRIMITIVE_DERIVED BIT(1) /* not from raw data */
71#define RAPL_PRIMITIVE_DUMMY BIT(2) 72#define RAPL_PRIMITIVE_DUMMY BIT(2)
72 73
73/* scale RAPL units to avoid floating point math inside kernel */
74#define POWER_UNIT_SCALE (1000000)
75#define ENERGY_UNIT_SCALE (1000000)
76#define TIME_UNIT_SCALE (1000000)
77
78#define TIME_WINDOW_MAX_MSEC 40000 74#define TIME_WINDOW_MAX_MSEC 40000
79#define TIME_WINDOW_MIN_MSEC 250 75#define TIME_WINDOW_MIN_MSEC 250
80 76
@@ -175,9 +171,9 @@ struct rapl_package {
175 unsigned int id; /* physical package/socket id */ 171 unsigned int id; /* physical package/socket id */
176 unsigned int nr_domains; 172 unsigned int nr_domains;
177 unsigned long domain_map; /* bit map of active domains */ 173 unsigned long domain_map; /* bit map of active domains */
178 unsigned int power_unit_divisor; 174 unsigned int power_unit;
179 unsigned int energy_unit_divisor; 175 unsigned int energy_unit;
180 unsigned int time_unit_divisor; 176 unsigned int time_unit;
181 struct rapl_domain *domains; /* array of domains, sized at runtime */ 177 struct rapl_domain *domains; /* array of domains, sized at runtime */
182 struct powercap_zone *power_zone; /* keep track of parent zone */ 178 struct powercap_zone *power_zone; /* keep track of parent zone */
183 int nr_cpus; /* active cpus on the package, topology info is lost during 179 int nr_cpus; /* active cpus on the package, topology info is lost during
@@ -188,6 +184,18 @@ struct rapl_package {
188 */ 184 */
189 struct list_head plist; 185 struct list_head plist;
190}; 186};
187
188struct rapl_defaults {
189 int (*check_unit)(struct rapl_package *rp, int cpu);
190 void (*set_floor_freq)(struct rapl_domain *rd, bool mode);
191 u64 (*compute_time_window)(struct rapl_package *rp, u64 val,
192 bool to_raw);
193};
194static struct rapl_defaults *rapl_defaults;
195
196/* Sideband MBI registers */
197#define IOSF_CPU_POWER_BUDGET_CTL (0x2)
198
191#define PACKAGE_PLN_INT_SAVED BIT(0) 199#define PACKAGE_PLN_INT_SAVED BIT(0)
192#define MAX_PRIM_NAME (32) 200#define MAX_PRIM_NAME (32)
193 201
@@ -339,23 +347,13 @@ static int find_nr_power_limit(struct rapl_domain *rd)
339static int set_domain_enable(struct powercap_zone *power_zone, bool mode) 347static int set_domain_enable(struct powercap_zone *power_zone, bool mode)
340{ 348{
341 struct rapl_domain *rd = power_zone_to_rapl_domain(power_zone); 349 struct rapl_domain *rd = power_zone_to_rapl_domain(power_zone);
342 int nr_powerlimit;
343 350
344 if (rd->state & DOMAIN_STATE_BIOS_LOCKED) 351 if (rd->state & DOMAIN_STATE_BIOS_LOCKED)
345 return -EACCES; 352 return -EACCES;
353
346 get_online_cpus(); 354 get_online_cpus();
347 nr_powerlimit = find_nr_power_limit(rd);
348 /* here we activate/deactivate the hardware for power limiting */
349 rapl_write_data_raw(rd, PL1_ENABLE, mode); 355 rapl_write_data_raw(rd, PL1_ENABLE, mode);
350 /* always enable clamp such that p-state can go below OS requested 356 rapl_defaults->set_floor_freq(rd, mode);
351 * range. power capping priority over guranteed frequency.
352 */
353 rapl_write_data_raw(rd, PL1_CLAMP, mode);
354 /* some domains have pl2 */
355 if (nr_powerlimit > 1) {
356 rapl_write_data_raw(rd, PL2_ENABLE, mode);
357 rapl_write_data_raw(rd, PL2_CLAMP, mode);
358 }
359 put_online_cpus(); 357 put_online_cpus();
360 358
361 return 0; 359 return 0;
@@ -653,9 +651,7 @@ static void rapl_init_domains(struct rapl_package *rp)
653static u64 rapl_unit_xlate(int package, enum unit_type type, u64 value, 651static u64 rapl_unit_xlate(int package, enum unit_type type, u64 value,
654 int to_raw) 652 int to_raw)
655{ 653{
656 u64 divisor = 1; 654 u64 units = 1;
657 int scale = 1; /* scale to user friendly data without floating point */
658 u64 f, y; /* fraction and exp. used for time unit */
659 struct rapl_package *rp; 655 struct rapl_package *rp;
660 656
661 rp = find_package_by_id(package); 657 rp = find_package_by_id(package);
@@ -664,42 +660,24 @@ static u64 rapl_unit_xlate(int package, enum unit_type type, u64 value,
664 660
665 switch (type) { 661 switch (type) {
666 case POWER_UNIT: 662 case POWER_UNIT:
667 divisor = rp->power_unit_divisor; 663 units = rp->power_unit;
668 scale = POWER_UNIT_SCALE;
669 break; 664 break;
670 case ENERGY_UNIT: 665 case ENERGY_UNIT:
671 scale = ENERGY_UNIT_SCALE; 666 units = rp->energy_unit;
672 divisor = rp->energy_unit_divisor;
673 break; 667 break;
674 case TIME_UNIT: 668 case TIME_UNIT:
675 divisor = rp->time_unit_divisor; 669 return rapl_defaults->compute_time_window(rp, value, to_raw);
676 scale = TIME_UNIT_SCALE;
677 /* special processing based on 2^Y*(1+F)/4 = val/divisor, refer
678 * to Intel Software Developer's manual Vol. 3a, CH 14.7.4.
679 */
680 if (!to_raw) {
681 f = (value & 0x60) >> 5;
682 y = value & 0x1f;
683 value = (1 << y) * (4 + f) * scale / 4;
684 return div64_u64(value, divisor);
685 } else {
686 do_div(value, scale);
687 value *= divisor;
688 y = ilog2(value);
689 f = div64_u64(4 * (value - (1 << y)), 1 << y);
690 value = (y & 0x1f) | ((f & 0x3) << 5);
691 return value;
692 }
693 break;
694 case ARBITRARY_UNIT: 670 case ARBITRARY_UNIT:
695 default: 671 default:
696 return value; 672 return value;
697 }; 673 };
698 674
699 if (to_raw) 675 if (to_raw)
700 return div64_u64(value * divisor, scale); 676 return div64_u64(value, units);
701 else 677
702 return div64_u64(value * scale, divisor); 678 value *= units;
679
680 return value;
703} 681}
704 682
705/* in the order of enum rapl_primitives */ 683/* in the order of enum rapl_primitives */
@@ -833,12 +811,18 @@ static int rapl_write_data_raw(struct rapl_domain *rd,
833 return 0; 811 return 0;
834} 812}
835 813
836static const struct x86_cpu_id energy_unit_quirk_ids[] = { 814/*
837 { X86_VENDOR_INTEL, 6, 0x37},/* Valleyview */ 815 * Raw RAPL data stored in MSRs are in certain scales. We need to
838 {} 816 * convert them into standard units based on the units reported in
839}; 817 * the RAPL unit MSRs. This is specific to CPUs as the method to
840 818 * calculate units differ on different CPUs.
841static int rapl_check_unit(struct rapl_package *rp, int cpu) 819 * We convert the units to below format based on CPUs.
820 * i.e.
821 * energy unit: microJoules : Represented in microJoules by default
822 * power unit : microWatts : Represented in milliWatts by default
823 * time unit : microseconds: Represented in seconds by default
824 */
825static int rapl_check_unit_core(struct rapl_package *rp, int cpu)
842{ 826{
843 u64 msr_val; 827 u64 msr_val;
844 u32 value; 828 u32 value;
@@ -849,36 +833,47 @@ static int rapl_check_unit(struct rapl_package *rp, int cpu)
849 return -ENODEV; 833 return -ENODEV;
850 } 834 }
851 835
852 /* Raw RAPL data stored in MSRs are in certain scales. We need to
853 * convert them into standard units based on the divisors reported in
854 * the RAPL unit MSRs.
855 * i.e.
856 * energy unit: 1/enery_unit_divisor Joules
857 * power unit: 1/power_unit_divisor Watts
858 * time unit: 1/time_unit_divisor Seconds
859 */
860 value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET; 836 value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
861 /* some CPUs have different way to calculate energy unit */ 837 rp->energy_unit = 1000000 / (1 << value);
862 if (x86_match_cpu(energy_unit_quirk_ids))
863 rp->energy_unit_divisor = 1000000 / (1 << value);
864 else
865 rp->energy_unit_divisor = 1 << value;
866 838
867 value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET; 839 value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
868 rp->power_unit_divisor = 1 << value; 840 rp->power_unit = 1000000 / (1 << value);
869 841
870 value = (msr_val & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET; 842 value = (msr_val & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET;
871 rp->time_unit_divisor = 1 << value; 843 rp->time_unit = 1000000 / (1 << value);
872 844
873 pr_debug("Physical package %d units: energy=%d, time=%d, power=%d\n", 845 pr_debug("Core CPU package %d energy=%duJ, time=%dus, power=%duW\n",
874 rp->id, 846 rp->id, rp->energy_unit, rp->time_unit, rp->power_unit);
875 rp->energy_unit_divisor,
876 rp->time_unit_divisor,
877 rp->power_unit_divisor);
878 847
879 return 0; 848 return 0;
880} 849}
881 850
851static int rapl_check_unit_atom(struct rapl_package *rp, int cpu)
852{
853 u64 msr_val;
854 u32 value;
855
856 if (rdmsrl_safe_on_cpu(cpu, MSR_RAPL_POWER_UNIT, &msr_val)) {
857 pr_err("Failed to read power unit MSR 0x%x on CPU %d, exit.\n",
858 MSR_RAPL_POWER_UNIT, cpu);
859 return -ENODEV;
860 }
861 value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
862 rp->energy_unit = 1 << value;
863
864 value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
865 rp->power_unit = (1 << value) * 1000;
866
867 value = (msr_val & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET;
868 rp->time_unit = 1000000 / (1 << value);
869
870 pr_debug("Atom package %d energy=%duJ, time=%dus, power=%duW\n",
871 rp->id, rp->energy_unit, rp->time_unit, rp->power_unit);
872
873 return 0;
874}
875
876
882/* REVISIT: 877/* REVISIT:
883 * When package power limit is set artificially low by RAPL, LVT 878 * When package power limit is set artificially low by RAPL, LVT
884 * thermal interrupt for package power limit should be ignored 879 * thermal interrupt for package power limit should be ignored
@@ -946,16 +941,107 @@ static void package_power_limit_irq_restore(int package_id)
946 wrmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, l, h); 941 wrmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, l, h);
947} 942}
948 943
944static void set_floor_freq_default(struct rapl_domain *rd, bool mode)
945{
946 int nr_powerlimit = find_nr_power_limit(rd);
947
948 /* always enable clamp such that p-state can go below OS requested
949 * range. power capping priority over guranteed frequency.
950 */
951 rapl_write_data_raw(rd, PL1_CLAMP, mode);
952
953 /* some domains have pl2 */
954 if (nr_powerlimit > 1) {
955 rapl_write_data_raw(rd, PL2_ENABLE, mode);
956 rapl_write_data_raw(rd, PL2_CLAMP, mode);
957 }
958}
959
960static void set_floor_freq_atom(struct rapl_domain *rd, bool enable)
961{
962 static u32 power_ctrl_orig_val;
963 u32 mdata;
964
965 if (!power_ctrl_orig_val)
966 iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_PMC_READ,
967 IOSF_CPU_POWER_BUDGET_CTL, &power_ctrl_orig_val);
968 mdata = power_ctrl_orig_val;
969 if (enable) {
970 mdata &= ~(0x7f << 8);
971 mdata |= 1 << 8;
972 }
973 iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_PMC_WRITE,
974 IOSF_CPU_POWER_BUDGET_CTL, mdata);
975}
976
977static u64 rapl_compute_time_window_core(struct rapl_package *rp, u64 value,
978 bool to_raw)
979{
980 u64 f, y; /* fraction and exp. used for time unit */
981
982 /*
983 * Special processing based on 2^Y*(1+F/4), refer
984 * to Intel Software Developer's manual Vol.3B: CH 14.9.3.
985 */
986 if (!to_raw) {
987 f = (value & 0x60) >> 5;
988 y = value & 0x1f;
989 value = (1 << y) * (4 + f) * rp->time_unit / 4;
990 } else {
991 do_div(value, rp->time_unit);
992 y = ilog2(value);
993 f = div64_u64(4 * (value - (1 << y)), 1 << y);
994 value = (y & 0x1f) | ((f & 0x3) << 5);
995 }
996 return value;
997}
998
999static u64 rapl_compute_time_window_atom(struct rapl_package *rp, u64 value,
1000 bool to_raw)
1001{
1002 /*
1003 * Atom time unit encoding is straight forward val * time_unit,
1004 * where time_unit is default to 1 sec. Never 0.
1005 */
1006 if (!to_raw)
1007 return (value) ? value *= rp->time_unit : rp->time_unit;
1008 else
1009 value = div64_u64(value, rp->time_unit);
1010
1011 return value;
1012}
1013
1014static const struct rapl_defaults rapl_defaults_core = {
1015 .check_unit = rapl_check_unit_core,
1016 .set_floor_freq = set_floor_freq_default,
1017 .compute_time_window = rapl_compute_time_window_core,
1018};
1019
1020static const struct rapl_defaults rapl_defaults_atom = {
1021 .check_unit = rapl_check_unit_atom,
1022 .set_floor_freq = set_floor_freq_atom,
1023 .compute_time_window = rapl_compute_time_window_atom,
1024};
1025
1026#define RAPL_CPU(_model, _ops) { \
1027 .vendor = X86_VENDOR_INTEL, \
1028 .family = 6, \
1029 .model = _model, \
1030 .driver_data = (kernel_ulong_t)&_ops, \
1031 }
1032
949static const struct x86_cpu_id rapl_ids[] = { 1033static const struct x86_cpu_id rapl_ids[] = {
950 { X86_VENDOR_INTEL, 6, 0x2a},/* Sandy Bridge */ 1034 RAPL_CPU(0x2a, rapl_defaults_core),/* Sandy Bridge */
951 { X86_VENDOR_INTEL, 6, 0x2d},/* Sandy Bridge EP */ 1035 RAPL_CPU(0x2d, rapl_defaults_core),/* Sandy Bridge EP */
952 { X86_VENDOR_INTEL, 6, 0x37},/* Valleyview */ 1036 RAPL_CPU(0x37, rapl_defaults_atom),/* Valleyview */
953 { X86_VENDOR_INTEL, 6, 0x3a},/* Ivy Bridge */ 1037 RAPL_CPU(0x3a, rapl_defaults_core),/* Ivy Bridge */
954 { X86_VENDOR_INTEL, 6, 0x3c},/* Haswell */ 1038 RAPL_CPU(0x3c, rapl_defaults_core),/* Haswell */
955 { X86_VENDOR_INTEL, 6, 0x3d},/* Broadwell */ 1039 RAPL_CPU(0x3d, rapl_defaults_core),/* Broadwell */
956 { X86_VENDOR_INTEL, 6, 0x3f},/* Haswell */ 1040 RAPL_CPU(0x3f, rapl_defaults_core),/* Haswell */
957 { X86_VENDOR_INTEL, 6, 0x45},/* Haswell ULT */ 1041 RAPL_CPU(0x45, rapl_defaults_core),/* Haswell ULT */
958 /* TODO: Add more CPU IDs after testing */ 1042 RAPL_CPU(0x4C, rapl_defaults_atom),/* Braswell */
1043 RAPL_CPU(0x4A, rapl_defaults_atom),/* Tangier */
1044 RAPL_CPU(0x5A, rapl_defaults_atom),/* Annidale */
959 {} 1045 {}
960}; 1046};
961MODULE_DEVICE_TABLE(x86cpu, rapl_ids); 1047MODULE_DEVICE_TABLE(x86cpu, rapl_ids);
@@ -1241,7 +1327,7 @@ static int rapl_detect_topology(void)
1241 1327
1242 /* check if the package contains valid domains */ 1328 /* check if the package contains valid domains */
1243 if (rapl_detect_domains(new_package, i) || 1329 if (rapl_detect_domains(new_package, i) ||
1244 rapl_check_unit(new_package, i)) { 1330 rapl_defaults->check_unit(new_package, i)) {
1245 kfree(new_package->domains); 1331 kfree(new_package->domains);
1246 kfree(new_package); 1332 kfree(new_package);
1247 /* free up the packages already initialized */ 1333 /* free up the packages already initialized */
@@ -1296,7 +1382,7 @@ static int rapl_add_package(int cpu)
1296 rp->nr_cpus = 1; 1382 rp->nr_cpus = 1;
1297 /* check if the package contains valid domains */ 1383 /* check if the package contains valid domains */
1298 if (rapl_detect_domains(rp, cpu) || 1384 if (rapl_detect_domains(rp, cpu) ||
1299 rapl_check_unit(rp, cpu)) { 1385 rapl_defaults->check_unit(rp, cpu)) {
1300 ret = -ENODEV; 1386 ret = -ENODEV;
1301 goto err_free_package; 1387 goto err_free_package;
1302 } 1388 }
@@ -1358,14 +1444,18 @@ static struct notifier_block rapl_cpu_notifier = {
1358static int __init rapl_init(void) 1444static int __init rapl_init(void)
1359{ 1445{
1360 int ret = 0; 1446 int ret = 0;
1447 const struct x86_cpu_id *id;
1361 1448
1362 if (!x86_match_cpu(rapl_ids)) { 1449 id = x86_match_cpu(rapl_ids);
1450 if (!id) {
1363 pr_err("driver does not support CPU family %d model %d\n", 1451 pr_err("driver does not support CPU family %d model %d\n",
1364 boot_cpu_data.x86, boot_cpu_data.x86_model); 1452 boot_cpu_data.x86, boot_cpu_data.x86_model);
1365 1453
1366 return -ENODEV; 1454 return -ENODEV;
1367 } 1455 }
1368 1456
1457 rapl_defaults = (struct rapl_defaults *)id->driver_data;
1458
1369 cpu_notifier_register_begin(); 1459 cpu_notifier_register_begin();
1370 1460
1371 /* prevent CPU hotplug during detection */ 1461 /* prevent CPU hotplug during detection */
diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c
index fe2c2d595f59..f3ee439d6f0e 100644
--- a/drivers/sh/pm_runtime.c
+++ b/drivers/sh/pm_runtime.c
@@ -20,7 +20,7 @@
20#include <linux/bitmap.h> 20#include <linux/bitmap.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22 22
23#ifdef CONFIG_PM_RUNTIME 23#ifdef CONFIG_PM
24static int sh_pm_runtime_suspend(struct device *dev) 24static int sh_pm_runtime_suspend(struct device *dev)
25{ 25{
26 int ret; 26 int ret;
@@ -68,7 +68,7 @@ static struct dev_pm_domain default_pm_domain = {
68 68
69#define DEFAULT_PM_DOMAIN_PTR NULL 69#define DEFAULT_PM_DOMAIN_PTR NULL
70 70
71#endif /* CONFIG_PM_RUNTIME */ 71#endif /* CONFIG_PM */
72 72
73static struct pm_clk_notifier_block platform_bus_notifier = { 73static struct pm_clk_notifier_block platform_bus_notifier = {
74 .pm_domain = DEFAULT_PM_DOMAIN_PTR, 74 .pm_domain = DEFAULT_PM_DOMAIN_PTR,
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index fc2dd8441608..89ca162801da 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2377,7 +2377,7 @@ static int pl022_runtime_resume(struct device *dev)
2377 2377
2378static const struct dev_pm_ops pl022_dev_pm_ops = { 2378static const struct dev_pm_ops pl022_dev_pm_ops = {
2379 SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume) 2379 SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
2380 SET_PM_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL) 2380 SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
2381}; 2381};
2382 2382
2383static struct vendor_data vendor_arm = { 2383static struct vendor_data vendor_arm = {
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 9bffd26cea05..874dec31a111 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1493,10 +1493,6 @@ int usb_resume(struct device *dev, pm_message_t msg)
1493 return status; 1493 return status;
1494} 1494}
1495 1495
1496#endif /* CONFIG_PM */
1497
1498#ifdef CONFIG_PM_RUNTIME
1499
1500/** 1496/**
1501 * usb_enable_autosuspend - allow a USB device to be autosuspended 1497 * usb_enable_autosuspend - allow a USB device to be autosuspended
1502 * @udev: the USB device which may be autosuspended 1498 * @udev: the USB device which may be autosuspended
@@ -1876,7 +1872,7 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
1876 return ret; 1872 return ret;
1877} 1873}
1878 1874
1879#endif /* CONFIG_PM_RUNTIME */ 1875#endif /* CONFIG_PM */
1880 1876
1881struct bus_type usb_bus_type = { 1877struct bus_type usb_bus_type = {
1882 .name = "usb", 1878 .name = "usb",
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index efc953119ce2..9eb1cff28bd4 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -429,7 +429,6 @@ static int check_root_hub_suspended(struct device *dev)
429 return 0; 429 return 0;
430} 430}
431 431
432#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
433static int suspend_common(struct device *dev, bool do_wakeup) 432static int suspend_common(struct device *dev, bool do_wakeup)
434{ 433{
435 struct pci_dev *pci_dev = to_pci_dev(dev); 434 struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -528,7 +527,6 @@ static int resume_common(struct device *dev, int event)
528 } 527 }
529 return retval; 528 return retval;
530} 529}
531#endif /* SLEEP || RUNTIME */
532 530
533#ifdef CONFIG_PM_SLEEP 531#ifdef CONFIG_PM_SLEEP
534 532
@@ -607,8 +605,6 @@ static int hcd_pci_restore(struct device *dev)
607 605
608#endif /* CONFIG_PM_SLEEP */ 606#endif /* CONFIG_PM_SLEEP */
609 607
610#ifdef CONFIG_PM_RUNTIME
611
612static int hcd_pci_runtime_suspend(struct device *dev) 608static int hcd_pci_runtime_suspend(struct device *dev)
613{ 609{
614 int retval; 610 int retval;
@@ -630,13 +626,6 @@ static int hcd_pci_runtime_resume(struct device *dev)
630 return retval; 626 return retval;
631} 627}
632 628
633#else
634
635#define hcd_pci_runtime_suspend NULL
636#define hcd_pci_runtime_resume NULL
637
638#endif /* CONFIG_PM_RUNTIME */
639
640const struct dev_pm_ops usb_hcd_pci_pm_ops = { 629const struct dev_pm_ops usb_hcd_pci_pm_ops = {
641 .suspend = hcd_pci_suspend, 630 .suspend = hcd_pci_suspend,
642 .suspend_noirq = hcd_pci_suspend_noirq, 631 .suspend_noirq = hcd_pci_suspend_noirq,
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index a6efb4184f2b..278be0515e8e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2258,10 +2258,6 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
2258 return status; 2258 return status;
2259} 2259}
2260 2260
2261#endif /* CONFIG_PM */
2262
2263#ifdef CONFIG_PM_RUNTIME
2264
2265/* Workqueue routine for root-hub remote wakeup */ 2261/* Workqueue routine for root-hub remote wakeup */
2266static void hcd_resume_work(struct work_struct *work) 2262static void hcd_resume_work(struct work_struct *work)
2267{ 2263{
@@ -2293,7 +2289,7 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
2293} 2289}
2294EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); 2290EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
2295 2291
2296#endif /* CONFIG_PM_RUNTIME */ 2292#endif /* CONFIG_PM */
2297 2293
2298/*-------------------------------------------------------------------------*/ 2294/*-------------------------------------------------------------------------*/
2299 2295
@@ -2476,7 +2472,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
2476 init_timer(&hcd->rh_timer); 2472 init_timer(&hcd->rh_timer);
2477 hcd->rh_timer.function = rh_timer_func; 2473 hcd->rh_timer.function = rh_timer_func;
2478 hcd->rh_timer.data = (unsigned long) hcd; 2474 hcd->rh_timer.data = (unsigned long) hcd;
2479#ifdef CONFIG_PM_RUNTIME 2475#ifdef CONFIG_PM
2480 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2476 INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
2481#endif 2477#endif
2482 2478
@@ -2790,7 +2786,7 @@ error_create_attr_group:
2790 hcd->rh_registered = 0; 2786 hcd->rh_registered = 0;
2791 spin_unlock_irq(&hcd_root_hub_lock); 2787 spin_unlock_irq(&hcd_root_hub_lock);
2792 2788
2793#ifdef CONFIG_PM_RUNTIME 2789#ifdef CONFIG_PM
2794 cancel_work_sync(&hcd->wakeup_work); 2790 cancel_work_sync(&hcd->wakeup_work);
2795#endif 2791#endif
2796 mutex_lock(&usb_bus_list_lock); 2792 mutex_lock(&usb_bus_list_lock);
@@ -2858,7 +2854,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
2858 hcd->rh_registered = 0; 2854 hcd->rh_registered = 0;
2859 spin_unlock_irq (&hcd_root_hub_lock); 2855 spin_unlock_irq (&hcd_root_hub_lock);
2860 2856
2861#ifdef CONFIG_PM_RUNTIME 2857#ifdef CONFIG_PM
2862 cancel_work_sync(&hcd->wakeup_work); 2858 cancel_work_sync(&hcd->wakeup_work);
2863#endif 2859#endif
2864 2860
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b649fef2e35d..c9596525ba8c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1737,7 +1737,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1737 * - If user has indicated to prevent autosuspend by passing 1737 * - If user has indicated to prevent autosuspend by passing
1738 * usbcore.autosuspend = -1 then keep autosuspend disabled. 1738 * usbcore.autosuspend = -1 then keep autosuspend disabled.
1739 */ 1739 */
1740#ifdef CONFIG_PM_RUNTIME 1740#ifdef CONFIG_PM
1741 if (hdev->dev.power.autosuspend_delay >= 0) 1741 if (hdev->dev.power.autosuspend_delay >= 0)
1742 pm_runtime_set_autosuspend_delay(&hdev->dev, 0); 1742 pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
1743#endif 1743#endif
@@ -3449,7 +3449,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3449 return status; 3449 return status;
3450} 3450}
3451 3451
3452#ifdef CONFIG_PM_RUNTIME 3452#ifdef CONFIG_PM
3453 3453
3454int usb_remote_wakeup(struct usb_device *udev) 3454int usb_remote_wakeup(struct usb_device *udev)
3455{ 3455{
@@ -4856,7 +4856,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4856 udev->state != USB_STATE_NOTATTACHED) { 4856 udev->state != USB_STATE_NOTATTACHED) {
4857 if (portstatus & USB_PORT_STAT_ENABLE) { 4857 if (portstatus & USB_PORT_STAT_ENABLE) {
4858 status = 0; /* Nothing to do */ 4858 status = 0; /* Nothing to do */
4859#ifdef CONFIG_PM_RUNTIME 4859#ifdef CONFIG_PM
4860 } else if (udev->state == USB_STATE_SUSPENDED && 4860 } else if (udev->state == USB_STATE_SUSPENDED &&
4861 udev->persist_enabled) { 4861 udev->persist_enabled) {
4862 /* For a suspended device, treat this as a 4862 /* For a suspended device, treat this as a
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index cd3f9dc24a06..210618319f10 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -72,7 +72,7 @@ static void usb_port_device_release(struct device *dev)
72 kfree(port_dev); 72 kfree(port_dev);
73} 73}
74 74
75#ifdef CONFIG_PM_RUNTIME 75#ifdef CONFIG_PM
76static int usb_port_runtime_resume(struct device *dev) 76static int usb_port_runtime_resume(struct device *dev)
77{ 77{
78 struct usb_port *port_dev = to_usb_port(dev); 78 struct usb_port *port_dev = to_usb_port(dev);
@@ -171,7 +171,7 @@ static int usb_port_runtime_suspend(struct device *dev)
171#endif 171#endif
172 172
173static const struct dev_pm_ops usb_port_pm_ops = { 173static const struct dev_pm_ops usb_port_pm_ops = {
174#ifdef CONFIG_PM_RUNTIME 174#ifdef CONFIG_PM
175 .runtime_suspend = usb_port_runtime_suspend, 175 .runtime_suspend = usb_port_runtime_suspend,
176 .runtime_resume = usb_port_runtime_resume, 176 .runtime_resume = usb_port_runtime_resume,
177#endif 177#endif
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 1236c6011c70..d26973844a4d 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -334,14 +334,6 @@ static void remove_persist_attributes(struct device *dev)
334 &dev_attr_persist.attr, 334 &dev_attr_persist.attr,
335 power_group_name); 335 power_group_name);
336} 336}
337#else
338
339#define add_persist_attributes(dev) 0
340#define remove_persist_attributes(dev) do {} while (0)
341
342#endif /* CONFIG_PM */
343
344#ifdef CONFIG_PM_RUNTIME
345 337
346static ssize_t connected_duration_show(struct device *dev, 338static ssize_t connected_duration_show(struct device *dev,
347 struct device_attribute *attr, char *buf) 339 struct device_attribute *attr, char *buf)
@@ -585,10 +577,13 @@ static void remove_power_attributes(struct device *dev)
585 577
586#else 578#else
587 579
580#define add_persist_attributes(dev) 0
581#define remove_persist_attributes(dev) do {} while (0)
582
588#define add_power_attributes(dev) 0 583#define add_power_attributes(dev) 0
589#define remove_power_attributes(dev) do {} while (0) 584#define remove_power_attributes(dev) do {} while (0)
590 585
591#endif /* CONFIG_PM_RUNTIME */ 586#endif /* CONFIG_PM */
592 587
593 588
594/* Descriptor fields */ 589/* Descriptor fields */
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 2dd2362198d2..2a92b97f0144 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -49,7 +49,7 @@ const char *usbcore_name = "usbcore";
49 49
50static bool nousb; /* Disable USB when built into kernel image */ 50static bool nousb; /* Disable USB when built into kernel image */
51 51
52#ifdef CONFIG_PM_RUNTIME 52#ifdef CONFIG_PM
53static int usb_autosuspend_delay = 2; /* Default delay value, 53static int usb_autosuspend_delay = 2; /* Default delay value,
54 * in seconds */ 54 * in seconds */
55module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); 55module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
@@ -348,11 +348,9 @@ static const struct dev_pm_ops usb_device_pm_ops = {
348 .thaw = usb_dev_thaw, 348 .thaw = usb_dev_thaw,
349 .poweroff = usb_dev_poweroff, 349 .poweroff = usb_dev_poweroff,
350 .restore = usb_dev_restore, 350 .restore = usb_dev_restore,
351#ifdef CONFIG_PM_RUNTIME
352 .runtime_suspend = usb_runtime_suspend, 351 .runtime_suspend = usb_runtime_suspend,
353 .runtime_resume = usb_runtime_resume, 352 .runtime_resume = usb_runtime_resume,
354 .runtime_idle = usb_runtime_idle, 353 .runtime_idle = usb_runtime_idle,
355#endif
356}; 354};
357 355
358#endif /* CONFIG_PM */ 356#endif /* CONFIG_PM */
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index b1b34d0557c9..7eb1e26798e5 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -75,6 +75,14 @@ extern int usb_resume_complete(struct device *dev);
75extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); 75extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
76extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); 76extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
77 77
78extern void usb_autosuspend_device(struct usb_device *udev);
79extern int usb_autoresume_device(struct usb_device *udev);
80extern int usb_remote_wakeup(struct usb_device *dev);
81extern int usb_runtime_suspend(struct device *dev);
82extern int usb_runtime_resume(struct device *dev);
83extern int usb_runtime_idle(struct device *dev);
84extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
85
78#else 86#else
79 87
80static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg) 88static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
@@ -87,20 +95,6 @@ static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
87 return 0; 95 return 0;
88} 96}
89 97
90#endif
91
92#ifdef CONFIG_PM_RUNTIME
93
94extern void usb_autosuspend_device(struct usb_device *udev);
95extern int usb_autoresume_device(struct usb_device *udev);
96extern int usb_remote_wakeup(struct usb_device *dev);
97extern int usb_runtime_suspend(struct device *dev);
98extern int usb_runtime_resume(struct device *dev);
99extern int usb_runtime_idle(struct device *dev);
100extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
101
102#else
103
104#define usb_autosuspend_device(udev) do {} while (0) 98#define usb_autosuspend_device(udev) do {} while (0)
105static inline int usb_autoresume_device(struct usb_device *udev) 99static inline int usb_autoresume_device(struct usb_device *udev)
106{ 100{
@@ -111,6 +105,7 @@ static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
111{ 105{
112 return 0; 106 return 0;
113} 107}
108
114#endif 109#endif
115 110
116extern struct bus_type usb_bus_type; 111extern struct bus_type usb_bus_type;
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index ca7b964124af..851006a0d97b 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -305,7 +305,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
305 } 305 }
306 } 306 }
307 307
308#ifdef CONFIG_PM_RUNTIME 308#ifdef CONFIG_PM
309 if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) 309 if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev))
310 ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 310 ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
311#endif 311#endif
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index ad0c348e68e9..25fb1da8d3d7 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -22,7 +22,7 @@
22 * and usb-storage. 22 * and usb-storage.
23 * 23 *
24 * TODO: 24 * TODO:
25 * - usb suspend/resume triggered by sl811 (with PM_RUNTIME) 25 * - usb suspend/resume triggered by sl811
26 * - various issues noted in the code 26 * - various issues noted in the code
27 * - performance work; use both register banks; ... 27 * - performance work; use both register banks; ...
28 * - use urb->iso_frame_desc[] with ISO transfers 28 * - use urb->iso_frame_desc[] with ISO transfers
@@ -1752,8 +1752,7 @@ sl811h_probe(struct platform_device *dev)
1752#ifdef CONFIG_PM 1752#ifdef CONFIG_PM
1753 1753
1754/* for this device there's no useful distinction between the controller 1754/* for this device there's no useful distinction between the controller
1755 * and its root hub, except that the root hub only gets direct PM calls 1755 * and its root hub.
1756 * when CONFIG_PM_RUNTIME is enabled.
1757 */ 1756 */
1758 1757
1759static int 1758static int
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index c0671750671f..bf86630b3cea 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3144,8 +3144,7 @@ static int u132_probe(struct platform_device *pdev)
3144#ifdef CONFIG_PM 3144#ifdef CONFIG_PM
3145/* 3145/*
3146 * for this device there's no useful distinction between the controller 3146 * for this device there's no useful distinction between the controller
3147 * and its root hub, except that the root hub only gets direct PM calls 3147 * and its root hub.
3148 * when CONFIG_PM_RUNTIME is enabled.
3149 */ 3148 */
3150static int u132_suspend(struct platform_device *pdev, pm_message_t state) 3149static int u132_suspend(struct platform_device *pdev, pm_message_t state)
3151{ 3150{
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 388cfd83b6b6..a7865c4b0498 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1145,7 +1145,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1145 set_bit(port_index, &bus_state->bus_suspended); 1145 set_bit(port_index, &bus_state->bus_suspended);
1146 } 1146 }
1147 /* USB core sets remote wake mask for USB 3.0 hubs, 1147 /* USB core sets remote wake mask for USB 3.0 hubs,
1148 * including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME 1148 * including the USB 3.0 roothub, but only if CONFIG_PM
1149 * is enabled, so also enable remote wake here. 1149 * is enabled, so also enable remote wake here.
1150 */ 1150 */
1151 if (hcd->self.root_hub->do_remote_wakeup) { 1151 if (hcd->self.root_hub->do_remote_wakeup) {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 033b46c470bd..cf3413116aff 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4029,7 +4029,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
4029 return ret; 4029 return ret;
4030} 4030}
4031 4031
4032#ifdef CONFIG_PM_RUNTIME 4032#ifdef CONFIG_PM
4033 4033
4034/* BESL to HIRD Encoding array for USB2 LPM */ 4034/* BESL to HIRD Encoding array for USB2 LPM */
4035static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000, 4035static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000,
@@ -4244,24 +4244,8 @@ int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4244 return 0; 4244 return 0;
4245} 4245}
4246 4246
4247#else
4248
4249int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4250 struct usb_device *udev, int enable)
4251{
4252 return 0;
4253}
4254
4255int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4256{
4257 return 0;
4258}
4259
4260#endif /* CONFIG_PM_RUNTIME */
4261
4262/*---------------------- USB 3.0 Link PM functions ------------------------*/ 4247/*---------------------- USB 3.0 Link PM functions ------------------------*/
4263 4248
4264#ifdef CONFIG_PM
4265/* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */ 4249/* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */
4266static unsigned long long xhci_service_interval_to_ns( 4250static unsigned long long xhci_service_interval_to_ns(
4267 struct usb_endpoint_descriptor *desc) 4251 struct usb_endpoint_descriptor *desc)
@@ -4692,6 +4676,17 @@ int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd,
4692} 4676}
4693#else /* CONFIG_PM */ 4677#else /* CONFIG_PM */
4694 4678
4679int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4680 struct usb_device *udev, int enable)
4681{
4682 return 0;
4683}
4684
4685int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4686{
4687 return 0;
4688}
4689
4695int xhci_enable_usb3_lpm_timeout(struct usb_hcd *hcd, 4690int xhci_enable_usb3_lpm_timeout(struct usb_hcd *hcd,
4696 struct usb_device *udev, enum usb3_link_state state) 4691 struct usb_device *udev, enum usb3_link_state state)
4697{ 4692{
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7843ef7dd0ff..29be0e654ecc 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1761,7 +1761,7 @@ static int msm_otg_remove(struct platform_device *pdev)
1761 return 0; 1761 return 0;
1762} 1762}
1763 1763
1764#ifdef CONFIG_PM_RUNTIME 1764#ifdef CONFIG_PM
1765static int msm_otg_runtime_idle(struct device *dev) 1765static int msm_otg_runtime_idle(struct device *dev)
1766{ 1766{
1767 struct msm_otg *motg = dev_get_drvdata(dev); 1767 struct msm_otg *motg = dev_get_drvdata(dev);
diff --git a/include/acpi/acbuffer.h b/include/acpi/acbuffer.h
index 88cb477524a6..d5ec6c87810f 100644
--- a/include/acpi/acbuffer.h
+++ b/include/acpi/acbuffer.h
@@ -111,7 +111,9 @@ struct acpi_gtm_info {
111struct acpi_pld_info { 111struct acpi_pld_info {
112 u8 revision; 112 u8 revision;
113 u8 ignore_color; 113 u8 ignore_color;
114 u32 color; 114 u8 red;
115 u8 green;
116 u8 blue;
115 u16 width; 117 u16 width;
116 u16 height; 118 u16 height;
117 u8 user_visible; 119 u8 user_visible;
@@ -155,8 +157,14 @@ struct acpi_pld_info {
155#define ACPI_PLD_GET_IGNORE_COLOR(dword) ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK) 157#define ACPI_PLD_GET_IGNORE_COLOR(dword) ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK)
156#define ACPI_PLD_SET_IGNORE_COLOR(dword,value) ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value) /* Offset 7, Len 1 */ 158#define ACPI_PLD_SET_IGNORE_COLOR(dword,value) ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value) /* Offset 7, Len 1 */
157 159
158#define ACPI_PLD_GET_COLOR(dword) ACPI_GET_BITS (dword, 8, ACPI_24BIT_MASK) 160#define ACPI_PLD_GET_RED(dword) ACPI_GET_BITS (dword, 8, ACPI_8BIT_MASK)
159#define ACPI_PLD_SET_COLOR(dword,value) ACPI_SET_BITS (dword, 8, ACPI_24BIT_MASK, value) /* Offset 8, Len 24 */ 161#define ACPI_PLD_SET_RED(dword,value) ACPI_SET_BITS (dword, 8, ACPI_8BIT_MASK, value) /* Offset 8, Len 8 */
162
163#define ACPI_PLD_GET_GREEN(dword) ACPI_GET_BITS (dword, 16, ACPI_8BIT_MASK)
164#define ACPI_PLD_SET_GREEN(dword,value) ACPI_SET_BITS (dword, 16, ACPI_8BIT_MASK, value) /* Offset 16, Len 8 */
165
166#define ACPI_PLD_GET_BLUE(dword) ACPI_GET_BITS (dword, 24, ACPI_8BIT_MASK)
167#define ACPI_PLD_SET_BLUE(dword,value) ACPI_SET_BITS (dword, 24, ACPI_8BIT_MASK, value) /* Offset 24, Len 8 */
160 168
161/* Second 32-bit dword, bits 33:63 */ 169/* Second 32-bit dword, bits 33:63 */
162 170
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index f34a0835aa4f..7581518e3eff 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -27,6 +27,7 @@
27#define __ACPI_BUS_H__ 27#define __ACPI_BUS_H__
28 28
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/property.h>
30 31
31/* TBD: Make dynamic */ 32/* TBD: Make dynamic */
32#define ACPI_MAX_HANDLES 10 33#define ACPI_MAX_HANDLES 10
@@ -337,10 +338,20 @@ struct acpi_device_physical_node {
337 bool put_online:1; 338 bool put_online:1;
338}; 339};
339 340
341/* ACPI Device Specific Data (_DSD) */
342struct acpi_device_data {
343 const union acpi_object *pointer;
344 const union acpi_object *properties;
345 const union acpi_object *of_compatible;
346};
347
348struct acpi_gpio_mapping;
349
340/* Device */ 350/* Device */
341struct acpi_device { 351struct acpi_device {
342 int device_type; 352 int device_type;
343 acpi_handle handle; /* no handle for fixed hardware */ 353 acpi_handle handle; /* no handle for fixed hardware */
354 struct fwnode_handle fwnode;
344 struct acpi_device *parent; 355 struct acpi_device *parent;
345 struct list_head children; 356 struct list_head children;
346 struct list_head node; 357 struct list_head node;
@@ -353,17 +364,35 @@ struct acpi_device {
353 struct acpi_device_wakeup wakeup; 364 struct acpi_device_wakeup wakeup;
354 struct acpi_device_perf performance; 365 struct acpi_device_perf performance;
355 struct acpi_device_dir dir; 366 struct acpi_device_dir dir;
367 struct acpi_device_data data;
356 struct acpi_scan_handler *handler; 368 struct acpi_scan_handler *handler;
357 struct acpi_hotplug_context *hp; 369 struct acpi_hotplug_context *hp;
358 struct acpi_driver *driver; 370 struct acpi_driver *driver;
371 const struct acpi_gpio_mapping *driver_gpios;
359 void *driver_data; 372 void *driver_data;
360 struct device dev; 373 struct device dev;
361 unsigned int physical_node_count; 374 unsigned int physical_node_count;
375 unsigned int dep_unmet;
362 struct list_head physical_node_list; 376 struct list_head physical_node_list;
363 struct mutex physical_node_lock; 377 struct mutex physical_node_lock;
364 void (*remove)(struct acpi_device *); 378 void (*remove)(struct acpi_device *);
365}; 379};
366 380
381static inline bool is_acpi_node(struct fwnode_handle *fwnode)
382{
383 return fwnode && fwnode->type == FWNODE_ACPI;
384}
385
386static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode)
387{
388 return fwnode ? container_of(fwnode, struct acpi_device, fwnode) : NULL;
389}
390
391static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
392{
393 return &adev->fwnode;
394}
395
367static inline void *acpi_driver_data(struct acpi_device *d) 396static inline void *acpi_driver_data(struct acpi_device *d)
368{ 397{
369 return d->driver_data; 398 return d->driver_data;
@@ -516,6 +545,7 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
516 void (*work_func)(struct work_struct *work)); 545 void (*work_func)(struct work_struct *work));
517acpi_status acpi_remove_pm_notifier(struct acpi_device *adev); 546acpi_status acpi_remove_pm_notifier(struct acpi_device *adev);
518int acpi_pm_device_sleep_state(struct device *, int *, int); 547int acpi_pm_device_sleep_state(struct device *, int *, int);
548int acpi_pm_device_run_wake(struct device *, bool);
519#else 549#else
520static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, 550static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
521 struct device *dev, 551 struct device *dev,
@@ -535,11 +565,6 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
535 return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ? 565 return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
536 m : ACPI_STATE_D0; 566 m : ACPI_STATE_D0;
537} 567}
538#endif
539
540#ifdef CONFIG_PM_RUNTIME
541int acpi_pm_device_run_wake(struct device *, bool);
542#else
543static inline int acpi_pm_device_run_wake(struct device *dev, bool enable) 568static inline int acpi_pm_device_run_wake(struct device *dev, bool enable)
544{ 569{
545 return -ENODEV; 570 return -ENODEV;
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index ab2acf629a64..5ba78464c1b1 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
46 46
47/* Current ACPICA subsystem version in YYYYMMDD format */ 47/* Current ACPICA subsystem version in YYYYMMDD format */
48 48
49#define ACPI_CA_VERSION 0x20140926 49#define ACPI_CA_VERSION 0x20141107
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 7000e66f768e..bbef17368e49 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -736,6 +736,10 @@ typedef u32 acpi_event_status;
736#define ACPI_GPE_ENABLE 0 736#define ACPI_GPE_ENABLE 0
737#define ACPI_GPE_DISABLE 1 737#define ACPI_GPE_DISABLE 1
738#define ACPI_GPE_CONDITIONAL_ENABLE 2 738#define ACPI_GPE_CONDITIONAL_ENABLE 2
739#define ACPI_GPE_SAVE_MASK 4
740
741#define ACPI_GPE_ENABLE_SAVE (ACPI_GPE_ENABLE | ACPI_GPE_SAVE_MASK)
742#define ACPI_GPE_DISABLE_SAVE (ACPI_GPE_DISABLE | ACPI_GPE_SAVE_MASK)
739 743
740/* 744/*
741 * GPE info flags - Per GPE 745 * GPE info flags - Per GPE
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 9b9b6f29bbf3..3ca9b751f122 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -67,9 +67,6 @@ struct acpi_processor_cx {
67}; 67};
68 68
69struct acpi_processor_power { 69struct acpi_processor_power {
70 struct acpi_processor_cx *state;
71 unsigned long bm_check_timestamp;
72 u32 default_state;
73 int count; 70 int count;
74 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; 71 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
75 int timer_broadcast_on_state; 72 int timer_broadcast_on_state;
@@ -313,11 +310,13 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
313#endif /* CONFIG_CPU_FREQ */ 310#endif /* CONFIG_CPU_FREQ */
314 311
315/* in processor_core.c */ 312/* in processor_core.c */
316void acpi_processor_set_pdc(acpi_handle handle);
317int acpi_get_apicid(acpi_handle, int type, u32 acpi_id); 313int acpi_get_apicid(acpi_handle, int type, u32 acpi_id);
318int acpi_map_cpuid(int apic_id, u32 acpi_id); 314int acpi_map_cpuid(int apic_id, u32 acpi_id);
319int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
320 316
317/* in processor_pdc.c */
318void acpi_processor_set_pdc(acpi_handle handle);
319
321/* in processor_throttling.c */ 320/* in processor_throttling.c */
322int acpi_processor_tstate_has_changed(struct acpi_processor *pr); 321int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
323int acpi_processor_get_throttling_info(struct acpi_processor *pr); 322int acpi_processor_get_throttling_info(struct acpi_processor *pr);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 407a12f663eb..6bff83b1f298 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -28,6 +28,7 @@
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/ioport.h> /* for struct resource */ 29#include <linux/ioport.h> /* for struct resource */
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/property.h>
31 32
32#ifndef _LINUX 33#ifndef _LINUX
33#define _LINUX 34#define _LINUX
@@ -123,6 +124,10 @@ int acpi_numa_init (void);
123 124
124int acpi_table_init (void); 125int acpi_table_init (void);
125int acpi_table_parse(char *id, acpi_tbl_table_handler handler); 126int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
127int __init acpi_parse_entries(char *id, unsigned long table_size,
128 acpi_tbl_entry_handler handler,
129 struct acpi_table_header *table_header,
130 int entry_id, unsigned int max_entries);
126int __init acpi_table_parse_entries(char *id, unsigned long table_size, 131int __init acpi_table_parse_entries(char *id, unsigned long table_size,
127 int entry_id, 132 int entry_id,
128 acpi_tbl_entry_handler handler, 133 acpi_tbl_entry_handler handler,
@@ -423,14 +428,11 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
423const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 428const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
424 const struct device *dev); 429 const struct device *dev);
425 430
426static inline bool acpi_driver_match_device(struct device *dev, 431extern bool acpi_driver_match_device(struct device *dev,
427 const struct device_driver *drv) 432 const struct device_driver *drv);
428{
429 return !!acpi_match_device(drv->acpi_match_table, dev);
430}
431
432int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); 433int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
433int acpi_device_modalias(struct device *, char *, int); 434int acpi_device_modalias(struct device *, char *, int);
435void acpi_walk_dep_device_list(acpi_handle handle);
434 436
435struct platform_device *acpi_create_platform_device(struct acpi_device *); 437struct platform_device *acpi_create_platform_device(struct acpi_device *);
436#define ACPI_PTR(_ptr) (_ptr) 438#define ACPI_PTR(_ptr) (_ptr)
@@ -443,6 +445,23 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *);
443#define ACPI_COMPANION_SET(dev, adev) do { } while (0) 445#define ACPI_COMPANION_SET(dev, adev) do { } while (0)
444#define ACPI_HANDLE(dev) (NULL) 446#define ACPI_HANDLE(dev) (NULL)
445 447
448struct fwnode_handle;
449
450static inline bool is_acpi_node(struct fwnode_handle *fwnode)
451{
452 return false;
453}
454
455static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode)
456{
457 return NULL;
458}
459
460static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
461{
462 return NULL;
463}
464
446static inline const char *acpi_dev_name(struct acpi_device *adev) 465static inline const char *acpi_dev_name(struct acpi_device *adev)
447{ 466{
448 return NULL; 467 return NULL;
@@ -553,16 +572,26 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr,
553#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) 572#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
554#endif 573#endif
555 574
556#if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME) 575#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
557int acpi_dev_runtime_suspend(struct device *dev); 576int acpi_dev_runtime_suspend(struct device *dev);
558int acpi_dev_runtime_resume(struct device *dev); 577int acpi_dev_runtime_resume(struct device *dev);
559int acpi_subsys_runtime_suspend(struct device *dev); 578int acpi_subsys_runtime_suspend(struct device *dev);
560int acpi_subsys_runtime_resume(struct device *dev); 579int acpi_subsys_runtime_resume(struct device *dev);
580struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
581int acpi_dev_pm_attach(struct device *dev, bool power_on);
561#else 582#else
562static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; } 583static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
563static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; } 584static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
564static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; } 585static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
565static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; } 586static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
587static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
588{
589 return NULL;
590}
591static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
592{
593 return -ENODEV;
594}
566#endif 595#endif
567 596
568#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) 597#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
@@ -585,20 +614,6 @@ static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
585static inline int acpi_subsys_freeze(struct device *dev) { return 0; } 614static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
586#endif 615#endif
587 616
588#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
589struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
590int acpi_dev_pm_attach(struct device *dev, bool power_on);
591#else
592static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
593{
594 return NULL;
595}
596static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
597{
598 return -ENODEV;
599}
600#endif
601
602#ifdef CONFIG_ACPI 617#ifdef CONFIG_ACPI
603__printf(3, 4) 618__printf(3, 4)
604void acpi_handle_printk(const char *level, acpi_handle handle, 619void acpi_handle_printk(const char *level, acpi_handle handle,
@@ -659,4 +674,114 @@ do { \
659#endif 674#endif
660#endif 675#endif
661 676
677struct acpi_gpio_params {
678 unsigned int crs_entry_index;
679 unsigned int line_index;
680 bool active_low;
681};
682
683struct acpi_gpio_mapping {
684 const char *name;
685 const struct acpi_gpio_params *data;
686 unsigned int size;
687};
688
689#if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
690int acpi_dev_add_driver_gpios(struct acpi_device *adev,
691 const struct acpi_gpio_mapping *gpios);
692
693static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
694{
695 if (adev)
696 adev->driver_gpios = NULL;
697}
698#else
699static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
700 const struct acpi_gpio_mapping *gpios)
701{
702 return -ENXIO;
703}
704static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
705#endif
706
707/* Device properties */
708
709#define MAX_ACPI_REFERENCE_ARGS 8
710struct acpi_reference_args {
711 struct acpi_device *adev;
712 size_t nargs;
713 u64 args[MAX_ACPI_REFERENCE_ARGS];
714};
715
716#ifdef CONFIG_ACPI
717int acpi_dev_get_property(struct acpi_device *adev, const char *name,
718 acpi_object_type type, const union acpi_object **obj);
719int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
720 acpi_object_type type,
721 const union acpi_object **obj);
722int acpi_dev_get_property_reference(struct acpi_device *adev,
723 const char *name, size_t index,
724 struct acpi_reference_args *args);
725
726int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
727 void **valptr);
728int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
729 enum dev_prop_type proptype, void *val);
730int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
731 enum dev_prop_type proptype, void *val, size_t nval);
732
733struct acpi_device *acpi_get_next_child(struct device *dev,
734 struct acpi_device *child);
735#else
736static inline int acpi_dev_get_property(struct acpi_device *adev,
737 const char *name, acpi_object_type type,
738 const union acpi_object **obj)
739{
740 return -ENXIO;
741}
742static inline int acpi_dev_get_property_array(struct acpi_device *adev,
743 const char *name,
744 acpi_object_type type,
745 const union acpi_object **obj)
746{
747 return -ENXIO;
748}
749static inline int acpi_dev_get_property_reference(struct acpi_device *adev,
750 const char *name, const char *cells_name,
751 size_t index, struct acpi_reference_args *args)
752{
753 return -ENXIO;
754}
755
756static inline int acpi_dev_prop_get(struct acpi_device *adev,
757 const char *propname,
758 void **valptr)
759{
760 return -ENXIO;
761}
762
763static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
764 const char *propname,
765 enum dev_prop_type proptype,
766 void *val)
767{
768 return -ENXIO;
769}
770
771static inline int acpi_dev_prop_read(struct acpi_device *adev,
772 const char *propname,
773 enum dev_prop_type proptype,
774 void *val, size_t nval)
775{
776 return -ENXIO;
777}
778
779static inline struct acpi_device *acpi_get_next_child(struct device *dev,
780 struct acpi_device *child)
781{
782 return NULL;
783}
784
785#endif
786
662#endif /*_LINUX_ACPI_H*/ 787#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6d76b8b4aa2b..0495e3854247 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -398,7 +398,7 @@ struct request_queue {
398 */ 398 */
399 struct kobject mq_kobj; 399 struct kobject mq_kobj;
400 400
401#ifdef CONFIG_PM_RUNTIME 401#ifdef CONFIG_PM
402 struct device *dev; 402 struct device *dev;
403 int rpm_status; 403 int rpm_status;
404 unsigned int nr_pending; 404 unsigned int nr_pending;
@@ -1057,7 +1057,7 @@ extern void blk_put_queue(struct request_queue *);
1057/* 1057/*
1058 * block layer runtime pm functions 1058 * block layer runtime pm functions
1059 */ 1059 */
1060#ifdef CONFIG_PM_RUNTIME 1060#ifdef CONFIG_PM
1061extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); 1061extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev);
1062extern int blk_pre_runtime_suspend(struct request_queue *q); 1062extern int blk_pre_runtime_suspend(struct request_queue *q);
1063extern void blk_post_runtime_suspend(struct request_queue *q, int err); 1063extern void blk_post_runtime_suspend(struct request_queue *q, int err);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 503b085b7832..4d078cebafd2 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -217,26 +217,26 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
217 217
218 218
219struct cpufreq_driver { 219struct cpufreq_driver {
220 char name[CPUFREQ_NAME_LEN]; 220 char name[CPUFREQ_NAME_LEN];
221 u8 flags; 221 u8 flags;
222 void *driver_data; 222 void *driver_data;
223 223
224 /* needed by all drivers */ 224 /* needed by all drivers */
225 int (*init) (struct cpufreq_policy *policy); 225 int (*init)(struct cpufreq_policy *policy);
226 int (*verify) (struct cpufreq_policy *policy); 226 int (*verify)(struct cpufreq_policy *policy);
227 227
228 /* define one out of two */ 228 /* define one out of two */
229 int (*setpolicy) (struct cpufreq_policy *policy); 229 int (*setpolicy)(struct cpufreq_policy *policy);
230 230
231 /* 231 /*
232 * On failure, should always restore frequency to policy->restore_freq 232 * On failure, should always restore frequency to policy->restore_freq
233 * (i.e. old freq). 233 * (i.e. old freq).
234 */ 234 */
235 int (*target) (struct cpufreq_policy *policy, /* Deprecated */ 235 int (*target)(struct cpufreq_policy *policy,
236 unsigned int target_freq, 236 unsigned int target_freq,
237 unsigned int relation); 237 unsigned int relation); /* Deprecated */
238 int (*target_index) (struct cpufreq_policy *policy, 238 int (*target_index)(struct cpufreq_policy *policy,
239 unsigned int index); 239 unsigned int index);
240 /* 240 /*
241 * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION 241 * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION
242 * unset. 242 * unset.
@@ -252,27 +252,31 @@ struct cpufreq_driver {
252 * wish to switch to intermediate frequency for some target frequency. 252 * wish to switch to intermediate frequency for some target frequency.
253 * In that case core will directly call ->target_index(). 253 * In that case core will directly call ->target_index().
254 */ 254 */
255 unsigned int (*get_intermediate)(struct cpufreq_policy *policy, 255 unsigned int (*get_intermediate)(struct cpufreq_policy *policy,
256 unsigned int index); 256 unsigned int index);
257 int (*target_intermediate)(struct cpufreq_policy *policy, 257 int (*target_intermediate)(struct cpufreq_policy *policy,
258 unsigned int index); 258 unsigned int index);
259 259
260 /* should be defined, if possible */ 260 /* should be defined, if possible */
261 unsigned int (*get) (unsigned int cpu); 261 unsigned int (*get)(unsigned int cpu);
262 262
263 /* optional */ 263 /* optional */
264 int (*bios_limit) (int cpu, unsigned int *limit); 264 int (*bios_limit)(int cpu, unsigned int *limit);
265
266 int (*exit)(struct cpufreq_policy *policy);
267 void (*stop_cpu)(struct cpufreq_policy *policy);
268 int (*suspend)(struct cpufreq_policy *policy);
269 int (*resume)(struct cpufreq_policy *policy);
270
271 /* Will be called after the driver is fully initialized */
272 void (*ready)(struct cpufreq_policy *policy);
265 273
266 int (*exit) (struct cpufreq_policy *policy); 274 struct freq_attr **attr;
267 void (*stop_cpu) (struct cpufreq_policy *policy);
268 int (*suspend) (struct cpufreq_policy *policy);
269 int (*resume) (struct cpufreq_policy *policy);
270 struct freq_attr **attr;
271 275
272 /* platform specific boost support code */ 276 /* platform specific boost support code */
273 bool boost_supported; 277 bool boost_supported;
274 bool boost_enabled; 278 bool boost_enabled;
275 int (*set_boost) (int state); 279 int (*set_boost)(int state);
276}; 280};
277 281
278/* flags */ 282/* flags */
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 25e0df6155a4..a07e087f54b2 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -53,7 +53,7 @@ struct cpuidle_state {
53}; 53};
54 54
55/* Idle State Flags */ 55/* Idle State Flags */
56#define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ 56#define CPUIDLE_FLAG_TIME_INVALID (0x01) /* is residency time measurable? */
57#define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */ 57#define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
58#define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */ 58#define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */
59 59
@@ -90,7 +90,7 @@ DECLARE_PER_CPU(struct cpuidle_device, cpuidle_dev);
90 * cpuidle_get_last_residency - retrieves the last state's residency time 90 * cpuidle_get_last_residency - retrieves the last state's residency time
91 * @dev: the target CPU 91 * @dev: the target CPU
92 * 92 *
93 * NOTE: this value is invalid if CPUIDLE_FLAG_TIME_VALID isn't set 93 * NOTE: this value is invalid if CPUIDLE_FLAG_TIME_INVALID is set
94 */ 94 */
95static inline int cpuidle_get_last_residency(struct cpuidle_device *dev) 95static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
96{ 96{
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 12f146fa6604..00b1b70d68ba 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -94,6 +94,13 @@ int gpiod_to_irq(const struct gpio_desc *desc);
94struct gpio_desc *gpio_to_desc(unsigned gpio); 94struct gpio_desc *gpio_to_desc(unsigned gpio);
95int desc_to_gpio(const struct gpio_desc *desc); 95int desc_to_gpio(const struct gpio_desc *desc);
96 96
97/* Child properties interface */
98struct fwnode_handle;
99
100struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
101 const char *propname);
102struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
103 struct fwnode_handle *child);
97#else /* CONFIG_GPIOLIB */ 104#else /* CONFIG_GPIOLIB */
98 105
99static inline struct gpio_desc *__must_check __gpiod_get(struct device *dev, 106static inline struct gpio_desc *__must_check __gpiod_get(struct device *dev,
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index 8b622468952c..ee2d8c6f9130 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -2,6 +2,7 @@
2#define _GPIO_KEYS_H 2#define _GPIO_KEYS_H
3 3
4struct device; 4struct device;
5struct gpio_desc;
5 6
6/** 7/**
7 * struct gpio_keys_button - configuration parameters 8 * struct gpio_keys_button - configuration parameters
@@ -17,6 +18,7 @@ struct device;
17 * disable button via sysfs 18 * disable button via sysfs
18 * @value: axis value for %EV_ABS 19 * @value: axis value for %EV_ABS
19 * @irq: Irq number in case of interrupt keys 20 * @irq: Irq number in case of interrupt keys
21 * @gpiod: GPIO descriptor
20 */ 22 */
21struct gpio_keys_button { 23struct gpio_keys_button {
22 unsigned int code; 24 unsigned int code;
@@ -29,6 +31,7 @@ struct gpio_keys_button {
29 bool can_disable; 31 bool can_disable;
30 int value; 32 int value;
31 unsigned int irq; 33 unsigned int irq;
34 struct gpio_desc *gpiod;
32}; 35};
33 36
34/** 37/**
diff --git a/include/linux/leds.h b/include/linux/leds.h
index a57611d0c94e..361101fef270 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -261,6 +261,7 @@ struct gpio_led {
261 unsigned retain_state_suspended : 1; 261 unsigned retain_state_suspended : 1;
262 unsigned default_state : 2; 262 unsigned default_state : 2;
263 /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */ 263 /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
264 struct gpio_desc *gpiod;
264}; 265};
265#define LEDS_GPIO_DEFSTATE_OFF 0 266#define LEDS_GPIO_DEFSTATE_OFF 0
266#define LEDS_GPIO_DEFSTATE_ON 1 267#define LEDS_GPIO_DEFSTATE_ON 1
@@ -273,7 +274,7 @@ struct gpio_led_platform_data {
273#define GPIO_LED_NO_BLINK_LOW 0 /* No blink GPIO state low */ 274#define GPIO_LED_NO_BLINK_LOW 0 /* No blink GPIO state low */
274#define GPIO_LED_NO_BLINK_HIGH 1 /* No blink GPIO state high */ 275#define GPIO_LED_NO_BLINK_HIGH 1 /* No blink GPIO state high */
275#define GPIO_LED_BLINK 2 /* Please, blink */ 276#define GPIO_LED_BLINK 2 /* Please, blink */
276 int (*gpio_blink_set)(unsigned gpio, int state, 277 int (*gpio_blink_set)(struct gpio_desc *desc, int state,
277 unsigned long *delay_on, 278 unsigned long *delay_on,
278 unsigned long *delay_off); 279 unsigned long *delay_off);
279}; 280};
diff --git a/include/linux/of.h b/include/linux/of.h
index c55b50018ac4..1a66b8881c01 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -23,6 +23,7 @@
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/topology.h> 24#include <linux/topology.h>
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/property.h>
26 27
27#include <asm/byteorder.h> 28#include <asm/byteorder.h>
28#include <asm/errno.h> 29#include <asm/errno.h>
@@ -49,6 +50,7 @@ struct device_node {
49 const char *type; 50 const char *type;
50 phandle phandle; 51 phandle phandle;
51 const char *full_name; 52 const char *full_name;
53 struct fwnode_handle fwnode;
52 54
53 struct property *properties; 55 struct property *properties;
54 struct property *deadprops; /* removed properties */ 56 struct property *deadprops; /* removed properties */
@@ -79,6 +81,7 @@ extern struct kobj_type of_node_ktype;
79static inline void of_node_init(struct device_node *node) 81static inline void of_node_init(struct device_node *node)
80{ 82{
81 kobject_init(&node->kobj, &of_node_ktype); 83 kobject_init(&node->kobj, &of_node_ktype);
84 node->fwnode.type = FWNODE_OF;
82} 85}
83 86
84/* true when node is initialized */ 87/* true when node is initialized */
@@ -114,6 +117,16 @@ extern struct device_node *of_aliases;
114extern struct device_node *of_stdout; 117extern struct device_node *of_stdout;
115extern raw_spinlock_t devtree_lock; 118extern raw_spinlock_t devtree_lock;
116 119
120static inline bool is_of_node(struct fwnode_handle *fwnode)
121{
122 return fwnode && fwnode->type == FWNODE_OF;
123}
124
125static inline struct device_node *of_node(struct fwnode_handle *fwnode)
126{
127 return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL;
128}
129
117static inline bool of_have_populated_dt(void) 130static inline bool of_have_populated_dt(void)
118{ 131{
119 return of_allnodes != NULL; 132 return of_allnodes != NULL;
@@ -263,6 +276,10 @@ extern int of_property_read_u32_array(const struct device_node *np,
263 size_t sz); 276 size_t sz);
264extern int of_property_read_u64(const struct device_node *np, 277extern int of_property_read_u64(const struct device_node *np,
265 const char *propname, u64 *out_value); 278 const char *propname, u64 *out_value);
279extern int of_property_read_u64_array(const struct device_node *np,
280 const char *propname,
281 u64 *out_values,
282 size_t sz);
266 283
267extern int of_property_read_string(struct device_node *np, 284extern int of_property_read_string(struct device_node *np,
268 const char *propname, 285 const char *propname,
@@ -355,6 +372,16 @@ bool of_console_check(struct device_node *dn, char *name, int index);
355 372
356#else /* CONFIG_OF */ 373#else /* CONFIG_OF */
357 374
375static inline bool is_of_node(struct fwnode_handle *fwnode)
376{
377 return false;
378}
379
380static inline struct device_node *of_node(struct fwnode_handle *fwnode)
381{
382 return NULL;
383}
384
358static inline const char* of_node_full_name(const struct device_node *np) 385static inline const char* of_node_full_name(const struct device_node *np)
359{ 386{
360 return "<no-node>"; 387 return "<no-node>";
@@ -477,6 +504,13 @@ static inline int of_property_read_u32_array(const struct device_node *np,
477 return -ENOSYS; 504 return -ENOSYS;
478} 505}
479 506
507static inline int of_property_read_u64_array(const struct device_node *np,
508 const char *propname,
509 u64 *out_values, size_t sz)
510{
511 return -ENOSYS;
512}
513
480static inline int of_property_read_string(struct device_node *np, 514static inline int of_property_read_string(struct device_node *np,
481 const char *propname, 515 const char *propname,
482 const char **out_string) 516 const char **out_string)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 383fd68aaee1..66a656eb335b 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -342,7 +342,7 @@ struct dev_pm_ops {
342#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) 342#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
343#endif 343#endif
344 344
345#ifdef CONFIG_PM_RUNTIME 345#ifdef CONFIG_PM
346#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ 346#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
347 .runtime_suspend = suspend_fn, \ 347 .runtime_suspend = suspend_fn, \
348 .runtime_resume = resume_fn, \ 348 .runtime_resume = resume_fn, \
@@ -351,14 +351,7 @@ struct dev_pm_ops {
351#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) 351#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
352#endif 352#endif
353 353
354#ifdef CONFIG_PM 354#define SET_PM_RUNTIME_PM_OPS SET_RUNTIME_PM_OPS
355#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
356 .runtime_suspend = suspend_fn, \
357 .runtime_resume = resume_fn, \
358 .runtime_idle = idle_fn,
359#else
360#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
361#endif
362 355
363/* 356/*
364 * Use this if you want to use the same suspend and resume callbacks for suspend 357 * Use this if you want to use the same suspend and resume callbacks for suspend
@@ -538,11 +531,7 @@ enum rpm_request {
538}; 531};
539 532
540struct wakeup_source; 533struct wakeup_source;
541 534struct pm_domain_data;
542struct pm_domain_data {
543 struct list_head list_node;
544 struct device *dev;
545};
546 535
547struct pm_subsys_data { 536struct pm_subsys_data {
548 spinlock_t lock; 537 spinlock_t lock;
@@ -576,7 +565,7 @@ struct dev_pm_info {
576#else 565#else
577 unsigned int should_wakeup:1; 566 unsigned int should_wakeup:1;
578#endif 567#endif
579#ifdef CONFIG_PM_RUNTIME 568#ifdef CONFIG_PM
580 struct timer_list suspend_timer; 569 struct timer_list suspend_timer;
581 unsigned long timer_expires; 570 unsigned long timer_expires;
582 struct work_struct work; 571 struct work_struct work;
diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h
index 8348866e7b05..0b0039634410 100644
--- a/include/linux/pm_clock.h
+++ b/include/linux/pm_clock.h
@@ -18,6 +18,8 @@ struct pm_clk_notifier_block {
18 char *con_ids[]; 18 char *con_ids[];
19}; 19};
20 20
21struct clk;
22
21#ifdef CONFIG_PM_CLK 23#ifdef CONFIG_PM_CLK
22static inline bool pm_clk_no_clocks(struct device *dev) 24static inline bool pm_clk_no_clocks(struct device *dev)
23{ 25{
@@ -29,6 +31,7 @@ extern void pm_clk_init(struct device *dev);
29extern int pm_clk_create(struct device *dev); 31extern int pm_clk_create(struct device *dev);
30extern void pm_clk_destroy(struct device *dev); 32extern void pm_clk_destroy(struct device *dev);
31extern int pm_clk_add(struct device *dev, const char *con_id); 33extern int pm_clk_add(struct device *dev, const char *con_id);
34extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
32extern void pm_clk_remove(struct device *dev, const char *con_id); 35extern void pm_clk_remove(struct device *dev, const char *con_id);
33extern int pm_clk_suspend(struct device *dev); 36extern int pm_clk_suspend(struct device *dev);
34extern int pm_clk_resume(struct device *dev); 37extern int pm_clk_resume(struct device *dev);
@@ -51,6 +54,11 @@ static inline int pm_clk_add(struct device *dev, const char *con_id)
51{ 54{
52 return -EINVAL; 55 return -EINVAL;
53} 56}
57
58static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
59{
60 return -EINVAL;
61}
54static inline void pm_clk_remove(struct device *dev, const char *con_id) 62static inline void pm_clk_remove(struct device *dev, const char *con_id)
55{ 63{
56} 64}
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 2e0e06daf8c0..6cd20d5e651b 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -17,6 +17,9 @@
17#include <linux/notifier.h> 17#include <linux/notifier.h>
18#include <linux/cpuidle.h> 18#include <linux/cpuidle.h>
19 19
20/* Defines used for the flags field in the struct generic_pm_domain */
21#define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */
22
20enum gpd_status { 23enum gpd_status {
21 GPD_STATE_ACTIVE = 0, /* PM domain is active */ 24 GPD_STATE_ACTIVE = 0, /* PM domain is active */
22 GPD_STATE_WAIT_MASTER, /* PM domain's master is being waited for */ 25 GPD_STATE_WAIT_MASTER, /* PM domain's master is being waited for */
@@ -76,6 +79,7 @@ struct generic_pm_domain {
76 struct device *dev); 79 struct device *dev);
77 void (*detach_dev)(struct generic_pm_domain *domain, 80 void (*detach_dev)(struct generic_pm_domain *domain,
78 struct device *dev); 81 struct device *dev);
82 unsigned int flags; /* Bit field of configs for genpd */
79}; 83};
80 84
81static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) 85static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -100,6 +104,11 @@ struct gpd_timing_data {
100 bool cached_stop_ok; 104 bool cached_stop_ok;
101}; 105};
102 106
107struct pm_domain_data {
108 struct list_head list_node;
109 struct device *dev;
110};
111
103struct generic_pm_domain_data { 112struct generic_pm_domain_data {
104 struct pm_domain_data base; 113 struct pm_domain_data base;
105 struct gpd_timing_data td; 114 struct gpd_timing_data td;
@@ -147,6 +156,7 @@ extern void pm_genpd_init(struct generic_pm_domain *genpd,
147 156
148extern int pm_genpd_poweron(struct generic_pm_domain *genpd); 157extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
149extern int pm_genpd_name_poweron(const char *domain_name); 158extern int pm_genpd_name_poweron(const char *domain_name);
159extern void pm_genpd_poweroff_unused(void);
150 160
151extern struct dev_power_governor simple_qos_governor; 161extern struct dev_power_governor simple_qos_governor;
152extern struct dev_power_governor pm_domain_always_on_gov; 162extern struct dev_power_governor pm_domain_always_on_gov;
@@ -221,6 +231,7 @@ static inline int pm_genpd_name_poweron(const char *domain_name)
221{ 231{
222 return -ENOSYS; 232 return -ENOSYS;
223} 233}
234static inline void pm_genpd_poweroff_unused(void) {}
224#define simple_qos_governor NULL 235#define simple_qos_governor NULL
225#define pm_domain_always_on_gov NULL 236#define pm_domain_always_on_gov NULL
226#endif 237#endif
@@ -237,12 +248,6 @@ static inline int pm_genpd_name_add_device(const char *domain_name,
237 return __pm_genpd_name_add_device(domain_name, dev, NULL); 248 return __pm_genpd_name_add_device(domain_name, dev, NULL);
238} 249}
239 250
240#ifdef CONFIG_PM_GENERIC_DOMAINS_RUNTIME
241extern void pm_genpd_poweroff_unused(void);
242#else
243static inline void pm_genpd_poweroff_unused(void) {}
244#endif
245
246#ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP 251#ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP
247extern void pm_genpd_syscore_poweroff(struct device *dev); 252extern void pm_genpd_syscore_poweroff(struct device *dev);
248extern void pm_genpd_syscore_poweron(struct device *dev); 253extern void pm_genpd_syscore_poweron(struct device *dev);
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 0330217abfad..cec2d4540914 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -21,7 +21,7 @@ struct dev_pm_opp;
21struct device; 21struct device;
22 22
23enum dev_pm_opp_event { 23enum dev_pm_opp_event {
24 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, 24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25}; 25};
26 26
27#if defined(CONFIG_PM_OPP) 27#if defined(CONFIG_PM_OPP)
@@ -44,6 +44,7 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
44 44
45int dev_pm_opp_add(struct device *dev, unsigned long freq, 45int dev_pm_opp_add(struct device *dev, unsigned long freq,
46 unsigned long u_volt); 46 unsigned long u_volt);
47void dev_pm_opp_remove(struct device *dev, unsigned long freq);
47 48
48int dev_pm_opp_enable(struct device *dev, unsigned long freq); 49int dev_pm_opp_enable(struct device *dev, unsigned long freq);
49 50
@@ -90,6 +91,10 @@ static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
90 return -EINVAL; 91 return -EINVAL;
91} 92}
92 93
94static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
95{
96}
97
93static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) 98static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
94{ 99{
95 return 0; 100 return 0;
@@ -109,11 +114,16 @@ static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
109 114
110#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) 115#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
111int of_init_opp_table(struct device *dev); 116int of_init_opp_table(struct device *dev);
117void of_free_opp_table(struct device *dev);
112#else 118#else
113static inline int of_init_opp_table(struct device *dev) 119static inline int of_init_opp_table(struct device *dev)
114{ 120{
115 return -EINVAL; 121 return -EINVAL;
116} 122}
123
124static inline void of_free_opp_table(struct device *dev)
125{
126}
117#endif 127#endif
118 128
119#endif /* __LINUX_OPP_H__ */ 129#endif /* __LINUX_OPP_H__ */
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 636e82834506..7b3ae0cffc05 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -154,6 +154,23 @@ void dev_pm_qos_constraints_destroy(struct device *dev);
154int dev_pm_qos_add_ancestor_request(struct device *dev, 154int dev_pm_qos_add_ancestor_request(struct device *dev,
155 struct dev_pm_qos_request *req, 155 struct dev_pm_qos_request *req,
156 enum dev_pm_qos_req_type type, s32 value); 156 enum dev_pm_qos_req_type type, s32 value);
157int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value);
158void dev_pm_qos_hide_latency_limit(struct device *dev);
159int dev_pm_qos_expose_flags(struct device *dev, s32 value);
160void dev_pm_qos_hide_flags(struct device *dev);
161int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set);
162s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev);
163int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val);
164
165static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev)
166{
167 return dev->power.qos->resume_latency_req->data.pnode.prio;
168}
169
170static inline s32 dev_pm_qos_requested_flags(struct device *dev)
171{
172 return dev->power.qos->flags_req->data.flr.flags;
173}
157#else 174#else
158static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, 175static inline enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev,
159 s32 mask) 176 s32 mask)
@@ -200,27 +217,6 @@ static inline int dev_pm_qos_add_ancestor_request(struct device *dev,
200 enum dev_pm_qos_req_type type, 217 enum dev_pm_qos_req_type type,
201 s32 value) 218 s32 value)
202 { return 0; } 219 { return 0; }
203#endif
204
205#ifdef CONFIG_PM_RUNTIME
206int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value);
207void dev_pm_qos_hide_latency_limit(struct device *dev);
208int dev_pm_qos_expose_flags(struct device *dev, s32 value);
209void dev_pm_qos_hide_flags(struct device *dev);
210int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set);
211s32 dev_pm_qos_get_user_latency_tolerance(struct device *dev);
212int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val);
213
214static inline s32 dev_pm_qos_requested_resume_latency(struct device *dev)
215{
216 return dev->power.qos->resume_latency_req->data.pnode.prio;
217}
218
219static inline s32 dev_pm_qos_requested_flags(struct device *dev)
220{
221 return dev->power.qos->flags_req->data.flr.flags;
222}
223#else
224static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value) 220static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value)
225 { return 0; } 221 { return 0; }
226static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {} 222static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {}
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 367f49b9a1c9..eda4feede048 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -35,16 +35,6 @@ extern int pm_generic_runtime_suspend(struct device *dev);
35extern int pm_generic_runtime_resume(struct device *dev); 35extern int pm_generic_runtime_resume(struct device *dev);
36extern int pm_runtime_force_suspend(struct device *dev); 36extern int pm_runtime_force_suspend(struct device *dev);
37extern int pm_runtime_force_resume(struct device *dev); 37extern int pm_runtime_force_resume(struct device *dev);
38#else
39static inline bool queue_pm_work(struct work_struct *work) { return false; }
40
41static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
42static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
43static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
44static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
45#endif
46
47#ifdef CONFIG_PM_RUNTIME
48 38
49extern int __pm_runtime_idle(struct device *dev, int rpmflags); 39extern int __pm_runtime_idle(struct device *dev, int rpmflags);
50extern int __pm_runtime_suspend(struct device *dev, int rpmflags); 40extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
@@ -128,7 +118,14 @@ static inline void pm_runtime_mark_last_busy(struct device *dev)
128 ACCESS_ONCE(dev->power.last_busy) = jiffies; 118 ACCESS_ONCE(dev->power.last_busy) = jiffies;
129} 119}
130 120
131#else /* !CONFIG_PM_RUNTIME */ 121#else /* !CONFIG_PM */
122
123static inline bool queue_pm_work(struct work_struct *work) { return false; }
124
125static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
126static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
127static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
128static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
132 129
133static inline int __pm_runtime_idle(struct device *dev, int rpmflags) 130static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
134{ 131{
@@ -179,7 +176,7 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
179static inline void pm_runtime_set_memalloc_noio(struct device *dev, 176static inline void pm_runtime_set_memalloc_noio(struct device *dev,
180 bool enable){} 177 bool enable){}
181 178
182#endif /* !CONFIG_PM_RUNTIME */ 179#endif /* !CONFIG_PM */
183 180
184static inline int pm_runtime_idle(struct device *dev) 181static inline int pm_runtime_idle(struct device *dev)
185{ 182{
diff --git a/include/linux/property.h b/include/linux/property.h
new file mode 100644
index 000000000000..a6a3d98bd7e9
--- /dev/null
+++ b/include/linux/property.h
@@ -0,0 +1,143 @@
1/*
2 * property.h - Unified device property interface.
3 *
4 * Copyright (C) 2014, Intel Corporation
5 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 * Mika Westerberg <mika.westerberg@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _LINUX_PROPERTY_H_
14#define _LINUX_PROPERTY_H_
15
16#include <linux/types.h>
17
18struct device;
19
20enum dev_prop_type {
21 DEV_PROP_U8,
22 DEV_PROP_U16,
23 DEV_PROP_U32,
24 DEV_PROP_U64,
25 DEV_PROP_STRING,
26 DEV_PROP_MAX,
27};
28
29bool device_property_present(struct device *dev, const char *propname);
30int device_property_read_u8_array(struct device *dev, const char *propname,
31 u8 *val, size_t nval);
32int device_property_read_u16_array(struct device *dev, const char *propname,
33 u16 *val, size_t nval);
34int device_property_read_u32_array(struct device *dev, const char *propname,
35 u32 *val, size_t nval);
36int device_property_read_u64_array(struct device *dev, const char *propname,
37 u64 *val, size_t nval);
38int device_property_read_string_array(struct device *dev, const char *propname,
39 const char **val, size_t nval);
40int device_property_read_string(struct device *dev, const char *propname,
41 const char **val);
42
43enum fwnode_type {
44 FWNODE_INVALID = 0,
45 FWNODE_OF,
46 FWNODE_ACPI,
47};
48
49struct fwnode_handle {
50 enum fwnode_type type;
51};
52
53bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname);
54int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
55 const char *propname, u8 *val,
56 size_t nval);
57int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
58 const char *propname, u16 *val,
59 size_t nval);
60int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
61 const char *propname, u32 *val,
62 size_t nval);
63int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
64 const char *propname, u64 *val,
65 size_t nval);
66int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
67 const char *propname, const char **val,
68 size_t nval);
69int fwnode_property_read_string(struct fwnode_handle *fwnode,
70 const char *propname, const char **val);
71
72struct fwnode_handle *device_get_next_child_node(struct device *dev,
73 struct fwnode_handle *child);
74
75#define device_for_each_child_node(dev, child) \
76 for (child = device_get_next_child_node(dev, NULL); child; \
77 child = device_get_next_child_node(dev, child))
78
79void fwnode_handle_put(struct fwnode_handle *fwnode);
80
81unsigned int device_get_child_node_count(struct device *dev);
82
83static inline bool device_property_read_bool(struct device *dev,
84 const char *propname)
85{
86 return device_property_present(dev, propname);
87}
88
89static inline int device_property_read_u8(struct device *dev,
90 const char *propname, u8 *val)
91{
92 return device_property_read_u8_array(dev, propname, val, 1);
93}
94
95static inline int device_property_read_u16(struct device *dev,
96 const char *propname, u16 *val)
97{
98 return device_property_read_u16_array(dev, propname, val, 1);
99}
100
101static inline int device_property_read_u32(struct device *dev,
102 const char *propname, u32 *val)
103{
104 return device_property_read_u32_array(dev, propname, val, 1);
105}
106
107static inline int device_property_read_u64(struct device *dev,
108 const char *propname, u64 *val)
109{
110 return device_property_read_u64_array(dev, propname, val, 1);
111}
112
113static inline bool fwnode_property_read_bool(struct fwnode_handle *fwnode,
114 const char *propname)
115{
116 return fwnode_property_present(fwnode, propname);
117}
118
119static inline int fwnode_property_read_u8(struct fwnode_handle *fwnode,
120 const char *propname, u8 *val)
121{
122 return fwnode_property_read_u8_array(fwnode, propname, val, 1);
123}
124
125static inline int fwnode_property_read_u16(struct fwnode_handle *fwnode,
126 const char *propname, u16 *val)
127{
128 return fwnode_property_read_u16_array(fwnode, propname, val, 1);
129}
130
131static inline int fwnode_property_read_u32(struct fwnode_handle *fwnode,
132 const char *propname, u32 *val)
133{
134 return fwnode_property_read_u32_array(fwnode, propname, val, 1);
135}
136
137static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
138 const char *propname, u64 *val)
139{
140 return fwnode_property_read_u64_array(fwnode, propname, val, 1);
141}
142
143#endif /* _LINUX_PROPERTY_H_ */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447a7e2fc19b..f89c24a03bd9 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -637,7 +637,7 @@ static inline bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
637#endif 637#endif
638 638
639/* USB autosuspend and autoresume */ 639/* USB autosuspend and autoresume */
640#ifdef CONFIG_PM_RUNTIME 640#ifdef CONFIG_PM
641extern void usb_enable_autosuspend(struct usb_device *udev); 641extern void usb_enable_autosuspend(struct usb_device *udev);
642extern void usb_disable_autosuspend(struct usb_device *udev); 642extern void usb_disable_autosuspend(struct usb_device *udev);
643 643
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index cd96a2bc3388..668898e29d0e 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -93,7 +93,7 @@ struct usb_hcd {
93 93
94 struct timer_list rh_timer; /* drives root-hub polling */ 94 struct timer_list rh_timer; /* drives root-hub polling */
95 struct urb *status_urb; /* the current status urb */ 95 struct urb *status_urb; /* the current status urb */
96#ifdef CONFIG_PM_RUNTIME 96#ifdef CONFIG_PM
97 struct work_struct wakeup_work; /* for remote wakeup */ 97 struct work_struct wakeup_work; /* for remote wakeup */
98#endif 98#endif
99 99
@@ -625,16 +625,13 @@ extern int usb_find_interface_driver(struct usb_device *dev,
625extern void usb_root_hub_lost_power(struct usb_device *rhdev); 625extern void usb_root_hub_lost_power(struct usb_device *rhdev);
626extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); 626extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
627extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); 627extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
628#endif /* CONFIG_PM */
629
630#ifdef CONFIG_PM_RUNTIME
631extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 628extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
632#else 629#else
633static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 630static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
634{ 631{
635 return; 632 return;
636} 633}
637#endif /* CONFIG_PM_RUNTIME */ 634#endif /* CONFIG_PM */
638 635
639/*-------------------------------------------------------------------------*/ 636/*-------------------------------------------------------------------------*/
640 637
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index bbef57f5bdfd..6e7708c2c21f 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -94,6 +94,7 @@ config PM_STD_PARTITION
94config PM_SLEEP 94config PM_SLEEP
95 def_bool y 95 def_bool y
96 depends on SUSPEND || HIBERNATE_CALLBACKS 96 depends on SUSPEND || HIBERNATE_CALLBACKS
97 select PM_RUNTIME
97 98
98config PM_SLEEP_SMP 99config PM_SLEEP_SMP
99 def_bool y 100 def_bool y
@@ -131,7 +132,6 @@ config PM_WAKELOCKS_GC
131 132
132config PM_RUNTIME 133config PM_RUNTIME
133 bool "Run-time PM core functionality" 134 bool "Run-time PM core functionality"
134 depends on !IA64_HP_SIM
135 ---help--- 135 ---help---
136 Enable functionality allowing I/O devices to be put into energy-saving 136 Enable functionality allowing I/O devices to be put into energy-saving
137 (low power) states at run time (or autosuspended) after a specified 137 (low power) states at run time (or autosuspended) after a specified
@@ -298,14 +298,9 @@ config PM_GENERIC_DOMAINS_SLEEP
298 def_bool y 298 def_bool y
299 depends on PM_SLEEP && PM_GENERIC_DOMAINS 299 depends on PM_SLEEP && PM_GENERIC_DOMAINS
300 300
301config PM_GENERIC_DOMAINS_RUNTIME
302 def_bool y
303 depends on PM_RUNTIME && PM_GENERIC_DOMAINS
304
305config PM_GENERIC_DOMAINS_OF 301config PM_GENERIC_DOMAINS_OF
306 def_bool y 302 def_bool y
307 depends on PM_GENERIC_DOMAINS && OF 303 depends on PM_GENERIC_DOMAINS && OF
308 304
309config CPU_PM 305config CPU_PM
310 bool 306 bool
311 depends on SUSPEND || CPU_IDLE
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 1f35a3478f3c..2329daae5255 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -28,6 +28,7 @@
28#include <linux/syscore_ops.h> 28#include <linux/syscore_ops.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/genhd.h> 30#include <linux/genhd.h>
31#include <linux/ktime.h>
31#include <trace/events/power.h> 32#include <trace/events/power.h>
32 33
33#include "power.h" 34#include "power.h"
@@ -232,20 +233,17 @@ static void platform_recover(int platform_mode)
232 * @nr_pages: Number of memory pages processed between @start and @stop. 233 * @nr_pages: Number of memory pages processed between @start and @stop.
233 * @msg: Additional diagnostic message to print. 234 * @msg: Additional diagnostic message to print.
234 */ 235 */
235void swsusp_show_speed(struct timeval *start, struct timeval *stop, 236void swsusp_show_speed(ktime_t start, ktime_t stop,
236 unsigned nr_pages, char *msg) 237 unsigned nr_pages, char *msg)
237{ 238{
239 ktime_t diff;
238 u64 elapsed_centisecs64; 240 u64 elapsed_centisecs64;
239 unsigned int centisecs; 241 unsigned int centisecs;
240 unsigned int k; 242 unsigned int k;
241 unsigned int kps; 243 unsigned int kps;
242 244
243 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start); 245 diff = ktime_sub(stop, start);
244 /* 246 elapsed_centisecs64 = ktime_divns(diff, 10*NSEC_PER_MSEC);
245 * If "(s64)elapsed_centisecs64 < 0", it will print long elapsed time,
246 * it is obvious enough for what went wrong.
247 */
248 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
249 centisecs = elapsed_centisecs64; 247 centisecs = elapsed_centisecs64;
250 if (centisecs == 0) 248 if (centisecs == 0)
251 centisecs = 1; /* avoid div-by-zero */ 249 centisecs = 1; /* avoid div-by-zero */
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 2df883a9d3cb..ce9b8328a689 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -174,8 +174,7 @@ extern int hib_wait_on_bio_chain(struct bio **bio_chain);
174 174
175struct timeval; 175struct timeval;
176/* kernel/power/swsusp.c */ 176/* kernel/power/swsusp.c */
177extern void swsusp_show_speed(struct timeval *, struct timeval *, 177extern void swsusp_show_speed(ktime_t, ktime_t, unsigned int, char *);
178 unsigned int, char *);
179 178
180#ifdef CONFIG_SUSPEND 179#ifdef CONFIG_SUSPEND
181/* kernel/power/suspend.c */ 180/* kernel/power/suspend.c */
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 791a61892bb5..0c40c16174b4 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -28,6 +28,7 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/compiler.h> 30#include <linux/compiler.h>
31#include <linux/ktime.h>
31 32
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33#include <asm/mmu_context.h> 34#include <asm/mmu_context.h>
@@ -1576,11 +1577,11 @@ int hibernate_preallocate_memory(void)
1576 struct zone *zone; 1577 struct zone *zone;
1577 unsigned long saveable, size, max_size, count, highmem, pages = 0; 1578 unsigned long saveable, size, max_size, count, highmem, pages = 0;
1578 unsigned long alloc, save_highmem, pages_highmem, avail_normal; 1579 unsigned long alloc, save_highmem, pages_highmem, avail_normal;
1579 struct timeval start, stop; 1580 ktime_t start, stop;
1580 int error; 1581 int error;
1581 1582
1582 printk(KERN_INFO "PM: Preallocating image memory... "); 1583 printk(KERN_INFO "PM: Preallocating image memory... ");
1583 do_gettimeofday(&start); 1584 start = ktime_get();
1584 1585
1585 error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY); 1586 error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY);
1586 if (error) 1587 if (error)
@@ -1709,9 +1710,9 @@ int hibernate_preallocate_memory(void)
1709 free_unnecessary_pages(); 1710 free_unnecessary_pages();
1710 1711
1711 out: 1712 out:
1712 do_gettimeofday(&stop); 1713 stop = ktime_get();
1713 printk(KERN_CONT "done (allocated %lu pages)\n", pages); 1714 printk(KERN_CONT "done (allocated %lu pages)\n", pages);
1714 swsusp_show_speed(&start, &stop, pages, "Allocated"); 1715 swsusp_show_speed(start, stop, pages, "Allocated");
1715 1716
1716 return 0; 1717 return 0;
1717 1718
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index aaa3261dea5d..570aff817543 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -30,6 +30,7 @@
30#include <linux/atomic.h> 30#include <linux/atomic.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/crc32.h> 32#include <linux/crc32.h>
33#include <linux/ktime.h>
33 34
34#include "power.h" 35#include "power.h"
35 36
@@ -445,8 +446,8 @@ static int save_image(struct swap_map_handle *handle,
445 int nr_pages; 446 int nr_pages;
446 int err2; 447 int err2;
447 struct bio *bio; 448 struct bio *bio;
448 struct timeval start; 449 ktime_t start;
449 struct timeval stop; 450 ktime_t stop;
450 451
451 printk(KERN_INFO "PM: Saving image data pages (%u pages)...\n", 452 printk(KERN_INFO "PM: Saving image data pages (%u pages)...\n",
452 nr_to_write); 453 nr_to_write);
@@ -455,7 +456,7 @@ static int save_image(struct swap_map_handle *handle,
455 m = 1; 456 m = 1;
456 nr_pages = 0; 457 nr_pages = 0;
457 bio = NULL; 458 bio = NULL;
458 do_gettimeofday(&start); 459 start = ktime_get();
459 while (1) { 460 while (1) {
460 ret = snapshot_read_next(snapshot); 461 ret = snapshot_read_next(snapshot);
461 if (ret <= 0) 462 if (ret <= 0)
@@ -469,12 +470,12 @@ static int save_image(struct swap_map_handle *handle,
469 nr_pages++; 470 nr_pages++;
470 } 471 }
471 err2 = hib_wait_on_bio_chain(&bio); 472 err2 = hib_wait_on_bio_chain(&bio);
472 do_gettimeofday(&stop); 473 stop = ktime_get();
473 if (!ret) 474 if (!ret)
474 ret = err2; 475 ret = err2;
475 if (!ret) 476 if (!ret)
476 printk(KERN_INFO "PM: Image saving done.\n"); 477 printk(KERN_INFO "PM: Image saving done.\n");
477 swsusp_show_speed(&start, &stop, nr_to_write, "Wrote"); 478 swsusp_show_speed(start, stop, nr_to_write, "Wrote");
478 return ret; 479 return ret;
479} 480}
480 481
@@ -580,8 +581,8 @@ static int save_image_lzo(struct swap_map_handle *handle,
580 int nr_pages; 581 int nr_pages;
581 int err2; 582 int err2;
582 struct bio *bio; 583 struct bio *bio;
583 struct timeval start; 584 ktime_t start;
584 struct timeval stop; 585 ktime_t stop;
585 size_t off; 586 size_t off;
586 unsigned thr, run_threads, nr_threads; 587 unsigned thr, run_threads, nr_threads;
587 unsigned char *page = NULL; 588 unsigned char *page = NULL;
@@ -674,7 +675,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
674 m = 1; 675 m = 1;
675 nr_pages = 0; 676 nr_pages = 0;
676 bio = NULL; 677 bio = NULL;
677 do_gettimeofday(&start); 678 start = ktime_get();
678 for (;;) { 679 for (;;) {
679 for (thr = 0; thr < nr_threads; thr++) { 680 for (thr = 0; thr < nr_threads; thr++) {
680 for (off = 0; off < LZO_UNC_SIZE; off += PAGE_SIZE) { 681 for (off = 0; off < LZO_UNC_SIZE; off += PAGE_SIZE) {
@@ -759,12 +760,12 @@ static int save_image_lzo(struct swap_map_handle *handle,
759 760
760out_finish: 761out_finish:
761 err2 = hib_wait_on_bio_chain(&bio); 762 err2 = hib_wait_on_bio_chain(&bio);
762 do_gettimeofday(&stop); 763 stop = ktime_get();
763 if (!ret) 764 if (!ret)
764 ret = err2; 765 ret = err2;
765 if (!ret) 766 if (!ret)
766 printk(KERN_INFO "PM: Image saving done.\n"); 767 printk(KERN_INFO "PM: Image saving done.\n");
767 swsusp_show_speed(&start, &stop, nr_to_write, "Wrote"); 768 swsusp_show_speed(start, stop, nr_to_write, "Wrote");
768out_clean: 769out_clean:
769 if (crc) { 770 if (crc) {
770 if (crc->thr) 771 if (crc->thr)
@@ -965,8 +966,8 @@ static int load_image(struct swap_map_handle *handle,
965{ 966{
966 unsigned int m; 967 unsigned int m;
967 int ret = 0; 968 int ret = 0;
968 struct timeval start; 969 ktime_t start;
969 struct timeval stop; 970 ktime_t stop;
970 struct bio *bio; 971 struct bio *bio;
971 int err2; 972 int err2;
972 unsigned nr_pages; 973 unsigned nr_pages;
@@ -978,7 +979,7 @@ static int load_image(struct swap_map_handle *handle,
978 m = 1; 979 m = 1;
979 nr_pages = 0; 980 nr_pages = 0;
980 bio = NULL; 981 bio = NULL;
981 do_gettimeofday(&start); 982 start = ktime_get();
982 for ( ; ; ) { 983 for ( ; ; ) {
983 ret = snapshot_write_next(snapshot); 984 ret = snapshot_write_next(snapshot);
984 if (ret <= 0) 985 if (ret <= 0)
@@ -996,7 +997,7 @@ static int load_image(struct swap_map_handle *handle,
996 nr_pages++; 997 nr_pages++;
997 } 998 }
998 err2 = hib_wait_on_bio_chain(&bio); 999 err2 = hib_wait_on_bio_chain(&bio);
999 do_gettimeofday(&stop); 1000 stop = ktime_get();
1000 if (!ret) 1001 if (!ret)
1001 ret = err2; 1002 ret = err2;
1002 if (!ret) { 1003 if (!ret) {
@@ -1005,7 +1006,7 @@ static int load_image(struct swap_map_handle *handle,
1005 if (!snapshot_image_loaded(snapshot)) 1006 if (!snapshot_image_loaded(snapshot))
1006 ret = -ENODATA; 1007 ret = -ENODATA;
1007 } 1008 }
1008 swsusp_show_speed(&start, &stop, nr_to_read, "Read"); 1009 swsusp_show_speed(start, stop, nr_to_read, "Read");
1009 return ret; 1010 return ret;
1010} 1011}
1011 1012
@@ -1067,8 +1068,8 @@ static int load_image_lzo(struct swap_map_handle *handle,
1067 int ret = 0; 1068 int ret = 0;
1068 int eof = 0; 1069 int eof = 0;
1069 struct bio *bio; 1070 struct bio *bio;
1070 struct timeval start; 1071 ktime_t start;
1071 struct timeval stop; 1072 ktime_t stop;
1072 unsigned nr_pages; 1073 unsigned nr_pages;
1073 size_t off; 1074 size_t off;
1074 unsigned i, thr, run_threads, nr_threads; 1075 unsigned i, thr, run_threads, nr_threads;
@@ -1190,7 +1191,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
1190 m = 1; 1191 m = 1;
1191 nr_pages = 0; 1192 nr_pages = 0;
1192 bio = NULL; 1193 bio = NULL;
1193 do_gettimeofday(&start); 1194 start = ktime_get();
1194 1195
1195 ret = snapshot_write_next(snapshot); 1196 ret = snapshot_write_next(snapshot);
1196 if (ret <= 0) 1197 if (ret <= 0)
@@ -1343,7 +1344,7 @@ out_finish:
1343 wait_event(crc->done, atomic_read(&crc->stop)); 1344 wait_event(crc->done, atomic_read(&crc->stop));
1344 atomic_set(&crc->stop, 0); 1345 atomic_set(&crc->stop, 0);
1345 } 1346 }
1346 do_gettimeofday(&stop); 1347 stop = ktime_get();
1347 if (!ret) { 1348 if (!ret) {
1348 printk(KERN_INFO "PM: Image loading done.\n"); 1349 printk(KERN_INFO "PM: Image loading done.\n");
1349 snapshot_write_finalize(snapshot); 1350 snapshot_write_finalize(snapshot);
@@ -1359,7 +1360,7 @@ out_finish:
1359 } 1360 }
1360 } 1361 }
1361 } 1362 }
1362 swsusp_show_speed(&start, &stop, nr_to_read, "Read"); 1363 swsusp_show_speed(start, stop, nr_to_read, "Read");
1363out_clean: 1364out_clean:
1364 for (i = 0; i < ring_size; i++) 1365 for (i = 0; i < ring_size; i++)
1365 free_page((unsigned long)page[i]); 1366 free_page((unsigned long)page[i]);
@@ -1374,7 +1375,7 @@ out_clean:
1374 kthread_stop(data[thr].thr); 1375 kthread_stop(data[thr].thr);
1375 vfree(data); 1376 vfree(data);
1376 } 1377 }
1377 if (page) vfree(page); 1378 vfree(page);
1378 1379
1379 return ret; 1380 return ret;
1380} 1381}
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 0f62326c0f5e..2a4717967502 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -63,6 +63,15 @@ static const struct rfkill_ops rfkill_gpio_ops = {
63 .set_block = rfkill_gpio_set_power, 63 .set_block = rfkill_gpio_set_power,
64}; 64};
65 65
66static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
67static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
68
69static const struct acpi_gpio_mapping acpi_rfkill_default_gpios[] = {
70 { "reset-gpios", &reset_gpios, 1 },
71 { "shutdown-gpios", &shutdown_gpios, 1 },
72 { },
73};
74
66static int rfkill_gpio_acpi_probe(struct device *dev, 75static int rfkill_gpio_acpi_probe(struct device *dev,
67 struct rfkill_gpio_data *rfkill) 76 struct rfkill_gpio_data *rfkill)
68{ 77{
@@ -75,7 +84,8 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
75 rfkill->name = dev_name(dev); 84 rfkill->name = dev_name(dev);
76 rfkill->type = (unsigned)id->driver_data; 85 rfkill->type = (unsigned)id->driver_data;
77 86
78 return 0; 87 return acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
88 acpi_rfkill_default_gpios);
79} 89}
80 90
81static int rfkill_gpio_probe(struct platform_device *pdev) 91static int rfkill_gpio_probe(struct platform_device *pdev)
@@ -102,7 +112,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
102 112
103 rfkill->clk = devm_clk_get(&pdev->dev, NULL); 113 rfkill->clk = devm_clk_get(&pdev->dev, NULL);
104 114
105 gpio = devm_gpiod_get_index(&pdev->dev, "reset", 0); 115 gpio = devm_gpiod_get(&pdev->dev, "reset");
106 if (!IS_ERR(gpio)) { 116 if (!IS_ERR(gpio)) {
107 ret = gpiod_direction_output(gpio, 0); 117 ret = gpiod_direction_output(gpio, 0);
108 if (ret) 118 if (ret)
@@ -110,7 +120,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
110 rfkill->reset_gpio = gpio; 120 rfkill->reset_gpio = gpio;
111 } 121 }
112 122
113 gpio = devm_gpiod_get_index(&pdev->dev, "shutdown", 1); 123 gpio = devm_gpiod_get(&pdev->dev, "shutdown");
114 if (!IS_ERR(gpio)) { 124 if (!IS_ERR(gpio)) {
115 ret = gpiod_direction_output(gpio, 0); 125 ret = gpiod_direction_output(gpio, 0);
116 if (ret) 126 if (ret)
@@ -150,6 +160,8 @@ static int rfkill_gpio_remove(struct platform_device *pdev)
150 rfkill_unregister(rfkill->rfkill_dev); 160 rfkill_unregister(rfkill->rfkill_dev);
151 rfkill_destroy(rfkill->rfkill_dev); 161 rfkill_destroy(rfkill->rfkill_dev);
152 162
163 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
164
153 return 0; 165 return 0;
154} 166}
155 167
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index 75e66de7e7a7..458d69b444ad 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -22,13 +22,13 @@
22 22
23static void cpuidle_cpu_output(unsigned int cpu, int verbose) 23static void cpuidle_cpu_output(unsigned int cpu, int verbose)
24{ 24{
25 unsigned int idlestates, idlestate; 25 int idlestates, idlestate;
26 char *tmp; 26 char *tmp;
27 27
28 printf(_ ("Analyzing CPU %d:\n"), cpu); 28 printf(_ ("Analyzing CPU %d:\n"), cpu);
29 29
30 idlestates = sysfs_get_idlestate_count(cpu); 30 idlestates = sysfs_get_idlestate_count(cpu);
31 if (idlestates == 0) { 31 if (idlestates < 1) {
32 printf(_("CPU %u: No idle states\n"), cpu); 32 printf(_("CPU %u: No idle states\n"), cpu);
33 return; 33 return;
34 } 34 }
@@ -100,10 +100,10 @@ static void cpuidle_general_output(void)
100static void proc_cpuidle_cpu_output(unsigned int cpu) 100static void proc_cpuidle_cpu_output(unsigned int cpu)
101{ 101{
102 long max_allowed_cstate = 2000000000; 102 long max_allowed_cstate = 2000000000;
103 unsigned int cstate, cstates; 103 int cstate, cstates;
104 104
105 cstates = sysfs_get_idlestate_count(cpu); 105 cstates = sysfs_get_idlestate_count(cpu);
106 if (cstates == 0) { 106 if (cstates < 1) {
107 printf(_("CPU %u: No C-states info\n"), cpu); 107 printf(_("CPU %u: No C-states info\n"), cpu);
108 return; 108 return;
109 } 109 }