1
2
3
4
5
6
7
8#ifndef __MACH_MXS_IOMUX_H__
9#define __MACH_MXS_IOMUX_H__
10
11#ifndef __ASSEMBLY__
12
13#include <asm/types.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29typedef u32 iomux_cfg_t;
30
31#define MXS_PAD_BANK_SHIFT 0
32#define MXS_PAD_BANK_MASK ((iomux_cfg_t)0x7 << MXS_PAD_BANK_SHIFT)
33#define MXS_PAD_PIN_SHIFT 3
34#define MXS_PAD_PIN_MASK ((iomux_cfg_t)0x1f << MXS_PAD_PIN_SHIFT)
35#define MXS_PAD_MUXSEL_SHIFT 8
36#define MXS_PAD_MUXSEL_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MUXSEL_SHIFT)
37#define MXS_PAD_MA_SHIFT 10
38#define MXS_PAD_MA_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MA_SHIFT)
39#define MXS_PAD_MA_VALID_SHIFT 12
40#define MXS_PAD_MA_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_MA_VALID_SHIFT)
41#define MXS_PAD_VOL_SHIFT 13
42#define MXS_PAD_VOL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_SHIFT)
43#define MXS_PAD_VOL_VALID_SHIFT 14
44#define MXS_PAD_VOL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_VALID_SHIFT)
45#define MXS_PAD_PULL_SHIFT 15
46#define MXS_PAD_PULL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_SHIFT)
47#define MXS_PAD_PULL_VALID_SHIFT 16
48#define MXS_PAD_PULL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_VALID_SHIFT)
49
50#define PAD_MUXSEL_0 0
51#define PAD_MUXSEL_1 1
52#define PAD_MUXSEL_2 2
53#define PAD_MUXSEL_GPIO 3
54
55#define PAD_4MA 0
56#define PAD_8MA 1
57#define PAD_12MA 2
58#define PAD_16MA 3
59
60#define PAD_1V8 0
61#if defined(CONFIG_MX28)
62#define PAD_3V3 1
63#else
64#define PAD_3V3 0
65#endif
66
67#define PAD_NOPULL 0
68#define PAD_PULLUP 1
69
70#define MXS_PAD_4MA ((PAD_4MA << MXS_PAD_MA_SHIFT) | \
71 MXS_PAD_MA_VALID_MASK)
72#define MXS_PAD_8MA ((PAD_8MA << MXS_PAD_MA_SHIFT) | \
73 MXS_PAD_MA_VALID_MASK)
74#define MXS_PAD_12MA ((PAD_12MA << MXS_PAD_MA_SHIFT) | \
75 MXS_PAD_MA_VALID_MASK)
76#define MXS_PAD_16MA ((PAD_16MA << MXS_PAD_MA_SHIFT) | \
77 MXS_PAD_MA_VALID_MASK)
78
79#define MXS_PAD_1V8 ((PAD_1V8 << MXS_PAD_VOL_SHIFT) | \
80 MXS_PAD_VOL_VALID_MASK)
81#define MXS_PAD_3V3 ((PAD_3V3 << MXS_PAD_VOL_SHIFT) | \
82 MXS_PAD_VOL_VALID_MASK)
83
84#define MXS_PAD_NOPULL ((PAD_NOPULL << MXS_PAD_PULL_SHIFT) | \
85 MXS_PAD_PULL_VALID_MASK)
86#define MXS_PAD_PULLUP ((PAD_PULLUP << MXS_PAD_PULL_SHIFT) | \
87 MXS_PAD_PULL_VALID_MASK)
88
89
90#define MXS_PAD_CTRL (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL)
91
92#define MXS_IOMUX_PAD(_bank, _pin, _muxsel, _ma, _vol, _pull) \
93 (((iomux_cfg_t)(_bank) << MXS_PAD_BANK_SHIFT) | \
94 ((iomux_cfg_t)(_pin) << MXS_PAD_PIN_SHIFT) | \
95 ((iomux_cfg_t)(_muxsel) << MXS_PAD_MUXSEL_SHIFT) | \
96 ((iomux_cfg_t)(_ma) << MXS_PAD_MA_SHIFT) | \
97 ((iomux_cfg_t)(_vol) << MXS_PAD_VOL_SHIFT) | \
98 ((iomux_cfg_t)(_pull) << MXS_PAD_PULL_SHIFT))
99
100
101
102
103
104#define MXS_IOMUX_PAD_NAKED(_bank, _pin, _muxsel) \
105 MXS_IOMUX_PAD(_bank, _pin, _muxsel, 0, 0, 0)
106
107static inline unsigned int PAD_BANK(iomux_cfg_t pad)
108{
109 return (pad & MXS_PAD_BANK_MASK) >> MXS_PAD_BANK_SHIFT;
110}
111
112static inline unsigned int PAD_PIN(iomux_cfg_t pad)
113{
114 return (pad & MXS_PAD_PIN_MASK) >> MXS_PAD_PIN_SHIFT;
115}
116
117static inline unsigned int PAD_MUXSEL(iomux_cfg_t pad)
118{
119 return (pad & MXS_PAD_MUXSEL_MASK) >> MXS_PAD_MUXSEL_SHIFT;
120}
121
122static inline unsigned int PAD_MA(iomux_cfg_t pad)
123{
124 return (pad & MXS_PAD_MA_MASK) >> MXS_PAD_MA_SHIFT;
125}
126
127static inline unsigned int PAD_MA_VALID(iomux_cfg_t pad)
128{
129 return (pad & MXS_PAD_MA_VALID_MASK) >> MXS_PAD_MA_VALID_SHIFT;
130}
131
132static inline unsigned int PAD_VOL(iomux_cfg_t pad)
133{
134 return (pad & MXS_PAD_VOL_MASK) >> MXS_PAD_VOL_SHIFT;
135}
136
137static inline unsigned int PAD_VOL_VALID(iomux_cfg_t pad)
138{
139 return (pad & MXS_PAD_VOL_VALID_MASK) >> MXS_PAD_VOL_VALID_SHIFT;
140}
141
142static inline unsigned int PAD_PULL(iomux_cfg_t pad)
143{
144 return (pad & MXS_PAD_PULL_MASK) >> MXS_PAD_PULL_SHIFT;
145}
146
147static inline unsigned int PAD_PULL_VALID(iomux_cfg_t pad)
148{
149 return (pad & MXS_PAD_PULL_VALID_MASK) >> MXS_PAD_PULL_VALID_SHIFT;
150}
151
152
153
154
155int mxs_iomux_setup_pad(iomux_cfg_t pad);
156
157
158
159
160
161int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
162
163#endif
164#endif
165