0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LINUX_MFD_MT6397_RTC_H_
0010 #define _LINUX_MFD_MT6397_RTC_H_
0011
0012 #include <linux/jiffies.h>
0013 #include <linux/mutex.h>
0014 #include <linux/regmap.h>
0015 #include <linux/rtc.h>
0016
0017 #define RTC_BBPU 0x0000
0018 #define RTC_BBPU_CBUSY BIT(6)
0019 #define RTC_BBPU_KEY (0x43 << 8)
0020
0021 #define RTC_WRTGR_MT6358 0x003a
0022 #define RTC_WRTGR_MT6397 0x003c
0023 #define RTC_WRTGR_MT6323 RTC_WRTGR_MT6397
0024
0025 #define RTC_IRQ_STA 0x0002
0026 #define RTC_IRQ_STA_AL BIT(0)
0027 #define RTC_IRQ_STA_LP BIT(3)
0028
0029 #define RTC_IRQ_EN 0x0004
0030 #define RTC_IRQ_EN_AL BIT(0)
0031 #define RTC_IRQ_EN_ONESHOT BIT(2)
0032 #define RTC_IRQ_EN_LP BIT(3)
0033 #define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL)
0034
0035 #define RTC_AL_MASK 0x0008
0036 #define RTC_AL_MASK_DOW BIT(4)
0037
0038 #define RTC_TC_SEC 0x000a
0039 #define RTC_TC_MTH_MASK 0x000f
0040
0041 #define RTC_OFFSET_SEC 0
0042 #define RTC_OFFSET_MIN 1
0043 #define RTC_OFFSET_HOUR 2
0044 #define RTC_OFFSET_DOM 3
0045 #define RTC_OFFSET_DOW 4
0046 #define RTC_OFFSET_MTH 5
0047 #define RTC_OFFSET_YEAR 6
0048 #define RTC_OFFSET_COUNT 7
0049
0050 #define RTC_AL_SEC 0x0018
0051
0052 #define RTC_AL_SEC_MASK 0x003f
0053 #define RTC_AL_MIN_MASK 0x003f
0054 #define RTC_AL_HOU_MASK 0x001f
0055 #define RTC_AL_DOM_MASK 0x001f
0056 #define RTC_AL_DOW_MASK 0x0007
0057 #define RTC_AL_MTH_MASK 0x000f
0058 #define RTC_AL_YEA_MASK 0x007f
0059
0060 #define RTC_PDN2 0x002e
0061 #define RTC_PDN2_PWRON_ALARM BIT(4)
0062
0063 #define RTC_MIN_YEAR 1968
0064 #define RTC_BASE_YEAR 1900
0065 #define RTC_NUM_YEARS 128
0066 #define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR)
0067
0068 #define MTK_RTC_POLL_DELAY_US 10
0069 #define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ))
0070
0071 struct mtk_rtc_data {
0072 u32 wrtgr;
0073 };
0074
0075 struct mt6397_rtc {
0076 struct rtc_device *rtc_dev;
0077
0078
0079 struct mutex lock;
0080 struct regmap *regmap;
0081 int irq;
0082 u32 addr_base;
0083 const struct mtk_rtc_data *data;
0084 };
0085
0086 #endif