[Vibrator] Add twl6040 vibrator driver

Adding twl6040 Android vibrator driver.

Change-Id: I2a01bdf2a1fd5e53854173ac042a909100c175d0
Signed-off-by: Dan Murphy <dmurphy@ti.com>

Conflicts:
	drivers/misc/Kconfig
	drivers/misc/Makefile
misc: twl6040-vib: Voltage raise speed made configurable in Board support file

Add support to dynamically configure the voltage raise speed for the vibrator.

Change-Id: I443dd7e614838327aac9fb0d83c19ed9c5d9e092
Signed-off-by: Dan Murphy <dmurphy@ti.com>
misc: twl6040-vib: Power the vibrator up/down as needed

The vibrator was being powered up at the probe stage, and then never
released to power down.  This patch powers the vibrator up/down only
when it is being used.

To reduce power cycles and improve haptic latency, the twl6040 is held
on for 5 seconds after the last use.

Change-Id: I923bcb993326b3df05976bf9c6ca055fa0181698
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
MFD: twl6040-codec: Allow passing flags to IRQ request

Allow passing irqflags to TWL6040 IRQ request API (twl6040_request_irq).

Change-Id: I731931c4f8fc9aee57bb3707c94f7b763e140c0a
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
ASoC: twl6040: Convert PLUGINT to no-suspend irq

During suspend/resume cycle, PLUGINT could be processed while
corresponding irq has not being enabled back, so PLUGINT handler
is skipped. Converting PLUGINT to no-suspend type makes this
interrupt to be handled properly during resume as it's kept enabled
during suspend.

Change-Id: I38c344113816afcf05634cb92cdd0d81a908b088
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
OMAP4430: USB Host: Implement workaround for Errata i719

The OMAP4 EHCI controller has the following defect (errata ID i719):

Title:
	HS USB: Multiple OFF Mode Transitions Introduce Corruption

Description:
	When the system enters off mode, the save-and-restore (SAR)
        process comes into play. When the save of the USB context
	occurs, an extra pulse of UTMI_root clock coming from USB
	DPLL is entering the IP, and generates a minor corruption.
	This corrupted context is saved and restored later.
	This corruption will impact the next use of the USB module:
	it could be while resuming a suspended device, or it could
	be upon the enumeration of a new device. The exact failure
	is not predictable: disconnection or stalls have been observed.
	TLL and external PHY modes are impacted.

WORKAROUND:
	During ON time, anytime before starting the next save sequence:
	• Set the CM_L3INIT_HSUSBHOST_CLKCTRL[1:0] MODULEMODE bit field
	  to 0x2 (enabled).
	• Wait 1 ms.
	• Set the same bit field back to 0x0 (disabled).

All OMAP4430 devices are impacted.

Change-Id: I63c866504ae3899c73755e6f6b00d388205c20bd
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
Add thermal framework to the staging area

Add a thermal framework to the kernel so that thermal
sensors, thermal governors and thermal cooling agents
can register.

This framework presents a single point of thermal integration.
The framework is responsible for receiving the temperature
from the temp sensor and pushing the temperature to the correct
governor.

The temp sensor is expected just to report the temp for a particular domain
The governor is the policy holder for the specifc domain
The cooling device is the agent used to cool the specific domain

The sensor, governor and cooling device are linked via the domain_name
entry in the thermal_dev structure.

Change-Id: I892e52d508dddf4320f7366e0eab3c706c2850bd
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Add OMAP on-die governor to the thermal fw

Add the OMAP on-die governor to the thermal framework.
This component will impose the policy for the on-die temp
sensor.

Change-Id: I68d69309c79088e44573991c940139e9710377f1
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Add OMAP on die temp sensor support

Add the OMAP4 on-die temperature sensor support to
the thermal framework

Change-Id: I6b3a5e0de1620b229f2d6e61111da20f148bf7d8
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Fix panic on 4430 for the temp sensor idle

On 4430 the on-die temp sensor is not used.  But the CPU idle
path still calls the temp sensor idle.  This is not right

