976424b3fbdce0c0b7f972769396781405d3199c
[firefly-linux-kernel-4.4.55.git] / include / dt-bindings / pinctrl / rockchip.h
1 /*
2  * Header providing constants for Rockchip pinctrl bindings.
3  *
4  * Copyright (c) 2013 MundoReader S.L.
5  * Author: Heiko Stuebner <heiko@sntech.de>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  */
17
18 #ifndef __DT_BINDINGS_ROCKCHIP_PINCTRL_H__
19 #define __DT_BINDINGS_ROCKCHIP_PINCTRL_H__
20
21 #define RK_GPIO0        0
22 #define RK_GPIO1        1
23 #define RK_GPIO2        2
24 #define RK_GPIO3        3
25 #define RK_GPIO4        4
26 #define RK_GPIO5        5
27 #define RK_GPIO6        6
28 #define RK_GPIO7        7
29 #define RK_GPIO8        8
30
31
32 #define RK_FUNC_GPIO    0
33 #define RK_FUNC_1       1
34 #define RK_FUNC_2       2
35 #define RK_FUNC_3       3
36 #define RK_FUNC_4       4
37 #define RK_FUNC_5       5
38 #define RK_FUNC_6       6
39 #define RK_FUNC_7       7
40
41
42
43 /*special virtual pin for vcc domain setting*/
44 #define VIRTUAL_PIN_FOR_AP0_VCC         0xfA00
45 #define VIRTUAL_PIN_FOR_AP1_VCC         0xfA10
46 #define VIRTUAL_PIN_FOR_CIF_VCC         0xfA20
47 #define VIRTUAL_PIN_FOR_FLASH_VCC       0xfA30
48 #define VIRTUAL_PIN_FOR_VCCIO0_VCC      0xfA40
49 #define VIRTUAL_PIN_FOR_VCCIO1_VCC      0xfA50
50 #define VIRTUAL_PIN_FOR_LCDC0_VCC       0xfA60
51 #define VIRTUAL_PIN_FOR_LCDC1_VCC       0xfA70
52
53
54 #define RK32_VIRTUAL_PIN_FOR_LCDC_VCC           0xfA00
55 #define RK32_VIRTUAL_PIN_FOR_DVP_VCC            0xfA10
56 #define RK32_VIRTUAL_PIN_FOR_FLASH0_VCC         0xfA20
57 #define RK32_VIRTUAL_PIN_FOR_FLASH1_VCC         0xfA30
58 #define RK32_VIRTUAL_PIN_FOR_WIFI_VCC           0xfA40
59 #define RK32_VIRTUAL_PIN_FOR_BB_VCC             0xfA50
60 #define RK32_VIRTUAL_PIN_FOR_AUDIO_VCC          0xfA60
61 #define RK32_VIRTUAL_PIN_FOR_SDCARD_VCC         0xfA70
62
63 #define RK32_VIRTUAL_PIN_FOR_GPIO30_VCC         0xfB00
64 #define RK32_VIRTUAL_PIN_FOR_GPIO1830_VCC       0xfB10
65
66
67 #define TYPE_PULL_REG           0x01
68 #define TYPE_VOL_REG            0x02
69 #define TYPE_DRV_REG            0x03
70 #define TYPE_TRI_REG            0x04
71
72 #define RK2928_PULL_OFFSET              0x118
73 #define RK2928_PULL_PINS_PER_REG        16
74 #define RK2928_PULL_BANK_STRIDE         8
75
76 #define RK3188_PULL_BITS_PER_PIN        2
77 #define RK3188_PULL_PINS_PER_REG        8
78 #define RK3188_PULL_BANK_STRIDE         16
79
80 #define RK3036_PULL_BITS_PER_PIN        1
81 #define RK3036_PULL_PINS_PER_REG        16
82 #define RK3036_PULL_BANK_STRIDE         8
83
84 #define RK312X_PULL_BITS_PER_PIN        1
85 #define RK312X_PULL_PINS_PER_REG        16
86 #define RK312X_PULL_BANK_STRIDE         8
87
88
89 /*warning:don not chang the following value*/
90 #define VALUE_PULL_NORMAL       0
91 #define VALUE_PULL_UP           1
92 #define VALUE_PULL_DOWN         2
93 #define VALUE_PULL_KEEP         3
94 #define VALUE_PULL_DISABLE      4 //don't set and keep pull default
95 #define VALUE_PULL_DEFAULT      4 //don't set and keep pull default
96
97
98 //for rk2928,rk3036
99 #define VALUE_PULL_UPDOWN_DISABLE               0
100 #define VALUE_PULL_UPDOWN_ENABLE                1
101
102 #define VALUE_VOL_DEFAULT       0
103 #define VALUE_VOL_3V3           0
104 #define VALUE_VOL_1V8           1
105
106 #define VALUE_DRV_DEFAULT       0
107 #define VALUE_DRV_2MA           0
108 #define VALUE_DRV_4MA           1
109 #define VALUE_DRV_8MA           2
110 #define VALUE_DRV_12MA          3
111
112 #define VALUE_TRI_DEFAULT       0
113 #define VALUE_TRI_FALSE         0
114 #define VALUE_TRI_TRUE          1
115
116
117 /*
118  * pin config bit field definitions
119  *
120  * pull-up:     1..0    (2)
121  * voltage:     3..2    (2)
122  * drive:               5..4    (2)
123  * trisiate:    7..6    (2)
124  *
125  * MSB of each field is presence bit for the config.
126  */
127 #define PULL_SHIFT              0
128 #define PULL_PRESENT            (1 << 2)
129 #define VOL_SHIFT               3
130 #define VOL_PRESENT             (1 << 5)
131 #define DRV_SHIFT               6
132 #define DRV_PRESENT             (1 << 8)
133 #define TRI_SHIFT               9
134 #define TRI_PRESENT             (1 << 11)
135
136 #define CONFIG_TO_PULL(c)       ((c) >> PULL_SHIFT & 0x3)
137 #define CONFIG_TO_VOL(c)        ((c) >> VOL_SHIFT & 0x3)
138 #define CONFIG_TO_DRV(c)        ((c) >> DRV_SHIFT & 0x3)
139 #define CONFIG_TO_TRI(c)        ((c) >> TRI_SHIFT & 0x3)
140
141
142 #define MAX_NUM_CONFIGS         4
143 #define POS_PULL                0
144 #define POS_VOL                 1
145 #define POS_DRV                 2
146 #define POS_TRI                 3
147
148
149 #define GPIO_A0                 0
150 #define GPIO_A1                 1
151 #define GPIO_A2                 2
152 #define GPIO_A3                 3
153 #define GPIO_A4                 4
154 #define GPIO_A5                 5
155 #define GPIO_A6                 6
156 #define GPIO_A7                 7
157 #define GPIO_B0                 8
158 #define GPIO_B1                 9
159 #define GPIO_B2                 10
160 #define GPIO_B3                 11
161 #define GPIO_B4                 12
162 #define GPIO_B5                 13
163 #define GPIO_B6                 14
164 #define GPIO_B7                 15
165 #define GPIO_C0                 16
166 #define GPIO_C1                 17
167 #define GPIO_C2                 18
168 #define GPIO_C3                 19
169 #define GPIO_C4                 20
170 #define GPIO_C5                 21
171 #define GPIO_C6                 22
172 #define GPIO_C7                 23
173 #define GPIO_D0                 24
174 #define GPIO_D1                 25
175 #define GPIO_D2                 26
176 #define GPIO_D3                 27
177 #define GPIO_D4                 28
178 #define GPIO_D5                 29
179 #define GPIO_D6                 30
180 #define GPIO_D7                 31
181
182 #define FUNC_TO_GPIO(m)         ((m) & 0xfff0)
183
184
185 #endif