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>
19 #include <linux/module.h>
21 #include <linux/of_device.h>
22 #include <linux/of_address.h>
23 #include <linux/pinctrl/machine.h>
24 #include <linux/pinctrl/pinconf.h>
25 #include <linux/pinctrl/pinctrl.h>
26 #include <linux/pinctrl/pinmux.h>
27 #include <linux/slab.h>
28 #include <linux/regmap.h>
31 #include "pinctrl-imx.h"
33 /* The bits in CONFIG cell defined in binding doc*/
34 #define IMX_NO_PAD_CTL 0x80000000 /* no pin config need */
35 #define IMX_PAD_SION 0x40000000 /* set SION */
38 * @dev: a pointer back to containing device
39 * @base: the offset to the controller in virtual memory
43 struct pinctrl_dev
*pctl
;
45 void __iomem
*input_sel_base
;
46 const struct imx_pinctrl_soc_info
*info
;
49 static const inline struct imx_pin_group
*imx_pinctrl_find_group_by_name(
50 const struct imx_pinctrl_soc_info
*info
,
53 const struct imx_pin_group
*grp
= NULL
;
56 for (i
= 0; i
< info
->ngroups
; i
++) {
57 if (!strcmp(info
->groups
[i
].name
, name
)) {
58 grp
= &info
->groups
[i
];
66 static int imx_get_groups_count(struct pinctrl_dev
*pctldev
)
68 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
69 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
74 static const char *imx_get_group_name(struct pinctrl_dev
*pctldev
,
77 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
78 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
80 return info
->groups
[selector
].name
;
83 static int imx_get_group_pins(struct pinctrl_dev
*pctldev
, unsigned selector
,
84 const unsigned **pins
,
87 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
88 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
90 if (selector
>= info
->ngroups
)
93 *pins
= info
->groups
[selector
].pin_ids
;
94 *npins
= info
->groups
[selector
].npins
;
99 static void imx_pin_dbg_show(struct pinctrl_dev
*pctldev
, struct seq_file
*s
,
102 seq_printf(s
, "%s", dev_name(pctldev
->dev
));
105 static int imx_dt_node_to_map(struct pinctrl_dev
*pctldev
,
106 struct device_node
*np
,
107 struct pinctrl_map
**map
, unsigned *num_maps
)
109 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
110 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
111 const struct imx_pin_group
*grp
;
112 struct pinctrl_map
*new_map
;
113 struct device_node
*parent
;
118 * first find the group of this node and check if we need create
119 * config maps for pins
121 grp
= imx_pinctrl_find_group_by_name(info
, np
->name
);
123 dev_err(info
->dev
, "unable to find group for node %s\n",
128 for (i
= 0; i
< grp
->npins
; i
++) {
129 if (!(grp
->pins
[i
].config
& IMX_NO_PAD_CTL
))
133 new_map
= kmalloc(sizeof(struct pinctrl_map
) * map_num
, GFP_KERNEL
);
141 parent
= of_get_parent(np
);
146 new_map
[0].type
= PIN_MAP_TYPE_MUX_GROUP
;
147 new_map
[0].data
.mux
.function
= parent
->name
;
148 new_map
[0].data
.mux
.group
= np
->name
;
151 /* create config map */
153 for (i
= j
= 0; i
< grp
->npins
; i
++) {
154 if (!(grp
->pins
[i
].config
& IMX_NO_PAD_CTL
)) {
155 new_map
[j
].type
= PIN_MAP_TYPE_CONFIGS_PIN
;
156 new_map
[j
].data
.configs
.group_or_pin
=
157 pin_get_name(pctldev
, grp
->pins
[i
].pin
);
158 new_map
[j
].data
.configs
.configs
= &grp
->pins
[i
].config
;
159 new_map
[j
].data
.configs
.num_configs
= 1;
164 dev_dbg(pctldev
->dev
, "maps: function %s group %s num %d\n",
165 (*map
)->data
.mux
.function
, (*map
)->data
.mux
.group
, map_num
);
170 static void imx_dt_free_map(struct pinctrl_dev
*pctldev
,
171 struct pinctrl_map
*map
, unsigned num_maps
)
176 static const struct pinctrl_ops imx_pctrl_ops
= {
177 .get_groups_count
= imx_get_groups_count
,
178 .get_group_name
= imx_get_group_name
,
179 .get_group_pins
= imx_get_group_pins
,
180 .pin_dbg_show
= imx_pin_dbg_show
,
181 .dt_node_to_map
= imx_dt_node_to_map
,
182 .dt_free_map
= imx_dt_free_map
,
186 static int imx_pmx_set(struct pinctrl_dev
*pctldev
, unsigned selector
,
189 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
190 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
191 const struct imx_pin_reg
*pin_reg
;
192 unsigned int npins
, pin_id
;
194 struct imx_pin_group
*grp
;
197 * Configure the mux mode for each pin in the group for a specific
200 grp
= &info
->groups
[group
];
203 dev_dbg(ipctl
->dev
, "enable function %s group %s\n",
204 info
->functions
[selector
].name
, grp
->name
);
206 for (i
= 0; i
< npins
; i
++) {
207 struct imx_pin
*pin
= &grp
->pins
[i
];
209 pin_reg
= &info
->pin_regs
[pin_id
];
211 if (pin_reg
->mux_reg
== -1) {
212 dev_dbg(ipctl
->dev
, "Pin(%s) does not support mux function\n",
213 info
->pins
[pin_id
].name
);
217 if (info
->flags
& SHARE_MUX_CONF_REG
) {
219 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
221 reg
|= (pin
->mux_mode
<< 20);
222 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
224 writel(pin
->mux_mode
, ipctl
->base
+ pin_reg
->mux_reg
);
226 dev_dbg(ipctl
->dev
, "write: offset 0x%x val 0x%x\n",
227 pin_reg
->mux_reg
, pin
->mux_mode
);
230 * If the select input value begins with 0xff, it's a quirky
231 * select input and the value should be interpreted as below.
233 * | 0xff | shift | width | select |
234 * It's used to work around the problem that the select
235 * input for some pin is not implemented in the select
236 * input register but in some general purpose register.
237 * We encode the select input value, width and shift of
238 * the bit field into input_val cell of pin function ID
239 * in device tree, and then decode them here for setting
240 * up the select input bits in general purpose register.
242 if (pin
->input_val
>> 24 == 0xff) {
243 u32 val
= pin
->input_val
;
244 u8 select
= val
& 0xff;
245 u8 width
= (val
>> 8) & 0xff;
246 u8 shift
= (val
>> 16) & 0xff;
247 u32 mask
= ((1 << width
) - 1) << shift
;
249 * The input_reg[i] here is actually some IOMUXC general
250 * purpose register, not regular select input register.
252 val
= readl(ipctl
->base
+ pin
->input_reg
);
254 val
|= select
<< shift
;
255 writel(val
, ipctl
->base
+ pin
->input_reg
);
256 } else if (pin
->input_reg
) {
258 * Regular select input register can never be at offset
259 * 0, and we only print register value for regular case.
261 if (ipctl
->input_sel_base
)
262 writel(pin
->input_val
, ipctl
->input_sel_base
+
265 writel(pin
->input_val
, ipctl
->base
+
268 "==>select_input: offset 0x%x val 0x%x\n",
269 pin
->input_reg
, pin
->input_val
);
276 static int imx_pmx_get_funcs_count(struct pinctrl_dev
*pctldev
)
278 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
279 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
281 return info
->nfunctions
;
284 static const char *imx_pmx_get_func_name(struct pinctrl_dev
*pctldev
,
287 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
288 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
290 return info
->functions
[selector
].name
;
293 static int imx_pmx_get_groups(struct pinctrl_dev
*pctldev
, unsigned selector
,
294 const char * const **groups
,
295 unsigned * const num_groups
)
297 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
298 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
300 *groups
= info
->functions
[selector
].groups
;
301 *num_groups
= info
->functions
[selector
].num_groups
;
306 static int imx_pmx_gpio_request_enable(struct pinctrl_dev
*pctldev
,
307 struct pinctrl_gpio_range
*range
, unsigned offset
)
309 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
310 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
311 const struct imx_pin_reg
*pin_reg
;
312 struct imx_pin_group
*grp
;
313 struct imx_pin
*imx_pin
;
314 unsigned int pin
, group
;
317 /* Currently implementation only for shared mux/conf register */
318 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
321 pin_reg
= &info
->pin_regs
[offset
];
322 if (pin_reg
->mux_reg
== -1)
325 /* Find the pinctrl config with GPIO mux mode for the requested pin */
326 for (group
= 0; group
< info
->ngroups
; group
++) {
327 grp
= &info
->groups
[group
];
328 for (pin
= 0; pin
< grp
->npins
; pin
++) {
329 imx_pin
= &grp
->pins
[pin
];
330 if (imx_pin
->pin
== offset
&& !imx_pin
->mux_mode
)
338 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
340 reg
|= imx_pin
->config
;
341 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
346 static void imx_pmx_gpio_disable_free(struct pinctrl_dev
*pctldev
,
347 struct pinctrl_gpio_range
*range
, unsigned offset
)
349 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
350 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
351 const struct imx_pin_reg
*pin_reg
;
355 * Only Vybrid has the input/output buffer enable flags (IBE/OBE)
356 * They are part of the shared mux/conf register.
358 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
361 pin_reg
= &info
->pin_regs
[offset
];
362 if (pin_reg
->mux_reg
== -1)
365 /* Clear IBE/OBE/PUE to disable the pin (Hi-Z) */
366 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
368 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
371 static int imx_pmx_gpio_set_direction(struct pinctrl_dev
*pctldev
,
372 struct pinctrl_gpio_range
*range
, unsigned offset
, bool input
)
374 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
375 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
376 const struct imx_pin_reg
*pin_reg
;
380 * Only Vybrid has the input/output buffer enable flags (IBE/OBE)
381 * They are part of the shared mux/conf register.
383 if (!(info
->flags
& SHARE_MUX_CONF_REG
))
386 pin_reg
= &info
->pin_regs
[offset
];
387 if (pin_reg
->mux_reg
== -1)
390 /* IBE always enabled allows us to read the value "on the wire" */
391 reg
= readl(ipctl
->base
+ pin_reg
->mux_reg
);
396 writel(reg
, ipctl
->base
+ pin_reg
->mux_reg
);
401 static const struct pinmux_ops imx_pmx_ops
= {
402 .get_functions_count
= imx_pmx_get_funcs_count
,
403 .get_function_name
= imx_pmx_get_func_name
,
404 .get_function_groups
= imx_pmx_get_groups
,
405 .set_mux
= imx_pmx_set
,
406 .gpio_request_enable
= imx_pmx_gpio_request_enable
,
407 .gpio_disable_free
= imx_pmx_gpio_disable_free
,
408 .gpio_set_direction
= imx_pmx_gpio_set_direction
,
411 static int imx_pinconf_get(struct pinctrl_dev
*pctldev
,
412 unsigned pin_id
, unsigned long *config
)
414 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
415 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
416 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
418 if (pin_reg
->conf_reg
== -1) {
419 dev_err(info
->dev
, "Pin(%s) does not support config function\n",
420 info
->pins
[pin_id
].name
);
424 *config
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
426 if (info
->flags
& SHARE_MUX_CONF_REG
)
432 static int imx_pinconf_set(struct pinctrl_dev
*pctldev
,
433 unsigned pin_id
, unsigned long *configs
,
434 unsigned num_configs
)
436 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
437 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
438 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
441 if (pin_reg
->conf_reg
== -1) {
442 dev_err(info
->dev
, "Pin(%s) does not support config function\n",
443 info
->pins
[pin_id
].name
);
447 dev_dbg(ipctl
->dev
, "pinconf set pin %s\n",
448 info
->pins
[pin_id
].name
);
450 for (i
= 0; i
< num_configs
; i
++) {
451 if (info
->flags
& SHARE_MUX_CONF_REG
) {
453 reg
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
456 writel(reg
, ipctl
->base
+ pin_reg
->conf_reg
);
458 writel(configs
[i
], ipctl
->base
+ pin_reg
->conf_reg
);
460 dev_dbg(ipctl
->dev
, "write: offset 0x%x val 0x%lx\n",
461 pin_reg
->conf_reg
, configs
[i
]);
462 } /* for each config */
467 static void imx_pinconf_dbg_show(struct pinctrl_dev
*pctldev
,
468 struct seq_file
*s
, unsigned pin_id
)
470 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
471 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
472 const struct imx_pin_reg
*pin_reg
= &info
->pin_regs
[pin_id
];
473 unsigned long config
;
475 if (!pin_reg
|| pin_reg
->conf_reg
== -1) {
476 seq_printf(s
, "N/A");
480 config
= readl(ipctl
->base
+ pin_reg
->conf_reg
);
481 seq_printf(s
, "0x%lx", config
);
484 static void imx_pinconf_group_dbg_show(struct pinctrl_dev
*pctldev
,
485 struct seq_file
*s
, unsigned group
)
487 struct imx_pinctrl
*ipctl
= pinctrl_dev_get_drvdata(pctldev
);
488 const struct imx_pinctrl_soc_info
*info
= ipctl
->info
;
489 struct imx_pin_group
*grp
;
490 unsigned long config
;
494 if (group
> info
->ngroups
)
498 grp
= &info
->groups
[group
];
499 for (i
= 0; i
< grp
->npins
; i
++) {
500 struct imx_pin
*pin
= &grp
->pins
[i
];
501 name
= pin_get_name(pctldev
, pin
->pin
);
502 ret
= imx_pinconf_get(pctldev
, pin
->pin
, &config
);
505 seq_printf(s
, "%s: 0x%lx", name
, config
);
509 static const struct pinconf_ops imx_pinconf_ops
= {
510 .pin_config_get
= imx_pinconf_get
,
511 .pin_config_set
= imx_pinconf_set
,
512 .pin_config_dbg_show
= imx_pinconf_dbg_show
,
513 .pin_config_group_dbg_show
= imx_pinconf_group_dbg_show
,
516 static struct pinctrl_desc imx_pinctrl_desc
= {
517 .pctlops
= &imx_pctrl_ops
,
518 .pmxops
= &imx_pmx_ops
,
519 .confops
= &imx_pinconf_ops
,
520 .owner
= THIS_MODULE
,
524 * Each pin represented in fsl,pins consists of 5 u32 PIN_FUNC_ID and
525 * 1 u32 CONFIG, so 24 types in total for each pin.
527 #define FSL_PIN_SIZE 24
528 #define SHARE_FSL_PIN_SIZE 20
530 static int imx_pinctrl_parse_groups(struct device_node
*np
,
531 struct imx_pin_group
*grp
,
532 struct imx_pinctrl_soc_info
*info
,
540 dev_dbg(info
->dev
, "group(%d): %s\n", index
, np
->name
);
542 if (info
->flags
& SHARE_MUX_CONF_REG
)
543 pin_size
= SHARE_FSL_PIN_SIZE
;
545 pin_size
= FSL_PIN_SIZE
;
546 /* Initialise group */
547 grp
->name
= np
->name
;
550 * the binding format is fsl,pins = <PIN_FUNC_ID CONFIG ...>,
551 * do sanity check and calculate pins number
553 list
= of_get_property(np
, "fsl,pins", &size
);
555 dev_err(info
->dev
, "no fsl,pins property in node %s\n", np
->full_name
);
559 /* we do not check return since it's safe node passed down */
560 if (!size
|| size
% pin_size
) {
561 dev_err(info
->dev
, "Invalid fsl,pins property in node %s\n", np
->full_name
);
565 grp
->npins
= size
/ pin_size
;
566 grp
->pins
= devm_kzalloc(info
->dev
, grp
->npins
* sizeof(struct imx_pin
),
568 grp
->pin_ids
= devm_kzalloc(info
->dev
, grp
->npins
* sizeof(unsigned int),
570 if (!grp
->pins
|| ! grp
->pin_ids
)
573 for (i
= 0; i
< grp
->npins
; i
++) {
574 u32 mux_reg
= be32_to_cpu(*list
++);
577 struct imx_pin_reg
*pin_reg
;
578 struct imx_pin
*pin
= &grp
->pins
[i
];
580 if (!(info
->flags
& ZERO_OFFSET_VALID
) && !mux_reg
)
583 if (info
->flags
& SHARE_MUX_CONF_REG
) {
586 conf_reg
= be32_to_cpu(*list
++);
591 pin_id
= (mux_reg
!= -1) ? mux_reg
/ 4 : conf_reg
/ 4;
592 pin_reg
= &info
->pin_regs
[pin_id
];
594 grp
->pin_ids
[i
] = pin_id
;
595 pin_reg
->mux_reg
= mux_reg
;
596 pin_reg
->conf_reg
= conf_reg
;
597 pin
->input_reg
= be32_to_cpu(*list
++);
598 pin
->mux_mode
= be32_to_cpu(*list
++);
599 pin
->input_val
= be32_to_cpu(*list
++);
601 /* SION bit is in mux register */
602 config
= be32_to_cpu(*list
++);
603 if (config
& IMX_PAD_SION
)
604 pin
->mux_mode
|= IOMUXC_CONFIG_SION
;
605 pin
->config
= config
& ~IMX_PAD_SION
;
607 dev_dbg(info
->dev
, "%s: 0x%x 0x%08lx", info
->pins
[pin_id
].name
,
608 pin
->mux_mode
, pin
->config
);
614 static int imx_pinctrl_parse_functions(struct device_node
*np
,
615 struct imx_pinctrl_soc_info
*info
,
618 struct device_node
*child
;
619 struct imx_pmx_func
*func
;
620 struct imx_pin_group
*grp
;
623 dev_dbg(info
->dev
, "parse function(%d): %s\n", index
, np
->name
);
625 func
= &info
->functions
[index
];
627 /* Initialise function */
628 func
->name
= np
->name
;
629 func
->num_groups
= of_get_child_count(np
);
630 if (func
->num_groups
== 0) {
631 dev_err(info
->dev
, "no groups defined in %s\n", np
->full_name
);
634 func
->groups
= devm_kzalloc(info
->dev
,
635 func
->num_groups
* sizeof(char *), GFP_KERNEL
);
637 for_each_child_of_node(np
, child
) {
638 func
->groups
[i
] = child
->name
;
639 grp
= &info
->groups
[info
->group_index
++];
640 imx_pinctrl_parse_groups(child
, grp
, info
, i
++);
647 * Check if the DT contains pins in the direct child nodes. This indicates the
648 * newer DT format to store pins. This function returns true if the first found
649 * fsl,pins property is in a child of np. Otherwise false is returned.
651 static bool imx_pinctrl_dt_is_flat_functions(struct device_node
*np
)
653 struct device_node
*function_np
;
654 struct device_node
*pinctrl_np
;
656 for_each_child_of_node(np
, function_np
) {
657 if (of_property_read_bool(function_np
, "fsl,pins"))
660 for_each_child_of_node(function_np
, pinctrl_np
) {
661 if (of_property_read_bool(pinctrl_np
, "fsl,pins"))
669 static int imx_pinctrl_probe_dt(struct platform_device
*pdev
,
670 struct imx_pinctrl_soc_info
*info
)
672 struct device_node
*np
= pdev
->dev
.of_node
;
673 struct device_node
*child
;
681 flat_funcs
= imx_pinctrl_dt_is_flat_functions(np
);
685 nfuncs
= of_get_child_count(np
);
687 dev_err(&pdev
->dev
, "no functions defined\n");
692 info
->nfunctions
= nfuncs
;
693 info
->functions
= devm_kzalloc(&pdev
->dev
, nfuncs
* sizeof(struct imx_pmx_func
),
695 if (!info
->functions
)
699 info
->ngroups
= of_get_child_count(np
);
702 for_each_child_of_node(np
, child
)
703 info
->ngroups
+= of_get_child_count(child
);
705 info
->groups
= devm_kzalloc(&pdev
->dev
, info
->ngroups
* sizeof(struct imx_pin_group
),
711 imx_pinctrl_parse_functions(np
, info
, 0);
713 for_each_child_of_node(np
, child
)
714 imx_pinctrl_parse_functions(child
, info
, i
++);
720 int imx_pinctrl_probe(struct platform_device
*pdev
,
721 struct imx_pinctrl_soc_info
*info
)
723 struct regmap_config config
= { .name
= "gpr" };
724 struct device_node
*dev_np
= pdev
->dev
.of_node
;
725 struct device_node
*np
;
726 struct imx_pinctrl
*ipctl
;
727 struct resource
*res
;
731 if (!info
|| !info
->pins
|| !info
->npins
) {
732 dev_err(&pdev
->dev
, "wrong pinctrl info\n");
735 info
->dev
= &pdev
->dev
;
737 if (info
->gpr_compatible
) {
738 gpr
= syscon_regmap_lookup_by_compatible(info
->gpr_compatible
);
740 regmap_attach_dev(&pdev
->dev
, gpr
, &config
);
743 /* Create state holders etc for this driver */
744 ipctl
= devm_kzalloc(&pdev
->dev
, sizeof(*ipctl
), GFP_KERNEL
);
748 info
->pin_regs
= devm_kmalloc(&pdev
->dev
, sizeof(*info
->pin_regs
) *
749 info
->npins
, GFP_KERNEL
);
753 for (i
= 0; i
< info
->npins
; i
++) {
754 info
->pin_regs
[i
].mux_reg
= -1;
755 info
->pin_regs
[i
].conf_reg
= -1;
758 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
759 ipctl
->base
= devm_ioremap_resource(&pdev
->dev
, res
);
760 if (IS_ERR(ipctl
->base
))
761 return PTR_ERR(ipctl
->base
);
763 if (of_property_read_bool(dev_np
, "fsl,input-sel")) {
764 np
= of_parse_phandle(dev_np
, "fsl,input-sel", 0);
766 dev_err(&pdev
->dev
, "iomuxc fsl,input-sel property not found\n");
770 ipctl
->input_sel_base
= of_iomap(np
, 0);
772 if (!ipctl
->input_sel_base
) {
774 "iomuxc input select base address not found\n");
779 imx_pinctrl_desc
.name
= dev_name(&pdev
->dev
);
780 imx_pinctrl_desc
.pins
= info
->pins
;
781 imx_pinctrl_desc
.npins
= info
->npins
;
783 ret
= imx_pinctrl_probe_dt(pdev
, info
);
785 dev_err(&pdev
->dev
, "fail to probe dt properties\n");
790 ipctl
->dev
= info
->dev
;
791 platform_set_drvdata(pdev
, ipctl
);
792 ipctl
->pctl
= devm_pinctrl_register(&pdev
->dev
, &imx_pinctrl_desc
, ipctl
);
793 if (IS_ERR(ipctl
->pctl
)) {
794 dev_err(&pdev
->dev
, "could not register IMX pinctrl driver\n");
795 return PTR_ERR(ipctl
->pctl
);
798 dev_info(&pdev
->dev
, "initialized IMX pinctrl driver\n");