karo: tx6: replace open coded interpretation of cpurev by calls to is_cpu_type()
[karo-tx-uboot.git] / board / karo / tx6 / rn5t567.h
1 /*
2  * Copyright (C) 2015 Lothar WaƟmann <LW@KARO-electronics.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
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.
10  *
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.
15  *
16  */
17
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_DC1DAC          0x36
27 #define RN5T567_DC2DAC          0x37
28 #define RN5T567_DC3DAC          0x38
29 #define RN5T567_DC4DAC          0x39
30 #define RN5T567_DC1DAC_SLP      0x3b
31 #define RN5T567_DC2DAC_SLP      0x3c
32 #define RN5T567_DC3DAC_SLP      0x3d
33 #define RN5T567_DC4DAC_SLP      0x3e
34 #define RN5T567_LDOEN1          0x44
35 #define RN5T567_LDOEN2          0x45
36 #define RN5T567_LDODIS          0x46
37 #define RN5T567_LDO1DAC         0x4c
38 #define RN5T567_LDO2DAC         0x4d
39 #define RN5T567_LDO3DAC         0x4e
40 #define RN5T567_LDO4DAC         0x4f
41 #define RN5T567_LDO5DAC         0x50
42 #define RN5T567_LDORTC1DAC      0x56 /* VBACKUP */
43
44 #define NOETIMSET_DIS_OFF_NOE_TIM       (1 << 3)
45
46 #define DC2_DC2EN               (1 << 0)
47 #define DC2_DC2DIS              (1 << 1)
48
49 /* calculate voltages in 10mV */
50 #define rn5t_v2r(v,n,m)                 DIV_ROUND(((((v) < (n)) ? (n) : (v)) - (n)), (m))
51 #define rn5t_r2v(r,n,m)                 (((r) * (m) + (n)) / 10)
52
53 /* DCDC1-4 */
54 #define rn5t_mV_to_regval(mV)           rn5t_v2r((mV) * 10, 6000, 125)
55 #define rn5t_regval_to_mV(r)            rn5t_r2v(r, 6000, 125)
56
57 /* LDO1-2, 4-5 */
58 #define rn5t_mV_to_regval2(mV)          rn5t_v2r((mV) * 10, 9000, 250)
59 #define rn5t_regval2_to_mV(r)           rn5t_r2v(r, 9000, 250)
60
61 /* LDO3 */
62 #define rn5t_mV_to_regval3(mV)          rn5t_v2r((mV) * 10, 6000, 250)
63 #define rn5t_regval3_to_mV(r)           rn5t_r2v(r, 6000, 250)
64
65 /* LDORTC */
66 #define rn5t_mV_to_regval_rtc(mV)       rn5t_v2r((mV) * 10, 17000, 250)
67 #define rn5t_regval_rtc_to_mV(r)        rn5t_r2v(r, 17000, 250)