blob: 0bef6e246357c0d929f4297e2d914f5557d822c1 [file] [log] [blame]
Stephen Warrene2969952014-03-21 12:28:54 -06001/*
2 * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved.
3 * Copyright (c) 2011 The Chromium OS Authors.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <asm/io.h>
10#include <asm/arch/pinmux.h>
11
12/* return 1 if a pingrp is in range */
Stephen Warrendfb42fc2014-03-21 12:28:56 -060013#define pmux_pingrp_isvalid(pin) (((pin) >= 0) && ((pin) < PMUX_PINGRP_COUNT))
Stephen Warrene2969952014-03-21 12:28:54 -060014
15/* return 1 if a pmux_func is in range */
16#define pmux_func_isvalid(func) \
Stephen Warrend3812942014-03-21 15:58:03 -060017 (((func) >= 0) && ((func) < PMUX_FUNC_COUNT))
Stephen Warrene2969952014-03-21 12:28:54 -060018
19/* return 1 if a pin_pupd_is in range */
20#define pmux_pin_pupd_isvalid(pupd) \
21 (((pupd) >= PMUX_PULL_NORMAL) && ((pupd) <= PMUX_PULL_UP))
22
23/* return 1 if a pin_tristate_is in range */
24#define pmux_pin_tristate_isvalid(tristate) \
25 (((tristate) >= PMUX_TRI_NORMAL) && ((tristate) <= PMUX_TRI_TRISTATE))
26
27#ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC
28/* return 1 if a pin_io_is in range */
29#define pmux_pin_io_isvalid(io) \
30 (((io) >= PMUX_PIN_OUTPUT) && ((io) <= PMUX_PIN_INPUT))
31
32/* return 1 if a pin_lock is in range */
33#define pmux_pin_lock_isvalid(lock) \
34 (((lock) >= PMUX_PIN_LOCK_DISABLE) && ((lock) <= PMUX_PIN_LOCK_ENABLE))
35
36/* return 1 if a pin_od is in range */
37#define pmux_pin_od_isvalid(od) \
38 (((od) >= PMUX_PIN_OD_DISABLE) && ((od) <= PMUX_PIN_OD_ENABLE))
39
40/* return 1 if a pin_ioreset_is in range */
41#define pmux_pin_ioreset_isvalid(ioreset) \
42 (((ioreset) >= PMUX_PIN_IO_RESET_DISABLE) && \
43 ((ioreset) <= PMUX_PIN_IO_RESET_ENABLE))
44
45#ifdef TEGRA_PMX_HAS_RCV_SEL
46/* return 1 if a pin_rcv_sel_is in range */
47#define pmux_pin_rcv_sel_isvalid(rcv_sel) \
48 (((rcv_sel) >= PMUX_PIN_RCV_SEL_NORMAL) && \
49 ((rcv_sel) <= PMUX_PIN_RCV_SEL_HIGH))
50#endif /* TEGRA_PMX_HAS_RCV_SEL */
51#endif /* TEGRA_PMX_HAS_PIN_IO_BIT_ETC */
52
53#define _R(offset) (u32 *)(NV_PA_APB_MISC_BASE + (offset))
54
55#if defined(CONFIG_TEGRA20)
56
57#define MUX_REG(grp) _R(0x80 + ((tegra_soc_pingroups[grp].ctl_id / 16) * 4))
58#define MUX_SHIFT(grp) ((tegra_soc_pingroups[grp].ctl_id % 16) * 2)
59
60#define PULL_REG(grp) _R(0xa0 + ((tegra_soc_pingroups[grp].pull_id / 16) * 4))
61#define PULL_SHIFT(grp) ((tegra_soc_pingroups[grp].pull_id % 16) * 2)
62
63#define TRI_REG(grp) _R(0x14 + (((grp) / 32) * 4))
64#define TRI_SHIFT(grp) ((grp) % 32)
65
66#else
67
68#define REG(pin) _R(0x3000 + ((pin) * 4))
69
70#define MUX_REG(pin) REG(pin)
71#define MUX_SHIFT(pin) 0
72
73#define PULL_REG(pin) REG(pin)
74#define PULL_SHIFT(pin) 2
75
76#define TRI_REG(pin) REG(pin)
77#define TRI_SHIFT(pin) 4
78
79#endif /* CONFIG_TEGRA20 */
80
81#define DRV_REG(group) _R(0x868 + ((group) * 4))
82
83#define IO_SHIFT 5
84#define OD_SHIFT 6
85#define LOCK_SHIFT 7
86#define IO_RESET_SHIFT 8
87#define RCV_SEL_SHIFT 9
88
Stephen Warrenbb144692014-04-22 14:37:54 -060089#if !defined(CONFIG_TEGRA20) && !defined(CONFIG_TEGRA30)
90/* This register/field only exists on Tegra114 and later */
91#define APB_MISC_PP_PINMUX_GLOBAL_0 0x40
92#define CLAMP_INPUTS_WHEN_TRISTATED 1
93
94void pinmux_set_tristate_input_clamping(void)
95{
96 u32 *reg = _R(APB_MISC_PP_PINMUX_GLOBAL_0);
Stephen Warrenbb144692014-04-22 14:37:54 -060097
Stephen Warrenf799b032015-02-18 13:27:03 -070098 setbits_le32(reg, CLAMP_INPUTS_WHEN_TRISTATED);
99}
100
101void pinmux_clear_tristate_input_clamping(void)
102{
103 u32 *reg = _R(APB_MISC_PP_PINMUX_GLOBAL_0);
104
105 clrbits_le32(reg, CLAMP_INPUTS_WHEN_TRISTATED);
Stephen Warrenbb144692014-04-22 14:37:54 -0600106}
107#endif
108
Stephen Warrene2969952014-03-21 12:28:54 -0600109void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
110{
111 u32 *reg = MUX_REG(pin);
112 int i, mux = -1;
113 u32 val;
114
Stephen Warren4a68d342014-04-22 14:37:52 -0600115 if (func == PMUX_FUNC_DEFAULT)
116 return;
117
Stephen Warrene2969952014-03-21 12:28:54 -0600118 /* Error check on pin and func */
119 assert(pmux_pingrp_isvalid(pin));
120 assert(pmux_func_isvalid(func));
121
Stephen Warrend3812942014-03-21 15:58:03 -0600122 if (func >= PMUX_FUNC_RSVD1) {
123 mux = (func - PMUX_FUNC_RSVD1) & 3;
Stephen Warrene2969952014-03-21 12:28:54 -0600124 } else {
125 /* Search for the appropriate function */
126 for (i = 0; i < 4; i++) {
127 if (tegra_soc_pingroups[pin].funcs[i] == func) {
128 mux = i;
129 break;
130 }
131 }
132 }
133 assert(mux != -1);
134
135 val = readl(reg);
136 val &= ~(3 << MUX_SHIFT(pin));
137 val |= (mux << MUX_SHIFT(pin));
138 writel(val, reg);
139}
140
141void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd)
142{
143 u32 *reg = PULL_REG(pin);
144 u32 val;
145
146 /* Error check on pin and pupd */
147 assert(pmux_pingrp_isvalid(pin));
148 assert(pmux_pin_pupd_isvalid(pupd));
149
150 val = readl(reg);
151 val &= ~(3 << PULL_SHIFT(pin));
152 val |= (pupd << PULL_SHIFT(pin));
153 writel(val, reg);
154}
155
Stephen Warrena45fa432014-03-21 12:28:55 -0600156static void pinmux_set_tristate(enum pmux_pingrp pin, int tri)
Stephen Warrene2969952014-03-21 12:28:54 -0600157{
158 u32 *reg = TRI_REG(pin);
159 u32 val;
160
161 /* Error check on pin */
162 assert(pmux_pingrp_isvalid(pin));
163 assert(pmux_pin_tristate_isvalid(tri));
164
165 val = readl(reg);
166 if (tri == PMUX_TRI_TRISTATE)
167 val |= (1 << TRI_SHIFT(pin));
168 else
169 val &= ~(1 << TRI_SHIFT(pin));
170 writel(val, reg);
171}
172
173void pinmux_tristate_enable(enum pmux_pingrp pin)
174{
175 pinmux_set_tristate(pin, PMUX_TRI_TRISTATE);
176}
177
178void pinmux_tristate_disable(enum pmux_pingrp pin)
179{
180 pinmux_set_tristate(pin, PMUX_TRI_NORMAL);
181}
182
183#ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC
184void pinmux_set_io(enum pmux_pingrp pin, enum pmux_pin_io io)
185{
186 u32 *reg = REG(pin);
187 u32 val;
188
189 if (io == PMUX_PIN_NONE)
190 return;
191
192 /* Error check on pin and io */
193 assert(pmux_pingrp_isvalid(pin));
194 assert(pmux_pin_io_isvalid(io));
195
196 val = readl(reg);
197 if (io == PMUX_PIN_INPUT)
198 val |= (io & 1) << IO_SHIFT;
199 else
200 val &= ~(1 << IO_SHIFT);
201 writel(val, reg);
202}
203
204static void pinmux_set_lock(enum pmux_pingrp pin, enum pmux_pin_lock lock)
205{
206 u32 *reg = REG(pin);
207 u32 val;
208
209 if (lock == PMUX_PIN_LOCK_DEFAULT)
210 return;
211
212 /* Error check on pin and lock */
213 assert(pmux_pingrp_isvalid(pin));
214 assert(pmux_pin_lock_isvalid(lock));
215
216 val = readl(reg);
217 if (lock == PMUX_PIN_LOCK_ENABLE) {
218 val |= (1 << LOCK_SHIFT);
219 } else {
220 if (val & (1 << LOCK_SHIFT))
221 printf("%s: Cannot clear LOCK bit!\n", __func__);
222 val &= ~(1 << LOCK_SHIFT);
223 }
224 writel(val, reg);
225
226 return;
227}
228
229static void pinmux_set_od(enum pmux_pingrp pin, enum pmux_pin_od od)
230{
231 u32 *reg = REG(pin);
232 u32 val;
233
234 if (od == PMUX_PIN_OD_DEFAULT)
235 return;
236
237 /* Error check on pin and od */
238 assert(pmux_pingrp_isvalid(pin));
239 assert(pmux_pin_od_isvalid(od));
240
241 val = readl(reg);
242 if (od == PMUX_PIN_OD_ENABLE)
243 val |= (1 << OD_SHIFT);
244 else
245 val &= ~(1 << OD_SHIFT);
246 writel(val, reg);
247
248 return;
249}
250
251static void pinmux_set_ioreset(enum pmux_pingrp pin,
252 enum pmux_pin_ioreset ioreset)
253{
254 u32 *reg = REG(pin);
255 u32 val;
256
257 if (ioreset == PMUX_PIN_IO_RESET_DEFAULT)
258 return;
259
260 /* Error check on pin and ioreset */
261 assert(pmux_pingrp_isvalid(pin));
262 assert(pmux_pin_ioreset_isvalid(ioreset));
263
264 val = readl(reg);
265 if (ioreset == PMUX_PIN_IO_RESET_ENABLE)
266 val |= (1 << IO_RESET_SHIFT);
267 else
268 val &= ~(1 << IO_RESET_SHIFT);
269 writel(val, reg);
270
271 return;
272}
273
274#ifdef TEGRA_PMX_HAS_RCV_SEL
275static void pinmux_set_rcv_sel(enum pmux_pingrp pin,
276 enum pmux_pin_rcv_sel rcv_sel)
277{
278 u32 *reg = REG(pin);
279 u32 val;
280
281 if (rcv_sel == PMUX_PIN_RCV_SEL_DEFAULT)
282 return;
283
284 /* Error check on pin and rcv_sel */
285 assert(pmux_pingrp_isvalid(pin));
286 assert(pmux_pin_rcv_sel_isvalid(rcv_sel));
287
288 val = readl(reg);
289 if (rcv_sel == PMUX_PIN_RCV_SEL_HIGH)
290 val |= (1 << RCV_SEL_SHIFT);
291 else
292 val &= ~(1 << RCV_SEL_SHIFT);
293 writel(val, reg);
294
295 return;
296}
297#endif /* TEGRA_PMX_HAS_RCV_SEL */
298#endif /* TEGRA_PMX_HAS_PIN_IO_BIT_ETC */
299
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600300static void pinmux_config_pingrp(const struct pmux_pingrp_config *config)
Stephen Warrene2969952014-03-21 12:28:54 -0600301{
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600302 enum pmux_pingrp pin = config->pingrp;
Stephen Warrene2969952014-03-21 12:28:54 -0600303
304 pinmux_set_func(pin, config->func);
305 pinmux_set_pullupdown(pin, config->pull);
306 pinmux_set_tristate(pin, config->tristate);
307#ifdef TEGRA_PMX_HAS_PIN_IO_BIT_ETC
308 pinmux_set_io(pin, config->io);
309 pinmux_set_lock(pin, config->lock);
310 pinmux_set_od(pin, config->od);
311 pinmux_set_ioreset(pin, config->ioreset);
312#ifdef TEGRA_PMX_HAS_RCV_SEL
313 pinmux_set_rcv_sel(pin, config->rcv_sel);
314#endif
315#endif
316}
317
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600318void pinmux_config_pingrp_table(const struct pmux_pingrp_config *config,
319 int len)
Stephen Warrene2969952014-03-21 12:28:54 -0600320{
321 int i;
322
323 for (i = 0; i < len; i++)
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600324 pinmux_config_pingrp(&config[i]);
Stephen Warrene2969952014-03-21 12:28:54 -0600325}
326
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600327#ifdef TEGRA_PMX_HAS_DRVGRPS
Stephen Warrene2969952014-03-21 12:28:54 -0600328
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600329#define pmux_drvgrp_isvalid(pd) (((pd) >= 0) && ((pd) < PMUX_DRVGRP_COUNT))
Stephen Warrene2969952014-03-21 12:28:54 -0600330
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600331#define pmux_slw_isvalid(slw) \
332 (((slw) >= PMUX_SLWF_MIN) && ((slw) <= PMUX_SLWF_MAX))
Stephen Warrene2969952014-03-21 12:28:54 -0600333
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600334#define pmux_drv_isvalid(drv) \
335 (((drv) >= PMUX_DRVUP_MIN) && ((drv) <= PMUX_DRVUP_MAX))
Stephen Warrene2969952014-03-21 12:28:54 -0600336
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600337#define pmux_lpmd_isvalid(lpm) \
338 (((lpm) >= PMUX_LPMD_X8) && ((lpm) <= PMUX_LPMD_X))
Stephen Warrene2969952014-03-21 12:28:54 -0600339
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600340#define pmux_schmt_isvalid(schmt) \
341 (((schmt) >= PMUX_SCHMT_DISABLE) && ((schmt) <= PMUX_SCHMT_ENABLE))
Stephen Warrene2969952014-03-21 12:28:54 -0600342
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600343#define pmux_hsm_isvalid(hsm) \
344 (((hsm) >= PMUX_HSM_DISABLE) && ((hsm) <= PMUX_HSM_ENABLE))
Stephen Warrene2969952014-03-21 12:28:54 -0600345
346#define HSM_SHIFT 2
347#define SCHMT_SHIFT 3
348#define LPMD_SHIFT 4
349#define LPMD_MASK (3 << LPMD_SHIFT)
Stephen Warren9f21c1a2015-02-24 14:08:23 -0700350/*
351 * Note that the following DRV* and SLW* defines are accurate for many drive
352 * groups on many SoCs. We really need a per-group data structure to solve
353 * this, since the fields are in different positions/sizes in different
354 * registers (for different groups).
355 *
356 * On Tegra30/114/124, the DRV*_SHIFT values vary.
357 * On Tegra30, the SLW*_SHIFT values vary.
358 * On Tegra30/114/124/210, the DRV*_MASK values vary, although the values
359 * below are wide enough to cover the widest fields, and hopefully don't
360 * interfere with any other fields.
361 * On Tegra30, the SLW*_MASK values vary, but we can't use a value that's
362 * wide enough to cover all cases, since that would cause the field to
363 * overlap with other fields in the narrower cases.
364 */
Stephen Warrene2969952014-03-21 12:28:54 -0600365#define DRVDN_SHIFT 12
366#define DRVDN_MASK (0x7F << DRVDN_SHIFT)
367#define DRVUP_SHIFT 20
368#define DRVUP_MASK (0x7F << DRVUP_SHIFT)
369#define SLWR_SHIFT 28
370#define SLWR_MASK (3 << SLWR_SHIFT)
371#define SLWF_SHIFT 30
372#define SLWF_MASK (3 << SLWF_SHIFT)
373
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600374static void pinmux_set_drvup_slwf(enum pmux_drvgrp grp, int slwf)
Stephen Warrene2969952014-03-21 12:28:54 -0600375{
376 u32 *reg = DRV_REG(grp);
377 u32 val;
378
379 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600380 if (slwf == PMUX_SLWF_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600381 return;
382
383 /* Error check on pad and slwf */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600384 assert(pmux_drvgrp_isvalid(grp));
385 assert(pmux_slw_isvalid(slwf));
Stephen Warrene2969952014-03-21 12:28:54 -0600386
387 val = readl(reg);
388 val &= ~SLWF_MASK;
389 val |= (slwf << SLWF_SHIFT);
390 writel(val, reg);
391
392 return;
393}
394
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600395static void pinmux_set_drvdn_slwr(enum pmux_drvgrp grp, int slwr)
Stephen Warrene2969952014-03-21 12:28:54 -0600396{
397 u32 *reg = DRV_REG(grp);
398 u32 val;
399
400 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600401 if (slwr == PMUX_SLWR_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600402 return;
403
404 /* Error check on pad and slwr */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600405 assert(pmux_drvgrp_isvalid(grp));
406 assert(pmux_slw_isvalid(slwr));
Stephen Warrene2969952014-03-21 12:28:54 -0600407
408 val = readl(reg);
409 val &= ~SLWR_MASK;
410 val |= (slwr << SLWR_SHIFT);
411 writel(val, reg);
412
413 return;
414}
415
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600416static void pinmux_set_drvup(enum pmux_drvgrp grp, int drvup)
Stephen Warrene2969952014-03-21 12:28:54 -0600417{
418 u32 *reg = DRV_REG(grp);
419 u32 val;
420
421 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600422 if (drvup == PMUX_DRVUP_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600423 return;
424
425 /* Error check on pad and drvup */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600426 assert(pmux_drvgrp_isvalid(grp));
427 assert(pmux_drv_isvalid(drvup));
Stephen Warrene2969952014-03-21 12:28:54 -0600428
429 val = readl(reg);
430 val &= ~DRVUP_MASK;
431 val |= (drvup << DRVUP_SHIFT);
432 writel(val, reg);
433
434 return;
435}
436
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600437static void pinmux_set_drvdn(enum pmux_drvgrp grp, int drvdn)
Stephen Warrene2969952014-03-21 12:28:54 -0600438{
439 u32 *reg = DRV_REG(grp);
440 u32 val;
441
442 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600443 if (drvdn == PMUX_DRVDN_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600444 return;
445
446 /* Error check on pad and drvdn */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600447 assert(pmux_drvgrp_isvalid(grp));
448 assert(pmux_drv_isvalid(drvdn));
Stephen Warrene2969952014-03-21 12:28:54 -0600449
450 val = readl(reg);
451 val &= ~DRVDN_MASK;
452 val |= (drvdn << DRVDN_SHIFT);
453 writel(val, reg);
454
455 return;
456}
457
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600458static void pinmux_set_lpmd(enum pmux_drvgrp grp, enum pmux_lpmd lpmd)
Stephen Warrene2969952014-03-21 12:28:54 -0600459{
460 u32 *reg = DRV_REG(grp);
461 u32 val;
462
463 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600464 if (lpmd == PMUX_LPMD_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600465 return;
466
467 /* Error check pad and lpmd value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600468 assert(pmux_drvgrp_isvalid(grp));
469 assert(pmux_lpmd_isvalid(lpmd));
Stephen Warrene2969952014-03-21 12:28:54 -0600470
471 val = readl(reg);
472 val &= ~LPMD_MASK;
473 val |= (lpmd << LPMD_SHIFT);
474 writel(val, reg);
475
476 return;
477}
478
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600479static void pinmux_set_schmt(enum pmux_drvgrp grp, enum pmux_schmt schmt)
Stephen Warrene2969952014-03-21 12:28:54 -0600480{
481 u32 *reg = DRV_REG(grp);
482 u32 val;
483
484 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600485 if (schmt == PMUX_SCHMT_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600486 return;
487
488 /* Error check pad */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600489 assert(pmux_drvgrp_isvalid(grp));
490 assert(pmux_schmt_isvalid(schmt));
Stephen Warrene2969952014-03-21 12:28:54 -0600491
492 val = readl(reg);
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600493 if (schmt == PMUX_SCHMT_ENABLE)
Stephen Warrene2969952014-03-21 12:28:54 -0600494 val |= (1 << SCHMT_SHIFT);
495 else
496 val &= ~(1 << SCHMT_SHIFT);
497 writel(val, reg);
498
499 return;
500}
501
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600502static void pinmux_set_hsm(enum pmux_drvgrp grp, enum pmux_hsm hsm)
Stephen Warrene2969952014-03-21 12:28:54 -0600503{
504 u32 *reg = DRV_REG(grp);
505 u32 val;
506
507 /* NONE means unspecified/do not change/use POR value */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600508 if (hsm == PMUX_HSM_NONE)
Stephen Warrene2969952014-03-21 12:28:54 -0600509 return;
510
511 /* Error check pad */
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600512 assert(pmux_drvgrp_isvalid(grp));
513 assert(pmux_hsm_isvalid(hsm));
Stephen Warrene2969952014-03-21 12:28:54 -0600514
515 val = readl(reg);
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600516 if (hsm == PMUX_HSM_ENABLE)
Stephen Warrene2969952014-03-21 12:28:54 -0600517 val |= (1 << HSM_SHIFT);
518 else
519 val &= ~(1 << HSM_SHIFT);
520 writel(val, reg);
521
522 return;
523}
524
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600525static void pinmux_config_drvgrp(const struct pmux_drvgrp_config *config)
Stephen Warrene2969952014-03-21 12:28:54 -0600526{
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600527 enum pmux_drvgrp grp = config->drvgrp;
Stephen Warrene2969952014-03-21 12:28:54 -0600528
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600529 pinmux_set_drvup_slwf(grp, config->slwf);
530 pinmux_set_drvdn_slwr(grp, config->slwr);
531 pinmux_set_drvup(grp, config->drvup);
532 pinmux_set_drvdn(grp, config->drvdn);
533 pinmux_set_lpmd(grp, config->lpmd);
534 pinmux_set_schmt(grp, config->schmt);
535 pinmux_set_hsm(grp, config->hsm);
Stephen Warrene2969952014-03-21 12:28:54 -0600536}
537
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600538void pinmux_config_drvgrp_table(const struct pmux_drvgrp_config *config,
539 int len)
Stephen Warrene2969952014-03-21 12:28:54 -0600540{
541 int i;
542
543 for (i = 0; i < len; i++)
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600544 pinmux_config_drvgrp(&config[i]);
Stephen Warrene2969952014-03-21 12:28:54 -0600545}
Stephen Warrendfb42fc2014-03-21 12:28:56 -0600546#endif /* TEGRA_PMX_HAS_DRVGRPS */