MFD: twl6040-codec: Add test registers definitions

MFD: twl6040-codec: Add test registers definitions

Add definitions for test registers.

Change-Id: Ic046f4639781981ca2421f5b75c0c5408a3dc976
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
MFD: twl6040-codec: Add uEvent based event notification

Add initial support for a kobject event based notification mechanism
to inform userspace about TWL6040 events like handsfree overcurrent,
vibrator overcurrent, thermal event.

Since the events can be handled in other drivers apart from the MFD,
a new API (twl6040_report_event) is created so that MFD clients can
notify their events using a single kobject.

modified for Tuna from OMAPZOOM reference by faux123
MFD: twl6040-codec: Add register cache

Add register cache and define register operations (read, write,
set_bits, clear_bits) on cache only. So register operations
performed on I2C registers are now differentiated.

Register operations APIs exported by TWL6040 MFD are a wrapper
to its I2C counterparts at the moment.

Change-Id: I76137099e6264de9ac3213c596f662a50299aa82
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
modified for Tuna from OMAPZOOM reference by faux123
MFD: twl6040-codec: Add register supply query APIs

MFD: twl6040-codec: Add register supply query APIs

Add a new set of APIs to TWL6040 MFD to query the supply of its
registers: twl6040_get_reg_supply(), twl6040_reg_is_vdd() and
twl6040_reg_is_vio().

Change-Id: Ic320ad7759c66d705f6025361cd6a296ac695dd9
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
MFD: twl6040-codec: Add register context restore

MFD: twl6040-codec: Add register context restore

Add register context restore per supply.

Change-Id: I4918efee4fcc83f4998f59f3d376b798822ca3ce
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
MFD: twl6040-codec: Handle thermal interrupt

When the TWL6040 temperature increases above a threshold that could
damage the device, a thermal interrupt and shutdown are started
automatically by the hardware.

The thermal event handling involves the following steps:
1. Forcefully deassert AUDPWRON to avoid keeping TWL6040 is
   Power-On state any longer
2. The event is notified to Android userspace through the switch
   class based mechanism so that further actions can be taken
3. While the device is in thermal shutdown, accesses to VDD/VSS
   registers will affect only register cache
4. Once the device has recovered from the thermal event, it will
   be put back to Power-On state regardless of the state requested
   by MFD clients:
   4.1. If clients have requested Power-On state, then the context
        of VDD/VSS registers is restored
   4.2. If clients have requested Sleep state, then the request will
        be honored. The additional Power-On -> Sleep transition is
        required to ensure that reference system is disabled after
        thermal shutdown
5. An additional notification is sent to Android userspace to inform
   about thermal shutdown recovery.

modified for Tuna from OMAPZOOM reference by faux123