mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back

The kernel allows us to specify a function call-back which will be
invoked when a system power-off request has been received. Here we
provide one which is to be used when shutting down AB8500 based
platforms.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
mfd: ab8500-sysctrl: If a charger is present, reboot instead

If a charger is attached on power off, reboot the system
into charging mode instead of powering it off.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known

When a charger is connected, we usually want AB8500 based systems to
reboot into charging-only mode. However, if the battery type cannot
be identified this would be futile, so we'll just shut the system
down instead.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
mfd: ab8500-sysctrl.c: Provide charging as reset reason

It's possible to supply a string to provide a reason for
triggering a restart. In this case our reason is to enter
charging-only mode, as a charger was found to be present.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
mfd: ab8500-gpadc: Change to usleep_range() for greater resolution

The resolution of msleep is related to HZ, so with HZ set to
100 any msleep of less than 10ms will become ~10ms.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers

Add the possibility to pass configuration settings for
SysCl1kReqRfClkBuf to SysClk8ReqRfClkBuf via platform data.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Kennet Wallden <kennet.wallden@stericsson.com>
Reviewed-by: Karl-Johan PERNTZ <karl-johan.perntz@stericsson.com>
Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
mfd: ab8500-sysctrl: export read/write symbols

Export ab8500_sysctrl_read() and ab8500_sysctrl_write() symobols.

They will be used by LTP test cases.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
mfd: abx500-core: Provide an API to dump all ABx500 registers

Some drivers can detect subsystem failures e.g. shared memory driver
can detect modem sub system failures. It would be helpful in analyzing
these failures if AB register dump is available at that point. This
patch adds the API for the drivers to dump AB registers in the kernel
log.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs

Allow users to subscribe to and view IRQ events live from debugfs.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
mfd: ab8500-debugfs: Keep count of IRQs in debugfs

This patch adds a counter to the sysfs file dynamically created
by debugfs. It also fixes an array index error.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
Reviewed-by: Mattias NILSSON <mattias.i.nilsson@stericsson.com>
mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer

Partly for coding style reasons, but mostly because sparse warns on it.

This patch is a completion of a previous patch by Mark Brown.

Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry

Add debugfs entry ab8500/hwreg to read/write bit-field in AB8500 registers.
Check the debugfs entries usage from heading comments in ab8500-debugfs.c

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: carriere etienne <etienne.carriere@stericsson.com>
Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
mfd: ab8500-debugfs: Export all AB8500 ADCs as debugfs nodes

Allow a user to take a glimpse into the inner workings of the
AB8500 Analogue-to-Digital Converters, via debugfs.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: John Beckett <john.beckett@stericsson.com>
Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
mfd: ab8500-debugfs: Set the USB charging current to 300mA for ABV3

In case of AB-V3, the eye diagram related issues are resolved.
So, set the device charging current to 300mA when connected to
standard host. Also, add the USB PHY tuning values to improve
the USB eye diagram

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: <thirupathi.chippakurthy@stericsson.com>
mfd: ab8500-debugfs: add debugfs node to read all registers

Update the ab8500_registers_print() to reuse it from multiple places.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
mfd: ab8500-core: Allow the possibility to dump all AB8500 registers

Implement an API so that a user may dump all AB8500 registers
via debugfs file access.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
mfd: ab8500-debugfs: Allow number of IRQs to be provided more dynamically

With the introduction of new AB* platforms, it's important to allow
as much code reuse as possible. By allowing a system's number of IRQs
to be dynamically passed, we can reuse almost all of the -debugfs
driver.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
mfd ab8500-gpadc: Introduce new AB version detection

Add support for AB8505 and AB9540

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Maxime Coquelin <maxime.coquelin@stericsson.com>
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
mfd: ab8500-debugfs: Add interrupt debug

This patch adds an entry in debugfs to check number of interrupts
from the AB.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
mfd: ab8500-gpadc: Add runtime pm support

Add runtime pm support to speed up multiple ADC reads in a row.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>