2 * Copyright (C) 2015 Lothar Waßmann <LW@KARO-electronics.de>
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
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.
18 #define RN5T567_NOETIMSET 0x11
19 #define RN5T567_LDORTC1_SLOT 0x2a
20 #define RN5T567_DC1CTL 0x2c
21 #define RN5T567_DC1CTL2 0x2d
22 #define RN5T567_DC2CTL 0x2e
23 #define RN5T567_DC2CTL2 0x2f
24 #define RN5T567_DC3CTL 0x30
25 #define RN5T567_DC3CTL2 0x31
26 #define RN5T567_DC4CTL 0x32
27 #define RN5T567_DC4CTL2 0x33
28 #define RN5T567_DC1DAC 0x36
29 #define RN5T567_DC2DAC 0x37
30 #define RN5T567_DC3DAC 0x38
31 #define RN5T567_DC4DAC 0x39
32 #define RN5T567_DC1DAC_SLP 0x3b
33 #define RN5T567_DC2DAC_SLP 0x3c
34 #define RN5T567_DC3DAC_SLP 0x3d
35 #define RN5T567_DC4DAC_SLP 0x3e
36 #define RN5T567_IREN 0x40
37 #define RN5T567_LDOEN1 0x44
38 #define RN5T567_LDOEN2 0x45
39 #define RN5T567_LDODIS 0x46
40 #define RN5T567_LDO1DAC 0x4c
41 #define RN5T567_LDO2DAC 0x4d
42 #define RN5T567_LDO3DAC 0x4e
43 #define RN5T567_LDO4DAC 0x4f
44 #define RN5T567_LDO5DAC 0x50
45 #define RN5T567_LDORTC1DAC 0x56 /* VBACKUP */
46 #define RN5T567_LDO1DAC_SLP 0x58
47 #define RN5T567_LDO2DAC_SLP 0x59
48 #define RN5T567_LDO3DAC_SLP 0x5a
49 #define RN5T567_LDO4DAC_SLP 0x5b
50 #define RN5T567_LDO5DAC_SLP 0x5c
51 #define RN5T567_IOSEL 0x90
52 #define RN5T567_IOOUT 0x91
53 #define RN5T567_GPEDGE1 0x92
54 #define RN5T567_EN_GPIR 0x94
55 #define RN5T567_INTPOL 0x9c
56 #define RN5T567_INTEN 0x9d
58 #define NOETIMSET_DIS_OFF_NOE_TIM (1 << 3)
60 #define DCnCTL_DCnEN (1 << 0)
61 #define DCnCTL_DCnDIS (1 << 1)
62 #define DCnMODE(m) (((m) & 0x3) << 4)
63 #define DCnMODE_SLP(m) (((m) & 0x3) << 6)
64 #define DCnMODE_AUTO 0
68 /* calculate voltages in 10mV */
69 #define rn5t_v2r(v,n,m) DIV_ROUND(((((v) * 10 < (n)) ? (n) : (v) * 10) - (n)), m)
70 #define rn5t_r2v(r,n,m) (((r) * (m) + (n)) / 10)
73 #define rn5t_mV_to_regval(mV) rn5t_v2r(mV, 6000, 125)
74 #define rn5t_regval_to_mV(r) rn5t_r2v(r, 6000, 125)
77 #define rn5t_mV_to_regval2(mV) (rn5t_v2r(mV, 9000, 500) << 1)
78 #define rn5t_regval2_to_mV(r) rn5t_r2v((r) >> 1, 9000, 500)
81 #define rn5t_mV_to_regval3(mV) (rn5t_v2r(mV, 6000, 500) << 1)
82 #define rn5t_regval3_to_mV(r) rn5t_r2v((r) >> 1, 6000, 500)
85 #define rn5t_mV_to_regval_rtc(mV) (rn5t_v2r(mV, 12000, 500) << 1)
86 #define rn5t_regval_rtc_to_mV(r) rn5t_r2v((r) >> 1, 12000, 500)