gpio / ACPI: add ACPI support

Add support for translating ACPI GPIO pin numbers to Linux GPIO API pins.
Needs a gpio controller driver with the acpi handler hook set.

Drivers can use acpi_get_gpio() to translate ACPI5 GpioIO and GpioInt
resources to Linux GPIO's.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
spi / ACPI: add ACPI enumeration support

ACPI 5 introduced SPISerialBus resource that allows us to enumerate and
configure the SPI slave devices behind the SPI controller. This patch adds
support for this to the SPI core.

In addition we bind ACPI nodes to SPI devices. This makes it possible for
the slave drivers to get the ACPI handle for further configuration.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: SPEAr: Add CPUFreq driver

SPEAr is an ARM based family of SoCs. This patch adds in support of cpufreq
driver for SPEAr SoCs. It is supported via DT only and so bindings are present
in binding document.

Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: ondemand: update sampling rate only on right CPUs

Fix cpufreq_gov_ondemand to skip CPU where another governor is used.

The bug present itself as NULL pointer access on the mutex_lock() call,
an can be reproduced on an SMP machine by setting the default governor
to anything other than ondemand, setting a single CPU's governor to
ondemand, then changing the sample rate by writing on:

> /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate

Backtrace:

Nov 26 17:36:54 balto kernel: [  839.585241] BUG: unable to handle kernel NULL pointer dereference at           (null)
Nov 26 17:36:54 balto kernel: [  839.585311] IP: [<ffffffff8174e082>] __mutex_lock_slowpath+0xb2/0x170
[snip]
Nov 26 17:36:54 balto kernel: [  839.587005] Call Trace:
Nov 26 17:36:54 balto kernel: [  839.587030]  [<ffffffff8174da82>] mutex_lock+0x22/0x40
Nov 26 17:36:54 balto kernel: [  839.587067]  [<ffffffff81610b8f>] store_sampling_rate+0xbf/0x150
Nov 26 17:36:54 balto kernel: [  839.587110]  [<ffffffff81031e9c>] ?  __do_page_fault+0x1cc/0x4c0
Nov 26 17:36:54 balto kernel: [  839.587153]  [<ffffffff813309bf>] kobj_attr_store+0xf/0x20
Nov 26 17:36:54 balto kernel: [  839.587192]  [<ffffffff811bb62d>] sysfs_write_file+0xcd/0x140
Nov 26 17:36:54 balto kernel: [  839.587234]  [<ffffffff8114c12c>] vfs_write+0xac/0x180
Nov 26 17:36:54 balto kernel: [  839.587271]  [<ffffffff8114c472>] sys_write+0x52/0xa0
Nov 26 17:36:54 balto kernel: [  839.587306]  [<ffffffff810321ce>] ?  do_page_fault+0xe/0x10
Nov 26 17:36:54 balto kernel: [  839.587345]  [<ffffffff81751202>] system_call_fastpath+0x16/0x1b

Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpuidle: Measure idle state durations with monotonic clock

Many cpuidle drivers measure their time spent in an idle state by
reading the wallclock time before and after idling and calculating the
difference. This leads to erroneous results when the wallclock time gets
updated by another processor in the meantime, adding that clock
adjustment to the idle state's time counter.

If the clock adjustment was negative, the result is even worse due to an
erroneous cast from int to unsigned long long of the last_residency
variable. The negative 32 bit integer will zero-extend and result in a
forward time jump of roughly four billion milliseconds or 1.3 hours on
the idle state residency counter.

This patch changes all affected cpuidle drivers to either use the
monotonic clock for their measurements or make use of the generic time
measurement wrapper in cpuidle.c, which was already working correctly.
Some superfluous CLIs/STIs in the ACPI code are removed (interrupts
should always already be disabled before entering the idle function, and
not get reenabled until the generic wrapper has performed its second
measurement). It also removes the erroneous cast, making sure that
negative residency values are applied correctly even though they should
not appear anymore.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Tested-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Len Brown <len.brown@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'pm-qos' into linux-next

* pm-qos:
  PM / QoS: Handle device PM QoS flags while removing constraints
  PM / QoS: Resume device before exposing/hiding PM QoS flags
  PM / QoS: Document request manipulation requirement for flags
  PM / QoS: Fix a free error in the dev_pm_qos_constraints_destroy()
  PM / QoS: Fix the return value of dev_pm_qos_update_request()
  PM / ACPI: Take device PM QoS flags into account
  PM / Domains: Check device PM QoS flags in pm_genpd_poweroff()
  PM / QoS: Make it possible to expose PM QoS device flags to user space
  PM / QoS: Introduce PM QoS device flags support
  PM / QoS: Prepare struct dev_pm_qos_request for more request types
  PM / QoS: Introduce request and constraint data types for PM QoS flags
  PM / QoS: Prepare device structure for adding more constraint types
