ARM: dts: Disable the ADC on exynos5250 by default

Upstream the ADC is diabled by default.  Let's do the same so that we
don't need to add an explicit "disabled" for all of our devices.

Note that we used to use the ADC on exynos5250-snow but we stopped
using it since newer revisions of hardware removed their thermistors.
I'll totally remove the ADC from the snow device tree in the next
change.

BUG=chrome-os-partner:27407
TEST=Boot and see no adc errors in logs; see no other problems

Change-Id: Iffd6f9c695fa3f2372ca7ca716057e6d47932c81
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196253
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
ARM: dts: Remove the adc from cros5250-common

The ADC was only ever used on snow and it is no longer used since we
removed the thermistors.

BUG=chrome-os-partner:27407
TEST=Boot and see no adc errors in logs; see no other problems

Change-Id: Ie67ea22688a7e75933c30b5070bfa9fd20cb4353
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196254
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
drm/exynos: Remove non-kds flip error

It's valid to flip non-kds buffers in test applications, remove the
error msg.

BUG=None
TEST=Tested by hand on snow

Change-Id: If2dca5d92fd800ae58ea7855b83a347f6f1022f0
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/192083
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
drm/exynos: Add new manager update() hook

Add a new hook for managers which causes the primary plane to be updated.

BUG=chromium:336809
TEST=Tested on snow & pit, no regressions noted

Change-Id: I5847b32691111a465843244f6d6b11fb64beb3cd
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/195460
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Input: adds support for elan i2c touchscreen.

1. Power management function for device suspend/resume, based on touchscreen set sleep/active command.
2. Create dbfs for user-space program
3. Create sysfs for attributes for user-space operations and related functions
   a. FW Version

Fix some bugs:
1. Fix name-confusing variable issue.
2. Fix build error arisen from CONFIG_PM_SLEEP scope in this source file.
3. Remove executable permissions of dbfs file

BUG=None
TEST=on Elan touchscreen, boot and touchscreen works.

Change-Id: I9dd69608792767e0794a80833d04b1f34957fc8b
Signed-off-by: Liang Po-Hsiang <iamshyang@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/193588
Reviewed-by: Charles Mooney <charliemooney@chromium.org>
Commit-Queue: Charles Mooney <charliemooney@chromium.org>
Tested-by: Charles Mooney <charliemooney@chromium.org>
mmc: dw_mmc: Don't print data errors

Data errors are completely expected during tuning.  Printing them out
is confusing people looking at the kernel logs.  They see things like:

 [    3.613296] dwmmc_exynos 12200000.dwmmc0: data error, status 0x00000088

...and they think something is wrong with their hardware.

Remove the printouts.  We'll leave it up to a higher level to report
about errors.

BUG=None
TEST=Boot on pit/pi and no longer see errors in dmesg

Change-Id: If48767e93e5276b40795b6d84be83d837bca1905
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196356
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Commit-Queue: Alim Akhtar <alim.akhtar@samsung.com>
UPSTREAM: kdb: Setup basic kdb state before invoking commands via kgdb

Although invasive kdb commands are not supported via kgdb, some useful
non-invasive commands like bt* require basic kdb state to be setup before
calling into the kdb code. Factor out some of this code and call it before
and after executing kdb commands via kgdb.

BUG=chromium:365011
TEST="monitor dumpall" in kgdb works now

Signed-off-by: Matt Klein <mklein@twitter.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
(cherry picked from commit 00370b8f8dd6e3171b8202f9c5187a5f73e99497)
Signed-off-by: Doug Anderson <dianders@chromium.org>

Change-Id: I24f0023ad42b56b1d72fe846df08a596f355421f
Reviewed-on: https://chromium-review.googlesource.com/196377
Tested-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Doug Anderson <dianders@chromium.org>
UPSTREAM: add generic fixmap.h

