BACKPORT: ACPI / LPSS: add support for Intel BayTrail

Intel BayTrail has almost the same Low Power Subsystem than Lynxpoint with
few differences. Peripherals are clocked with different speeds (typically
lower) and the clock is not always gated. To support this we add
possibility to share a common fixed rate clock and make clock gating
optional.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit f627217064dbef1eef53ceb01edb9c94203991e0)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system

Change-Id: I0746a6a2323711aa9de0658a45df9099cc2ff876
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178550
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl: add pin list based GPIO ranges

Traditionally, GPIO ranges are based on consecutive ranges of both GPIO
and pin numbers. This patch allows for GPIO ranges with arbitrary lists
of pin numbers.

Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit c8587eeef8fc219e806e868c6f0c7170c769efab)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178550

Change-Id: I5b26b865ca2ef5b00a87afaf8eebac078ec60099
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178551
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl: add Intel BayTrail GPIO/pinctrl support

Add support for gpio on Intel BayTrail platforms. BayTrail supports 3 banks
of gpios called SCORE, NCORE ans SUS with 102, 28 and 44 gpio pins.
Supports gpio interrupts and ACPI gpio events

Pins may be muxed to alternate function instead of gpio by firmware.
This driver does not touch the pin muxing and expect firmare
to set pin muxing and pullup/down properties properly.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit a5d811bbf1c6df86cfe23948059ea614554b9f19)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178551

Change-Id: Ib0409e7d706421ca95e9c7b34b0db8127b26cf06
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178552
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl-baytrail: fix indentations

There are two minor issues with indentation in the code. This patch fixes them.
No functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit ec243320e02ca9e3cb64c0ba774e25db73b32fdb)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178552

Change-Id: Ib5ef2f11b0a27f62c8f5423708242619b3891f49
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178553
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl-baytrail: change lvl to level

Additionally remove trailing whitespace when print triggering type.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 1583449ef71610cc07df264db34870f79f4bcd12)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178553

Change-Id: I1a533470c1b707da9272eb04432bef1c20259cf5
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178554
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl-baytrail: remove redundant ptr variable

There is no need to have an additional variable in byt_gpio_reg().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 9c5b65579597609844ae248a6e76f614f02e3c42)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178554

Change-Id: I88babd997d401935f6c731a82c0977c639496fb0
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178555
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl-baytrail: introduce to_byt_gpio() macro

The introduced macro helps to convert struct gpio_chip to struct byt_gpio.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 17e52464292320d0de260b146605d93326a9014c)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178555

Change-Id: Id68bcd408d6790923d7ee864ec74c8e4fb1c37bb
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178556
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: pinctrl-baytrail: fix to avoid sparse warnings

There are couple of sparse warnings we could avoid if we use a bit verbose
version of the code in byt_gpio_direction_output().

drivers/pinctrl/pinctrl-baytrail.c:266:45: warning: dubious: x | !y
drivers/pinctrl/pinctrl-baytrail.c:267:36: warning: dubious: x | !y

Additionally simplify a bit the code in byt_gpio_direction_input().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 496940c10278599528cfbde0e05208bf4ef0c7c0)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178556

Change-Id: I5daeddb690c16661893a8e14f190334c5afcb24b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178557
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
CHROMIUM: acpi: Add BayTrail SoC GPIO and LPSS ACPI IDs

This adds the new ACPI ID (INT33FC) for the BayTrail GPIO
banks as seen on a BayTrail M System-On-Chip platform.  This
ACPI ID is used by the BayTrail GPIO (pinctrl) driver to
manage the Low Power Subsystem (LPSS).

NOTE: this was sent upstream but is not merged so it is not
quite a backport yet.

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178557

Change-Id: Idea96367e111d08e931be58e70fa4d4d7d10ac08
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178558
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
BACKPORT: x86/intel/lpss: Add pin control support to Intel low power subsystem

x86 chips with LPSS (low power subsystem) such as Lynxpoint and
Baytrail have SoC like peripheral support and controllable pins.

At the moment, Baytrail needs the pinctrl-baytrail driver to let
peripherals control their gpio resources, but more pincontrol
functions such as pin muxing and grouping are possible to add
later.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: http://lkml.kernel.org/r/1379080949-21734-1-git-send-email-mathias.nyman@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit 0f531431d3de88efb4234d6c0ce22089ec035a38)

BUG=chrome-os-partner:24314
TEST=build and boot on rambi system
CQ-DEPEND=CL:178558

Change-Id: I2042be410c7226d17cf37296565a60c50dfdab47
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178559
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
CHROMIUM: x86: chromeos_laptop: Update NFC GPIO to 9

Proto1b boards use GPIO9 for NFC interrupt.

BUG=chrome-os-partner:23752
TEST=boot and see NFC controller interrupt assigned

Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/176643
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Arman Uguray <armansito@chromium.org>
(cherry picked from commit 44ffc316318eaad2814b83747d14a5f89946d1cc in
cros/chromeos-3.8)

Change-Id: Icc138ba86ff6d2691d8bf192279f8b592f2abc08
Signed-off-by: Arman Uguray <armansito@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180229
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
UPSTREAM: thermal: cut the spaces when user sets policy

Setting policy results in invalid value error.
	% echo "step_wise" > policy
	% echo: write error: Invalid argument

Need clean up of the buffer which "echo" may add based on the arguments, before
comparing aganist list of governor names.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verfied. echo "step_wise" > policy, it run ok.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Tested-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
(cherry picked from commit 42a5bf507d7f7ecbf606eb392dd9d2e4d009c36b)