Merge branch 'acpi-dev-pm' into linux-next

* acpi-dev-pm:
  ACPI / PM: Allow attach/detach routines to change device power states
  ACPI / PM: Introduce os_accessible flag for power_state
  ACPI / PM: Add check preventing transitioning to non-D0 state from D3.
  ACPI / PM: Fix build problem when CONFIG_ACPI or CONFIG_PM is not set
  ACPI / PM: Fix build problem related to acpi_target_system_state()
  ACPI / PM: Provide ACPI PM callback routines for subsystems
  ACPI / PM: Move device PM functions related to sleep states
  ACPI / PM: Provide device PM functions operating on struct acpi_device
  ACPI / PM: Split device wakeup management routines
  ACPI / PM: Move runtime remote wakeup setup routine to device_pm.c
  ACPI / PM: Move device power state selection routine to device_pm.c
  ACPI / PM: Move routines for adding/removing device wakeup notifiers
  ACPI / PM: Fix device PM kernedoc comments and #ifdefs
Merge branch 'acpi-enumeration' into linux-next

* acpi-enumeration:
  ACPI: remove unnecessary INIT_LIST_HEAD
  ACPI / platform: include missed header into acpi_platform.c
  platform / ACPI: Attach/detach ACPI PM during probe/remove/shutdown
  mmc: sdhci-acpi: add SDHCI ACPI driver
  ACPI: add SDHCI to ACPI platform devices
  ACPI / PNP: skip ACPI device nodes associated with physical nodes already
  i2c / ACPI: add ACPI enumeration support
  ACPI / platform: Initialize ACPI handles of platform devices in advance
  ACPI / driver core: Introduce struct acpi_dev_node and related macros
  ACPI: Allow ACPI handles of devices to be initialized in advance
  ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks
  ACPI: Centralized processing of ACPI device resources
  ACPI / platform: Use common ACPI device resource parsing routines
  ACPI: Move device resources interpretation code from PNP to ACPI core
  ACPI / platform: use ACPI device name instead of _HID._UID
  ACPI: Add support for platform bus type
  ACPI / ia64: Export acpi_[un]register_gsi()
  ACPI / x86: Export acpi_[un]register_gsi()
  ACPI: Provide generic functions for matching ACPI device nodes
  driver core / ACPI: Move ACPI support to core device and driver types
Merge branch 'acpica' into linux-next

* acpica: (26 commits)
  ACPICA: Update version to 20121018
  ACPICA: AcpiGetObjectInfo: Add support for ACPI 5 _SUB method
  ACPICA: Update for 64-bit generation of recent error message changes
  ACPICA: Fix externalize name to complete migration to ACPI_MOVE_NAME
  ACPICA: Add starting offset parameter to common dump buffer routine
  ACPICA: Deploy ACPI_MOVE_NAME across ACPICA source base
  ACPICA: Update support for ACPI 5 MPST table
  ACPICA: Enhance error reporting for invalid opcodes and bad ACPI_NAMEs
  ACPICA: Add ACPI_MOVE_NAME macro to optimize 4-byte ACPI_NAME copies
  ACPICA: AcpiExec: Improve algorithm for tracking memory leaks
  ACPICA: Add debug print message for mutex objects that are force-released
  ACPICA: Resource Mgr: Small fix for buffer size calculation
  ACPICA: Remove extra spaces after periods in the Intel license
  ACPICA: Remove extra spaces after periods within comments
  ACPICA: Update local C library module comments for ASCII table
  ACPICA: Fix for predefined name loop during ACPICA initialization
  ACPICA: Fix some typos in comments
  ACPICA: ACPICA core: Cleanup empty lines at file start and end
  ACPICA: Audit/update for ACPICA return macros and debug depth counter
  ACPICA: Fix unmerged acmacros.h divergences.
  ...
Merge branch 'acpi-general' into linux-next

