]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - arch/arm/mach-tegra/include/mach/pinmux.h
arm/tegra: prepare pinmux code for multiple tegra variants
[can-eth-gw-linux.git] / arch / arm / mach-tegra / include / mach / pinmux.h
1 /*
2  * linux/arch/arm/mach-tegra/include/mach/pinmux.h
3  *
4  * Copyright (C) 2010 Google, Inc.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #ifndef __MACH_TEGRA_PINMUX_H
18 #define __MACH_TEGRA_PINMUX_H
19
20 enum tegra_mux_func {
21         TEGRA_MUX_RSVD = 0x8000,
22         TEGRA_MUX_RSVD1 = 0x8000,
23         TEGRA_MUX_RSVD2 = 0x8001,
24         TEGRA_MUX_RSVD3 = 0x8002,
25         TEGRA_MUX_RSVD4 = 0x8003,
26         TEGRA_MUX_NONE = -1,
27         TEGRA_MUX_AHB_CLK,
28         TEGRA_MUX_APB_CLK,
29         TEGRA_MUX_AUDIO_SYNC,
30         TEGRA_MUX_CRT,
31         TEGRA_MUX_DAP1,
32         TEGRA_MUX_DAP2,
33         TEGRA_MUX_DAP3,
34         TEGRA_MUX_DAP4,
35         TEGRA_MUX_DAP5,
36         TEGRA_MUX_DISPLAYA,
37         TEGRA_MUX_DISPLAYB,
38         TEGRA_MUX_EMC_TEST0_DLL,
39         TEGRA_MUX_EMC_TEST1_DLL,
40         TEGRA_MUX_GMI,
41         TEGRA_MUX_GMI_INT,
42         TEGRA_MUX_HDMI,
43         TEGRA_MUX_I2C,
44         TEGRA_MUX_I2C2,
45         TEGRA_MUX_I2C3,
46         TEGRA_MUX_IDE,
47         TEGRA_MUX_IRDA,
48         TEGRA_MUX_KBC,
49         TEGRA_MUX_MIO,
50         TEGRA_MUX_MIPI_HS,
51         TEGRA_MUX_NAND,
52         TEGRA_MUX_OSC,
53         TEGRA_MUX_OWR,
54         TEGRA_MUX_PCIE,
55         TEGRA_MUX_PLLA_OUT,
56         TEGRA_MUX_PLLC_OUT1,
57         TEGRA_MUX_PLLM_OUT1,
58         TEGRA_MUX_PLLP_OUT2,
59         TEGRA_MUX_PLLP_OUT3,
60         TEGRA_MUX_PLLP_OUT4,
61         TEGRA_MUX_PWM,
62         TEGRA_MUX_PWR_INTR,
63         TEGRA_MUX_PWR_ON,
64         TEGRA_MUX_RTCK,
65         TEGRA_MUX_SDIO1,
66         TEGRA_MUX_SDIO2,
67         TEGRA_MUX_SDIO3,
68         TEGRA_MUX_SDIO4,
69         TEGRA_MUX_SFLASH,
70         TEGRA_MUX_SPDIF,
71         TEGRA_MUX_SPI1,
72         TEGRA_MUX_SPI2,
73         TEGRA_MUX_SPI2_ALT,
74         TEGRA_MUX_SPI3,
75         TEGRA_MUX_SPI4,
76         TEGRA_MUX_TRACE,
77         TEGRA_MUX_TWC,
78         TEGRA_MUX_UARTA,
79         TEGRA_MUX_UARTB,
80         TEGRA_MUX_UARTC,
81         TEGRA_MUX_UARTD,
82         TEGRA_MUX_UARTE,
83         TEGRA_MUX_ULPI,
84         TEGRA_MUX_VI,
85         TEGRA_MUX_VI_SENSOR_CLK,
86         TEGRA_MUX_XIO,
87         TEGRA_MUX_SAFE,
88         TEGRA_MAX_MUX,
89 };
90
91 enum tegra_pullupdown {
92         TEGRA_PUPD_NORMAL = 0,
93         TEGRA_PUPD_PULL_DOWN,
94         TEGRA_PUPD_PULL_UP,
95 };
96
97 enum tegra_tristate {
98         TEGRA_TRI_NORMAL = 0,
99         TEGRA_TRI_TRISTATE = 1,
100 };
101
102 enum tegra_vddio {
103         TEGRA_VDDIO_BB = 0,
104         TEGRA_VDDIO_LCD,
105         TEGRA_VDDIO_VI,
106         TEGRA_VDDIO_UART,
107         TEGRA_VDDIO_DDR,
108         TEGRA_VDDIO_NAND,
109         TEGRA_VDDIO_SYS,
110         TEGRA_VDDIO_AUDIO,
111         TEGRA_VDDIO_SD,
112 };
113
114 struct tegra_pingroup_config {
115         int pingroup;
116         enum tegra_mux_func     func;
117         enum tegra_pullupdown   pupd;
118         enum tegra_tristate     tristate;
119 };
120
121 enum tegra_slew {
122         TEGRA_SLEW_FASTEST = 0,
123         TEGRA_SLEW_FAST,
124         TEGRA_SLEW_SLOW,
125         TEGRA_SLEW_SLOWEST,
126         TEGRA_MAX_SLEW,
127 };
128
129 enum tegra_pull_strength {
130         TEGRA_PULL_0 = 0,
131         TEGRA_PULL_1,
132         TEGRA_PULL_2,
133         TEGRA_PULL_3,
134         TEGRA_PULL_4,
135         TEGRA_PULL_5,
136         TEGRA_PULL_6,
137         TEGRA_PULL_7,
138         TEGRA_PULL_8,
139         TEGRA_PULL_9,
140         TEGRA_PULL_10,
141         TEGRA_PULL_11,
142         TEGRA_PULL_12,
143         TEGRA_PULL_13,
144         TEGRA_PULL_14,
145         TEGRA_PULL_15,
146         TEGRA_PULL_16,
147         TEGRA_PULL_17,
148         TEGRA_PULL_18,
149         TEGRA_PULL_19,
150         TEGRA_PULL_20,
151         TEGRA_PULL_21,
152         TEGRA_PULL_22,
153         TEGRA_PULL_23,
154         TEGRA_PULL_24,
155         TEGRA_PULL_25,
156         TEGRA_PULL_26,
157         TEGRA_PULL_27,
158         TEGRA_PULL_28,
159         TEGRA_PULL_29,
160         TEGRA_PULL_30,
161         TEGRA_PULL_31,
162         TEGRA_MAX_PULL,
163 };
164
165 enum tegra_drive {
166         TEGRA_DRIVE_DIV_8 = 0,
167         TEGRA_DRIVE_DIV_4,
168         TEGRA_DRIVE_DIV_2,
169         TEGRA_DRIVE_DIV_1,
170         TEGRA_MAX_DRIVE,
171 };
172
173 enum tegra_hsm {
174         TEGRA_HSM_DISABLE = 0,
175         TEGRA_HSM_ENABLE,
176 };
177
178 enum tegra_schmitt {
179         TEGRA_SCHMITT_DISABLE = 0,
180         TEGRA_SCHMITT_ENABLE,
181 };
182
183 struct tegra_drive_pingroup_config {
184         int pingroup;
185         enum tegra_hsm hsm;
186         enum tegra_schmitt schmitt;
187         enum tegra_drive drive;
188         enum tegra_pull_strength pull_down;
189         enum tegra_pull_strength pull_up;
190         enum tegra_slew slew_rising;
191         enum tegra_slew slew_falling;
192 };
193
194 struct tegra_drive_pingroup_desc {
195         const char *name;
196         s16 reg_bank;
197         s16 reg;
198 };
199
200 struct tegra_pingroup_desc {
201         const char *name;
202         int funcs[4];
203         int func_safe;
204         int vddio;
205         s16 tri_bank;   /* Register bank the tri_reg exists within */
206         s16 mux_bank;   /* Register bank the mux_reg exists within */
207         s16 pupd_bank;  /* Register bank the pupd_reg exists within */
208         s16 tri_reg;    /* offset into the TRISTATE_REG_* register bank */
209         s16 mux_reg;    /* offset into the PIN_MUX_CTL_* register bank */
210         s16 pupd_reg;   /* offset into the PULL_UPDOWN_REG_* register bank */
211         s8 tri_bit;     /* offset into the TRISTATE_REG_* register bit */
212         s8 mux_bit;     /* offset into the PIN_MUX_CTL_* register bit */
213         s8 pupd_bit;    /* offset into the PULL_UPDOWN_REG_* register bit */
214 };
215
216 typedef void (*pinmux_init) (const struct tegra_pingroup_desc **pg,
217         int *pg_max, const struct tegra_drive_pingroup_desc **pgdrive,
218         int *pgdrive_max);
219
220 void tegra20_pinmux_init(const struct tegra_pingroup_desc **pg, int *pg_max,
221         const struct tegra_drive_pingroup_desc **pgdrive, int *pgdrive_max);
222
223 int tegra_pinmux_set_tristate(int pg, enum tegra_tristate tristate);
224 int tegra_pinmux_set_pullupdown(int pg, enum tegra_pullupdown pupd);
225
226 void tegra_pinmux_config_table(const struct tegra_pingroup_config *config,
227         int len);
228
229 void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config *config,
230         int len);
231 void tegra_pinmux_set_safe_pinmux_table(const struct tegra_pingroup_config *config,
232         int len);
233 void tegra_pinmux_config_pinmux_table(const struct tegra_pingroup_config *config,
234         int len);
235 void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config *config,
236         int len, enum tegra_tristate tristate);
237 void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *config,
238         int len, enum tegra_pullupdown pupd);
239 #endif