aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/ab8500-core.c')
-rw-r--r--drivers/mfd/ab8500-core.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index b6887014d687..6e185b272d00 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -4,7 +4,7 @@
4 * License Terms: GNU General Public License v2 4 * License Terms: GNU General Public License v2
5 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> 5 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
6 * Author: Rabin Vincent <rabin.vincent@stericsson.com> 6 * Author: Rabin Vincent <rabin.vincent@stericsson.com>
7 * Changes: Mattias Wallin <mattias.wallin@stericsson.com> 7 * Author: Mattias Wallin <mattias.wallin@stericsson.com>
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -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
@@ -686,9 +715,10 @@ int __devinit ab8500_init(struct ab8500 *ab8500)
686 * 0x10 - Cut 1.0 715 * 0x10 - Cut 1.0
687 * 0x11 - Cut 1.1 716 * 0x11 - Cut 1.1
688 * 0x20 - Cut 2.0 717 * 0x20 - Cut 2.0
718 * 0x30 - Cut 3.0
689 */ 719 */
690 if (value == 0x0 || value == 0x10 || value == 0x11 || value == 0x20) { 720 if (value == 0x0 || value == 0x10 || value == 0x11 || value == 0x20 ||
691 ab8500->revision = value; 721 value == 0x30) {
692 dev_info(ab8500->dev, "detected chip, revision: %#x\n", value); 722 dev_info(ab8500->dev, "detected chip, revision: %#x\n", value);
693 } else { 723 } else {
694 dev_err(ab8500->dev, "unknown chip, revision: %#x\n", value); 724 dev_err(ab8500->dev, "unknown chip, revision: %#x\n", value);
@@ -696,6 +726,24 @@ int __devinit ab8500_init(struct ab8500 *ab8500)
696 } 726 }
697 ab8500->chip_id = value; 727 ab8500->chip_id = value;
698 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
699 if (plat && plat->init) 747 if (plat && plat->init)
700 plat->init(ab8500); 748 plat->init(ab8500);
701 749
@@ -764,6 +812,6 @@ int __devexit ab8500_exit(struct ab8500 *ab8500)
764 return 0; 812 return 0;
765} 813}
766 814
767MODULE_AUTHOR("Srinidhi Kasagar, Rabin Vincent"); 815MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent");
768MODULE_DESCRIPTION("AB8500 MFD core"); 816MODULE_DESCRIPTION("AB8500 MFD core");
769MODULE_LICENSE("GPL v2"); 817MODULE_LICENSE("GPL v2");