ARM: tegra: loki: fix build error due to warning
[linux-3.10.git] / arch / arm / mach-tegra / board-laguna-pinmux.c
1 /*
2  * arch/arm/mach-tegra/board-laguna-pinmux.c
3  *
4  * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
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 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/gpio.h>
20 #include <mach/pinmux.h>
21 #include <mach/gpio-tegra.h>
22
23 #include "board.h"
24 #include "board-ardbeg.h"
25 #include "devices.h"
26 #include "gpio-names.h"
27
28 #include <mach/pinmux-t12.h>
29
30 #define DEFAULT_DRIVE(_name)                                    \
31         {                                                       \
32                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,       \
33                 .hsm = TEGRA_HSM_DISABLE,                       \
34                 .schmitt = TEGRA_SCHMITT_ENABLE,                \
35                 .drive = TEGRA_DRIVE_DIV_1,                     \
36                 .pull_down = TEGRA_PULL_31,                     \
37                 .pull_up = TEGRA_PULL_31,                       \
38                 .slew_rising = TEGRA_SLEW_SLOWEST,              \
39                 .slew_falling = TEGRA_SLEW_SLOWEST,             \
40         }
41 /* Setting the drive strength of pins
42  * hsm: Enable High speed mode (ENABLE/DISABLE)
43  * Schimit: Enable/disable schimit (ENABLE/DISABLE)
44  * drive: low power mode (DIV_1, DIV_2, DIV_4, DIV_8)
45  * pulldn_drive - drive down (falling edge) - Driver Output Pull-Down drive
46  *                strength code. Value from 0 to 31.
47  * pullup_drive - drive up (rising edge)  - Driver Output Pull-Up drive
48  *                strength code. Value from 0 to 31.
49  * pulldn_slew -  Driver Output Pull-Up slew control code  - 2bit code
50  *                code 11 is least slewing of signal. code 00 is highest
51  *                slewing of the signal.
52  *                Value - FASTEST, FAST, SLOW, SLOWEST
53  * pullup_slew -  Driver Output Pull-Down slew control code -
54  *                code 11 is least slewing of signal. code 00 is highest
55  *                slewing of the signal.
56  *                Value - FASTEST, FAST, SLOW, SLOWEST
57  */
58 #define SET_DRIVE(_name, _hsm, _schmitt, _drive, _pulldn_drive,\
59                 _pullup_drive, _pulldn_slew, _pullup_slew) \
60         {                                               \
61                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,   \
62                 .hsm = TEGRA_HSM_##_hsm,                    \
63                 .schmitt = TEGRA_SCHMITT_##_schmitt,        \
64                 .drive = TEGRA_DRIVE_##_drive,              \
65                 .pull_down = TEGRA_PULL_##_pulldn_drive,    \
66                 .pull_up = TEGRA_PULL_##_pullup_drive,          \
67                 .slew_rising = TEGRA_SLEW_##_pulldn_slew,   \
68                 .slew_falling = TEGRA_SLEW_##_pullup_slew,      \
69         }
70
71 /* Setting the drive strength of pins
72  * hsm: Enable High speed mode (ENABLE/DISABLE)
73  * Schimit: Enable/disable schimit (ENABLE/DISABLE)
74  * drive: low power mode (DIV_1, DIV_2, DIV_4, DIV_8)
75  * pulldn_drive - drive down (falling edge) - Driver Output Pull-Down drive
76  *                strength code. Value from 0 to 31.
77  * pullup_drive - drive up (rising edge)  - Driver Output Pull-Up drive
78  *                strength code. Value from 0 to 31.
79  * pulldn_slew -  Driver Output Pull-Up slew control code  - 2bit code
80  *                code 11 is least slewing of signal. code 00 is highest
81  *                slewing of the signal.
82  *                Value - FASTEST, FAST, SLOW, SLOWEST
83  * pullup_slew -  Driver Output Pull-Down slew control code -
84  *                code 11 is least slewing of signal. code 00 is highest
85  *                slewing of the signal.
86  *                Value - FASTEST, FAST, SLOW, SLOWEST
87  * drive_type - Drive type to be used depending on the resistors.
88  */
89
90 #define SET_DRIVE_WITH_TYPE(_name, _hsm, _schmitt, _drive, _pulldn_drive,\
91                 _pullup_drive, _pulldn_slew, _pullup_slew, _drive_type) \
92         {                                                               \
93                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,               \
94                 .hsm = TEGRA_HSM_##_hsm,                                \
95                 .schmitt = TEGRA_SCHMITT_##_schmitt,                    \
96                 .drive = TEGRA_DRIVE_##_drive,                          \
97                 .pull_down = TEGRA_PULL_##_pulldn_drive,                \
98                 .pull_up = TEGRA_PULL_##_pullup_drive,                  \
99                 .slew_rising = TEGRA_SLEW_##_pulldn_slew,               \
100                 .slew_falling = TEGRA_SLEW_##_pullup_slew,              \
101                 .drive_type = TEGRA_DRIVE_TYPE_##_drive_type,           \
102         }
103
104 #define DEFAULT_PINMUX(_pingroup, _mux, _pupd, _tri, _io)       \
105         {                                                       \
106                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
107                 .func           = TEGRA_MUX_##_mux,             \
108                 .pupd           = TEGRA_PUPD_##_pupd,           \
109                 .tristate       = TEGRA_TRI_##_tri,             \
110                 .io             = TEGRA_PIN_##_io,              \
111                 .lock           = TEGRA_PIN_LOCK_DEFAULT,       \
112                 .od             = TEGRA_PIN_OD_DEFAULT,         \
113                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
114         }
115
116 #define I2C_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _od) \
117         {                                                       \
118                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
119                 .func           = TEGRA_MUX_##_mux,             \
120                 .pupd           = TEGRA_PUPD_##_pupd,           \
121                 .tristate       = TEGRA_TRI_##_tri,             \
122                 .io             = TEGRA_PIN_##_io,              \
123                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
124                 .od             = TEGRA_PIN_OD_##_od,           \
125                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
126         }
127
128 #define DDC_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _rcv_sel) \
129         {                                                       \
130                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
131                 .func           = TEGRA_MUX_##_mux,             \
132                 .pupd           = TEGRA_PUPD_##_pupd,           \
133                 .tristate       = TEGRA_TRI_##_tri,             \
134                 .io             = TEGRA_PIN_##_io,              \
135                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
136                 .rcv_sel        = TEGRA_PIN_RCV_SEL_##_rcv_sel,         \
137                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
138         }
139
140 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
141         {                                                       \
142                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
143                 .func           = TEGRA_MUX_##_mux,             \
144                 .pupd           = TEGRA_PUPD_##_pupd,           \
145                 .tristate       = TEGRA_TRI_##_tri,             \
146                 .io             = TEGRA_PIN_##_io,              \
147                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
148                 .od             = TEGRA_PIN_OD_DEFAULT,         \
149                 .ioreset        = TEGRA_PIN_IO_RESET_##_ioreset \
150         }
151
152 #define CEC_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _od)   \
153         {                                                               \
154                 .pingroup   = TEGRA_PINGROUP_##_pingroup,                   \
155                 .func       = TEGRA_MUX_##_mux,                             \
156                 .pupd       = TEGRA_PUPD_##_pupd,                           \
157                 .tristate   = TEGRA_TRI_##_tri,                             \
158                 .io         = TEGRA_PIN_##_io,                              \
159                 .lock       = TEGRA_PIN_LOCK_##_lock,                       \
160                 .od         = TEGRA_PIN_OD_##_od,                           \
161                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,                   \
162         }
163
164 #define USB_PINMUX CEC_PINMUX
165
166 #define GPIO_INIT_PIN_MODE(_gpio, _is_input, _value)    \
167         {                                       \
168                 .gpio_nr        = _gpio,        \
169                 .is_input       = _is_input,    \
170                 .value          = _value,       \
171         }
172 #define GPIO_PINMUX(_pingroup, _pupd, _tri, _io, _od)   \
173         {                                                   \
174                 .pingroup   = TEGRA_PINGROUP_##_pingroup,       \
175                 .func       = TEGRA_MUX_SAFE,                   \
176                 .pupd       = TEGRA_PUPD_##_pupd,               \
177                 .tristate   = TEGRA_TRI_##_tri,                 \
178                 .io         = TEGRA_PIN_##_io,                  \
179                 .lock       = TEGRA_PIN_LOCK_DEFAULT,           \
180                 .od         = TEGRA_PIN_OD_##_od,               \
181                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,       \
182         }
183 #define UNUSED_PINMUX(_pingroup)                    \
184         {                                               \
185                 .pingroup   = TEGRA_PINGROUP_##_pingroup,   \
186                 .func       = TEGRA_MUX_SAFE,               \
187                 .pupd       = TEGRA_PUPD_PULL_DOWN,         \
188                 .tristate   = TEGRA_TRI_TRISTATE,           \
189                 .io         = TEGRA_PIN_OUTPUT,             \
190                 .lock       = TEGRA_PIN_LOCK_DEFAULT,       \
191                 .od         = TEGRA_PIN_OD_DEFAULT,         \
192                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,   \
193         }
194
195 static __initdata struct tegra_drive_pingroup_config laguna_drive_pinmux[] = {
196         /*Set DAP2 drive (required for Codec Master Mode)*/
197         SET_DRIVE(DAP2, DISABLE, ENABLE, DIV_1, 51, 51, FASTEST, FASTEST),
198
199         /* FIXME: update settings for t124 laguna */
200         SET_DRIVE(SDIO1, ENABLE, DISABLE, DIV_1, 36, 20, SLOW, SLOW),
201
202         /* SDMMC3 */
203         SET_DRIVE(SDIO3, ENABLE, DISABLE, DIV_1, 22, 36, FASTEST, FASTEST),
204
205         /* SDMMC4 */
206         SET_DRIVE_WITH_TYPE(GMA, ENABLE, DISABLE, DIV_1, 2, 1, FASTEST,
207                                                                 FASTEST, 1),
208 };
209
210 #include "board-laguna-pinmux-t12x.h"
211
212 static void __init laguna_gpio_init_configure(void)
213 {
214         int len;
215         int i;
216         struct gpio_init_pin_info *pins_info;
217
218         len = ARRAY_SIZE(init_gpio_mode_laguna_common);
219         pins_info = init_gpio_mode_laguna_common;
220
221         for (i = 0; i < len; ++i) {
222                 tegra_gpio_init_configure(pins_info->gpio_nr,
223                         pins_info->is_input, pins_info->value);
224                 pins_info++;
225         }
226 }
227
228 int __init laguna_pinmux_init(void)
229 {
230         laguna_gpio_init_configure();
231
232         tegra_pinmux_config_table(laguna_pinmux_common, ARRAY_SIZE(laguna_pinmux_common));
233         tegra_drive_pinmux_config_table(laguna_drive_pinmux,
234                                         ARRAY_SIZE(laguna_drive_pinmux));
235         tegra_pinmux_config_table(unused_pins_lowpower,
236                 ARRAY_SIZE(unused_pins_lowpower));
237
238         return 0;
239 }