arm: tegra: macallan: create board file
[linux-3.10.git] / arch / arm / mach-tegra / board-macallan-pinmux.c
1 /*
2  * arch/arm/mach-tegra/board-macallan-pinmux.c
3  *
4  * Copyright (C) 2013 NVIDIA Corporation
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-macallan.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 GPIO_PINMUX(_pingroup, _pupd, _tri, _io, _od)   \
163         {                                                   \
164                 .pingroup   = TEGRA_PINGROUP_##_pingroup,       \
165                 .func       = TEGRA_MUX_SAFE,                   \
166                 .pupd       = TEGRA_PUPD_##_pupd,               \
167                 .tristate   = TEGRA_TRI_##_tri,                 \
168                 .io         = TEGRA_PIN_##_io,                  \
169                 .lock       = TEGRA_PIN_LOCK_DEFAULT,           \
170                 .od         = TEGRA_PIN_OD_##_od,               \
171                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,       \
172         }
173
174 #define UNUSED_PINMUX(_pingroup)                    \
175         {                                               \
176                 .pingroup   = TEGRA_PINGROUP_##_pingroup,   \
177                 .func       = TEGRA_MUX_SAFE,               \
178                 .pupd       = TEGRA_PUPD_PULL_DOWN,         \
179                 .tristate   = TEGRA_TRI_TRISTATE,           \
180                 .io         = TEGRA_PIN_OUTPUT,             \
181                 .lock       = TEGRA_PIN_LOCK_DEFAULT,       \
182                 .od         = TEGRA_PIN_OD_DEFAULT,         \
183                 .ioreset    = TEGRA_PIN_IO_RESET_DEFAULT,   \
184         }
185
186 #define USB_PINMUX CEC_PINMUX
187
188 #define GPIO_INIT_PIN_MODE(_gpio, _is_input, _value)    \
189         {                                       \
190                 .gpio_nr        = _gpio,        \
191                 .is_input       = _is_input,    \
192                 .value          = _value,       \
193         }
194
195 static __initdata struct tegra_drive_pingroup_config macallan_drive_pinmux[] = {
196         /* DEFAULT_DRIVE(<pin_group>), */
197         /* SDMMC1 */
198         SET_DRIVE(SDIO1, ENABLE, DISABLE, DIV_1, 36, 20, SLOW, SLOW),
199
200         /* SDMMC3 */
201         SET_DRIVE(SDIO3, ENABLE, DISABLE, DIV_1, 22, 36, FASTEST, FASTEST),
202
203         /* SDMMC4 */
204         SET_DRIVE_WITH_TYPE(GMA, ENABLE, DISABLE, DIV_1, 2, 1, FASTEST,
205                                                                 FASTEST, 1),
206 };
207
208 #include "board-macallan-pinmux-t11x.h"
209
210 /* THIS IS FOR TESTING OR WORKAROUND PURPOSES. ANYTHING INSIDE THIS TABLE
211  * SHOULD BE PUSHED TO PINMUX SPREADSHEET FOR AUTOGEN OR FIXED
212  * */
213 static __initdata struct tegra_pingroup_config manual_config_pinmux[] = {
214
215         /* ULPI SFIOs are not supposed to be supported.
216          * This setting is only for Macallan. */
217         DEFAULT_PINMUX(ULPI_DATA0,    ULPI,        NORMAL,    NORMAL,   INPUT),
218         DEFAULT_PINMUX(ULPI_DATA1,    ULPI,        NORMAL,    NORMAL,   INPUT),
219         DEFAULT_PINMUX(ULPI_DATA5,    ULPI,        NORMAL,    NORMAL,   INPUT),
220         DEFAULT_PINMUX(ULPI_DATA6,    ULPI,        NORMAL,    NORMAL,   INPUT),
221         DEFAULT_PINMUX(ULPI_DATA7,    ULPI,        NORMAL,    NORMAL,   INPUT),
222 };
223
224 static void __init macallan_gpio_init_configure(void)
225 {
226         int len;
227         int i;
228         struct gpio_init_pin_info *pins_info;
229
230         len = ARRAY_SIZE(init_gpio_mode_macallan_common);
231         pins_info = init_gpio_mode_macallan_common;
232
233         for (i = 0; i < len; ++i) {
234                 tegra_gpio_init_configure(pins_info->gpio_nr,
235                         pins_info->is_input, pins_info->value);
236                 pins_info++;
237         }
238 }
239
240 int __init macallan_pinmux_init(void)
241 {
242         macallan_gpio_init_configure();
243
244         tegra_pinmux_config_table(macallan_pinmux_common,
245                                         ARRAY_SIZE(macallan_pinmux_common));
246         tegra_drive_pinmux_config_table(macallan_drive_pinmux,
247                                         ARRAY_SIZE(macallan_drive_pinmux));
248         tegra_pinmux_config_table(unused_pins_lowpower,
249                 ARRAY_SIZE(unused_pins_lowpower));
250         tegra_pinmux_config_table(manual_config_pinmux,
251                 ARRAY_SIZE(manual_config_pinmux));
252
253         return 0;
254 }