aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-core.c
diff options
context:
space:
mode:
authorMattias Wallin <mattias.wallin@stericsson.com>2011-03-02 05:52:36 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 05:42:02 -0400
commite5c238c3fde93afdddef36aec2642155c709d93a (patch)
tree11672950437eab7f30218fe2b9b6e44fb1dccde9 /drivers/mfd/ab8500-core.c
parentadceed6263887e04721b477e6504aa24789f827d (diff)
mfd: ab8500-core switch off status added
This patch adds a sysfs file with the ab8500 switch off status. The switch off status contains information of what caused the ab8500 chip to power off. A print during boot is also added. Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com> Acked-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.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 8d6c29251dcd..6e185b272d00 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -90,6 +90,7 @@
90#define AB8500_IT_MASK24_REG 0x57 90#define AB8500_IT_MASK24_REG 0x57
91 91
92#define AB8500_REV_REG 0x80 92#define AB8500_REV_REG 0x80
93#define AB8500_SWITCH_OFF_STATUS 0x00
93 94
94/* 95/*
95 * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt 96 * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt
@@ -652,10 +653,38 @@ static ssize_t show_chip_id(struct device *dev,
652 return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); 653 return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL);
653} 654}
654 655
656/*
657 * ab8500 has switched off due to (SWITCH_OFF_STATUS):
658 * 0x01 Swoff bit programming
659 * 0x02 Thermal protection activation
660 * 0x04 Vbat lower then BattOk falling threshold
661 * 0x08 Watchdog expired
662 * 0x10 Non presence of 32kHz clock
663 * 0x20 Battery level lower than power on reset threshold
664 * 0x40 Power on key 1 pressed longer than 10 seconds
665 * 0x80 DB8500 thermal shutdown
666 */
667static ssize_t show_switch_off_status(struct device *dev,
668 struct device_attribute *attr, char *buf)
669{
670 int ret;
671 u8 value;
672 struct ab8500 *ab8500;
673
674 ab8500 = dev_get_drvdata(dev);
675 ret = get_register_interruptible(ab8500, AB8500_RTC,
676 AB8500_SWITCH_OFF_STATUS, &value);
677 if (ret < 0)
678 return ret;
679 return sprintf(buf, "%#x\n", value);
680}
681
655static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); 682static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL);
683static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL);
656 684
657static struct attribute *ab8500_sysfs_entries[] = { 685static struct attribute *ab8500_sysfs_entries[] = {
658 &dev_attr_chip_id.attr, 686 &dev_attr_chip_id.attr,
687 &dev_attr_switch_off_status.attr,
659 NULL, 688 NULL,
660}; 689};
661 690
@@ -697,6 +726,24 @@ int __devinit ab8500_init(struct ab8500 *ab8500)
697 } 726 }
698 ab8500->chip_id = value; 727 ab8500->chip_id = value;
699 728
729 /*
730 * ab8500 has switched off due to (SWITCH_OFF_STATUS):
731 * 0x01 Swoff bit programming
732 * 0x02 Thermal protection activation
733 * 0x04 Vbat lower then BattOk falling threshold
734 * 0x08 Watchdog expired
735 * 0x10 Non presence of 32kHz clock
736 * 0x20 Battery level lower than power on reset threshold
737 * 0x40 Power on key 1 pressed longer than 10 seconds
738 * 0x80 DB8500 thermal shutdown
739 */
740
741 ret = get_register_interruptible(ab8500, AB8500_RTC,
742 AB8500_SWITCH_OFF_STATUS, &value);
743 if (ret < 0)
744 return ret;
745 dev_info(ab8500->dev, "switch off status: %#x", value);
746
700 if (plat && plat->init) 747 if (plat && plat->init)
701 plat->init(ab8500); 748 plat->init(ab8500);
702 749