Linux 3.11-rc3
[cris-mirror.git] / drivers / pinctrl / pinctrl-mxs.h
blobfdd88d0bae22c843898b5240267fa6047ea5dc1b
1 /*
2 * Copyright 2012 Freescale Semiconductor, Inc.
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:
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
12 #ifndef __PINCTRL_MXS_H
13 #define __PINCTRL_MXS_H
15 #include <linux/platform_device.h>
16 #include <linux/pinctrl/pinctrl.h>
18 #define SET 0x4
19 #define CLR 0x8
20 #define TOG 0xc
22 #define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
23 #define PINID(bank, pin) ((bank) * 32 + (pin))
26 * pinmux-id bit field definitions
28 * bank: 15..12 (4)
29 * pin: 11..4 (8)
30 * muxsel: 3..0 (4)
32 #define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
33 #define MUXID_TO_MUXSEL(m) ((m) & 0xf)
35 #define PINID_TO_BANK(p) ((p) >> 5)
36 #define PINID_TO_PIN(p) ((p) % 32)
39 * pin config bit field definitions
41 * pull-up: 6..5 (2)
42 * voltage: 4..3 (2)
43 * mA: 2..0 (3)
45 * MSB of each field is presence bit for the config.
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)
57 struct mxs_function {
58 const char *name;
59 const char **groups;
60 unsigned ngroups;
63 struct mxs_group {
64 const char *name;
65 unsigned int *pins;
66 unsigned npins;
67 u8 *muxsel;
68 u8 config;
71 struct mxs_regs {
72 u16 muxsel;
73 u16 drive;
74 u16 pull;
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;
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);
91 #endif /* __PINCTRL_MXS_H */