xref: /freebsd/sys/dev/iicbus/pmic/rockchip/rk808reg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
143301ad2SEmmanuel Vadot /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
343301ad2SEmmanuel Vadot  *
443301ad2SEmmanuel Vadot  * Copyright (c) 2018-2021 Emmanuel Vadot <manu@FreeBSD.org>
543301ad2SEmmanuel Vadot  *
643301ad2SEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
743301ad2SEmmanuel Vadot  * modification, are permitted provided that the following conditions
843301ad2SEmmanuel Vadot  * are met:
943301ad2SEmmanuel Vadot  * 1. Redistributions of source code must retain the above copyright
1043301ad2SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer.
1143301ad2SEmmanuel Vadot  * 2. Redistributions in binary form must reproduce the above copyright
1243301ad2SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer in the
1343301ad2SEmmanuel Vadot  *    documentation and/or other materials provided with the distribution.
1443301ad2SEmmanuel Vadot  *
1543301ad2SEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1643301ad2SEmmanuel Vadot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1743301ad2SEmmanuel Vadot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1843301ad2SEmmanuel Vadot  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1943301ad2SEmmanuel Vadot  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2043301ad2SEmmanuel Vadot  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2143301ad2SEmmanuel Vadot  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2243301ad2SEmmanuel Vadot  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2343301ad2SEmmanuel Vadot  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2443301ad2SEmmanuel Vadot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2543301ad2SEmmanuel Vadot  * SUCH DAMAGE.
2643301ad2SEmmanuel Vadot  */
2743301ad2SEmmanuel Vadot 
2843301ad2SEmmanuel Vadot #ifndef _RK808REG_H_
2943301ad2SEmmanuel Vadot #define	 _RK808REG_H_
3043301ad2SEmmanuel Vadot 
3143301ad2SEmmanuel Vadot /* RTC registers */
3243301ad2SEmmanuel Vadot #define	RK808_RTC_SECS		0x00
3343301ad2SEmmanuel Vadot #define	 RK808_RTC_SECS_MASK	0x7f
3443301ad2SEmmanuel Vadot #define	RK808_RTC_MINUTES	0x01
3543301ad2SEmmanuel Vadot #define	 RK808_RTC_MINUTES_MASK	0x7f
3643301ad2SEmmanuel Vadot #define	RK808_RTC_HOURS		0x02
3743301ad2SEmmanuel Vadot #define	 RK808_RTC_HOURS_MASK	0x3f
3843301ad2SEmmanuel Vadot #define	RK808_RTC_DAYS		0x03
3943301ad2SEmmanuel Vadot #define	 RK808_RTC_DAYS_MASK	0x3f
4043301ad2SEmmanuel Vadot #define	RK808_RTC_MONTHS	0x04
4143301ad2SEmmanuel Vadot #define	 RK808_RTC_MONTHS_MASK	0x1f
4243301ad2SEmmanuel Vadot #define	RK808_RTC_YEARS		0x05
4343301ad2SEmmanuel Vadot #define	RK808_RTC_WEEKS		0x06 /* day of week */
4443301ad2SEmmanuel Vadot #define	 RK808_RTC_WEEKS_MASK	0x07
4543301ad2SEmmanuel Vadot #define	RK808_ALARM_SECONDS	0x8
4643301ad2SEmmanuel Vadot #define	RK808_ALARM_MINUTES	0x9
4743301ad2SEmmanuel Vadot #define	RK808_ALARM_HOURS	0xA
4843301ad2SEmmanuel Vadot #define	RK808_ALARM_DAYS	0xB
4943301ad2SEmmanuel Vadot #define	RK808_ALARM_MONTHS	0xC
5043301ad2SEmmanuel Vadot #define	RK808_ALARM_YEARS	0xD
5143301ad2SEmmanuel Vadot #define	RK808_RTC_CTRL		0x10
5243301ad2SEmmanuel Vadot #define	 RK808_RTC_CTRL_STOP	(1 << 0)
5343301ad2SEmmanuel Vadot #define	 RK808_RTC_AMPM_MODE	(1 << 3)
5443301ad2SEmmanuel Vadot #define	 RK808_RTC_GET_TIME	(1 << 6)
5543301ad2SEmmanuel Vadot #define	 RK808_RTC_READSEL	(1 << 7)
5643301ad2SEmmanuel Vadot #define	RK808_RTC_STATUS	0x11
5743301ad2SEmmanuel Vadot #define	RK808_RTC_INT		0x12
5843301ad2SEmmanuel Vadot #define	RK808_RTC_COMP_LSB	0x13
5943301ad2SEmmanuel Vadot #define	RK808_RTC_COMP_MSB	0x14
6043301ad2SEmmanuel Vadot 
6143301ad2SEmmanuel Vadot /* Misc registers*/
6243301ad2SEmmanuel Vadot #define	RK808_CLK32KOUT		0x20
6343301ad2SEmmanuel Vadot #define	RK808_VB_MON		0x21
6443301ad2SEmmanuel Vadot #define	RK808_THERMAL		0x22
6543301ad2SEmmanuel Vadot 
6643301ad2SEmmanuel Vadot /* Power channel control and monitoring registers */
6743301ad2SEmmanuel Vadot #define	RK808_DCDC_EN		0x23
6843301ad2SEmmanuel Vadot #define	RK808_LDO_EN		0x24
6943301ad2SEmmanuel Vadot #define	RK808_SLEEP_SET_OFF_1	0x25
7043301ad2SEmmanuel Vadot #define	RK808_SLEEP_SET_OFF_2	0x26
7143301ad2SEmmanuel Vadot #define	RK808_DCDC_UV_STS	0x27
7243301ad2SEmmanuel Vadot #define	RK808_DCDC_UV_ACT	0x28
7343301ad2SEmmanuel Vadot #define	RK808_LDO_UV_STS	0x29
7443301ad2SEmmanuel Vadot #define	RK808_LDO_UV_ACT	0x2A
7543301ad2SEmmanuel Vadot #define	RK808_DCDC_PG		0x2B
7643301ad2SEmmanuel Vadot #define	RK808_LDO_PG		0x2C
7743301ad2SEmmanuel Vadot #define	RK808_VOUT_MON_TDB	0x2D
7843301ad2SEmmanuel Vadot 
7943301ad2SEmmanuel Vadot /* Power channel configuration registers */
8043301ad2SEmmanuel Vadot #define	RK808_BUCK1_CONFIG	0x2E
8143301ad2SEmmanuel Vadot #define	RK808_BUCK1_ON_VSEL	0x2F
8243301ad2SEmmanuel Vadot #define	RK808_BUCK1_SLP_VSEL	0x30
8343301ad2SEmmanuel Vadot #define	RK808_BUCK2_CONFIG	0x32
8443301ad2SEmmanuel Vadot #define	RK808_BUCK2_ON_VSEL	0x33
8543301ad2SEmmanuel Vadot #define	RK808_BUCK2_SLEEP_VSEL	0x34
8643301ad2SEmmanuel Vadot #define	RK808_BUCK3_CONFIG	0x36
8743301ad2SEmmanuel Vadot #define	RK808_BUCK4_CONFIG	0x37
8843301ad2SEmmanuel Vadot #define	RK808_BUCK4_ON_VSEL	0x38
8943301ad2SEmmanuel Vadot #define	RK808_BUCK4_SLEEP_VSEL	0x39
9043301ad2SEmmanuel Vadot #define	RK808_DCDC_ILMAX_REG	0x90
9143301ad2SEmmanuel Vadot #define	RK808_LDO1_ON_VSEL	0x3B
9243301ad2SEmmanuel Vadot #define	RK808_LDO1_SLEEP_VSEL	0x3C
9343301ad2SEmmanuel Vadot #define	RK808_LDO2_ON_VSEL	0x3D
9443301ad2SEmmanuel Vadot #define	RK808_LDO2_SLEEP_VSEL	0x3E
9543301ad2SEmmanuel Vadot #define	RK808_LDO3_ON_VSEL	0x3F
9643301ad2SEmmanuel Vadot #define	RK808_LDO3_SLEEP_VSEL	0x40
9743301ad2SEmmanuel Vadot #define	RK808_LDO4_ON_VSEL	0x41
9843301ad2SEmmanuel Vadot #define	RK808_LDO4_SLEEP_VSEL	0x42
9943301ad2SEmmanuel Vadot #define	RK808_LDO5_ON_VSEL	0x43
10043301ad2SEmmanuel Vadot #define	RK808_LDO5_SLEEP_VSEL	0x44
10143301ad2SEmmanuel Vadot #define	RK808_LDO6_ON_VSEL	0x45
10243301ad2SEmmanuel Vadot #define	RK808_LDO6_SLEEP_VSEL	0x46
10343301ad2SEmmanuel Vadot #define	RK808_LDO7_ON_VSEL	0x47
10443301ad2SEmmanuel Vadot #define	RK808_LDO7_SLEEP_VSEL	0x48
10543301ad2SEmmanuel Vadot #define	RK808_LDO8_ON_VSEL	0x49
10643301ad2SEmmanuel Vadot #define	RK808_LDO8_SLEEP_VSEL	0x4A
10743301ad2SEmmanuel Vadot 
10894f4afd7SAndriy Gapon #define	RK808_DEV_CTRL		0x4B
10994f4afd7SAndriy Gapon #define	 RK808_DEV_CTRL_OFF	(1 << 0)
11094f4afd7SAndriy Gapon #define	 RK808_DEV_CTRL_SLP	(1 << 1)
11194f4afd7SAndriy Gapon 
11243301ad2SEmmanuel Vadot enum rk808_regulator {
11343301ad2SEmmanuel Vadot 	RK808_BUCK1 = 0,
11443301ad2SEmmanuel Vadot 	RK808_BUCK2,
11543301ad2SEmmanuel Vadot 	RK808_BUCK3,
11643301ad2SEmmanuel Vadot 	RK808_BUCK4,
11743301ad2SEmmanuel Vadot 	RK808_LDO1,
11843301ad2SEmmanuel Vadot 	RK808_LDO2,
11943301ad2SEmmanuel Vadot 	RK808_LDO3,
12043301ad2SEmmanuel Vadot 	RK808_LDO4,
12143301ad2SEmmanuel Vadot 	RK808_LDO5,
12243301ad2SEmmanuel Vadot 	RK808_LDO6,
12343301ad2SEmmanuel Vadot 	RK808_LDO7,
12443301ad2SEmmanuel Vadot 	RK808_LDO8,
12543301ad2SEmmanuel Vadot 	RK808_SWITCH1,
12643301ad2SEmmanuel Vadot 	RK808_SWITCH2,
12743301ad2SEmmanuel Vadot };
12843301ad2SEmmanuel Vadot 
12943301ad2SEmmanuel Vadot #endif /* _RK808REG_H_ */
130