CHROMIUM: Input: atmel_mxt_ts: fix out-of-bounds array accesses

The current_id map is fixed to a size of MXT_MAX_FINGER (10), but
the touch controller may generate reports for a larger number of
IDs.  On Nyan, for example, the controller claims it can report
up to 16 touch IDs.  During initialization of the touchscreen,
events were generated for all 16 touch IDs causing out-of-bounds
writes to the current_id map.  Instead of fixing the size to 10,
dynamically allocate the current_id map based on the number of
touch IDs the controller claims to support.

BUG=none
TEST=Build and boot on Nyan.  evtest output looks reasonable.
Suspend/resume is no longer broken.

Change-Id: Iabf5f91839ed1523374209beac7daa209bbf060d
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179758
Reviewed-by: Yufeng Shen <miletus@chromium.org>
CHROMIUM: atmel: Add support for probing device from ACPI

With firmware support it is possible to discover and probe devices
on I2C buses without needing the glue layer in chromeos_laptop that
we use today.

This requires that the drivers implement the new acpi_match_table
with compatible ACPI IDs.

I chose to use ATML0000 for touchpad and ATML0001 for touchscreen
since the driver likes to determine which has been probed based on
the device id and our config/firmware update scripts need to easily
distinguish between touchpad and touchscreen.

When probed from ACPI the i2c device id structure is NULL so we have
to pull out the ACPI ID and compare the ID to determine if it is a
touchpad or touchscreen.

Additionally the driver check to see if something is found at the
specified address is changed to always run, rather than just when
probing from DeviceTree.

BUG=chrome-os-partner:24380
TEST=manual:

With firmware changes to expose I2C controllers as ACPI devices
instead of in PCI mode and expose the Touchpad as an ACPI device
in that controller namespace with an appropriate I2cSerialBus()
resource the existing touchpad is probed without using the glue
layer in chromeos_laptop:

input: Atmel maXTouch Touchpad as /devices/platform/80860F41:00/i2c-0/0-004b/input/input3

The interrupt is also probed properly:
  51:        321          0   IO-APIC-edge      ATML0000:01

Change-Id: I8247f150fcd62037d8df6d39993760504828a261
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/182330
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
CHROMIUM: atmel_mxt_ts - adding prefix "atmel_mxt_ts" when logging

This makes the logging of atmel_mxt_ts driver consistent in prefix
message.

BUG=chromium:329814
TEST=checking demsg that all the atmel device logging has prefix
     "atmel_mxt_ts".

Change-Id: I14c29090f60097a8e296eae6cfa0b5263728e30d
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180985
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
(cherry picked from commit 7156b5e62cbb1fcc72e5287c681b3bda9109a9c8)
Signed-off-by: Benson Leung <bleung@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/183996
Enable atmel 540s trackpad for atmel_mxt_ts driver

The Atmel 540s chip has an additional object in Atmel's object protocol
that was not used by previous ChromeOS devices.  This object T100 needs
to be supported if we are to use 540s touchpads in the future.  This CL
adds support to the atmel_mxt_ts drive for the T100 object and its
related parameters so that 540s touchpads will work.

BUG=chrome-os-partner:24559
TEST=Run evtest on new trackpad. Check the pointer moving and that
input events are arriving as expected.  This patched driver was also
tested on a Spring to make sure that the old Atmel pads that don't use
the new T100 format still work.

Change-Id: I4c4512b2b3c1f334196ad672cb17f7db16d293ee
Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.com>
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180151
Reviewed-by: Wonjoon Lee <woojoo.lee@samsung.com>
Tested-by: Wonjoon Lee <woojoo.lee@samsung.com>
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/188876
Reviewed-by: Benson Leung <bleung@chromium.org>
CHROMIUM: atmel_mxt_ts - update appmode addr to bootloader mode address mapping

The current mapping for appmode addr and bootloader mode is
app mode        bootloader mode
0x4a                  0x26
0x4b                  0x25

Starting from 1664S, the mapping becomes
app mode        bootloader mode
0x4a                  0x26
0x4b                  0x27

This patch updates the mapping.

BUG=chromium:359268
TEST=fw update works on devices with new touch controllers.

Change-Id: I86939709dc98699b97842ca7e3572501ff08e486
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/192653
Reviewed-by: Benson Leung <bleung@chromium.org>
CHROMIUM: atmel_mxt_ts: Set T100 CTRL value for lid close event

Save the T100 CTRL value when receiving lid close event as same way
we do for T9 CTRL.

BUG=chrome-os-partner:26410
TEST=use lid to suspend/resume samus and make sure touchscreen/pad are
always working after resume.

Change-Id: I5e0fbbf5619f84fa8fa0af8b81d47836652bbc6a
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/194607
Reviewed-by: Benson Leung <bleung@chromium.org>