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_SLPCNT 0x0e
19 #define RN5T567_REPCNT 0x0f
20 #define RN5T567_PWRONTIMSET 0x10
21 #define RN5T567_NOETIMSET 0x11
22 #define RN5T567_PWRIRSEL 0x15
23 #define RN5T567_DC1_SLOT 0x16
24 #define RN5T567_DC2_SLOT 0x17
25 #define RN5T567_DC3_SLOT 0x18
26 #define RN5T567_DC4_SLOT 0x19
27 #define RN5T567_LDO1_SLOT 0x1b
28 #define RN5T567_LDO2_SLOT 0x1c
29 #define RN5T567_LDO3_SLOT 0x1d
30 #define RN5T567_LDO4_SLOT 0x1e
31 #define RN5T567_LDO5_SLOT 0x1f
32 #define RN5T567_PSO0_SLOT 0x25
33 #define RN5T567_PSO1_SLOT 0x26
34 #define RN5T567_PSO2_SLOT 0x27
35 #define RN5T567_PSO3_SLOT 0x28
36 #define RN5T567_LDORTC1_SLOT 0x2a
37 #define RN5T567_DC1CTL 0x2c
38 #define RN5T567_DC1CTL2 0x2d
39 #define RN5T567_DC2CTL 0x2e
40 #define RN5T567_DC2CTL2 0x2f
41 #define RN5T567_DC3CTL 0x30
42 #define RN5T567_DC3CTL2 0x31
43 #define RN5T567_DC4CTL 0x32
44 #define RN5T567_DC4CTL2 0x33
45 #define RN5T567_DC1DAC 0x36
46 #define RN5T567_DC2DAC 0x37
47 #define RN5T567_DC3DAC 0x38
48 #define RN5T567_DC4DAC 0x39
49 #define RN5T567_DC1DAC_SLP 0x3b
50 #define RN5T567_DC2DAC_SLP 0x3c
51 #define RN5T567_DC3DAC_SLP 0x3d
52 #define RN5T567_DC4DAC_SLP 0x3e
53 #define RN5T567_DCIREN 0x40
54 #define RN5T567_DCIRQ 0x41
55 #define RN5T567_DCIRMON 0x42
56 #define RN5T567_LDOEN1 0x44
57 #define RN5T567_LDOEN2 0x45
58 #define RN5T567_LDODIS 0x46
59 #define RN5T567_LDO1DAC 0x4c
60 #define RN5T567_LDO2DAC 0x4d
61 #define RN5T567_LDO3DAC 0x4e
62 #define RN5T567_LDO4DAC 0x4f
63 #define RN5T567_LDO5DAC 0x50
64 #define RN5T567_LDORTC1DAC 0x56 /* VBACKUP */
65 #define RN5T567_LDORTC2DAC 0x57
66 #define RN5T567_LDO1DAC_SLP 0x58
67 #define RN5T567_LDO2DAC_SLP 0x59
68 #define RN5T567_LDO3DAC_SLP 0x5a
69 #define RN5T567_LDO4DAC_SLP 0x5b
70 #define RN5T567_LDO5DAC_SLP 0x5c
71 #define RN5T567_IOSEL 0x90
72 #define RN5T567_IOOUT 0x91
73 #define RN5T567_GPEDGE1 0x92
74 #define RN5T567_EN_GPIR 0x94
75 #define RN5T567_INTPOL 0x9c
76 #define RN5T567_INTEN 0x9d
78 #define NOETIMSET_DIS_OFF_NOE_TIM (1 << 3)
80 #define DCnCTL_EN (1 << 0)
81 #define DCnCTL_DIS (1 << 1)
82 #define DCnMODE(m) (((m) & 0x3) << 4)
83 #define DCnMODE_SLP(m) (((m) & 0x3) << 6)
88 #define DCnCTL2_LIMSDEN (1 << 0)
89 #define DCnCTL2_LIM_NONE (0 << 1)
90 #define DCnCTL2_LIM_LOW (1 << 1)
91 #define DCnCTL2_LIM_MED (2 << 1)
92 #define DCnCTL2_LIM_HIGH (3 << 1)
93 #define DCnCTL2_SR_LOW (2 << 4)
94 #define DCnCTL2_SR_MED (1 << 4)
95 #define DCnCTL2_SR_HIGH (0 << 4)
96 #define DCnCTL2_OSC_LOW (0 << 6)
97 #define DCnCTL2_OSC_MED (1 << 6)
98 #define DCnCTL2_OSC_HIGH (2 << 6)
100 /* calculate voltages in 10mV */
101 #define rn5t_v2r(v,n,m) DIV_ROUND(((((v) * 10 < (n)) ? (n) : (v) * 10) - (n)), m)
102 #define rn5t_r2v(r,n,m) (((r) * (m) + (n)) / 10)
105 #define rn5t_mV_to_regval(mV) rn5t_v2r(mV, 6000, 125)
106 #define rn5t_regval_to_mV(r) rn5t_r2v(r, 6000, 125)
109 #define rn5t_mV_to_regval2(mV) (rn5t_v2r(mV, 9000, 500) << 1)
110 #define rn5t_regval2_to_mV(r) rn5t_r2v((r) >> 1, 9000, 500)
113 #define rn5t_mV_to_regval3(mV) (rn5t_v2r(mV, 6000, 500) << 1)
114 #define rn5t_regval3_to_mV(r) rn5t_r2v((r) >> 1, 6000, 500)
117 #define rn5t_mV_to_regval_rtc(mV) (rn5t_v2r(mV, 12000, 500) << 1)
118 #define rn5t_regval_rtc_to_mV(r) rn5t_r2v((r) >> 1, 12000, 500)