arm: tegra: pinmux: t114: correct pingroup func
[linux-3.10.git] / arch / arm / mach-tegra / board-dalmore-pinmux.c
1 /*
2  * arch/arm/mach-tegra/board-dalmore-pinmux.c
3  *
4  * Copyright (C) 2012-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 #include "board.h"
23 #include "board-dalmore.h"
24 #include "devices.h"
25 #include "gpio-names.h"
26
27 #include <mach/pinmux-t11.h>
28
29 #define DEFAULT_DRIVE(_name)                                    \
30         {                                                       \
31                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,       \
32                 .hsm = TEGRA_HSM_DISABLE,                       \
33                 .schmitt = TEGRA_SCHMITT_ENABLE,                \
34                 .drive = TEGRA_DRIVE_DIV_1,                     \
35                 .pull_down = TEGRA_PULL_31,                     \
36                 .pull_up = TEGRA_PULL_31,                       \
37                 .slew_rising = TEGRA_SLEW_SLOWEST,              \
38                 .slew_falling = TEGRA_SLEW_SLOWEST,             \
39         }
40 /* Setting the drive strength of pins
41  * hsm: Enable High speed mode (ENABLE/DISABLE)
42  * Schimit: Enable/disable schimit (ENABLE/DISABLE)
43  * drive: low power mode (DIV_1, DIV_2, DIV_4, DIV_8)
44  * pulldn_drive - drive down (falling edge) - Driver Output Pull-Down drive
45  *                strength code. Value from 0 to 31.
46  * pullup_drive - drive up (rising edge)  - Driver Output Pull-Up drive
47  *                strength code. Value from 0 to 31.
48  * pulldn_slew -  Driver Output Pull-Up slew control code  - 2bit code
49  *                code 11 is least slewing of signal. code 00 is highest
50  *                slewing of the signal.
51  *                Value - FASTEST, FAST, SLOW, SLOWEST
52  * pullup_slew -  Driver Output Pull-Down slew control code -
53  *                code 11 is least slewing of signal. code 00 is highest
54  *                slewing of the signal.
55  *                Value - FASTEST, FAST, SLOW, SLOWEST
56  */
57 #define SET_DRIVE(_name, _hsm, _schmitt, _drive, _pulldn_drive, _pullup_drive, _pulldn_slew, _pullup_slew) \
58         {                                               \
59                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,   \
60                 .hsm = TEGRA_HSM_##_hsm,                    \
61                 .schmitt = TEGRA_SCHMITT_##_schmitt,        \
62                 .drive = TEGRA_DRIVE_##_drive,              \
63                 .pull_down = TEGRA_PULL_##_pulldn_drive,    \
64                 .pull_up = TEGRA_PULL_##_pullup_drive,          \
65                 .slew_rising = TEGRA_SLEW_##_pulldn_slew,   \
66                 .slew_falling = TEGRA_SLEW_##_pullup_slew,      \
67         }
68
69 /* Setting the drive strength of pins
70  * hsm: Enable High speed mode (ENABLE/DISABLE)
71  * Schimit: Enable/disable schimit (ENABLE/DISABLE)
72  * drive: low power mode (DIV_1, DIV_2, DIV_4, DIV_8)
73  * pulldn_drive - drive down (falling edge) - Driver Output Pull-Down drive
74  *                strength code. Value from 0 to 31.
75  * pullup_drive - drive up (rising edge)  - Driver Output Pull-Up drive
76  *                strength code. Value from 0 to 31.
77  * pulldn_slew -  Driver Output Pull-Up slew control code  - 2bit code
78  *                code 11 is least slewing of signal. code 00 is highest
79  *                slewing of the signal.
80  *                Value - FASTEST, FAST, SLOW, SLOWEST
81  * pullup_slew -  Driver Output Pull-Down slew control code -
82  *                code 11 is least slewing of signal. code 00 is highest
83  *                slewing of the signal.
84  *                Value - FASTEST, FAST, SLOW, SLOWEST
85  * drive_type - Drive type to be used depending on the resistors.
86  */
87
88 #define SET_DRIVE_WITH_TYPE(_name, _hsm, _schmitt, _drive, _pulldn_drive,\
89                 _pullup_drive, _pulldn_slew, _pullup_slew, _drive_type) \
90         {                                                               \
91                 .pingroup = TEGRA_DRIVE_PINGROUP_##_name,               \
92                 .hsm = TEGRA_HSM_##_hsm,                                \
93                 .schmitt = TEGRA_SCHMITT_##_schmitt,                    \
94                 .drive = TEGRA_DRIVE_##_drive,                          \
95                 .pull_down = TEGRA_PULL_##_pulldn_drive,                \
96                 .pull_up = TEGRA_PULL_##_pullup_drive,                  \
97                 .slew_rising = TEGRA_SLEW_##_pulldn_slew,               \
98                 .slew_falling = TEGRA_SLEW_##_pullup_slew,              \
99                 .drive_type = TEGRA_DRIVE_TYPE_##_drive_type,           \
100         }
101
102 #define DEFAULT_PINMUX(_pingroup, _mux, _pupd, _tri, _io)       \
103         {                                                       \
104                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
105                 .func           = TEGRA_MUX_##_mux,             \
106                 .pupd           = TEGRA_PUPD_##_pupd,           \
107                 .tristate       = TEGRA_TRI_##_tri,             \
108                 .io             = TEGRA_PIN_##_io,              \
109                 .lock           = TEGRA_PIN_LOCK_DEFAULT,       \
110                 .od             = TEGRA_PIN_OD_DEFAULT,         \
111                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
112         }
113
114 #define I2C_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _od) \
115         {                                                       \
116                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
117                 .func           = TEGRA_MUX_##_mux,             \
118                 .pupd           = TEGRA_PUPD_##_pupd,           \
119                 .tristate       = TEGRA_TRI_##_tri,             \
120                 .io             = TEGRA_PIN_##_io,              \
121                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
122                 .od             = TEGRA_PIN_OD_##_od,           \
123                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
124         }
125
126 #define DDC_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _rcv_sel) \
127         {                                                       \
128                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
129                 .func           = TEGRA_MUX_##_mux,             \
130                 .pupd           = TEGRA_PUPD_##_pupd,           \
131                 .tristate       = TEGRA_TRI_##_tri,             \
132                 .io             = TEGRA_PIN_##_io,              \
133                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
134                 .rcv_sel        = TEGRA_PIN_RCV_SEL_##_rcv_sel,         \
135                 .ioreset        = TEGRA_PIN_IO_RESET_DEFAULT,   \
136         }
137
138 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
139         {                                                       \
140                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
141                 .func           = TEGRA_MUX_##_mux,             \
142                 .pupd           = TEGRA_PUPD_##_pupd,           \
143                 .tristate       = TEGRA_TRI_##_tri,             \
144                 .io             = TEGRA_PIN_##_io,              \
145                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
146                 .od             = TEGRA_PIN_OD_DEFAULT,         \
147                 .ioreset        = TEGRA_PIN_IO_RESET_##_ioreset \
148         }
149
150 #define CEC_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _od)   \
151         {                                                               \
152                 .pingroup   = TEGRA_PINGROUP_##_pingroup,                   \
153                 .func       = TEGRA_MUX_##_mux,                             \
154                 .pupd       = TEGRA_PUPD_##_pupd,                           \
155                 .tristate   = TEGRA_TRI_##_tri,                             \
156                 .io         = TEGRA_PIN_##_io,                              \
157                 .lock       = TEGRA_PIN_LOCK_##_lock,                       \
158                 .od         = TEGRA_PIN_OD_##_od,                           \
159                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,                   \
160         }
161
162 #define USB_PINMUX CEC_PINMUX
163
164 #define GPIO_INIT_PIN_MODE(_gpio, _is_input, _value)    \
165         {                                       \
166                 .gpio_nr        = _gpio,        \
167                 .is_input       = _is_input,    \
168                 .value          = _value,       \
169         }
170
171 static __initdata struct tegra_drive_pingroup_config dalmore_drive_pinmux[] = {
172         /* DEFAULT_DRIVE(<pin_group>), */
173         /* SDMMC1 */
174         SET_DRIVE(SDIO1, ENABLE, DISABLE, DIV_1, 36, 20, SLOW, SLOW),
175
176         /* SDMMC3 */
177         SET_DRIVE(SDIO3, ENABLE, DISABLE, DIV_1, 22, 36, FASTEST, FASTEST),
178
179         /* SDMMC4 */
180         SET_DRIVE_WITH_TYPE(GMA, ENABLE, DISABLE, DIV_1, 2, 1, FASTEST,
181                                                                 FASTEST, 1),
182 };
183
184 /* Initially setting all used GPIO's to non-TRISTATE */
185 static __initdata struct tegra_pingroup_config dalmore_pinmux_set_nontristate[] = {
186         DEFAULT_PINMUX(GPIO_X4_AUD,     RSVD,   PULL_DOWN,    NORMAL,    OUTPUT),
187         DEFAULT_PINMUX(GPIO_X5_AUD,     RSVD,   PULL_UP,      NORMAL,    INPUT),
188         DEFAULT_PINMUX(GPIO_X6_AUD,     RSVD3,  PULL_UP,      NORMAL,    INPUT),
189         DEFAULT_PINMUX(GPIO_X7_AUD,     RSVD,   PULL_DOWN,    NORMAL,    OUTPUT),
190         DEFAULT_PINMUX(GPIO_W2_AUD,     RSVD1,  PULL_UP,      NORMAL,    INPUT),
191         DEFAULT_PINMUX(GPIO_W3_AUD,     SPI6,   PULL_UP,      NORMAL,    INPUT),
192         DEFAULT_PINMUX(GPIO_X1_AUD,     RSVD3,  PULL_DOWN,    NORMAL,    INPUT),
193         DEFAULT_PINMUX(GPIO_X3_AUD,     RSVD3,  PULL_UP,      NORMAL,    INPUT),
194
195         DEFAULT_PINMUX(DAP3_FS,         I2S2,   PULL_DOWN,    NORMAL,    OUTPUT),
196         DEFAULT_PINMUX(DAP3_DIN,        I2S2,   PULL_DOWN,    NORMAL,    OUTPUT),
197         DEFAULT_PINMUX(DAP3_DOUT,       I2S2,   PULL_DOWN,    NORMAL,    OUTPUT),
198         DEFAULT_PINMUX(DAP3_SCLK,       I2S2,   PULL_DOWN,    NORMAL,    OUTPUT),
199         DEFAULT_PINMUX(GPIO_PV0,        RSVD3,  NORMAL,       NORMAL,    INPUT),
200         DEFAULT_PINMUX(GPIO_PV1,        RSVD,   NORMAL,       NORMAL,    INPUT),
201
202         DEFAULT_PINMUX(GPIO_PBB3,       RSVD3,  PULL_DOWN,    NORMAL,    OUTPUT),
203         DEFAULT_PINMUX(GPIO_PBB5,       RSVD3,  PULL_DOWN,    NORMAL,    OUTPUT),
204         DEFAULT_PINMUX(GPIO_PBB6,       RSVD3,  PULL_DOWN,    NORMAL,    OUTPUT),
205         DEFAULT_PINMUX(GPIO_PBB7,       RSVD3,  PULL_DOWN,    NORMAL,    OUTPUT),
206         DEFAULT_PINMUX(GPIO_PCC1,       RSVD3,  PULL_DOWN,    NORMAL,    INPUT),
207         DEFAULT_PINMUX(GPIO_PCC2,       RSVD3,  PULL_DOWN,    NORMAL,    INPUT),
208
209         DEFAULT_PINMUX(GMI_AD0,         GMI,    NORMAL,       NORMAL,    OUTPUT),
210         DEFAULT_PINMUX(GMI_AD1,         GMI,    NORMAL,       NORMAL,    OUTPUT),
211         DEFAULT_PINMUX(GMI_AD10,        GMI,    PULL_DOWN,    NORMAL,    OUTPUT),
212         DEFAULT_PINMUX(GMI_AD11,        GMI,    PULL_DOWN,    NORMAL,    OUTPUT),
213         DEFAULT_PINMUX(GMI_AD12,        GMI,    PULL_UP,      NORMAL,    INPUT),
214         DEFAULT_PINMUX(GMI_AD13,        GMI,    PULL_DOWN,    NORMAL,    OUTPUT),
215         DEFAULT_PINMUX(GMI_AD2,         GMI,    NORMAL,       NORMAL,    INPUT),
216         DEFAULT_PINMUX(GMI_AD3,         GMI,    NORMAL,       NORMAL,    INPUT),
217         DEFAULT_PINMUX(GMI_AD8,         GMI,    PULL_DOWN,    NORMAL,    OUTPUT),
218         DEFAULT_PINMUX(GMI_ADV_N,       GMI,    PULL_UP,      NORMAL,    INPUT),
219         DEFAULT_PINMUX(GMI_CLK,         GMI,    PULL_DOWN,    NORMAL,    OUTPUT),
220         DEFAULT_PINMUX(GMI_CS0_N,       GMI,    PULL_UP,      NORMAL,    INPUT),
221         DEFAULT_PINMUX(GMI_CS2_N,       GMI,    PULL_UP,      NORMAL,    INPUT),
222         DEFAULT_PINMUX(GMI_CS3_N,       GMI,    PULL_UP,      NORMAL,    OUTPUT),
223         DEFAULT_PINMUX(GMI_CS4_N,       GMI,    PULL_UP,      NORMAL,    INPUT),
224         DEFAULT_PINMUX(GMI_CS7_N,       GMI,    PULL_UP,      NORMAL,    INPUT),
225         DEFAULT_PINMUX(GMI_DQS_P,       GMI,    PULL_UP,      NORMAL,    INPUT),
226         DEFAULT_PINMUX(GMI_IORDY,       GMI,    PULL_UP,      NORMAL,    INPUT),
227         DEFAULT_PINMUX(GMI_WP_N,        GMI,    PULL_UP,      NORMAL,    INPUT),
228
229         DEFAULT_PINMUX(SDMMC1_WP_N,     SPI4,   PULL_UP,      NORMAL,    OUTPUT),
230         DEFAULT_PINMUX(CLK2_REQ,        RSVD3,  NORMAL,       NORMAL,    OUTPUT),
231
232         DEFAULT_PINMUX(KB_COL3,         KBC,    PULL_UP,      NORMAL,    OUTPUT),
233         DEFAULT_PINMUX(KB_COL5,         KBC,    PULL_UP,      NORMAL,    INPUT),
234         DEFAULT_PINMUX(KB_COL6,         KBC,    PULL_UP,      NORMAL,    OUTPUT),
235         DEFAULT_PINMUX(KB_COL7,         KBC,    PULL_UP,      NORMAL,    OUTPUT),
236         DEFAULT_PINMUX(KB_ROW3,         KBC,    PULL_DOWN,    NORMAL,    INPUT),
237         DEFAULT_PINMUX(KB_ROW4,         KBC,    PULL_DOWN,    NORMAL,    INPUT),
238         DEFAULT_PINMUX(KB_ROW6,         KBC,    PULL_DOWN,    NORMAL,    INPUT),
239         DEFAULT_PINMUX(KB_ROW7,         KBC,    PULL_UP,      NORMAL,    INPUT),
240         DEFAULT_PINMUX(KB_ROW8,         KBC,    PULL_UP,      NORMAL,    INPUT),
241
242         DEFAULT_PINMUX(CLK3_REQ,        RSVD3,  NORMAL,      NORMAL,    OUTPUT),
243         DEFAULT_PINMUX(GPIO_PU4,        PWM1,  NORMAL,      NORMAL,    OUTPUT),
244         DEFAULT_PINMUX(GPIO_PU5,        PWM2,  NORMAL,      NORMAL,    INPUT),
245         DEFAULT_PINMUX(GPIO_PU6,        PWM3,  NORMAL,      NORMAL,    INPUT),
246
247         DEFAULT_PINMUX(HDMI_INT,        RSVD,   PULL_DOWN,    NORMAL,    INPUT),
248
249         DEFAULT_PINMUX(GMI_AD9,         PWM1,   NORMAL,    NORMAL,     OUTPUT),
250 };
251
252 #include "board-dalmore-pinmux-t11x.h"
253
254 static void __init dalmore_gpio_init_configure(void)
255 {
256         int len;
257         int i;
258         struct gpio_init_pin_info *pins_info;
259
260         len = ARRAY_SIZE(init_gpio_mode_dalmore_common);
261         pins_info = init_gpio_mode_dalmore_common;
262
263         for (i = 0; i < len; ++i) {
264                 tegra_gpio_init_configure(pins_info->gpio_nr,
265                         pins_info->is_input, pins_info->value);
266                 pins_info++;
267         }
268 }
269
270 int __init dalmore_pinmux_init(void)
271 {
272         tegra_pinmux_config_table(dalmore_pinmux_set_nontristate,
273                                         ARRAY_SIZE(dalmore_pinmux_set_nontristate));
274         dalmore_gpio_init_configure();
275
276         tegra_pinmux_config_table(dalmore_pinmux_common, ARRAY_SIZE(dalmore_pinmux_common));
277         tegra_drive_pinmux_config_table(dalmore_drive_pinmux,
278                                         ARRAY_SIZE(dalmore_drive_pinmux));
279         tegra_pinmux_config_table(unused_pins_lowpower,
280                 ARRAY_SIZE(unused_pins_lowpower));
281
282         return 0;
283 }