blob: d919fb239a0eadae4f15987f3613c394de2e5ebb [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
Fabio Estevamdd79d0b2013-05-03 04:37:07 +000074#if defined(CONFIG_MX28)
Marek Vasutb473ec52011-11-08 23:18:11 +000075#define PAD_3V3 1
Fabio Estevamdd79d0b2013-05-03 04:37:07 +000076#else
77#define PAD_3V3 0
78#endif
Marek Vasutb473ec52011-11-08 23:18:11 +000079
80#define PAD_NOPULL 0
81#define PAD_PULLUP 1
82
83#define MXS_PAD_4MA ((PAD_4MA << MXS_PAD_MA_SHIFT) | \
84 MXS_PAD_MA_VALID_MASK)
85#define MXS_PAD_8MA ((PAD_8MA << MXS_PAD_MA_SHIFT) | \
86 MXS_PAD_MA_VALID_MASK)
87#define MXS_PAD_12MA ((PAD_12MA << MXS_PAD_MA_SHIFT) | \
88 MXS_PAD_MA_VALID_MASK)
89#define MXS_PAD_16MA ((PAD_16MA << MXS_PAD_MA_SHIFT) | \
90 MXS_PAD_MA_VALID_MASK)
91
92#define MXS_PAD_1V8 ((PAD_1V8 << MXS_PAD_VOL_SHIFT) | \
93 MXS_PAD_VOL_VALID_MASK)
94#define MXS_PAD_3V3 ((PAD_3V3 << MXS_PAD_VOL_SHIFT) | \
95 MXS_PAD_VOL_VALID_MASK)
96
97#define MXS_PAD_NOPULL ((PAD_NOPULL << MXS_PAD_PULL_SHIFT) | \
98 MXS_PAD_PULL_VALID_MASK)
99#define MXS_PAD_PULLUP ((PAD_PULLUP << MXS_PAD_PULL_SHIFT) | \
100 MXS_PAD_PULL_VALID_MASK)
101
102/* generic pad control used in most cases */
103#define MXS_PAD_CTRL (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL)
104
105#define MXS_IOMUX_PAD(_bank, _pin, _muxsel, _ma, _vol, _pull) \
106 (((iomux_cfg_t)(_bank) << MXS_PAD_BANK_SHIFT) | \
107 ((iomux_cfg_t)(_pin) << MXS_PAD_PIN_SHIFT) | \
108 ((iomux_cfg_t)(_muxsel) << MXS_PAD_MUXSEL_SHIFT) | \
109 ((iomux_cfg_t)(_ma) << MXS_PAD_MA_SHIFT) | \
110 ((iomux_cfg_t)(_vol) << MXS_PAD_VOL_SHIFT) | \
111 ((iomux_cfg_t)(_pull) << MXS_PAD_PULL_SHIFT))
112
113/*
114 * A pad becomes naked, when none of mA, vol or pull
115 * validity bits is set.
116 */
117#define MXS_IOMUX_PAD_NAKED(_bank, _pin, _muxsel) \
118 MXS_IOMUX_PAD(_bank, _pin, _muxsel, 0, 0, 0)
119
120static inline unsigned int PAD_BANK(iomux_cfg_t pad)
121{
122 return (pad & MXS_PAD_BANK_MASK) >> MXS_PAD_BANK_SHIFT;
123}
124
125static inline unsigned int PAD_PIN(iomux_cfg_t pad)
126{
127 return (pad & MXS_PAD_PIN_MASK) >> MXS_PAD_PIN_SHIFT;
128}
129
130static inline unsigned int PAD_MUXSEL(iomux_cfg_t pad)
131{
132 return (pad & MXS_PAD_MUXSEL_MASK) >> MXS_PAD_MUXSEL_SHIFT;
133}
134
135static inline unsigned int PAD_MA(iomux_cfg_t pad)
136{
137 return (pad & MXS_PAD_MA_MASK) >> MXS_PAD_MA_SHIFT;
138}
139
140static inline unsigned int PAD_MA_VALID(iomux_cfg_t pad)
141{
142 return (pad & MXS_PAD_MA_VALID_MASK) >> MXS_PAD_MA_VALID_SHIFT;
143}
144
145static inline unsigned int PAD_VOL(iomux_cfg_t pad)
146{
147 return (pad & MXS_PAD_VOL_MASK) >> MXS_PAD_VOL_SHIFT;
148}
149
150static inline unsigned int PAD_VOL_VALID(iomux_cfg_t pad)
151{
152 return (pad & MXS_PAD_VOL_VALID_MASK) >> MXS_PAD_VOL_VALID_SHIFT;
153}
154
155static inline unsigned int PAD_PULL(iomux_cfg_t pad)
156{
157 return (pad & MXS_PAD_PULL_MASK) >> MXS_PAD_PULL_SHIFT;
158}
159
160static inline unsigned int PAD_PULL_VALID(iomux_cfg_t pad)
161{
162 return (pad & MXS_PAD_PULL_VALID_MASK) >> MXS_PAD_PULL_VALID_SHIFT;
163}
164
165/*
166 * configures a single pad in the iomuxer
167 */
168int mxs_iomux_setup_pad(iomux_cfg_t pad);
169
170/*
171 * configures multiple pads
172 * convenient way to call the above function with tables
173 */
174int mxs_iomux_setup_multiple_pads(const iomux_cfg_t *pad_list, unsigned count);
175
Otavio Salvador1e5be162013-02-23 02:43:08 +0000176#endif /* __ASSEMBLY__ */
Marek Vasutb473ec52011-11-08 23:18:11 +0000177#endif /* __MACH_MXS_IOMUX_H__*/