mfd: pm8821-core: Add support for PMIC thermal alarm

Add a pm8xxx-tm subdevice into pm8821-core.  The pm8xxx-tm device
can be used to receive an interrupt when critical temperature
thresholds are reached.  Since PM8821 does not have an ADC, it is
not possible to read a real time PM8821 die temperature using
this pm8xxx-tm device.

Change-Id: I3720c79a0546e8bc69044166f70dd4c313e84daa
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 1604779c47df4bf003211c35e356210e689676d5)
This commit is contained in:
David Collins 2012-08-30 16:18:56 -07:00 committed by Iliyan Malchev
parent d295b07b2e
commit 56468a5ad1
2 changed files with 37 additions and 0 deletions

View file

@ -29,6 +29,9 @@
#define REG_MPP_BASE 0x050
#define REG_IRQ_BASE 0x100
#define REG_TEMP_ALARM_CTRL 0x01B
#define REG_TEMP_ALARM_PWM 0x09B
#define PM8821_VERSION_MASK 0xFFF0
#define PM8821_VERSION_VALUE 0x0BF0
#define PM8821_REVISION_MASK 0x000F
@ -142,6 +145,29 @@ static struct mfd_cell debugfs_cell __devinitdata = {
.pdata_size = sizeof("pm8821-dbg"),
};
static const struct resource thermal_alarm_cell_resources[] __devinitconst = {
SINGLE_IRQ_RESOURCE("pm8821_tempstat_irq", PM8821_TEMPSTAT_IRQ),
SINGLE_IRQ_RESOURCE("pm8821_overtemp_irq", PM8821_OVERTEMP_IRQ),
};
static struct pm8xxx_tm_core_data thermal_alarm_cdata = {
.adc_type = PM8XXX_TM_ADC_NONE,
.reg_addr_temp_alarm_ctrl = REG_TEMP_ALARM_CTRL,
.reg_addr_temp_alarm_pwm = REG_TEMP_ALARM_PWM,
.tm_name = "pm8821_tz",
.irq_name_temp_stat = "pm8821_tempstat_irq",
.irq_name_over_temp = "pm8821_overtemp_irq",
.default_no_adc_temp = 37000,
};
static struct mfd_cell thermal_alarm_cell __devinitdata = {
.name = PM8XXX_TM_DEV_NAME,
.id = 1,
.resources = thermal_alarm_cell_resources,
.num_resources = ARRAY_SIZE(thermal_alarm_cell_resources),
.platform_data = &thermal_alarm_cdata,
.pdata_size = sizeof(struct pm8xxx_tm_core_data),
};
static int __devinit
pm8821_add_subdevices(const struct pm8821_platform_data *pdata,
@ -183,6 +209,14 @@ pm8821_add_subdevices(const struct pm8821_platform_data *pdata,
goto bail;
}
ret = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL,
irq_base);
if (ret) {
pr_err("Failed to add thermal alarm subdevice ret=%d\n",
ret);
goto bail;
}
return 0;
bail:
if (pmic->irq_chip) {

View file

@ -21,6 +21,7 @@
#include <linux/device.h>
#include <linux/mfd/pm8xxx/pm8821-irq.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/tm.h>
#define PM8821_NR_IRQS (112)
#define PM8821_NR_MPPS (4)
@ -38,6 +39,8 @@
PM8821_IRQ_BLOCK_BIT(PM8821_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8821_OVERTEMP_IRQ PM8821_IRQ_BLOCK_BIT(5, 2)
#define PM8821_TEMPSTAT_IRQ PM8821_IRQ_BLOCK_BIT(5, 7)
struct pm8821_platform_data {
int irq_base;