Implement kexec-hardboot

"Allows hard booting (i.e., with a full hardware reboot) to a kernel
previously loaded in memory by kexec.  This works around the problem of
soft-booted kernel hangs due to improper device shutdown and/or
reinitialization."
More info in /arch/arm/Kconfig.

Original author: Mike Kasick <mike@kasick.org>

Vojtech Bocek <vbocek@gmail.com>:
  I've ported it to hammerhead, it is based of my mako/grouper port, which is
  based of Asus TF201 patch ported by Jens Andersen <jens.andersen@gmail.com>

  Hammerhead is the first device I've ported this patch to which uses
  device tree binary instead of atags. It is also rather picky - its
  bootloader erases first 128MB of RAM on reboot, so following hacks had
  to be applied:
  * Copy dtb to location passed in r2 before jumping to kexecd' kernel,
    the kernel would just freeze when I left dtb above 128MB of RAM.
  * Copy kexecd' kernel to location in the first 128MB before jumping to it,
    the decompressor operates very slowly if the kernel is above the cached
    area, copying it lower and decompressing it afterwards is much faster.

  Same as my mako/flo patches, the guest kernel does not require any
  modifications, kexec-hardboot is equivalent to standard kexec.

  To support dtb, following commit was backported from the mainline:
    commit 4cabd1d9625c7d88acd143f4021fbef75394f154
    Author: Matthew Leach <matthew.leach@arm.com>
    Date:   Fri Sep 21 18:56:02 2012 +0100

      ARM: 7539/1: kexec: scan for dtb magic in segments

      This patch allows a dtb to be passed to a new kernel using the kexec
      mechinism.

      When loading segments from userspace, scan each segment's first four
      bytes for the dtb magic. If this is found set the kexec_boot_atags
      parameter to the relocate_kernel code to the phyical address of this
      segment.

  and fixes of this commit:
    c564df4db85aac8d1d65a56176a0a25f46138064
    2456f44dd7a9aaffc2cd21a13f78198b3d94da08

ayysir <dresadd09691@gmail.com>:
  kexec: use mem_text_write_kernel_word to set reboot_code_buffer args
  in order to avoid protection faults (writes to read-only
  kernel memory) when CONFIG_STRICT_MEMORY_RWX is enabled.

Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
Add KEXEC option to cm kernel config

Change-Id: Idbc2ad30697e82b17fa0e7feed0431d050e0cf4a

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
LCD KCAL: Fix Gamma max value issue

Major thanks to Yorici Vz for his tireless pursuit of perfection on Nexus 5
Color / Gamma :D

Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_pp.c

Change-Id: Ia1f4e6c03d7eb5a6cc4f57676c0365fc7d14c8b2
Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
Fix compilation problems with Linaro 4.9

Change-Id: Iced91863687bd7c94dee7e58860c770498c29e08

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
Revert "msm: mdss: Restore gamma interface compatibility"

This reverts commit f65eed33c636d1f109e544e18536ccaebb913de3.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
Revert "msm: mdss: Add display gamma tuning"

This reverts commit a4a3dcf5b4528edd508cfd96d6db95c93aa49b26.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
Revert "msm: mdss: Remove debug fs"

This reverts commit 0585f017f43a021f4e76fe4d737fbbd1e19be6ec.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Display gamma control

TODO: confirm rgb channels, identify other tunables, cleanup,
apply values without switching screen (off and) on.

sysfs: /sys/devices/qcom,mdss_dsi_jdi_command_ors.69/*
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Apply commands values without switching screen (off and) on

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Remove tunable for command 32

Even slight changes look ugly or distort the screen.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: distinguish between Gamma RGB polarity Positive/Negative

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Remove sysfs for unused commands

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Identify white point in sysfs

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Add safety check for user input

Leave more checks either to the control app or the user's intelligence.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Finalize gamma interface and cleanup

- Remove all sysfs files of unused commands
- Remove auto sync for negative polarities, these must be written separately
- Protect offset bit of white point command as well
- Apply white point bit 2 as duplicate of bit 1

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Send panel commands via separate function

Sending panel comnmands is very expensive, add a separate function to
accomplish this. Once all commands have been stored write anything to
the kgamma_send file.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Add hardware revision check

Our gamma interface works with both current hardware revisions,
11 and 11j, although all testing was carried out on 11. As we
don't know about possible future revisions, let's bail out until
correct offsets for panel commands have been added.

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Use workqueue to send panel commands

Sending panel commands is known to be expensive, honor this by
scheduling this task. Also check for panel state and send commands
only when we're actually awake.

These fixes adress bug reports regarding behaviour during boot.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Find a stable sysfs node for the gamma interface

Move sysfs files to /sys/module/dsi_panel/*

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>
msm: mdss: Reset panel to apply RGB gamma data

Writing to the reset gpios produces a short flicker. This however
appears to be the only reliable method to apply RGB gamma data
without switching the panel off and on again.

Signed-off-by: Clyde Tan <bokbokan@yahoo.com>