aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-imx.h
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2013-02-19 21:32:52 -0500
committerShawn Guo <shawn.guo@linaro.org>2013-04-09 10:52:50 -0400
commite16415313c9b00b1adc313e85c2c8a81febe0b98 (patch)
treeb1e804b1bb647f3984036d9f9befbe53023bc519 /drivers/pinctrl/pinctrl-imx.h
parent36dffd8f49bc1364998db81bee739ea4574d88f7 (diff)
pinctrl: imx: move hard-coding data into device tree
Currently, all imx pinctrl drivers maintain a big array of struct imx_pin_reg which hard-codes data like register offset and mux mode setting for each pin function. Every time a new imx SoC support is added, we need to add such a big mount of data. With moving to single kernel build, it's only matter of time to be blamed on memory consuming. With DTC pre-processor support in place, the patch moves all these data into device tree by redefining the PIN_FUNC_ID in imxXX-pinfunc.h and changing the PIN_FUNC_ID parsing code a little bit. The pin id gets re-numbered based on mux register offset, or config register offset if the pin has no mux register, so that kernel can identify the pin id from register offsets provided by device tree. As a bonus point of the change, those arbitrary magic numbers standing for particular PIN_FUNC_ID in device tree sources are now replaced by macros to improve the readability of dts files. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Dong Aisheng <dong.aisheng@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-imx.h')
-rw-r--r--drivers/pinctrl/pinctrl-imx.h29
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/pinctrl/pinctrl-imx.h b/drivers/pinctrl/pinctrl-imx.h
index 9b65e7828f1d..607ef5497552 100644
--- a/drivers/pinctrl/pinctrl-imx.h
+++ b/drivers/pinctrl/pinctrl-imx.h
@@ -26,6 +26,10 @@ struct platform_device;
26 * elements in .pins so we can iterate over that array 26 * elements in .pins so we can iterate over that array
27 * @mux_mode: the mux mode for each pin in this group. The size of this 27 * @mux_mode: the mux mode for each pin in this group. The size of this
28 * array is the same as pins. 28 * array is the same as pins.
29 * @input_reg: select input register offset for this mux if any
30 * 0 if no select input setting needed.
31 * @input_val: the select input value for each pin in this group. The size of
32 * this array is the same as pins.
29 * @configs: the config for each pin in this group. The size of this 33 * @configs: the config for each pin in this group. The size of this
30 * array is the same as pins. 34 * array is the same as pins.
31 */ 35 */
@@ -34,6 +38,8 @@ struct imx_pin_group {
34 unsigned int *pins; 38 unsigned int *pins;
35 unsigned npins; 39 unsigned npins;
36 unsigned int *mux_mode; 40 unsigned int *mux_mode;
41 u16 *input_reg;
42 unsigned int *input_val;
37 unsigned long *configs; 43 unsigned long *configs;
38}; 44};
39 45
@@ -51,30 +57,19 @@ struct imx_pmx_func {
51 57
52/** 58/**
53 * struct imx_pin_reg - describe a pin reg map 59 * struct imx_pin_reg - describe a pin reg map
54 * The last 3 members are used for select input setting
55 * @pid: pin id
56 * @mux_reg: mux register offset 60 * @mux_reg: mux register offset
57 * @conf_reg: config register offset 61 * @conf_reg: config register offset
58 * @mux_mode: mux mode
59 * @input_reg: select input register offset for this mux if any
60 * 0 if no select input setting needed.
61 * @input_val: the value set to select input register
62 */ 62 */
63struct imx_pin_reg { 63struct imx_pin_reg {
64 u16 pid;
65 u16 mux_reg; 64 u16 mux_reg;
66 u16 conf_reg; 65 u16 conf_reg;
67 u8 mux_mode;
68 u16 input_reg;
69 u8 input_val;
70}; 66};
71 67
72struct imx_pinctrl_soc_info { 68struct imx_pinctrl_soc_info {
73 struct device *dev; 69 struct device *dev;
74 const struct pinctrl_pin_desc *pins; 70 const struct pinctrl_pin_desc *pins;
75 unsigned int npins; 71 unsigned int npins;
76 const struct imx_pin_reg *pin_regs; 72 struct imx_pin_reg *pin_regs;
77 unsigned int npin_regs;
78 struct imx_pin_group *groups; 73 struct imx_pin_group *groups;
79 unsigned int ngroups; 74 unsigned int ngroups;
80 struct imx_pmx_func *functions; 75 struct imx_pmx_func *functions;
@@ -84,16 +79,6 @@ struct imx_pinctrl_soc_info {
84#define NO_MUX 0x0 79#define NO_MUX 0x0
85#define NO_PAD 0x0 80#define NO_PAD 0x0
86 81
87#define IMX_PIN_REG(id, conf, mux, mode, input, val) \
88 { \
89 .pid = id, \
90 .conf_reg = conf, \
91 .mux_reg = mux, \
92 .mux_mode = mode, \
93 .input_reg = input, \
94 .input_val = val, \
95 }
96
97#define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin) 82#define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
98 83
99#define PAD_CTL_MASK(len) ((1 << len) - 1) 84#define PAD_CTL_MASK(len) ((1 << len) - 1)