xref: /freebsd/sys/dev/iicbus/pmic/rockchip/rk805reg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2018 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 _RK805REG_H_
29 #define	 _RK805REG_H_
30 
31 /* RTC registers */
32 #define	RK805_RTC_SECS		0x00
33 #define	 RK805_RTC_SECS_MASK	0x7f
34 #define	RK805_RTC_MINUTES	0x01
35 #define	 RK805_RTC_MINUTES_MASK	0x7f
36 #define	RK805_RTC_HOURS		0x02
37 #define	 RK805_RTC_HOURS_MASK	0x3f
38 #define	RK805_RTC_HOURS_PM	0x80
39 #define	RK805_RTC_DAYS		0x03
40 #define	 RK805_RTC_DAYS_MASK	0x3f
41 #define	RK805_RTC_MONTHS	0x04
42 #define	 RK805_RTC_MONTHS_MASK	0x1f
43 #define	RK805_RTC_YEARS		0x05
44 #define	RK805_RTC_WEEKS		0x06 /* day of week */
45 #define	 RK805_RTC_WEEKS_MASK	0x07
46 #define	RK805_ALARM_SECONDS	0x8
47 #define	RK805_ALARM_MINUTES	0x9
48 #define	RK805_ALARM_HOURS	0xA
49 #define	RK805_ALARM_DAYS	0xB
50 #define	RK805_ALARM_MONTHS	0xC
51 #define	RK805_ALARM_YEARS	0xD
52 #define	RK805_RTC_CTRL		0x10
53 #define	 RK805_RTC_CTRL_STOP	(1 << 0)
54 #define	 RK805_RTC_AMPM_MODE	(1 << 3)
55 #define	 RK805_RTC_GET_TIME	(1 << 6)
56 #define	 RK805_RTC_READSEL	(1 << 7)
57 #define	RK805_CLK32KOUT		0x20
58 
59 /* Version registers */
60 #define	RK805_CHIP_NAME		0x17
61 #define	RK805_CHIP_VER		0x18
62 #define	RK805_OTP_VER		0x19
63 
64 /* Power channel enable registers */
65 #define	RK805_DCDC_EN		0x23
66 #define	RK805_SLP_DCDC_EN	0x25
67 #define	RK805_SLP_LDO_EN	0x26
68 #define	RK805_LDO_EN		0x27
69 #define	RK805_BUCK_LDO_SLP_LP	0x2A
70 
71 /* Buck and LDO configuration registers */
72 #define	RK805_BUCK1_CONFIG	0x2E
73 #define	RK805_BUCK1_ON_VSEL	0x2F
74 #define	RK805_BUCK1_SLEEP_VSEL	0x30
75 #define	RK805_BUCK2_CONFIG	0x32
76 #define	RK805_BUCK2_ON_VSEL	0x33
77 #define	RK805_BUCK2_SLEEP_VSEL	0x34
78 #define	RK805_BUCK3_CONFIG	0x36
79 #define	RK805_BUCK4_CONFIG	0x37
80 #define	RK805_BUCK4_ON_VSEL	0x38
81 #define	RK805_BUCK4_SLEEP_VSEL	0x39
82 #define	RK805_LDO1_ON_VSEL	0x3B
83 #define	RK805_LDO1_SLEEP_VSEL	0x3C
84 #define	RK805_LDO2_ON_VSEL	0x3D
85 #define	RK805_LDO2_SLEEP_VSEL	0x3E
86 #define	RK805_LDO3_ON_VSEL	0x3F
87 #define	RK805_LDO3_SLEEP_VSEL	0x40
88 
89 #define	RK805_DEV_CTRL		0x4B
90 #define	 RK805_DEV_CTRL_OFF	(1 << 0)
91 #define	 RK805_DEV_CTRL_SLP	(1 << 1)
92 
93 enum rk805_regulator {
94 	RK805_BUCK1 = 0,
95 	RK805_BUCK2,
96 	RK805_BUCK3,
97 	RK805_BUCK4,
98 	RK805_LDO1,
99 	RK805_LDO2,
100 	RK805_LDO3,
101 };
102 
103 #endif /* _RK805REG_H_ */
104