By Toshi Kani (10) and others
* acpi-general: (37 commits)
  ACPI: drop unnecessary local variable from acpi_system_write_wakeup_device()
  ACPI: Fix logging when no pci_irq is allocated
  ACPI: Update Dock hotplug error messages
  ACPI: Update Container hotplug error messages
  ACPI: Update Memory hotplug error messages
  ACPI: Update CPU hotplug error messages
  ACPI: Add acpi_handle_<level>() interfaces
  ACPI: remove use of __devexit
  ACPI / PM: Add Sony Vaio VPCEB1S1E to nonvs blacklist.
  ACPI / battery: Correct battery capacity values on Thinkpads
  Revert "ACPI / x86: Add quirk for "CheckPoint P-20-00" to not use bridge _CRS_ info"
  ACPI: create _SUN sysfs file
  ACPI / memhotplug: bind the memory device when the driver is being loaded
  ACPI / memhotplug: don't allow to eject the memory device if it is being used
  ACPI / memhotplug: free memory device if acpi_memory_enable_device() failed
  ACPI / memhotplug: fix memory leak when memory device is unbound from acpi_memhotplug
  ACPI / memhotplug: deal with eject request in hotplug queue
  ACPI / memory-hotplug: add memory offline code to acpi_memory_device_remove()
  ACPI / memory-hotplug: call acpi_bus_trim() to remove memory device
  ACPI: add newline in power.c message
  ...

Conflicts:
	include/linux/acpi.h
Merge branch 'pm-cpufreq' into linux-next

* pm-cpufreq:
  cpufreq: governors: Fix jiffies/cputime mixup (revisited)
  cpufreq: ondemand: fix wrong delay sampling rate
  cpufreq: exynos: Use static for functions used in only this file
  cpufreq: exynos: Broadcast frequency change notifications for all cores
  cpufreq: remove use of __devexit
  cpufreq: remove use of __devinit
  cpufreq: remove use of __devexit_p
  cpufreq: Remove unnecessary initialization of a local variable
  cpufreq: Make sure target freq is within limits
  cpufreq: Avoid calling cpufreq driver's target() routine if target_freq == policy->cur
  cpufreq: Fix sparse warning by making local function static
  cpufreq: Fix sparse warnings by updating cputime64_t to u64
  cpufreq: governors: remove redundant code
  cpufreq: return early from __cpufreq_driver_getavg()
  cpufreq: fix jiffies/cputime mixup in conservative/ondemand governors
  cpufreq: Improve debug prints
  cpufreq: Move common part from governors to separate file, v2
  cpufreq / core: Fix printing of governor and driver name
  cpufreq / core: Fix typo in comment describing show_bios_limit()
Merge branch 'pm-cpuidle' into linux-next

* pm-cpuidle:
  cpuidle: fix a suspicious RCU usage in menu governor
  cpuidle: support multiple drivers
  cpuidle: prepare the cpuidle core to handle multiple drivers
  cpuidle: move driver checking within the lock section
  cpuidle: move driver's refcount to cpuidle
  cpuidle: fixup device.h header in cpuidle.h
  cpuidle / sysfs: move structure declaration into the sysfs.c file
  cpuidle: Get typical recent sleep interval
  cpuidle: Set residency to 0 if target Cstate not enter
  cpuidle: Quickly notice prediction failure in general case
  cpuidle: Quickly notice prediction failure for repeat mode
  cpuidle / sysfs: move kobj initialization in the syfs file
  cpuidle / sysfs: change function parameter
Merge branch 'pm-opp' into linux-next

* pm-opp:
  PM / OPP: using kfree_rcu() to simplify the code
  PM / OPP: predictable fail results for opp_find* functions, v2
  PM / OPP: Export symbols for module usage.
  PM / OPP: RCU reclaim
Merge branch 'pm-runtime' into linux-next

* pm-runtime:
  base: power - use clk_prepare_enable and clk_prepare_disable
Merge branch 'pm-sleep' into linux-next

* pm-sleep:
  PM / Freezer: Fixup compile error of try_to_freeze_nowarn()
  driver core / PM: move the calling to device_pm_remove behind the calling to bus_remove_device
  PM / Hibernate: use rb_entry
  PM / sysfs: replace strict_str* with kstrto*
Merge branch 'pm-cpufreq-next' into linux-next

* pm-cpufreq-next:
  cpufreq: ondemand: update sampling rate only on right CPUs
  cpufreq: SPEAr: Add CPUFreq driver
Merge branch 'pm-cpuidle-next' into linux-next

* pm-cpuidle-next:
  cpuidle: Measure idle state durations with monotonic clock
Merge branch 'acpi-enumeration-next' into linux-next

* acpi-enumeration-next:
  spi / ACPI: add ACPI enumeration support
  gpio / ACPI: add ACPI support