input: touchscreen: add Melfas MMSxxx driver

Change-Id: I60ff0ed9448e301fb9e486eaec31f940744c32ca
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: properly implement the multi-touch slot protocol

Also, drop support for non-MT proto.

Change-Id: I05bffe0609bcc804389932c169a3fc4e45566a6b
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: update driver to the new firmware i2c protocol

Change-Id: I8a5f65917de064972d06dade120cf973d08fc9f5
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: add firmware flashing support

A module parameter is present to force the driver to use
the builtin firmware in the kernel. Otherwise, a request to userspace
will be sent to find the correct version firmware binary.

Change-Id: Ia68cfbe41e4496c12425d1617a3e365ddfa197bd
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: add a power-on reset during initialization

Change-Id: I47ddc3553690182fa0243a10961db0aafbe4b478
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: update driver to work with firmware version 0x10

Change-Id: Ieb32d0e54e241baf75c4816af0bd6108720b6b15
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: don't report width major because we don't have it

Change-Id: If0e2bbac5df8a082941b5b9eb1da45d11bb1c027
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: wake up all waiting threads on initialization

Change-Id: I0443d04e1f6d696a2fa2b5e8a4da3828adfe844c
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: update driver to work with firmware version 0x11

Change-Id: I4a84c9123bc48d2bcd3b14b94bb07d6fb7b9da8f
Signed-off-by: tyoony <tyoony.yoon@samsung.com>
input: mms_ts: add suspend/resume support

Also, activate/deactivate the controller on input dev open/close.

Change-Id: I6c2d4c1d6cdb42eed6afba2ba6c166852d220524
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: add early_suspend and late_resume handler

If we have early_suspend, register those handlers instead of the
normal pm suspend/resume.

Change-Id: I5411b8077915d9731b63e84137a20a87d17e0000
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: ensure that we only enable/disable once

If the input device is closed after the early_suspend handler
turns off the controller and irq, the irq would have been disabled
a second time. Add a flag to keep track of whether the device is
on/off. When we remove the early_suspend handlers, this should
no longer be necessary.

Change-Id: I19ebd4a70a4d04e743a2b5894cb311e9f3223c21
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: update driver to work with firmware version 0x21

Change-Id: Ic5cb55f07338a660c88a8c9f121cf045dd5e6884
Signed-off-by: Colin Cross <ccross@android.com>
input: mms_ts: use i2c_transfer for reading finger data

The SMbus i2c function can read/write up to 32 byte. This could be problem
when the number of touch is greater than 5.

Change-Id: I615b4b1a01c8ccaa2312b76abf33142394e731eb
Signed-off-by: tyoony <tyoony.yoon@samsung.com>
input: mms_ts: firmware and driver update for VA24-3

VA24-3 features,
1. The 'touch' on screen edge is more enhanced.

2. Add a filter to block 'touch' caused by electric cable.

3. Added a filter of plam start that touch worked abnormally like ghost touch
   or didn't work until to restart when Palm touch and wake-up.

VA23 and VA22 features are also included.

VA23-2 features,
1. Expand 'edge scaler' to enhance the 'touch' on the screen edge.
   (edge scaler : 90->120)

2. Fix a bug that ignore screen edge's half size pattern of TX channel. MMS144
   have the half size pattern of TX channel on the top and bottom. There was
   a bug to calculate 'touch' point on this two channel.

3. The functionality of vendor specific test is implemented and optimized.

VA22 features,
1. Test routine is optimized to shorten takt time.
  - Previous firmware was designed to access test data from each node,
    which caused heavy load. Updated firmware is designed to access data
    from each axis.

2. Frequency of Tx channel(drive channel) was changed to 800kHz from 500kHz.
  - Tx frequency and related analog circuit settings are modified to prevent
    issues caused by power noise.

3. ISC which is a run-time configuration, needs parameter value to be allocated
   at given address of flash memory. And we found that some values were
   allocated at unexpected address due to coding miss, and is fixed at version
   VA22.

Change-Id: Icc0b8f7370bdddec3bc16831830615e20c05325d
Signed-off-by: tyoony <tyoony.yoon@samsung.com>

Conflicts:
	firmware/melfas/mms144_ts.fw.ihex
input: mms_ts: disable irqs during time sensitive operations

While flashing the new firmware, the touch IC is booted into a
separate mode and the firmware is bit banged over the
SCL/SDA/nINT(resetb) pins. Some operations are very timing
sensitive, and we just cannot guarantee that we can meet them.

It looks like, with the current delays, we can keep irqs off
for around 150uS-200uS.

This is unfortunate, but it is only done during firmware reflash
on boot.

Change-Id: If74de1931f5fb0ed0f8e5e2e1e636d515e1e77a5
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: make firmware flashing more robust

- Update some delays to meet timing requirements.
- Verify after every word instead of waiting till the whole image
  is written. If verify fails, retry the write several times.
- Upon a failure on retries of rewriting the word, retry firmware reflash
  from the beginning.
- If we run out of retries, do not make open()
  block anymore, just return an error.
- Update write/erase timings.
- Increase open timeout, up to 90 secs.

Change-Id: I072a2e47e3f8266d4233afd8a34cfef08ba1cf55
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: do not hardcode version in driver

The new firmware image format now includes a header
at the beginning of the data that includes the firmware
version information. So, we no longer have to modify
the driver when we update firmware, unless there is
an API change.

Change-Id: Ib573078144fad5fa99b6ded6d63e43d27fe0623d
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: don't flash fw in probe, let userspace handle it

Change-Id: I2aefa4c2a2b33fbc6ac20b2d9237db45690d9e87
Signed-off-by: Dima Zavin <dima@android.com>
input: mms_ts: allow the board to provide the firmware filename

The board file may ask the driver to load a different firmware
based on the board revision.

Change-Id: I65f1811f36952158a45aeeced53e935c1ee74d3f
Signed-off-by: Dima Zavin <dima@android.com>