UPSTREAM: clocksource: samsung_pwm_timer: Correct programming of clock events

In current code, the tick count value programmed to the hardware is
always decremented by one. This is reasonable for periodic mode, since
there is one extra tick between 0 and COUNT (after reloading), but it
makes oneshot events happen 1 tick earlier than requested, because the
interrupt is triggered on transition from 1 to 0.

This patch removes the decrementation from PWM channel setup code and
moves it instead to periodic timer setup, to make both periodic and
oneshot modes work correctly.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
(cherry picked from commit 6fe4dfd041dadbc1cc2460ed8680f2734dc3dc95)

BUG=chrome-os-partner:19401
TEST=Builds; not used.

Change-Id: I0f3fbb109171a7de01c9cb4006372f1b18dfcebb
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65087
Reviewed-by: Olof Johansson <olofj@chromium.org>
UPSTREAM: clocksource: samsung_pwm_timer: Work around rounding errors in clockevents core

Due to rounding errors in clockevents core (in conversions between ticks
and nsecs), it might happen that the set_next_event callback gets called
with cycles = 0, causing the code to incorrectly program the PWM timer.

This patch modifies the callback to program the timer for 1 tick, if
received tick count value is 0.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
(cherry picked from commit 81d4f7bfdc9417e7d8fc1133c762daa4458eec5e)

BUG=chrome-os-partner:19401
TEST=Builds; not used.

Change-Id: I9504b19e102b408bcbb526cb2349250c6d251b9f
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65088
Reviewed-by: Olof Johansson <olofj@chromium.org>
UPSTREAM: ARM: SAMSUNG: Do not register legacy timer interrupts on Exynos

This patch removes legacy PWM timer interrupt initialization from
exynos{4,5}_init_irq() functions, since it conflicts with internal
interrupt handling of the new PWM clocksource driver.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
(cherry picked from commit 278c800ec4bfcf26b76077e96f155c5b956bd1ad)

Conflicts:
	arch/arm/mach-exynos/common.c

BUG=chrome-os-partner:19401
TEST=Build and boot on Pit; no regressions noticed.

Change-Id: Iea75b8c7420b380dcb6d1b41b18888ba886561a3
[abrestic: fixed conflict due to local eint changes]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65089
Reviewed-by: Olof Johansson <olofj@chromium.org>
samsung_pwm: fix build for CONFIG_CLKSRC_SAMSUNG_PWM=n

If CONFIG_PWM_SAMSUNG=y and CONFIG_CLKSRC_SAMSUNG_PWM=n next-20130626
build fails with the following error:

drivers/pwm/pwm-samsung.c:89:19: error: static declaration of ‘samsung_pwm_lock’ follows non-static declaration
include/clocksource/samsung_pwm.h:23:19: note: previous declaration of ‘samsung_pwm_lock’ was here

It is caused by commit 9ebe293 ("pwm: Add new pwm-samsung driver").

Fix it by adding missing ifdef.

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Tomasz Figa <tomasz.figa@gmail.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

Posted upstream at:
    https://patchwork.kernel.org/patch/2787271/

BUG=chrome-os-partner:19401
TEST=Kernel builds when new samsung-pwm driver is added.

Change-Id: I4b8e823d296cc1fa307d520c5317cd74bb8b29a6
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65090
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: config: renormalize configs

Renormalize configs due to removal of legacy PWM, backlight, and IRQ
drivers for Exynos platforms.

BUG=chrome-os-partner:19401
TEST=Boot Pit; no regressions noticed.

Change-Id: I4cce13b00d0661d8fe6fde0feebeb56e0b310c6e
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65091
Reviewed-by: Olof Johansson <olofj@chromium.org>
pwm: samsung: Rename to pwm-samsung-legacy

This patch renames the old pwm-samsung driver to pwm-samsung-legacy to
create place for the new, rewritten, DT-aware pwm-samsung driver.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Mark Brown <broonie@linaro.org>
Tested-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thierry Reding <thierry.reding@gmail.com>

Posted upstream at:
    https://patchwork.kernel.org/patch/2830736/

Conflicts:
	drivers/pwm/Makefile

BUG=chrome-os-partner:19401
TEST=Builds; no-op since PWM isn't used yet.

Change-Id: I3debe4208e0443ff973b042ebccf1d2407d2a2b0
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65092
Reviewed-by: Olof Johansson <olofj@chromium.org>
pwm: Add new pwm-samsung driver

This patch introduces new Samsung PWM driver, which is completely
rewritten to be multiplatform- and DeviceTree-aware.

