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__
26 #include <asm/types.h>
29 * IOMUX/PAD Bit field definitions
33 * PAD_MUXSEL: 8..9 (2)
35 * PAD_MA_VALID: 12 (1)
37 * PAD_VOL_VALID: 14 (1)
39 * PAD_PULL_VALID: 16 (1)
40 * RESERVED: 17..31 (15)
42 typedef u32 iomux_cfg_t;
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)
63 #define PAD_MUXSEL_0 0
64 #define PAD_MUXSEL_1 1
65 #define PAD_MUXSEL_2 2
66 #define PAD_MUXSEL_GPIO 3
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)
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)
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)
98 /* generic pad control used in most cases */
99 #define MXS_PAD_CTRL (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL)
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))
110 * A pad becomes naked, when none of mA, vol or pull
111 * validity bits is set.
113 #define MXS_IOMUX_PAD_NAKED(_bank, _pin, _muxsel) \
114 MXS_IOMUX_PAD(_bank, _pin, _muxsel, 0, 0, 0)
116 static inline unsigned int PAD_BANK(iomux_cfg_t pad)
118 return (pad & MXS_PAD_BANK_MASK) >> MXS_PAD_BANK_SHIFT;
121 static inline unsigned int PAD_PIN(iomux_cfg_t pad)
123 return (pad & MXS_PAD_PIN_MASK) >> MXS_PAD_PIN_SHIFT;
126 static inline unsigned int PAD_MUXSEL(iomux_cfg_t pad)
128 return (pad & MXS_PAD_MUXSEL_MASK) >> MXS_PAD_MUXSEL_SHIFT;
131 static inline unsigned int PAD_MA(iomux_cfg_t pad)
133 return (pad & MXS_PAD_MA_MASK) >> MXS_PAD_MA_SHIFT;
136 static inline unsigned int PAD_MA_VALID(iomux_cfg_t pad)
138 return (pad & MXS_PAD_MA_VALID_MASK) >> MXS_PAD_MA_VALID_SHIFT;
141 static inline unsigned int PAD_VOL(iomux_cfg_t pad)
143 return (pad & MXS_PAD_VOL_MASK) >> MXS_PAD_VOL_SHIFT;
146 static inline unsigned int PAD_VOL_VALID(iomux_cfg_t pad)
148 return (pad & MXS_PAD_VOL_VALID_MASK) >> MXS_PAD_VOL_VALID_SHIFT;
151 static inline unsigned int PAD_PULL(iomux_cfg_t pad)
153 return (pad & MXS_PAD_PULL_MASK) >> MXS_PAD_PULL_SHIFT;
156 static inline unsigned int PAD_PULL_VALID(iomux_cfg_t pad)
158 return (pad & MXS_PAD_PULL_VALID_MASK) >> MXS_PAD_PULL_VALID_SHIFT;
162 * configures a single pad in the iomuxer
164 int mxs_iomux_setup_pad(iomux_cfg_t pad);
167 * configures multiple pads
168 * convenient way to call the above function with tables
170 int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
172 #endif /* __ASSEMBLY__ */
173 #endif /* __MACH_MXS_IOMUX_H__*/