1 /* rtc.h
2  *
3  * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd
4  *              http://www.samsung.com
5  *
6  * This program is free software; you can redistribute  it and/or modify it
7  * under  the terms of  the GNU General  Public License as published by the
8  * Free Software Foundation;  either version 2 of the  License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  */
17 
18 #ifndef __LINUX_MFD_SEC_RTC_H
19 #define __LINUX_MFD_SEC_RTC_H
20 
21 enum s5m_rtc_reg {
22 	S5M_RTC_SEC,
23 	S5M_RTC_MIN,
24 	S5M_RTC_HOUR,
25 	S5M_RTC_WEEKDAY,
26 	S5M_RTC_DATE,
27 	S5M_RTC_MONTH,
28 	S5M_RTC_YEAR1,
29 	S5M_RTC_YEAR2,
30 	S5M_ALARM0_SEC,
31 	S5M_ALARM0_MIN,
32 	S5M_ALARM0_HOUR,
33 	S5M_ALARM0_WEEKDAY,
34 	S5M_ALARM0_DATE,
35 	S5M_ALARM0_MONTH,
36 	S5M_ALARM0_YEAR1,
37 	S5M_ALARM0_YEAR2,
38 	S5M_ALARM1_SEC,
39 	S5M_ALARM1_MIN,
40 	S5M_ALARM1_HOUR,
41 	S5M_ALARM1_WEEKDAY,
42 	S5M_ALARM1_DATE,
43 	S5M_ALARM1_MONTH,
44 	S5M_ALARM1_YEAR1,
45 	S5M_ALARM1_YEAR2,
46 	S5M_ALARM0_CONF,
47 	S5M_ALARM1_CONF,
48 	S5M_RTC_STATUS,
49 	S5M_WTSR_SMPL_CNTL,
50 	S5M_RTC_UDR_CON,
51 
52 	S5M_RTC_REG_MAX,
53 };
54 
55 enum s2mps_rtc_reg {
56 	S2MPS_RTC_CTRL,
57 	S2MPS_WTSR_SMPL_CNTL,
58 	S2MPS_RTC_UDR_CON,
59 	S2MPS_RSVD,
60 	S2MPS_RTC_SEC,
61 	S2MPS_RTC_MIN,
62 	S2MPS_RTC_HOUR,
63 	S2MPS_RTC_WEEKDAY,
64 	S2MPS_RTC_DATE,
65 	S2MPS_RTC_MONTH,
66 	S2MPS_RTC_YEAR,
67 	S2MPS_ALARM0_SEC,
68 	S2MPS_ALARM0_MIN,
69 	S2MPS_ALARM0_HOUR,
70 	S2MPS_ALARM0_WEEKDAY,
71 	S2MPS_ALARM0_DATE,
72 	S2MPS_ALARM0_MONTH,
73 	S2MPS_ALARM0_YEAR,
74 	S2MPS_ALARM1_SEC,
75 	S2MPS_ALARM1_MIN,
76 	S2MPS_ALARM1_HOUR,
77 	S2MPS_ALARM1_WEEKDAY,
78 	S2MPS_ALARM1_DATE,
79 	S2MPS_ALARM1_MONTH,
80 	S2MPS_ALARM1_YEAR,
81 	S2MPS_OFFSRC,
82 
83 	S2MPS_RTC_REG_MAX,
84 };
85 
86 #define RTC_I2C_ADDR		(0x0C >> 1)
87 
88 #define HOUR_12			(1 << 7)
89 #define HOUR_AMPM		(1 << 6)
90 #define HOUR_PM			(1 << 5)
91 #define S5M_ALARM0_STATUS	(1 << 1)
92 #define S5M_ALARM1_STATUS	(1 << 2)
93 #define S5M_UPDATE_AD		(1 << 0)
94 
95 #define S2MPS_ALARM0_STATUS	(1 << 2)
96 #define S2MPS_ALARM1_STATUS	(1 << 1)
97 
98 /* RTC Control Register */
99 #define BCD_EN_SHIFT		0
100 #define BCD_EN_MASK		(1 << BCD_EN_SHIFT)
101 #define MODEL24_SHIFT		1
102 #define MODEL24_MASK		(1 << MODEL24_SHIFT)
103 /* RTC Update Register1 */
104 #define S5M_RTC_UDR_SHIFT	0
105 #define S5M_RTC_UDR_MASK	(1 << S5M_RTC_UDR_SHIFT)
106 #define S2MPS_RTC_WUDR_SHIFT	4
107 #define S2MPS_RTC_WUDR_MASK	(1 << S2MPS_RTC_WUDR_SHIFT)
108 #define S2MPS15_RTC_AUDR_SHIFT	4
109 #define S2MPS15_RTC_AUDR_MASK	(1 << S2MPS15_RTC_AUDR_SHIFT)
110 #define S2MPS13_RTC_AUDR_SHIFT	1
111 #define S2MPS13_RTC_AUDR_MASK	(1 << S2MPS13_RTC_AUDR_SHIFT)
112 #define S2MPS15_RTC_WUDR_SHIFT	1
113 #define S2MPS15_RTC_WUDR_MASK	(1 << S2MPS15_RTC_WUDR_SHIFT)
114 #define S2MPS_RTC_RUDR_SHIFT	0
115 #define S2MPS_RTC_RUDR_MASK	(1 << S2MPS_RTC_RUDR_SHIFT)
116 #define RTC_TCON_SHIFT		1
117 #define RTC_TCON_MASK		(1 << RTC_TCON_SHIFT)
118 #define S5M_RTC_TIME_EN_SHIFT	3
119 #define S5M_RTC_TIME_EN_MASK	(1 << S5M_RTC_TIME_EN_SHIFT)
120 /*
121  * UDR_T field in S5M_RTC_UDR_CON register determines the time needed
122  * for updating alarm and time registers. Default is 7.32 ms.
123  */
124 #define S5M_RTC_UDR_T_SHIFT	6
125 #define S5M_RTC_UDR_T_MASK	(0x3 << S5M_RTC_UDR_T_SHIFT)
126 #define S5M_RTC_UDR_T_7320_US	(0x0 << S5M_RTC_UDR_T_SHIFT)
127 #define S5M_RTC_UDR_T_1830_US	(0x1 << S5M_RTC_UDR_T_SHIFT)
128 #define S5M_RTC_UDR_T_3660_US	(0x2 << S5M_RTC_UDR_T_SHIFT)
129 #define S5M_RTC_UDR_T_450_US	(0x3 << S5M_RTC_UDR_T_SHIFT)
130 
131 /* RTC Hour register */
132 #define HOUR_PM_SHIFT		6
133 #define HOUR_PM_MASK		(1 << HOUR_PM_SHIFT)
134 /* RTC Alarm Enable */
135 #define ALARM_ENABLE_SHIFT	7
136 #define ALARM_ENABLE_MASK	(1 << ALARM_ENABLE_SHIFT)
137 
138 #define SMPL_ENABLE_SHIFT	7
139 #define SMPL_ENABLE_MASK	(1 << SMPL_ENABLE_SHIFT)
140 
141 #define WTSR_ENABLE_SHIFT	6
142 #define WTSR_ENABLE_MASK	(1 << WTSR_ENABLE_SHIFT)
143 
144 #endif /*  __LINUX_MFD_SEC_RTC_H */
145