In addition, remaining problems of old driver are fixed, such as:
 - proper handling of hardware variants,
 - synchronization on SMP systems,
 - handling of boundary parameter values,
 - hardware sharing with PWM clocksource driver,
 - undefined state of PWM output after stopping PWM channel.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Mark Brown <broonie@linaro.org>
Tested-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thierry Reding <thierry.reding@gmail.com>

Posted upstream at:
    https://patchwork.kernel.org/patch/2832379/

BUG=chrome-os-partner:19401
TEST=Builds; no-op since PWM isn't used yet.

Change-Id: I39542fdac375f39e00189ff67363ec524b09b6ec
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65093
Reviewed-by: Olof Johansson <olofj@chromium.org>
pwm: Remove superseded pwm-samsung-legacy driver

This patch removes the now unused pwm-samsung-legacy driver, which was
replaced by new pwm-samsung driver.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Mark Brown <broonie@linaro.org>
Tested-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thierry Reding <thierry.reding@gmail.com>

Posted upstream at:
    https://patchwork.kernel.org/patch/2830741/

Conflicts:
	drivers/pwm/Makefile

BUG=chrome-os-partner:19401
TEST=Builds; no-op since PWM isn't used yet.

Change-Id: I9c9e6a443631dd2159031358effe6f45974aef7b
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65094
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: drm/bridge: ps8622: allow use of external PWM

The ps8622/ps8625 have an internal PWM which is used by default to control
backlight brightness.  It may be desirable, however, to pass-through an
external PWM which has a higher resolution.  Add the device-tree property
"use-external-pwm" which indicates that the bridge should be configured
to use the external PWM.

BUG=chrome-os-partner:19401
TEST=Once DT bindings are added; observe that the backlight is controlled
using the bl_pwm driver instead of the ps8622 driver.

Change-Id: Iabee5206b198fbce03fe2f0bf72c8dc568c9515e
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65095
Reviewed-by: Olof Johansson <olofj@chromium.org>
clk: exynos5420: fix pcm gate clocks

The PCM bus clocks (pcm{1,2}) are controlled by bits 25 and 26 of
GATE_BUS_PERIC, not bits 26 and 27.  Fix it.

BUG=chrome-os-partner:19401
TEST=Boot Pit; no regressions noticed.

Change-Id: I3a0fff23e5929f140814b42165781d1603698257
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65215
clk: exynos5420: add pwm clock gate

The PWM clocks are derived from the PWM APB clock (pclk_pwm in the
Exynos 5420 datasheet).  Add a gate entry for it.

BUG=chrome-os-partner:19401
TEST=Observe that backlight control works with the 5420's internal PWM
once DT bindings are added.

Change-Id: I3d6b6e2c858d12bb0f5351fb53ecb4d3ac49b21a
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65096
UPSTREAM: gdm72xx: replace obsolete NLMSG_* with type safe nlmsg_*

Signed-off-by: Hong Zhiguo <honkiko@gmail.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit b96dc464994cb6d839c3b307b20061b440dc3edb)
Signed-off-by: Ben Chan <benchan@chromium.org>

BUG=chrome-os-partner:21768
TEST=Run network_WiMaxSmoke on daisy and lumpy with WiMAX module.

Change-Id: I46c3ea3b5be3e7b979401b73e70e77e88fb6b218
Reviewed-on: https://gerrit.chromium.org/gerrit/65118
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
UPSTREAM: staging: gdm72xx: cancel work when driver unloads

cancel the work function at driver unload stage and remove
the function from the queue

Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c0352cb71d3d573a33af92d320f29f1c79d71b8b)
Signed-off-by: Ben Chan <benchan@chromium.org>

BUG=chrome-os-partner:21768
TEST=Run network_WiMaxSmoke on daisy and lumpy with WiMAX module.

Change-Id: If5d3c16a90ffcdb0b0d5bce0fadb604e98347e17
Reviewed-on: https://gerrit.chromium.org/gerrit/65119
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
UPSTREAM: gdm72xx: remove unnecessary cast in gdm_wimax.c

This patch removes an unnecessary cast on the return value
of alloc_netdev(), since alloc_netdev() returns a pointer
to the allocated struct net_device anyway.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 9ef4090385a0c35192229ca77c9de273824040b4)
Signed-off-by: Ben Chan <benchan@chromium.org>

BUG=chrome-os-partner:21768
TEST=Run network_WiMaxSmoke on daisy and lumpy with WiMAX module.

