2 * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
4 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
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.
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,
21 #ifndef __MACH_MXS_IOMUX_H__
22 #define __MACH_MXS_IOMUX_H__
25 * IOMUX/PAD Bit field definitions
29 * PAD_MUXSEL: 8..9 (2)
31 * PAD_MA_VALID: 12 (1)
33 * PAD_VOL_VALID: 14 (1)
35 * PAD_PULL_VALID: 16 (1)
36 * RESERVED: 17..31 (15)
38 typedef u32 iomux_cfg_t
;
40 #define MXS_PAD_BANK_SHIFT 0
41 #define MXS_PAD_BANK_MASK ((iomux_cfg_t)0x7 << MXS_PAD_BANK_SHIFT)
42 #define MXS_PAD_PIN_SHIFT 3
43 #define MXS_PAD_PIN_MASK ((iomux_cfg_t)0x1f << MXS_PAD_PIN_SHIFT)
44 #define MXS_PAD_MUXSEL_SHIFT 8
45 #define MXS_PAD_MUXSEL_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MUXSEL_SHIFT)
46 #define MXS_PAD_MA_SHIFT 10
47 #define MXS_PAD_MA_MASK ((iomux_cfg_t)0x3 << MXS_PAD_MA_SHIFT)
48 #define MXS_PAD_MA_VALID_SHIFT 12
49 #define MXS_PAD_MA_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_MA_VALID_SHIFT)
50 #define MXS_PAD_VOL_SHIFT 13
51 #define MXS_PAD_VOL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_SHIFT)
52 #define MXS_PAD_VOL_VALID_SHIFT 14
53 #define MXS_PAD_VOL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_VOL_VALID_SHIFT)
54 #define MXS_PAD_PULL_SHIFT 15
55 #define MXS_PAD_PULL_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_SHIFT)
56 #define MXS_PAD_PULL_VALID_SHIFT 16
57 #define MXS_PAD_PULL_VALID_MASK ((iomux_cfg_t)0x1 << MXS_PAD_PULL_VALID_SHIFT)
59 #define PAD_MUXSEL_0 0
60 #define PAD_MUXSEL_1 1
61 #define PAD_MUXSEL_2 2
62 #define PAD_MUXSEL_GPIO 3
75 #define MXS_PAD_4MA ((PAD_4MA << MXS_PAD_MA_SHIFT) | \
76 MXS_PAD_MA_VALID_MASK)
77 #define MXS_PAD_8MA ((PAD_8MA << MXS_PAD_MA_SHIFT) | \
78 MXS_PAD_MA_VALID_MASK)
79 #define MXS_PAD_12MA ((PAD_12MA << MXS_PAD_MA_SHIFT) | \
80 MXS_PAD_MA_VALID_MASK)
81 #define MXS_PAD_16MA ((PAD_16MA << MXS_PAD_MA_SHIFT) | \
82 MXS_PAD_MA_VALID_MASK)
84 #define MXS_PAD_1V8 ((PAD_1V8 << MXS_PAD_VOL_SHIFT) | \
85 MXS_PAD_VOL_VALID_MASK)
86 #define MXS_PAD_3V3 ((PAD_3V3 << MXS_PAD_VOL_SHIFT) | \
87 MXS_PAD_VOL_VALID_MASK)
89 #define MXS_PAD_NOPULL ((PAD_NOPULL << MXS_PAD_PULL_SHIFT) | \
90 MXS_PAD_PULL_VALID_MASK)
91 #define MXS_PAD_PULLUP ((PAD_PULLUP << MXS_PAD_PULL_SHIFT) | \
92 MXS_PAD_PULL_VALID_MASK)
94 #define MXS_IOMUX_PAD(_bank, _pin, _muxsel, _ma, _vol, _pull) \
95 (((iomux_cfg_t)(_bank) << MXS_PAD_BANK_SHIFT) | \
96 ((iomux_cfg_t)(_pin) << MXS_PAD_PIN_SHIFT) | \
97 ((iomux_cfg_t)(_muxsel) << MXS_PAD_MUXSEL_SHIFT) | \
98 ((iomux_cfg_t)(_ma) << MXS_PAD_MA_SHIFT) | \
99 ((iomux_cfg_t)(_vol) << MXS_PAD_VOL_SHIFT) | \
100 ((iomux_cfg_t)(_pull) << MXS_PAD_PULL_SHIFT))
103 * A pad becomes naked, when none of mA, vol or pull
104 * validity bits is set.
106 #define MXS_IOMUX_PAD_NAKED(_bank, _pin, _muxsel) \
107 MXS_IOMUX_PAD(_bank, _pin, _muxsel, 0, 0, 0)
109 static inline unsigned int PAD_BANK(iomux_cfg_t pad
)
111 return (pad
& MXS_PAD_BANK_MASK
) >> MXS_PAD_BANK_SHIFT
;
114 static inline unsigned int PAD_PIN(iomux_cfg_t pad
)
116 return (pad
& MXS_PAD_PIN_MASK
) >> MXS_PAD_PIN_SHIFT
;
119 static inline unsigned int PAD_MUXSEL(iomux_cfg_t pad
)
121 return (pad
& MXS_PAD_MUXSEL_MASK
) >> MXS_PAD_MUXSEL_SHIFT
;
124 static inline unsigned int PAD_MA(iomux_cfg_t pad
)
126 return (pad
& MXS_PAD_MA_MASK
) >> MXS_PAD_MA_SHIFT
;
129 static inline unsigned int PAD_MA_VALID(iomux_cfg_t pad
)
131 return (pad
& MXS_PAD_MA_VALID_MASK
) >> MXS_PAD_MA_VALID_SHIFT
;
134 static inline unsigned int PAD_VOL(iomux_cfg_t pad
)
136 return (pad
& MXS_PAD_VOL_MASK
) >> MXS_PAD_VOL_SHIFT
;
139 static inline unsigned int PAD_VOL_VALID(iomux_cfg_t pad
)
141 return (pad
& MXS_PAD_VOL_VALID_MASK
) >> MXS_PAD_VOL_VALID_SHIFT
;
144 static inline unsigned int PAD_PULL(iomux_cfg_t pad
)
146 return (pad
& MXS_PAD_PULL_MASK
) >> MXS_PAD_PULL_SHIFT
;
149 static inline unsigned int PAD_PULL_VALID(iomux_cfg_t pad
)
151 return (pad
& MXS_PAD_PULL_VALID_MASK
) >> MXS_PAD_PULL_VALID_SHIFT
;
155 * configures a single pad in the iomuxer
157 int mxs_iomux_setup_pad(iomux_cfg_t pad
);
160 * configures multiple pads
161 * convenient way to call the above function with tables
163 int mxs_iomux_setup_multiple_pads(const iomux_cfg_t
*pad_list
, unsigned count
);
165 #endif /* __MACH_MXS_IOMUX_H__*/