xref: /freebsd/sys/dev/iicbus/pmic/rockchip/rk808reg.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2018-2021 Emmanuel Vadot <manu@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _RK808REG_H_
29 #define	 _RK808REG_H_
30 
31 /* RTC registers */
32 #define	RK808_RTC_SECS		0x00
33 #define	 RK808_RTC_SECS_MASK	0x7f
34 #define	RK808_RTC_MINUTES	0x01
35 #define	 RK808_RTC_MINUTES_MASK	0x7f
36 #define	RK808_RTC_HOURS		0x02
37 #define	 RK808_RTC_HOURS_MASK	0x3f
38 #define	RK808_RTC_DAYS		0x03
39 #define	 RK808_RTC_DAYS_MASK	0x3f
40 #define	RK808_RTC_MONTHS	0x04
41 #define	 RK808_RTC_MONTHS_MASK	0x1f
42 #define	RK808_RTC_YEARS		0x05
43 #define	RK808_RTC_WEEKS		0x06 /* day of week */
44 #define	 RK808_RTC_WEEKS_MASK	0x07
45 #define	RK808_ALARM_SECONDS	0x8
46 #define	RK808_ALARM_MINUTES	0x9
47 #define	RK808_ALARM_HOURS	0xA
48 #define	RK808_ALARM_DAYS	0xB
49 #define	RK808_ALARM_MONTHS	0xC
50 #define	RK808_ALARM_YEARS	0xD
51 #define	RK808_RTC_CTRL		0x10
52 #define	 RK808_RTC_CTRL_STOP	(1 << 0)
53 #define	 RK808_RTC_AMPM_MODE	(1 << 3)
54 #define	 RK808_RTC_GET_TIME	(1 << 6)
55 #define	 RK808_RTC_READSEL	(1 << 7)
56 #define	RK808_RTC_STATUS	0x11
57 #define	RK808_RTC_INT		0x12
58 #define	RK808_RTC_COMP_LSB	0x13
59 #define	RK808_RTC_COMP_MSB	0x14
60 
61 /* Misc registers*/
62 #define	RK808_CLK32KOUT		0x20
63 #define	RK808_VB_MON		0x21
64 #define	RK808_THERMAL		0x22
65 
66 /* Power channel control and monitoring registers */
67 #define	RK808_DCDC_EN		0x23
68 #define	RK808_LDO_EN		0x24
69 #define	RK808_SLEEP_SET_OFF_1	0x25
70 #define	RK808_SLEEP_SET_OFF_2	0x26
71 #define	RK808_DCDC_UV_STS	0x27
72 #define	RK808_DCDC_UV_ACT	0x28
73 #define	RK808_LDO_UV_STS	0x29
74 #define	RK808_LDO_UV_ACT	0x2A
75 #define	RK808_DCDC_PG		0x2B
76 #define	RK808_LDO_PG		0x2C
77 #define	RK808_VOUT_MON_TDB	0x2D
78 
79 /* Power channel configuration registers */
80 #define	RK808_BUCK1_CONFIG	0x2E
81 #define	RK808_BUCK1_ON_VSEL	0x2F
82 #define	RK808_BUCK1_SLP_VSEL	0x30
83 #define	RK808_BUCK2_CONFIG	0x32
84 #define	RK808_BUCK2_ON_VSEL	0x33
85 #define	RK808_BUCK2_SLEEP_VSEL	0x34
86 #define	RK808_BUCK3_CONFIG	0x36
87 #define	RK808_BUCK4_CONFIG	0x37
88 #define	RK808_BUCK4_ON_VSEL	0x38
89 #define	RK808_BUCK4_SLEEP_VSEL	0x39
90 #define	RK808_DCDC_ILMAX_REG	0x90
91 #define	RK808_LDO1_ON_VSEL	0x3B
92 #define	RK808_LDO1_SLEEP_VSEL	0x3C
93 #define	RK808_LDO2_ON_VSEL	0x3D
94 #define	RK808_LDO2_SLEEP_VSEL	0x3E
95 #define	RK808_LDO3_ON_VSEL	0x3F
96 #define	RK808_LDO3_SLEEP_VSEL	0x40
97 #define	RK808_LDO4_ON_VSEL	0x41
98 #define	RK808_LDO4_SLEEP_VSEL	0x42
99 #define	RK808_LDO5_ON_VSEL	0x43
100 #define	RK808_LDO5_SLEEP_VSEL	0x44
101 #define	RK808_LDO6_ON_VSEL	0x45
102 #define	RK808_LDO6_SLEEP_VSEL	0x46
103 #define	RK808_LDO7_ON_VSEL	0x47
104 #define	RK808_LDO7_SLEEP_VSEL	0x48
105 #define	RK808_LDO8_ON_VSEL	0x49
106 #define	RK808_LDO8_SLEEP_VSEL	0x4A
107 
108 #define	RK808_DEV_CTRL		0x4B
109 #define	 RK808_DEV_CTRL_OFF	(1 << 0)
110 #define	 RK808_DEV_CTRL_SLP	(1 << 1)
111 
112 enum rk808_regulator {
113 	RK808_BUCK1 = 0,
114 	RK808_BUCK2,
115 	RK808_BUCK3,
116 	RK808_BUCK4,
117 	RK808_LDO1,
118 	RK808_LDO2,
119 	RK808_LDO3,
120 	RK808_LDO4,
121 	RK808_LDO5,
122 	RK808_LDO6,
123 	RK808_LDO7,
124 	RK808_LDO8,
125 	RK808_SWITCH1,
126 	RK808_SWITCH2,
127 };
128 
129 #endif /* _RK808REG_H_ */
130