aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-core.c
diff options
context:
space:
mode:
authorAndrew Lynn <andrew.lynn@stericsson.com>2011-10-11 04:49:47 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2011-10-24 08:09:20 -0400
commitb4a310373209b87ba455f45227b5361cb746b946 (patch)
tree12c96489e713f68f9f0024b48e2eae4f257d60a0 /drivers/mfd/ab8500-core.c
parent9b626ddd7f87f9443e9b6dfac54b5e8f52fb8f52 (diff)
mfd: Expose TurnOnStatus in ab8500 sysfs
Expose TurnOnStatus (Power key, RTC alarm, Vbus detect, etc) in sysfs. This magic value can be read by system users to determine what caused the platform to turn on last (this) time. Signed-off-by: Andrew Lynn <andrew.lynn@stericsson.com> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> Reviewed-by: Jonas Aaberg <jonas.aberg@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/ab8500-core.c')
-rw-r--r--drivers/mfd/ab8500-core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 41da9735a960..1e9173804ede 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -92,6 +92,8 @@
92#define AB8500_REV_REG 0x80 92#define AB8500_REV_REG 0x80
93#define AB8500_SWITCH_OFF_STATUS 0x00 93#define AB8500_SWITCH_OFF_STATUS 0x00
94 94
95#define AB8500_TURN_ON_STATUS 0x00
96
95/* 97/*
96 * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt 98 * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt
97 * numbers are indexed into this array with (num / 8). 99 * numbers are indexed into this array with (num / 8).
@@ -812,12 +814,40 @@ static ssize_t show_switch_off_status(struct device *dev,
812 return sprintf(buf, "%#x\n", value); 814 return sprintf(buf, "%#x\n", value);
813} 815}
814 816
817/*
818 * ab8500 has turned on due to (TURN_ON_STATUS):
819 * 0x01 PORnVbat
820 * 0x02 PonKey1dbF
821 * 0x04 PonKey2dbF
822 * 0x08 RTCAlarm
823 * 0x10 MainChDet
824 * 0x20 VbusDet
825 * 0x40 UsbIDDetect
826 * 0x80 Reserved
827 */
828static ssize_t show_turn_on_status(struct device *dev,
829 struct device_attribute *attr, char *buf)
830{
831 int ret;
832 u8 value;
833 struct ab8500 *ab8500;
834
835 ab8500 = dev_get_drvdata(dev);
836 ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK,
837 AB8500_TURN_ON_STATUS, &value);
838 if (ret < 0)
839 return ret;
840 return sprintf(buf, "%#x\n", value);
841}
842
815static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); 843static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL);
816static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); 844static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL);
845static DEVICE_ATTR(turn_on_status, S_IRUGO, show_turn_on_status, NULL);
817 846
818static struct attribute *ab8500_sysfs_entries[] = { 847static struct attribute *ab8500_sysfs_entries[] = {
819 &dev_attr_chip_id.attr, 848 &dev_attr_chip_id.attr,
820 &dev_attr_switch_off_status.attr, 849 &dev_attr_switch_off_status.attr,
850 &dev_attr_turn_on_status.attr,
821 NULL, 851 NULL,
822}; 852};
823 853