Only allow idle on 4460.

Change-Id: I1e9be21bc0d6d05c015d718121b04e01d905efb1
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Thermal Governor: Disable annoying logging statement

Remove the informative statement from the thermal governor

Change-Id: I2bf574ad7c57ec3b19231c27944f529b345d7cbb
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Update adc to temperature table and the table boundaries

The adc value to temperature table is changed. Incorporating
the changes in the table and also changing the boundary values correspondigly.

Change-Id: I1505073269715385459a66d86560e2902f0476f8
Signed-off-by: Keerthy <j-keerthy@ti.com>
OMAP4 TEMP_SENSOR: Update the TSHUT configuration to a safer value

The configuration of THSUT_HOT value (where a thermal shutdown will occur)
shall take care of the temperature gradient that exists betwen the
on-die sensor and the OMAP hot spot temperature.
Thermal shutdown shall prevent the OMAP hot spot reaching 125C,
TSHUT_HOT (at on-die sensor level) shall be set at 110C.

Change-Id: I769f267c8dd659ea06282a1778b82698bda508b7
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4 TEMP_SENSOR: Fix configurations of thresholds and associated masks

In omap_configure_temp_sensor_thresholds() function, the temporary variable
temp shall not be ORed as it is not always initialized to '0'. This leads
to incorrect configuration of BGAP_TSHUT_OFFSET register.

In omap_set_thresholds() function, the new thresholds are compared
to the current temperature to set/clear corresponding masks.
The current temperature shall be defined in "ADC" code instead of
milli-celsius degree. Otherwise, the comparison fails and the masks
are wrongly set.

Change-Id: Ia3939b2467edab3979513f1f8c48a68ab0d96ac4
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4 TEMP_SENSOR: Removed unwanted save/restore of ctrl register

This patch fixes issue with switching temperature sensor off after
resume from suspend.

Change-Id: I015a1f8c9a3168e7da518d068e0439aaa950e490
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal Governor: Update the actions for each thermal zone

This patch applies the following changes to the governor:
 - Set the FATAL zone at 125C - accuracy of on-die sensor is already
included in the hot spot temperature extrapolation
 - Updated the formula to extrapolate the hot spot temperature:
the parameters of the formula are updated to keep OMAP in safe
thermal conditions
 - Fixed the main state machine handling the transition between
thermal zones
 - Fixed the thresholds and monitoring rate configuration
for the various thermal zones
 - Moved the cpu throttle from monitor zone to the panic zone
 - Updated the behavior in panic zone to handle consecutives entrance
into the panic zone
To summarize, this patch ensures that the CPU frequency is throttled
by 1 step when hot spot temperature enters into panic zone. Then
maximum CPU frequency is re-enabled when hot spot temperature comes back
into the monitor zone.

Change-Id: Idf870e3ae17c5b23921eeff9e31f2b3f193dbf2d
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal Governor: Added logging statement

This patch adds log when entering thermal zones

Change-Id: Iec6d70f6625bd756d5018026d3f50fbea7eddf3f
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal: Modify the panic zone to be more agressive

Modify the panic zone to be more agressive with the cooling.
Basically once this zone is reached the governor should set the
threshold windows so that it can be notified if the temp is still
increasing once the the CPU is throttle.  If the temp is still increasing
then go to the next OPP until max throttling.

Change-Id: I4d4698a8f8ead5ce243032d80e136d7638e675f9
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Thermal FW: Temp sensor: Update PM ops for runtime

Update the pm runtime resume handler for context lost
scenario.

Change-Id: I6cf010a396d01e096c5a0a024f6ab12bb0c7f790
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Staging: Temp sensor: Update the logging for missing func name

Change the logging for the clock on/off statement from err to debug
as this is not really an error.  Add the function name for debugging ease

Change-Id: I8fb5373914812ab10569de0e02d758ac034b95a5
Signed-off-by: Dan Murphy <dmurphy@ti.com>