Merge tag 'please-pull-mce' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / pinctrl / pinctrl-mxs.h
1 /*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12 #ifndef __PINCTRL_MXS_H
13 #define __PINCTRL_MXS_H
14
15 #include <linux/platform_device.h>
16 #include <linux/pinctrl/pinctrl.h>
17
18 #define SET 0x4
19 #define CLR 0x8
20 #define TOG 0xc
21
22 #define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
23 #define PINID(bank, pin) ((bank) * 32 + (pin))
24
25 /*
26 * pinmux-id bit field definitions
27 *
28 * bank: 15..12 (4)
29 * pin: 11..4 (8)
30 * muxsel: 3..0 (4)
31 */
32 #define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
33 #define MUXID_TO_MUXSEL(m) ((m) & 0xf)
34
35 #define PINID_TO_BANK(p) ((p) >> 5)
36 #define PINID_TO_PIN(p) ((p) % 32)
37
38 /*
39 * pin config bit field definitions
40 *
41 * pull-up: 6..5 (2)
42 * voltage: 4..3 (2)
43 * mA: 2..0 (3)
44 *
45 * MSB of each field is presence bit for the config.
46 */
47 #define PULL_PRESENT (1 << 6)
48 #define PULL_SHIFT 5
49 #define VOL_PRESENT (1 << 4)
50 #define VOL_SHIFT 3
51 #define MA_PRESENT (1 << 2)
52 #define MA_SHIFT 0
53 #define CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1)
54 #define CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1)
55 #define CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3)
56
57 struct mxs_function {
58 const char *name;
59 const char **groups;
60 unsigned ngroups;
61 };
62
63 struct mxs_group {
64 const char *name;
65 unsigned int *pins;
66 unsigned npins;
67 u8 *muxsel;
68 u8 config;
69 };
70
71 struct mxs_regs {
72 u16 muxsel;
73 u16 drive;
74 u16 pull;
75 };
76
77 struct mxs_pinctrl_soc_data {
78 const struct mxs_regs *regs;
79 const struct pinctrl_pin_desc *pins;
80 unsigned npins;
81 struct mxs_function *functions;
82 unsigned nfunctions;
83 struct mxs_group *groups;
84 unsigned ngroups;
85 };
86
87 int mxs_pinctrl_probe(struct platform_device *pdev,
88 struct mxs_pinctrl_soc_data *soc);
89 int mxs_pinctrl_remove(struct platform_device *pdev);
90
91 #endif /* __PINCTRL_MXS_H */