Change-Id: I2ca75564c6f928a2e8a489b6b4e20d1c1a404047
Reviewed-on: https://gerrit.chromium.org/gerrit/65120
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
UPSTREAM: staging: gdm72xx: WIMAX_GDM72XX should depend on either USB or MMC

The gdm72xx driver needs to have either the USB or SDIO implementation
enabled to provide useful functionalities, so the driver should depend
on either USB or MMC. This patch makes WIMAX_GDM72XX depend on either
USB or MMC.

Also, WIMAX_GDM72XX needs to be built as a module if its dependent
interface, either USB or MMC, is built as a module. This patch enforces
that in the WIMAX_GDM72XX_USB and WIMAX_GDM72XX_SDIO dependency.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ben Chan <benchan@chromium.org>
Cc: Sage Ahn <syahn@gctsemi.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 82ba972572f4f4e768cae8fed51399747dd5605c)
Signed-off-by: Ben Chan <benchan@chromium.org>

BUG=chrome-os-partner:21768
TEST=Run network_WiMaxSmoke on daisy and lumpy with WiMAX module.

Change-Id: I1377961c69b08e8837989d512c2e5dda7ba431ee
Reviewed-on: https://gerrit.chromium.org/gerrit/65121
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
UPSTREAM: staging: gdm72xx: potential use after free in send_qos_list()

Sometimes free_qos_entry() sometimes frees its argument.  I have moved
the dereference of "entry" ahead on line to avoid a use after free.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f2a6fed1ceaecf6054627f0ddbd4becf43c997fc)
Signed-off-by: Ben Chan <benchan@chromium.org>

BUG=chrome-os-partner:21768
TEST=Run network_WiMaxSmoke on daisy and lumpy with WiMAX module.

Change-Id: I3a370206347683f9a1d2b06256b4d294df0bdc17
Reviewed-on: https://gerrit.chromium.org/gerrit/65122
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
ARM: Add ".text.unlikely" and ".text.hot" to arm unwind tables

It appears that gcc may put some code in ".text.unlikely" or
".text.hot" sections.  Right now those aren't accounted for in unwind
tables.  Add them.

I found some docs about this at:
  http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc.pdf

Without this, if you have slub_debug turned on, you can get messages
that look like this:
  unwind: Index not found 7f008c50

BUG=chromium:269054
TEST=Boot and no longer see unwind spew

Change-Id: Ic67ea69f8d1ce8f6130e22f2187ae0d1168437d0
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64810
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
UPSTREAM: mmc: sdio: Fix SDIO 3.0 UHS-I initialization sequence

According to UHS-I initialization sequence for SDIO 3.0 cards,
the host must set bit[24] (S18R) of OCR register during OCR
handshake to know whether the SDIO card is capable of doing
1.8V I/O.

BUG=chrome-os-partner:20212, chrome-os-partner:20362
TEST=With other patches in series, see that WiFi shows up as SDR50 and
external card as SDR104.

Change-Id: Iabcaa1cc13f54d0d9041404728797098e2310cd8
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Johan Rudholm <johan.rudholm@stericsson.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit 41875e388401ad97c33252d5fa39d52e0b70ee9b)

Reviewed-on: https://gerrit.chromium.org/gerrit/61934
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Sonny Rao <sonnyrao@chromium.org>
UPSTREAM: mmc: sdio: print correct UHS mode during card detection

When SDIO3.0 card is detected, incorrect bus speed mode
is printed as part of card detection print in kernel logs.

This change fixes it so that user won't be confused by
looking at incorrect card detection message in logs.

BUG=chrome-os-partner:20212, chrome-os-partner:20362
TEST=With other patches in series, see that WiFi shows up as SDR50 and
external card as SDR104.

Change-Id: Id785976d482b204e95c440af72bb53b0075411cc
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Tested-by: Jackey Shen <Jackey.Shen@amd.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit 77e2ff08925c7ec7267dc87c27eda2e62d585b57)

Reviewed-on: https://gerrit.chromium.org/gerrit/61935
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Sonny Rao <sonnyrao@chromium.org>
UPSTREAM: mmc: sd: Simplify by using mmc_host_uhs

BUG=chrome-os-partner:20212, chrome-os-partner:20362
TEST=With other patches in series, see that WiFi shows up as SDR50 and
external card as SDR104.

Change-Id: If6a6b3d0f7412a16d69bd084e310f8ae9da69962
Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit 3f8a7fabd60e83eb2fb7add00d353d455c0e7a78)

Reviewed-on: https://gerrit.chromium.org/gerrit/61936
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Sonny Rao <sonnyrao@chromium.org>