blob: 42887154c4faefe862fffbaab5a843fb528161f4 [file] [log] [blame]
Marek Vasutb473ec52011-11-08 23:18:11 +00001/*
2 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
3 * <armlinux@phytec.de>
4 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
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 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#ifndef __MACH_MXS_IOMUX_H__
22#define __MACH_MXS_IOMUX_H__
23
Otavio Salvador1e5be162013-02-23 02:43:08 +000024#ifndef __ASSEMBLY__
25
26#include <asm/types.h>
27
Marek Vasutb473ec52011-11-08 23:18:11 +000028/*
29 * IOMUX/PAD Bit field definitions
30 *
31 * PAD_BANK: 0..2 (3)
32 * PAD_PIN: 3..7 (5)
33 * PAD_MUXSEL: 8..9 (2)
34 * PAD_MA: 10..11 (2)
35 * PAD_MA_VALID: 12 (1)
36 * PAD_VOL: 13 (1)
37 * PAD_VOL_VALID: 14 (1)
38 * PAD_PULL: 15 (1)
39 * PAD_PULL_VALID: 16 (1)
40 * RESERVED: 17..31 (15)
41 */
42typedef u32 iomux_cfg_t;
43
44#define MXS_PAD_BANK_SHIFT 0
45#define MXS_PAD_BANK_MASK ((iomux_cfg_t)0x7 << MXS_PAD_BANK_SHIFT)
46#define MXS_PAD_PIN_SHIFT 3
47#define MXS_PAD_PIN_MASK ((iomux_cfg_t)0x1f << MXS_PAD_PIN_SHIFT)
48#define MXS_PAD_MUXSEL_SHIFT 8
49#define MXS_PAD_MUXSEL_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MUXSEL_SHIFT)
50#define MXS_PAD_MA_SHIFT 10
51#define MXS_PAD_MA_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MA_SHIFT)
52#define MXS_PAD_MA_VALID_SHIFT 12
53#define MXS_PAD_MA_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_MA_VALID_SHIFT)
54#define MXS_PAD_VOL_SHIFT 13
55#define MXS_PAD_VOL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_SHIFT)
56#define MXS_PAD_VOL_VALID_SHIFT 14
57#define MXS_PAD_VOL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_VALID_SHIFT)
58#define MXS_PAD_PULL_SHIFT 15
59#define MXS_PAD_PULL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_SHIFT)
60#define MXS_PAD_PULL_VALID_SHIFT 16
61#define MXS_PAD_PULL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_VALID_SHIFT)
62
63#define PAD_MUXSEL_0 0
64#define PAD_MUXSEL_1 1
65#define PAD_MUXSEL_2 2
66#define PAD_MUXSEL_GPIO 3
67
68#define PAD_4MA 0
69#define PAD_8MA 1
70#define PAD_12MA 2
71#define PAD_16MA 3
72
73#define PAD_1V8 0
74#define PAD_3V3 1
75
76#define PAD_NOPULL 0
77#define PAD_PULLUP 1
78
79#define MXS_PAD_4MA ((PAD_4MA << MXS_PAD_MA_SHIFT) | \
80 MXS_PAD_MA_VALID_MASK)
81#define MXS_PAD_8MA ((PAD_8MA << MXS_PAD_MA_SHIFT) | \
82 MXS_PAD_MA_VALID_MASK)
83#define MXS_PAD_12MA ((PAD_12MA << MXS_PAD_MA_SHIFT) | \
84 MXS_PAD_MA_VALID_MASK)
85#define MXS_PAD_16MA ((PAD_16MA << MXS_PAD_MA_SHIFT) | \
86 MXS_PAD_MA_VALID_MASK)
87
88#define MXS_PAD_1V8 ((PAD_1V8 << MXS_PAD_VOL_SHIFT) | \
89 MXS_PAD_VOL_VALID_MASK)
90#define MXS_PAD_3V3 ((PAD_3V3 << MXS_PAD_VOL_SHIFT) | \
91 MXS_PAD_VOL_VALID_MASK)
92
93#define MXS_PAD_NOPULL ((PAD_NOPULL << MXS_PAD_PULL_SHIFT) | \
94 MXS_PAD_PULL_VALID_MASK)
95#define MXS_PAD_PULLUP ((PAD_PULLUP << MXS_PAD_PULL_SHIFT) | \
96 MXS_PAD_PULL_VALID_MASK)
97
98/* generic pad control used in most cases */
99#define MXS_PAD_CTRL (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL)
100
101#define MXS_IOMUX_PAD(_bank, _pin, _muxsel, _ma, _vol, _pull) \
102 (((iomux_cfg_t)(_bank) << MXS_PAD_BANK_SHIFT) | \
103 ((iomux_cfg_t)(_pin) << MXS_PAD_PIN_SHIFT) | \
104 ((iomux_cfg_t)(_muxsel) << MXS_PAD_MUXSEL_SHIFT) | \
105 ((iomux_cfg_t)(_ma) << MXS_PAD_MA_SHIFT) | \
106 ((iomux_cfg_t)(_vol) << MXS_PAD_VOL_SHIFT) | \
107 ((iomux_cfg_t)(_pull) << MXS_PAD_PULL_SHIFT))
108
109/*
110 * A pad becomes naked, when none of mA, vol or pull
111 * validity bits is set.
112 */
113#define MXS_IOMUX_PAD_NAKED(_bank, _pin, _muxsel) \
114 MXS_IOMUX_PAD(_bank, _pin, _muxsel, 0, 0, 0)
115
116static inline unsigned int PAD_BANK(iomux_cfg_t pad)
117{
118 return (pad & MXS_PAD_BANK_MASK) >> MXS_PAD_BANK_SHIFT;
119}
120
121static inline unsigned int PAD_PIN(iomux_cfg_t pad)
122{
123 return (pad & MXS_PAD_PIN_MASK) >> MXS_PAD_PIN_SHIFT;
124}
125
126static inline unsigned int PAD_MUXSEL(iomux_cfg_t pad)
127{
128 return (pad & MXS_PAD_MUXSEL_MASK) >> MXS_PAD_MUXSEL_SHIFT;
129}
130
131static inline unsigned int PAD_MA(iomux_cfg_t pad)
132{
133 return (pad & MXS_PAD_MA_MASK) >> MXS_PAD_MA_SHIFT;
134}
135
136static inline unsigned int PAD_MA_VALID(iomux_cfg_t pad)
137{
138 return (pad & MXS_PAD_MA_VALID_MASK) >> MXS_PAD_MA_VALID_SHIFT;
139}
140
141static inline unsigned int PAD_VOL(iomux_cfg_t pad)
142{
143 return (pad & MXS_PAD_VOL_MASK) >> MXS_PAD_VOL_SHIFT;
144}
145
146static inline unsigned int PAD_VOL_VALID(iomux_cfg_t pad)
147{
148 return (pad & MXS_PAD_VOL_VALID_MASK) >> MXS_PAD_VOL_VALID_SHIFT;
149}
150
151static inline unsigned int PAD_PULL(iomux_cfg_t pad)
152{
153 return (pad & MXS_PAD_PULL_MASK) >> MXS_PAD_PULL_SHIFT;
154}
155
156static inline unsigned int PAD_PULL_VALID(iomux_cfg_t pad)
157{
158 return (pad & MXS_PAD_PULL_VALID_MASK) >> MXS_PAD_PULL_VALID_SHIFT;
159}
160
161/*
162 * configures a single pad in the iomuxer
163 */
164int mxs_iomux_setup_pad(iomux_cfg_t pad);
165
166/*
167 * configures multiple pads
168 * convenient way to call the above function with tables
169 */
170int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
171
Otavio Salvador1e5be162013-02-23 02:43:08 +0000172#endif /* __ASSEMBLY__ */
Marek Vasutb473ec52011-11-08 23:18:11 +0000173#endif /* __MACH_MXS_IOMUX_H__*/