]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-mx5/iomux-v3.h
Unified codebase for TX28, TX48, TX51, TX53
[karo-tx-uboot.git] / arch / arm / include / asm / arch-mx5 / iomux-v3.h
1 /*
2  * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
3  *                      <armlinux@phytec.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  * MA 02110-1301, USA.
18  */
19
20 #ifndef __MACH_IOMUX_V3_H__
21 #define __MACH_IOMUX_V3_H__
22
23 #include <linux/compiler.h>
24
25 /*
26  *      build IOMUX_PAD structure
27  *
28  * This iomux scheme is based around pads, which are the physical balls
29  * on the processor.
30  *
31  * - Each pad has a pad control register (IOMUXC_SW_PAD_CTRL_x) which controls
32  *   things like driving strength and pullup/pulldown.
33  * - Each pad can have but not necessarily does have an output routing register
34  *   (IOMUXC_SW_MUX_CTL_PAD_x).
35  * - Each pad can have but not necessarily does have an input routing register
36  *   (IOMUXC_x_SELECT_INPUT)
37  *
38  * The three register sets do not have a fixed offset to each other,
39  * hence we order this table by pad control registers (which all pads
40  * have) and put the optional i/o routing registers into additional
41  * fields.
42  *
43  * The naming convention for the pad modes is MX35_PAD_<padname>__<padmode>
44  * If <padname> or <padmode> refers to a GPIO, it is named
45  * GPIO_<unit>_<num>
46  *
47  * IOMUX/PAD Bit field definitions
48  *
49  * MUX_CTRL_OFS:            0..11 (12)
50  * PAD_CTRL_OFS:           12..23 (12)
51  * SEL_INPUT_OFS:          24..35 (12)
52  * MUX_MODE + SION:        36..40  (5)
53  * PAD_CTRL + NO_PAD_CTRL: 41..57 (17)
54  * SEL_INP:                58..61  (4)
55  * reserved:                 63    (1)
56 */
57
58 typedef u64 iomux_v3_cfg_t;
59
60 #define MUX_CTRL_OFS_SHIFT      0
61 #define MUX_CTRL_OFS_MASK       ((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)
62 #define MUX_PAD_CTRL_OFS_SHIFT  12
63 #define MUX_PAD_CTRL_OFS_MASK   ((iomux_v3_cfg_t)0xfff << MUX_PAD_CTRL_OFS_SHIFT)
64 #define MUX_SEL_INPUT_OFS_SHIFT 24
65 #define MUX_SEL_INPUT_OFS_MASK  ((iomux_v3_cfg_t)0xfff << MUX_SEL_INPUT_OFS_SHIFT)
66
67 #define MUX_MODE_SHIFT          36
68 #define MUX_MODE_MASK           ((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
69 #define MUX_PAD_CTRL_SHIFT      41
70 #define MUX_PAD_CTRL_MASK       ((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
71 #define MUX_SEL_INPUT_SHIFT     58
72 #define MUX_SEL_INPUT_MASK      ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
73
74 #define MUX_PAD_CTRL(x)         ((iomux_v3_cfg_t)(x) << MUX_PAD_CTRL_SHIFT)
75
76 #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _sel_input_ofs, \
77                 _sel_input, _pad_ctrl)                                  \
78         (((iomux_v3_cfg_t)(_mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) |      \
79                 ((iomux_v3_cfg_t)(_mux_mode) << MUX_MODE_SHIFT) |       \
80                 ((iomux_v3_cfg_t)(_pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | \
81                 ((iomux_v3_cfg_t)(_pad_ctrl) << MUX_PAD_CTRL_SHIFT) |   \
82                 ((iomux_v3_cfg_t)(_sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | \
83                 ((iomux_v3_cfg_t)(_sel_input) << MUX_SEL_INPUT_SHIFT))
84
85 #define NEW_PAD_CTRL(cfg, pad)  (((cfg) & ~MUX_PAD_CTRL_MASK) | MUX_PAD_CTRL(pad))
86 /*
87  * Use to set PAD control
88  */
89
90 #define NO_PAD_CTRL                     (1 << 16)
91 #define PAD_CTL_DVS                     (1 << 13)
92 #define PAD_CTL_HYS                     (1 << 8)
93
94 #define PAD_CTL_PKE                     (1 << 7)
95 #define PAD_CTL_PUE                     (1 << 6 | PAD_CTL_PKE)
96 #define PAD_CTL_PUS_100K_DOWN           (0 << 4 | PAD_CTL_PUE)
97 #define PAD_CTL_PUS_47K_UP              (1 << 4 | PAD_CTL_PUE)
98 #define PAD_CTL_PUS_100K_UP             (2 << 4 | PAD_CTL_PUE)
99 #define PAD_CTL_PUS_22K_UP              (3 << 4 | PAD_CTL_PUE)
100
101 #define PAD_CTL_ODE                     (1 << 3)
102
103 #define PAD_CTL_DSE_LOW                 (0 << 1)
104 #define PAD_CTL_DSE_MED                 (1 << 1)
105 #define PAD_CTL_DSE_HIGH                (2 << 1)
106 #define PAD_CTL_DSE_MAX                 (3 << 1)
107
108 #define PAD_CTL_SRE_FAST                (1 << 0)
109 #define PAD_CTL_SRE_SLOW                (0 << 0)
110
111 #define IOMUX_CONFIG_SION               (0x1 << 4)
112
113 /*
114  * sets up a single pad in the iomuxer
115  */
116 int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
117
118 /*
119  * sets up mutliple pads
120  * convenient way to call the above function with tables
121  */
122 int mxc_iomux_v3_setup_multiple_pads(const iomux_v3_cfg_t *pad_list, unsigned count);
123
124 #endif /* __MACH_IOMUX_V3_H__*/
125