]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/karo/tx6/rn5t567.h
4ab1b0232a4a7249751a0c09f248dfbabcb19ae6
[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_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_IOSEL           0x90
47 #define RN5T567_IOOUT           0x91
48 #define RN5T567_GPEDGE1         0x92
49 #define RN5T567_EN_GPIR         0x94
50 #define RN5T567_INTPOL          0x9c
51 #define RN5T567_INTEN           0x9d
52
53 #define NOETIMSET_DIS_OFF_NOE_TIM       (1 << 3)
54
55 #define DCnCTL_DCnEN            (1 << 0)
56 #define DCnCTL_DCnDIS           (1 << 1)
57 #define DCnMODE(m)              (((m) & 0x3) << 4)
58 #define DCnMODE_SLP(m)          (((m) & 0x3) << 6)
59 #define DCnMODE_AUTO            0
60 #define DCnMODE_PWM             1
61 #define DCnMODE_PSM             2
62
63 /* calculate voltages in 10mV */
64 #define rn5t_v2r(v,n,m)                 DIV_ROUND(((((v) * 10 < (n)) ? (n) : (v) * 10) - (n)), m)
65 #define rn5t_r2v(r,n,m)                 (((r) * (m) + (n)) / 10)
66
67 /* DCDC1-4 */
68 #define rn5t_mV_to_regval(mV)           rn5t_v2r(mV, 6000, 125)
69 #define rn5t_regval_to_mV(r)            rn5t_r2v(r, 6000, 125)
70
71 /* LDO1-2, 4-5 */
72 #define rn5t_mV_to_regval2(mV)          (rn5t_v2r(mV, 9000, 500) << 1)
73 #define rn5t_regval2_to_mV(r)           rn5t_r2v((r) >> 1, 9000, 500)
74
75 /* LDO3 */
76 #define rn5t_mV_to_regval3(mV)          (rn5t_v2r(mV, 6000, 500) << 1)
77 #define rn5t_regval3_to_mV(r)           rn5t_r2v((r) >> 1, 6000, 500)
78
79 /* LDORTC */
80 #define rn5t_mV_to_regval_rtc(mV)       (rn5t_v2r(mV, 12000, 500) << 1)
81 #define rn5t_regval_rtc_to_mV(r)        rn5t_r2v((r) >> 1, 12000, 500)