Change-Id: I9daff419f3fd37ea241672b8bd8ced39c3f59b14
Reviewed-on: https://chromium-review.googlesource.com/181861
Tested-by: Wei Ni <wni.nvidia@gmail.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
UPSTREAM: thermal: hwmon: move hwmon support to single file

In order to improve code organization, this patch
moves the hwmon sysfs support to a file named
thermal_hwmon. This helps to add extra support
for hwmon without scrambling the code.

In order to do this move, the hwmon list head is now
using its own locking. Before, the list used
the global thermal locking. Also, some minor changes
in the code were required, as recommended by checkpatch.pl.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit 0dd88793aacd7c91b9724be7b618bb3f7c25befe)

Change-Id: Iff6da8206200d842d9d7a56a2f2d613439977561
Reviewed-on: https://chromium-review.googlesource.com/181440
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
UPSTREAM: drivers: thermal: make usage of CONFIG_THERMAL_HWMON optional

When registering a new thermal_device, the thermal framework
will always add a hwmon sysfs interface.

This patch adds a flag to make this behavior optional. Now
when registering a new thermal device, the caller can
optionally inform if hwmon interface is desirable. This can
be done by means of passing a thermal_zone_params.no_hwmon == true.

In order to keep same behavior as of today, all current
calls will by default create the hwmon interface.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: Zhang Rui <rui.zhang@intel.com>
Suggested-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit ccba4ffd9eff6120a20cc7656458ac554aec4b0c)

Change-Id: I9295a73eedb0b9165fb7ed8412cddb7f8cc559ac
Reviewed-on: https://chromium-review.googlesource.com/181441
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
UPSTREAM: thermal: thermal_core: allow binding with limits on bind_params

When registering a thermal zone device using platform information
via bind_params, the thermal framework will always perform the
cdev binding using the lowest and highest limits (THERMAL_NO_LIMIT).

This patch changes the data structures so that it is possible
to inform what are the desired limits for each trip point
inside a bind_param. The way the binding is performed is also
changed so that it uses the new data structure.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit a8892d83894bcbd2717846cfa85955152b73453f)

Change-Id: I71035ac366118b2a2b81afcfd9a0313fd5f55e29
Reviewed-on: https://chromium-review.googlesource.com/181442
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
UPSTREAM: drivers: thermal: add check when unregistering cpu cooling

This patch avoids NULL pointer accesses while unregistering
cpu cooling devices, in case a NULL pointer is received.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit 50e66c7ed8a1cd7e933628f9f5cf2617394adf5a)

Change-Id: Ieb670b63ecaf5b03a98e01dde0f2d6aa1479e3fc
Reviewed-on: https://chromium-review.googlesource.com/181443
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
UPSTREAM: thermal: allow registering without .get_temp

This patch changes the thermal core driver to allow
registration of thermal zones without the .get_temp callback.

The idea behind this change is to allow lazy registration
of sensor callbacks.

The thermal zone will be disabled whenever the ops
does not contain a .get_temp callback. The sysfs interface
will be returning -EINVAL on any temperature read operation.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit 81bd4e1cebed5efb85bd94a15342ee4d6965a416)

Change-Id: I68a1eac2f4755de73ffbf25eed0a0031af22233f
Reviewed-on: https://chromium-review.googlesource.com/181444
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Wei Ni <wni.nvidia@gmail.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
UPSTREAM: thermal: introduce device tree parser

This patch introduces a device tree bindings for
describing the hardware thermal behavior and limits.
Also a parser to read and interpret the data and feed
it in the thermal framework is presented.

This patch introduces a thermal data parser for device
tree. The parsed data is used to build thermal zones
and thermal binding parameters. The output data
can then be used to deploy thermal policies.

This patch adds also documentation regarding this
API and how to define tree nodes to use
this infrastructure.

Note that, in order to be able to have control
on the sensor registration on the DT thermal zone,
it was required to allow changing the thermal zone
.get_temp callback. For this reason, this patch
also removes the 'const' modifier from the .ops
field of thermal zone devices.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit 4e5e4705bf69ea450f58fc709ac5888f321a9299)

Change-Id: I0b389b4a034de3409ad250bf0f36e56185a5b3f4
Reviewed-on: https://chromium-review.googlesource.com/181445
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
UPSTREAM: ACPI / thermal: remove const from thermal_zone_device_ops declaration

The following commit introduced the requirement to not declare
thermal_zone_device_ops structs as const in order to allow
changing the .get_temp callback.

commit 4e5e4705bf69ea450f58fc709ac5888f321a9299
Author: Eduardo Valentin <eduardo.valentin@ti.com>
Date:   Wed Jul 3 15:35:39 2013 -0400

    thermal: introduce device tree parser

Modify acpi_thermal_zone_ops to follow the new requirement.

Signed-off-by: Emil Goode <emilgoode@gmail.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dylan Reid <dgreid@chromium.org>
(cherry picked from commit ec9c9c2ec1d164f3c5f3c9ac41f43de40040e43c)

Change-Id: If0b74cc2995a1da585e5c038ec4103f555653e1d
Reviewed-on: https://chromium-review.googlesource.com/182057
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
UPSTREAM: thermal: core: introduce thermal_of_cooling_device_register

This patch adds a new API to allow registering cooling devices
in the thermal framework derived from device tree nodes.

This API links the cooling device with the device tree node
so that binding with thermal zones is possible, given
that thermal zones are pointing to cooling device
device tree nodes.

Cherry picked from:
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

BUG=None
TEST=Verified. Build and boot up system.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
(cherry picked from commit a116b5d44f144586ef03a93f14ddc63f4a85e906)

Change-Id: I759f297c311d546444df66029d7f2262c115cb86
Reviewed-on: https://chromium-review.googlesource.com/181446
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>