Many architectures provide an asm/fixmap.h which defines support for
compile-time 'special' virtual mappings which need to be made before
paging_init() has run.  This support is also used for early ioremap on
x86.  Much of this support is identical across the architectures.  This
patch consolidates all of the common bits into asm-generic/fixmap.h
which is intended to be included from arch/*/include/asm/fixmap.h.

BUG=chromium:365011
TEST=Future patch for kgdb breakpoints works now

Change-Id: I9369d8a0558b6661b9a935680e8797222232206c
Signed-off-by: Mark Salter <msalter@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit d57c33c5daa4efa9e4d303bd0faf868080b532be)
Reviewed-on: https://chromium-review.googlesource.com/196670
Reviewed-by: Kees Cook <keescook@chromium.org>
UPSTREAM: arm: use generic fixmap.h

ARM is different from other architectures in that fixmap pages are indexed
with a positive offset from FIXADDR_START.  Other architectures index with
a negative offset from FIXADDR_TOP.  In order to use the generic fixmap.h
definitions, this patch redefines FIXADDR_TOP to be inclusive of the
useable range.  That is, FIXADDR_TOP is the virtual address of the topmost
fixed page.  The newly defined FIXADDR_END is the first virtual address
past the fixed mappings.

CQ-DEPEND=CL:I0db0ddfb00d9deee7a2cf9f715ec164e28a0427a
BUG=chromium:365011
TEST=Future patch for kgdb breakpoints works now

Change-Id: I9d531e9c1cad79bcef6f50b54794859ba86bd2e5
Signed-off-by: Mark Salter <msalter@redhat.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
(cherry picked from commit a665f864487da0e09351a694519e48d27064b712)
Reviewed-on: https://chromium-review.googlesource.com/196671
Reviewed-by: Kees Cook <keescook@chromium.org>
PM / Sleep: arm: mmu: Fix fixed pte suspend volatile mapping

In (31c22cd UPSTREAM: arm: use generic fixmap.h) we changed to using
the generic fixmap implementation.  This has the notable side effect
that fixmap id 0 is now the largest address, not the smallest.

Adjust the old (PM / Sleep: arm: mmu: Mark fixed ptes as volatile
during suspend) patch to handle the new fixmap style.

BUG=chromium:365011
TEST=Print volatile chunk base addr / size before and after this
series and see that it is identical.

Change-Id: I0db0ddfb00d9deee7a2cf9f715ec164e28a0427a
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196962
Reviewed-by: Kees Cook <keescook@chromium.org>
arm: fixmap: implement __set_fixmap()

This is used from set_fixmap() and clear_fixmap() via
asm-generic/fixmap.h.

This is picked from:
  https://patchwork.kernel.org/patch/3941001/

BUG=chromium:365011
TEST=Future patch for kgdb breakpoints works now

Change-Id: I0d8bdf26c33bea1df5eb53001c51d9897fcf82fa
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196672
Reviewed-by: Kees Cook <keescook@chromium.org>
arm: use fixmap for text patching when text is RO

Use fixmaps for text patching when the kernel text is read-only,
inspired by x86.  This makes jump labels and kprobes work with the
currently available CONFIG_DEBUG_SET_MODULE_RONX and the upcoming
CONFIG_DEBUG_RODATA options.

This is picked from:
  https://patchwork.kernel.org/patch/4054071/

BUG=chromium:365011
TEST=Future patch for kgdb breakpoints works now

Change-Id: Iecdb46652ffd6abb98874af68ffb80dfcc67fb17
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196673
Reviewed-by: Kees Cook <keescook@chromium.org>
kgdb,arm: Handle read-only text / modules

Handle the case where someone has set the text segment of the kernel
as read-only by using the newly introduced "patch" mechanism.

BUG=chromium:365011
TEST=Set a breakpoint on snow and continue--it hits now.

Change-Id: I3ebcd1a17e5d54248f3243f997c364c8370a71cc
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/196674
Reviewed-by: Kees Cook <keescook@chromium.org>
UPSTREAM: serial: samsung: Use the passed in "port", fixing kgdb w/ no console

The two functions in the samsung serial driver used for writing
characters out to the port were inconsistent about whether they used
the passed in "port" or the global "cons_uart".  There was no reason
to use the global and the use of the global in
s3c24xx_serial_put_poll_char() caused a crash in the case where you
used the serial port for kgdboc but not for console.

Fix it so we used the passed in variable.

Note that this doesn't fix all problems with the samsung serial
driver.  Specifically:
* s3c24xx_serial_console_putchar() is still 99% identical to
  s3c24xx_serial_put_poll_char() (the function signature is different,
  but that's about it).  A future patch will make them slightly less
  identical and judging by other serial drivers we may need yet more
  differences eventually.
* The samsung serial driver still doesn't allow you to have more than
  one console port since it still uses the global cons_uart in
  s3c24xx_serial_console_write().

BUG=chromium:365011
TEST=With series can drop into kdb w/ no console=ttySAC3

Change-Id: I792a6fa3635e964f6d74572f7eb05473f0051884
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from tty-linus
 commit bb7f09ba961dd43a2398975cc2d4ad0eb77ec865)
Reviewed-on: https://chromium-review.googlesource.com/196950
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
UPSTREAM: brcmfmac: Fix reconnect failure after beacon timeout

The DISASSOC command needs to be sent to firmware when a connection
loss is detected by firmware (e.g., beacon timeout). Otherwise the
next connect request fails due to a lingering LINK(down) event from
firmware. This patch resolves the issue by eliminating the incomplete
duplicated if statement and using brcmf_link_down() to take care of
the event.

BUG=chrome-os-partner:28366
TEST=autotest (network_WiFi_MissingBeacons)

Change-Id: I459f9cf1cb051ec54ad5dd8f9830f84a6f167e75
Signed-off-by: Daniel Kim <dekim@broadcom.com>
Reviewed-on: http://hnd-swgit.sj.broadcom.com:8080/322
Reviewed-by: brcm80211 ci
Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-on: https://chromium-review.googlesource.com/197065
Reviewed-by: Paul Stewart <pstew@chromium.org>
BACKPORT: drm/i915: don't disable the DP port if the link is lost

Currently if the DP link is lost (either because of a hot unplug, or
failed link status check) we disable the DP port, but leave the rest
of the pipe running. This is incompatible with the modeset disabling
sequence of some platforms/configurations. At least this is the case for
DP ports on the CPU as opposed to PCH.

Atm we'll also get a warning when we do a modeset disable after the
above link lost event, since we expect the DP port to be enabled at this
point (see the bugzilla ticket for the related dmesg).

Note that with this patch we'll still end up disabling the port, thanks
to the HPD uevent and subsequent modeset disable.

See also the next patch fixing the other half of this issue.

Solution suggested by Ville.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70570
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 5d6a1116c6475404e6505b708320f9579ae19acd)
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>

BUG=chromium:368395
TEST=builds and runs on link

Change-Id: I7460dd37ce199650a70b200362c2e32f57db0df6
Reviewed-on: https://chromium-review.googlesource.com/197581
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Stéphane Marchesin <marcheu@chromium.org>
drm/exynos/fimd: only finish pageflip if START == START_S

A framebuffer gets committed to FIMD's default window like this:
 exynos_drm_crtc_update()
  exynos_plane_commit()
   exynos_drm_crtc_plane_commit()
    fimd_win_commit()

fimd_win_commit() programs BUF_START[0].  At each vblank, FIMD hardware
copies the value from BUF_START to BUF_START_S (BUF_START's shadow
register), starts scanning out from BUF_START_S, and asserts its irq.

This irq is handled by fimd_irq_handler(), which calls
exynos_drm_crtc_finish_pageflip() to free the old buffer that FIMD just
finished scanning out, and potentially commit the next pending flip.

There is a race, however, if fimd_win_commit() programs BUF_START(0)
between the actual vblank irq, and its corresponding fimd_irq_handler().

 => FIMD vblank: BUF_START_S[0] := BUF_START[0], and irq asserted
 | => fimd_win_commit(0) writes new BUF_START[0]
 |    exynos_drm_crtc_try_do_flip() marks exynos_fb as prepared
 => fimd_irq_handler()
    exynos_drm_crtc_finish_pageflip() sees prepared exynos_fb,
         and unmaps "old" fb
 ==> but, since BUF_START_S[0] still points to that "old" fb...
 ==> FIMD iommu fault

This patch ensures that fimd_irq_handler() only calls
exynos_drm_crtc_finish_pageflip() if any previously scheduled flip
has really completed.

This works because exynos_drm_crtc's flip fifo ensures that
fimd_win_commit() is never called more than once per
exynos_drm_crtc_finish_pageflip().

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

BUG=chromium:336839
TEST=i=0; while true; do i=$((i+1)); echo "$(date) iteration ${i}"; \
      restart ui; sleep 5; done
   => No kcrash due to fimd iommu fault

Change-Id: I92de4a476e0634609bb86ea1ced99c329084cf88
Reviewed-on: https://chromium-review.googlesource.com/197205
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>
drm/exynos: Use drm_framebuffer's refcount instead of our own

drm_framebuffer is already refcounted using drm_fb_[un]reference().

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

BUG=none
TEST=sanity check ui
TEST=restart ui loop, suspend_stress_test, login/logout loop
     w/ and w/out external monitor

Change-Id: I8b1e7a4458dd2ed952cd334da88cbcb5ec133faa
Reviewed-on: https://chromium-review.googlesource.com/197206
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>
ARM: exynos542x: Re-adjust the L2 cache timings at resume

On the exynos5420 and exynos5422 we need to make sure that the Data
RAM Setup is 1, Tag RAM Setup is set to 1, and Tag and Data latency
is increased by 1, in order for things to be stable.
Unfortunately some early firmware shipped with devices
doesn't set this up properly.
We'll tweak the platform-specific resume code to detect exynos542x and
fix.

BUG=chrome-os-partner:27729
TEST=Run reboot tests on pit and pi and see that there are no hangs.

Change-Id: I85030b32c3d5a79789926e1efab8e16c04dd68c5
Signed-off-by: Arjun.K.V <arjun.kv@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/195813
Reviewed-by: Doug Anderson <dianders@chromium.org>
HACK: ARM: mm: Increase TAG RAM latency and DATA RAM latency at boot

When we were doing reboot tests on Pit and Pi, we observed
hangs in pretty quick time.
So H/W team suggested:
Increase TAG RAM latency from 4 to 5 - by increasing the main
latency by 1.
Increase DATA RAM latency from 6 to 7 - by increasing the main
latency by 1.

BUG=chrome-os-partner:27729
TEST=Run reboot test on Pit/Pi and see no hangs.

Change-Id: Iacd2e78a2a0fdd998d8b10c8ffc7d29dca8d809e
Signed-off-by: Arjun.K.V <arjun.kv@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/194886
Reviewed-by: Doug Anderson <dianders@chromium.org>