2 * Core driver for the imx pin controller
4 * Copyright (C) 2012 Freescale Semiconductor, Inc.
5 * Copyright (C) 2012 Linaro Ltd.
7 * Author: Dong Aisheng <dong.aisheng@linaro.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include <linux/err.h>
16 #include <linux/init.h>
18 #include <linux/mfd/syscon.h>
20 #include <linux/of_device.h>
21 #include <linux/of_address.h>
22 #include <linux/pinctrl/machine.h>
23 #include <linux/pinctrl/pinconf.h>
24 #include <linux/pinctrl/pinctrl.h>
25 #include <linux/pinctrl/pinmux.h>
26 #include <linux/slab.h>
27 #include <linux/regmap.h>
30 #include "pinctrl-imx.h"
32 /* The bits in CONFIG cell defined in binding doc*/
33 #define IMX_NO_PAD_CTL 0x80000000 /* no pin config need */
34 #define IMX_PAD_SION 0x40000000 /* set SION */
37 * @dev: a pointer back to containing device
38 * @base: the offset to the controller in virtual memory
42 struct pinctrl_dev
*pctl
;
44 void __iomem
*input_sel_base
;
45 const struct imx_pinctrl_soc_info
*info
;
48 static inline const struct imx_pin_group
*imx_pinctrl_find_group_by_name(
49 const struct imx_pinctrl_soc_info
*info
,
52 const struct imx_pin_group
*grp
= NULL
;
55 for (i
= 0; i
< info
->ngroups
; i
++) {
56 if (!strcmp(info
->groups
[i
].name
, name
)) {
57 grp
= &info
->groups
[i
];
65 static int imx_get_groups_count(struct pinctrl_dev
*pctldev
)
67 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
68 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
73 static const char *imx_get_group_name(struct pinctrl_dev
*pctldev
,
76 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
77 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
79 return info
->groups
[selector
].name
;
82 static int imx_get_group_pins(struct pinctrl_dev
*pctldev
, unsigned selector
,
83 const unsigned **pins
,
86 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
87 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
89 if (selector
>= info
->ngroups
)
92 *pins
= info
->groups
[selector
].pin_ids
;
93 *npins
= info
->groups
[selector
].npins
;
98 static void imx_pin_dbg_show(struct pinctrl_dev
*pctldev
, struct seq_file
*s
,
101 seq_printf(s
, "%s", dev_name(pctldev
->dev
));
104 static int imx_dt_node_to_map(struct pinctrl_dev
*pctldev
,
105 struct device_node
*np
,
106 struct pinctrl_map
**map
, unsigned *num_maps
)
108 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
109 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
110 const struct imx_pin_group
*grp
;
111 struct pinctrl_map
*new_map
;
112 struct device_node
*parent
;
117 * first find the group of this node and check if we need create
118 * config maps for pins
120 grp
= imx_pinctrl_find_group_by_name(info
, np
->name
);
122 dev_err(info
->dev
, "unable to find group for node %s\n",
127 for (i
= 0; i
< grp
->npins
; i
++) {
128 if (!(grp
->pins
[i
].config
& IMX_NO_PAD_CTL
))
132 new_map
= kmalloc(sizeof(struct pinctrl_map
) * map_num
, GFP_KERNEL
);
140 parent
= of_get_parent(np
);
145 new_map
[0].type
= PIN_MAP_TYPE_MUX_GROUP
;
146 new_map
[0].data
.mux
.function
= parent
->name
;
147 new_map
[0].data
.mux
.group
= np
->name
;
150 /* create config map */
152 for (i
= j
= 0; i
< grp
->npins
; i
++) {
153 if (!(grp
->pins
[i
].config
& IMX_NO_PAD_CTL
)) {
154 new_map
[j
].type
= PIN_MAP_TYPE_CONFIGS_PIN
;
155 new_map
[j
].data
.configs
.group_or_pin
=
156 pin_get_name(pctldev
, grp
->pins
[i
].pin
);
157 new_map
[j
].data
.configs
.configs
= &grp
->pins
[i
].config
;
158 new_map
[j
].data
.configs
.num_configs
= 1;
163 dev_dbg(pctldev
->dev
, "maps: function %s group %s num %d\n",
164 (*map
)->data
.mux
.function
, (*map
)->data
.mux
.group
, map_num
);
169 static void imx_dt_free_map(struct pinctrl_dev
*pctldev
,
170 struct pinctrl_map
*map
, unsigned num_maps
)
175 static const struct pinctrl_ops imx_pctrl_ops
= {
176 .get_groups_count
= imx_get_groups_count
,
177 .get_group_name
= imx_get_group_name
,
178 .get_group_pins
= imx_get_group_pins
,
179 .pin_dbg_show
= imx_pin_dbg_show
,
180 .dt_node_to_map
= imx_dt_node_to_map
,
181 .dt_free_map
= imx_dt_free_map
,
185 static int imx_pmx_set(struct pinctrl_dev
*pctldev
, unsigned selector
,
188 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
189 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
190 const struct imx_pin_reg
*pin_reg
;
191 unsigned int npins
, pin_id
;
193 struct imx_pin_group
*grp
;
196 * Configure the mux mode for each pin in the group for a specific
199 grp
= &info
->groups
[group
];
202 dev_dbg(ipctl
->dev
, "enable function %s group %s\n",
203 info
->functions
[selector
].name
, grp
->name
);
205 for (i
= 0; i
< npins
; i
++) {
206 struct imx_pin
*pin
= &grp
->pins
[i
];
208 pin_reg
= &info
->pin_regs
[pin_id
];
210 if (pin_reg
->mux_reg
== -1) {
211 dev_dbg(ipctl
->dev
, "Pin(%s) does not support mux function\n",
212 info
->pins
[pin_id
].name
);
216 if (info
->flags
& SHARE_MUX_CONF_REG
) {
218 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
220 reg
|= (pin
->mux_mode
<< 20);
221 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
223 writel(pin
->mux_mode
, ipctl
->base
+ pin_reg
->mux_reg
);
225 dev_dbg(ipctl
->dev
, "write: offset 0x%x val 0x%x\n",
226 pin_reg
->mux_reg
, pin
->mux_mode
);
229 * If the select input value begins with 0xff, it's a quirky
230 * select input and the value should be interpreted as below.
232 * | 0xff | shift | width | select |
233 * It's used to work around the problem that the select
234 * input for some pin is not implemented in the select
235 * input register but in some general purpose register.
236 * We encode the select input value, width and shift of
237 * the bit field into input_val cell of pin function ID
238 * in device tree, and then decode them here for setting
239 * up the select input bits in general purpose register.
241 if (pin
->input_val
>> 24 == 0xff) {
242 u32 val
= pin
->input_val
;
243 u8 select
= val
& 0xff;
244 u8 width
= (val
>> 8) & 0xff;
245 u8 shift
= (val
>> 16) & 0xff;
246 u32 mask
= ((1 << width
) - 1) << shift
;
248 * The input_reg[i] here is actually some IOMUXC general
249 * purpose register, not regular select input register.
251 val
= readl(ipctl
->base
+ pin
->input_reg
);
253 val
|= select
<< shift
;
254 writel(val
, ipctl
->base
+ pin
->input_reg
);
255 } else if (pin
->input_reg
) {
257 * Regular select input register can never be at offset
258 * 0, and we only print register value for regular case.
260 if (ipctl
->input_sel_base
)
261 writel(pin
->input_val
, ipctl
->input_sel_base
+
264 writel(pin
->input_val
, ipctl
->base
+
267 "==>select_input: offset 0x%x val 0x%x\n",
268 pin
->input_reg
, pin
->input_val
);
275 static int imx_pmx_get_funcs_count(struct pinctrl_dev
*pctldev
)
277 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
278 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
280 return info
->nfunctions
;
283 static const char *imx_pmx_get_func_name(struct pinctrl_dev
*pctldev
,
286 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
287 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
289 return info
->functions
[selector
].name
;
292 static int imx_pmx_get_groups(struct pinctrl_dev
*pctldev
, unsigned selector
,
293 const char * const **groups
,
294 unsigned * const num_groups
)
296 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
297 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
299 *groups
= info
->functions
[selector
].groups
;
300 *num_groups
= info
->functions
[selector
].num_groups
;
305 static int imx_pmx_gpio_request_enable(struct pinctrl_dev
*pctldev
,
306 struct pinctrl_gpio_range
*range
, unsigned offset
)
308 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
309 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
310 const struct imx_pin_reg
*pin_reg
;
311 struct imx_pin_group
*grp
;
312 struct imx_pin
*imx_pin
;
313 unsigned int pin
, group
;
316 /* Currently implementation only for shared mux/conf register */
317 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
320 pin_reg
= &info
->pin_regs
[offset
];
321 if (pin_reg
->mux_reg
== -1)
324 /* Find the pinctrl config with GPIO mux mode for the requested pin */
325 for (group
= 0; group
< info
->ngroups
; group
++) {
326 grp
= &info
->groups
[group
];
327 for (pin
= 0; pin
< grp
->npins
; pin
++) {
328 imx_pin
= &grp
->pins
[pin
];
329 if (imx_pin
->pin
== offset
&& !imx_pin
->mux_mode
)
337 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
339 reg
|= imx_pin
->config
;
340 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
345 static void imx_pmx_gpio_disable_free(struct pinctrl_dev
*pctldev
,
346 struct pinctrl_gpio_range
*range
, unsigned offset
)
348 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
349 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
350 const struct imx_pin_reg
*pin_reg
;
354 * Only Vybrid has the input/output buffer enable flags (IBE/OBE)
355 * They are part of the shared mux/conf register.
357 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
360 pin_reg
= &info
->pin_regs
[offset
];
361 if (pin_reg
->mux_reg
== -1)
364 /* Clear IBE/OBE/PUE to disable the pin (Hi-Z) */
365 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
367 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
370 static int imx_pmx_gpio_set_direction(struct pinctrl_dev
*pctldev
,
371 struct pinctrl_gpio_range
*range
, unsigned offset
, bool input
)
373 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
374 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
375 const struct imx_pin_reg
*pin_reg
;
379 * Only Vybrid has the input/output buffer enable flags (IBE/OBE)
380 * They are part of the shared mux/conf register.
382 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
385 pin_reg
= &info
->pin_regs
[offset
];
386 if (pin_reg
->mux_reg
== -1)
389 /* IBE always enabled allows us to read the value "on the wire" */
390 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
395 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
400 static const struct pinmux_ops imx_pmx_ops
= {
401 .get_functions_count
= imx_pmx_get_funcs_count
,
402 .get_function_name
= imx_pmx_get_func_name
,
403 .get_function_groups
= imx_pmx_get_groups
,
404 .set_mux
= imx_pmx_set
,
405 .gpio_request_enable
= imx_pmx_gpio_request_enable
,
406 .gpio_disable_free
= imx_pmx_gpio_disable_free
,
407 .gpio_set_direction
= imx_pmx_gpio_set_direction
,
410 static int imx_pinconf_get(struct pinctrl_dev
*pctldev
,
411 unsigned pin_id
, unsigned long *config
)
413 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
414 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
415 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
417 if (pin_reg
->conf_reg
== -1) {
418 dev_err(info
->dev
, "Pin(%s) does not support config function\n",
419 info
->pins
[pin_id
].name
);
423 *config
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
425 if (info
->flags
& SHARE_MUX_CONF_REG
)
431 static int imx_pinconf_set(struct pinctrl_dev
*pctldev
,
432 unsigned pin_id
, unsigned long *configs
,
433 unsigned num_configs
)
435 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
436 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
437 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
440 if (pin_reg
->conf_reg
== -1) {
441 dev_err(info
->dev
, "Pin(%s) does not support config function\n",
442 info
->pins
[pin_id
].name
);
446 dev_dbg(ipctl
->dev
, "pinconf set pin %s\n",
447 info
->pins
[pin_id
].name
);
449 for (i
= 0; i
< num_configs
; i
++) {
450 if (info
->flags
& SHARE_MUX_CONF_REG
) {
452 reg
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
455 writel(reg
, ipctl
->base
+ pin_reg
->conf_reg
);
457 writel(configs
[i
], ipctl
->base
+ pin_reg
->conf_reg
);
459 dev_dbg(ipctl
->dev
, "write: offset 0x%x val 0x%lx\n",
460 pin_reg
->conf_reg
, configs
[i
]);
461 } /* for each config */
466 static void imx_pinconf_dbg_show(struct pinctrl_dev
*pctldev
,
467 struct seq_file
*s
, unsigned pin_id
)
469 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
470 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
471 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
472 unsigned long config
;
474 if (!pin_reg
|| pin_reg
->conf_reg
== -1) {
475 seq_printf(s
, "N/A");
479 config
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
480 seq_printf(s
, "0x%lx", config
);
483 static void imx_pinconf_group_dbg_show(struct pinctrl_dev
*pctldev
,
484 struct seq_file
*s
, unsigned group
)
486 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
487 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
488 struct imx_pin_group
*grp
;
489 unsigned long config
;
493 if (group
> info
->ngroups
)
497 grp
= &info
->groups
[group
];
498 for (i
= 0; i
< grp
->npins
; i
++) {
499 struct imx_pin
*pin
= &grp
->pins
[i
];
500 name
= pin_get_name(pctldev
, pin
->pin
);
501 ret
= imx_pinconf_get(pctldev
, pin
->pin
, &config
);
504 seq_printf(s
, " %s: 0x%lx\n", name
, config
);
508 static const struct pinconf_ops imx_pinconf_ops
= {
509 .pin_config_get
= imx_pinconf_get
,
510 .pin_config_set
= imx_pinconf_set
,
511 .pin_config_dbg_show
= imx_pinconf_dbg_show
,
512 .pin_config_group_dbg_show
= imx_pinconf_group_dbg_show
,
516 * Each pin represented in fsl,pins consists of 5 u32 PIN_FUNC_ID and
517 * 1 u32 CONFIG, so 24 types in total for each pin.
519 #define FSL_PIN_SIZE 24
520 #define SHARE_FSL_PIN_SIZE 20
522 static int imx_pinctrl_parse_groups(struct device_node
*np
,
523 struct imx_pin_group
*grp
,
524 struct imx_pinctrl_soc_info
*info
,
532 dev_dbg(info
->dev
, "group(%d): %s\n", index
, np
->name
);
534 if (info
->flags
& SHARE_MUX_CONF_REG
)
535 pin_size
= SHARE_FSL_PIN_SIZE
;
537 pin_size
= FSL_PIN_SIZE
;
538 /* Initialise group */
539 grp
->name
= np
->name
;
542 * the binding format is fsl,pins = <PIN_FUNC_ID CONFIG ...>,
543 * do sanity check and calculate pins number
545 list
= of_get_property(np
, "fsl,pins", &size
);
547 dev_err(info
->dev
, "no fsl,pins property in node %s\n", np
->full_name
);
551 /* we do not check return since it's safe node passed down */
552 if (!size
|| size
% pin_size
) {
553 dev_err(info
->dev
, "Invalid fsl,pins property in node %s\n", np
->full_name
);
557 grp
->npins
= size
/ pin_size
;
558 grp
->pins
= devm_kzalloc(info
->dev
, grp
->npins
* sizeof(struct imx_pin
),
560 grp
->pin_ids
= devm_kzalloc(info
->dev
, grp
->npins
* sizeof(unsigned int),
562 if (!grp
->pins
|| ! grp
->pin_ids
)
565 for (i
= 0; i
< grp
->npins
; i
++) {
566 u32 mux_reg
= be32_to_cpu(*list
++);
569 struct imx_pin_reg
*pin_reg
;
570 struct imx_pin
*pin
= &grp
->pins
[i
];
572 if (!(info
->flags
& ZERO_OFFSET_VALID
) && !mux_reg
)
575 if (info
->flags
& SHARE_MUX_CONF_REG
) {
578 conf_reg
= be32_to_cpu(*list
++);
583 pin_id
= (mux_reg
!= -1) ? mux_reg
/ 4 : conf_reg
/ 4;
584 pin_reg
= &info
->pin_regs
[pin_id
];
586 grp
->pin_ids
[i
] = pin_id
;
587 pin_reg
->mux_reg
= mux_reg
;
588 pin_reg
->conf_reg
= conf_reg
;
589 pin
->input_reg
= be32_to_cpu(*list
++);
590 pin
->mux_mode
= be32_to_cpu(*list
++);
591 pin
->input_val
= be32_to_cpu(*list
++);
593 /* SION bit is in mux register */
594 config
= be32_to_cpu(*list
++);
595 if (config
& IMX_PAD_SION
)
596 pin
->mux_mode
|= IOMUXC_CONFIG_SION
;
597 pin
->config
= config
& ~IMX_PAD_SION
;
599 dev_dbg(info
->dev
, "%s: 0x%x 0x%08lx", info
->pins
[pin_id
].name
,
600 pin
->mux_mode
, pin
->config
);
606 static int imx_pinctrl_parse_functions(struct device_node
*np
,
607 struct imx_pinctrl_soc_info
*info
,
610 struct device_node
*child
;
611 struct imx_pmx_func
*func
;
612 struct imx_pin_group
*grp
;
615 dev_dbg(info
->dev
, "parse function(%d): %s\n", index
, np
->name
);
617 func
= &info
->functions
[index
];
619 /* Initialise function */
620 func
->name
= np
->name
;
621 func
->num_groups
= of_get_child_count(np
);
622 if (func
->num_groups
== 0) {
623 dev_err(info
->dev
, "no groups defined in %s\n", np
->full_name
);
626 func
->groups
= devm_kzalloc(info
->dev
,
627 func
->num_groups
* sizeof(char *), GFP_KERNEL
);
629 for_each_child_of_node(np
, child
) {
630 func
->groups
[i
] = child
->name
;
631 grp
= &info
->groups
[info
->group_index
++];
632 imx_pinctrl_parse_groups(child
, grp
, info
, i
++);
639 * Check if the DT contains pins in the direct child nodes. This indicates the
640 * newer DT format to store pins. This function returns true if the first found
641 * fsl,pins property is in a child of np. Otherwise false is returned.
643 static bool imx_pinctrl_dt_is_flat_functions(struct device_node
*np
)
645 struct device_node
*function_np
;
646 struct device_node
*pinctrl_np
;
648 for_each_child_of_node(np
, function_np
) {
649 if (of_property_read_bool(function_np
, "fsl,pins"))
652 for_each_child_of_node(function_np
, pinctrl_np
) {
653 if (of_property_read_bool(pinctrl_np
, "fsl,pins"))
661 static int imx_pinctrl_probe_dt(struct platform_device
*pdev
,
662 struct imx_pinctrl_soc_info
*info
)
664 struct device_node
*np
= pdev
->dev
.of_node
;
665 struct device_node
*child
;
673 flat_funcs
= imx_pinctrl_dt_is_flat_functions(np
);
677 nfuncs
= of_get_child_count(np
);
679 dev_err(&pdev
->dev
, "no functions defined\n");
684 info
->nfunctions
= nfuncs
;
685 info
->functions
= devm_kzalloc(&pdev
->dev
, nfuncs
* sizeof(struct imx_pmx_func
),
687 if (!info
->functions
)
690 info
->group_index
= 0;
692 info
->ngroups
= of_get_child_count(np
);
695 for_each_child_of_node(np
, child
)
696 info
->ngroups
+= of_get_child_count(child
);
698 info
->groups
= devm_kzalloc(&pdev
->dev
, info
->ngroups
* sizeof(struct imx_pin_group
),
704 imx_pinctrl_parse_functions(np
, info
, 0);
706 for_each_child_of_node(np
, child
)
707 imx_pinctrl_parse_functions(child
, info
, i
++);
713 int imx_pinctrl_probe(struct platform_device
*pdev
,
714 struct imx_pinctrl_soc_info
*info
)
716 struct regmap_config config
= { .name
= "gpr" };
717 struct device_node
*dev_np
= pdev
->dev
.of_node
;
718 struct pinctrl_desc
*imx_pinctrl_desc
;
719 struct device_node
*np
;
720 struct imx_pinctrl
*ipctl
;
721 struct resource
*res
;
725 if (!info
|| !info
->pins
|| !info
->npins
) {
726 dev_err(&pdev
->dev
, "wrong pinctrl info\n");
729 info
->dev
= &pdev
->dev
;
731 if (info
->gpr_compatible
) {
732 gpr
= syscon_regmap_lookup_by_compatible(info
->gpr_compatible
);
734 regmap_attach_dev(&pdev
->dev
, gpr
, &config
);
737 /* Create state holders etc for this driver */
738 ipctl
= devm_kzalloc(&pdev
->dev
, sizeof(*ipctl
), GFP_KERNEL
);
742 info
->pin_regs
= devm_kmalloc(&pdev
->dev
, sizeof(*info
->pin_regs
) *
743 info
->npins
, GFP_KERNEL
);
747 for (i
= 0; i
< info
->npins
; i
++) {
748 info
->pin_regs
[i
].mux_reg
= -1;
749 info
->pin_regs
[i
].conf_reg
= -1;
752 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
753 ipctl
->base
= devm_ioremap_resource(&pdev
->dev
, res
);
754 if (IS_ERR(ipctl
->base
))
755 return PTR_ERR(ipctl
->base
);
757 if (of_property_read_bool(dev_np
, "fsl,input-sel")) {
758 np
= of_parse_phandle(dev_np
, "fsl,input-sel", 0);
760 dev_err(&pdev
->dev
, "iomuxc fsl,input-sel property not found\n");
764 ipctl
->input_sel_base
= of_iomap(np
, 0);
766 if (!ipctl
->input_sel_base
) {
768 "iomuxc input select base address not found\n");
773 imx_pinctrl_desc
= devm_kzalloc(&pdev
->dev
, sizeof(*imx_pinctrl_desc
),
775 if (!imx_pinctrl_desc
)
778 imx_pinctrl_desc
->name
= dev_name(&pdev
->dev
);
779 imx_pinctrl_desc
->pins
= info
->pins
;
780 imx_pinctrl_desc
->npins
= info
->npins
;
781 imx_pinctrl_desc
->pctlops
= &imx_pctrl_ops
;
782 imx_pinctrl_desc
->pmxops
= &imx_pmx_ops
;
783 imx_pinctrl_desc
->confops
= &imx_pinconf_ops
;
784 imx_pinctrl_desc
->owner
= THIS_MODULE
;
786 ret
= imx_pinctrl_probe_dt(pdev
, info
);
788 dev_err(&pdev
->dev
, "fail to probe dt properties\n");
793 ipctl
->dev
= info
->dev
;
794 platform_set_drvdata(pdev
, ipctl
);
795 ipctl
->pctl
= devm_pinctrl_register(&pdev
->dev
,
796 imx_pinctrl_desc
, ipctl
);
797 if (IS_ERR(ipctl
->pctl
)) {
798 dev_err(&pdev
->dev
, "could not register IMX pinctrl driver\n");
799 return PTR_ERR(ipctl
->pctl
);
802 dev_info(&pdev
->dev
, "initialized IMX pinctrl driver\n");