blob: 641b3088876fb3037cfa56452f6088dbe3d456d6 [file] [log] [blame]
Fabio Estevamc2b39de2018-05-19 15:43:54 -03001// SPDX-License-Identifier: GPL-2.0+
2//
3// Copyright 2012 Freescale Semiconductor, Inc.
Shawn Guo17723112012-04-28 13:00:50 +08004
5#include <linux/err.h>
6#include <linux/init.h>
7#include <linux/io.h>
Shawn Guo17723112012-04-28 13:00:50 +08008#include <linux/of.h>
9#include <linux/of_address.h>
10#include <linux/pinctrl/machine.h>
11#include <linux/pinctrl/pinconf.h>
12#include <linux/pinctrl/pinctrl.h>
13#include <linux/pinctrl/pinmux.h>
14#include <linux/platform_device.h>
15#include <linux/slab.h>
Linus Walleijedad3b22014-09-03 13:37:38 +020016#include "../core.h"
Shawn Guo17723112012-04-28 13:00:50 +080017#include "pinctrl-mxs.h"
18
19#define SUFFIX_LEN 4
20
21struct mxs_pinctrl_data {
22 struct device *dev;
23 struct pinctrl_dev *pctl;
24 void __iomem *base;
25 struct mxs_pinctrl_soc_data *soc;
26};
27
28static int mxs_get_groups_count(struct pinctrl_dev *pctldev)
29{
30 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
31
32 return d->soc->ngroups;
33}
34
35static const char *mxs_get_group_name(struct pinctrl_dev *pctldev,
36 unsigned group)
37{
38 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
39
40 return d->soc->groups[group].name;
41}
42
43static int mxs_get_group_pins(struct pinctrl_dev *pctldev, unsigned group,
44 const unsigned **pins, unsigned *num_pins)
45{
46 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
47
48 *pins = d->soc->groups[group].pins;
49 *num_pins = d->soc->groups[group].npins;
50
51 return 0;
52}
53
54static void mxs_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
55 unsigned offset)
56{
57 seq_printf(s, " %s", dev_name(pctldev->dev));
58}
59
60static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev,
61 struct device_node *np,
62 struct pinctrl_map **map, unsigned *num_maps)
63{
64 struct pinctrl_map *new_map;
Shawn Guo3b7ac942012-05-13 23:19:00 +080065 char *group = NULL;
66 unsigned new_num = 1;
Shawn Guo17723112012-04-28 13:00:50 +080067 unsigned long config = 0;
68 unsigned long *pconfig;
69 int length = strlen(np->name) + SUFFIX_LEN;
Shawn Guo3b7ac942012-05-13 23:19:00 +080070 bool purecfg = false;
71 u32 val, reg;
72 int ret, i = 0;
73
74 /* Check for pin config node which has no 'reg' property */
75 if (of_property_read_u32(np, "reg", &reg))
76 purecfg = true;
Shawn Guo17723112012-04-28 13:00:50 +080077
78 ret = of_property_read_u32(np, "fsl,drive-strength", &val);
79 if (!ret)
80 config = val | MA_PRESENT;
81 ret = of_property_read_u32(np, "fsl,voltage", &val);
82 if (!ret)
83 config |= val << VOL_SHIFT | VOL_PRESENT;
84 ret = of_property_read_u32(np, "fsl,pull-up", &val);
85 if (!ret)
86 config |= val << PULL_SHIFT | PULL_PRESENT;
87
Shawn Guo3b7ac942012-05-13 23:19:00 +080088 /* Check for group node which has both mux and config settings */
89 if (!purecfg && config)
90 new_num = 2;
91
Kees Cook6396bb22018-06-12 14:03:40 -070092 new_map = kcalloc(new_num, sizeof(*new_map), GFP_KERNEL);
Shawn Guo17723112012-04-28 13:00:50 +080093 if (!new_map)
94 return -ENOMEM;
95
Shawn Guo3b7ac942012-05-13 23:19:00 +080096 if (!purecfg) {
97 new_map[i].type = PIN_MAP_TYPE_MUX_GROUP;
98 new_map[i].data.mux.function = np->name;
Shawn Guo17723112012-04-28 13:00:50 +080099
Shawn Guo3b7ac942012-05-13 23:19:00 +0800100 /* Compose group name */
101 group = kzalloc(length, GFP_KERNEL);
Devendra Naga0bf74812012-06-09 17:31:23 +0530102 if (!group) {
103 ret = -ENOMEM;
104 goto free;
105 }
Shawn Guo3b7ac942012-05-13 23:19:00 +0800106 snprintf(group, length, "%s.%d", np->name, reg);
107 new_map[i].data.mux.group = group;
108 i++;
109 }
Shawn Guo17723112012-04-28 13:00:50 +0800110
111 if (config) {
112 pconfig = kmemdup(&config, sizeof(config), GFP_KERNEL);
113 if (!pconfig) {
114 ret = -ENOMEM;
Devendra Naga0bf74812012-06-09 17:31:23 +0530115 goto free_group;
Shawn Guo17723112012-04-28 13:00:50 +0800116 }
117
Shawn Guo3b7ac942012-05-13 23:19:00 +0800118 new_map[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
119 new_map[i].data.configs.group_or_pin = purecfg ? np->name :
120 group;
121 new_map[i].data.configs.configs = pconfig;
122 new_map[i].data.configs.num_configs = 1;
Shawn Guo17723112012-04-28 13:00:50 +0800123 }
124
125 *map = new_map;
126 *num_maps = new_num;
127
128 return 0;
129
Devendra Naga0bf74812012-06-09 17:31:23 +0530130free_group:
131 if (!purecfg)
Fabio Estevam14e1e9f2012-06-13 14:06:07 -0300132 kfree(group);
Shawn Guo17723112012-04-28 13:00:50 +0800133free:
134 kfree(new_map);
135 return ret;
136}
137
138static void mxs_dt_free_map(struct pinctrl_dev *pctldev,
139 struct pinctrl_map *map, unsigned num_maps)
140{
Fabio Estevam4b090d82013-01-07 22:53:49 -0200141 u32 i;
Shawn Guo17723112012-04-28 13:00:50 +0800142
143 for (i = 0; i < num_maps; i++) {
144 if (map[i].type == PIN_MAP_TYPE_MUX_GROUP)
145 kfree(map[i].data.mux.group);
146 if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
147 kfree(map[i].data.configs.configs);
148 }
149
150 kfree(map);
151}
152
Laurent Pinchart022ab142013-02-16 10:25:07 +0100153static const struct pinctrl_ops mxs_pinctrl_ops = {
Shawn Guo17723112012-04-28 13:00:50 +0800154 .get_groups_count = mxs_get_groups_count,
155 .get_group_name = mxs_get_group_name,
156 .get_group_pins = mxs_get_group_pins,
157 .pin_dbg_show = mxs_pin_dbg_show,
158 .dt_node_to_map = mxs_dt_node_to_map,
159 .dt_free_map = mxs_dt_free_map,
160};
161
162static int mxs_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev)
163{
164 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
165
166 return d->soc->nfunctions;
167}
168
169static const char *mxs_pinctrl_get_func_name(struct pinctrl_dev *pctldev,
170 unsigned function)
171{
172 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
173
174 return d->soc->functions[function].name;
175}
176
177static int mxs_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
178 unsigned group,
179 const char * const **groups,
180 unsigned * const num_groups)
181{
182 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
183
184 *groups = d->soc->functions[group].groups;
185 *num_groups = d->soc->functions[group].ngroups;
186
187 return 0;
188}
189
Uwe Kleine-Königda6c2ad2017-05-18 11:23:55 +0200190static void mxs_pinctrl_rmwl(u32 value, u32 mask, u8 shift, void __iomem *reg)
191{
192 u32 tmp;
193
194 tmp = readl(reg);
195 tmp &= ~(mask << shift);
196 tmp |= value << shift;
197 writel(tmp, reg);
198}
199
Linus Walleij03e9f0c2014-09-03 13:02:56 +0200200static int mxs_pinctrl_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
201 unsigned group)
Shawn Guo17723112012-04-28 13:00:50 +0800202{
203 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
204 struct mxs_group *g = &d->soc->groups[group];
205 void __iomem *reg;
206 u8 bank, shift;
207 u16 pin;
Fabio Estevam4b090d82013-01-07 22:53:49 -0200208 u32 i;
Shawn Guo17723112012-04-28 13:00:50 +0800209
210 for (i = 0; i < g->npins; i++) {
211 bank = PINID_TO_BANK(g->pins[i]);
212 pin = PINID_TO_PIN(g->pins[i]);
213 reg = d->base + d->soc->regs->muxsel;
214 reg += bank * 0x20 + pin / 16 * 0x10;
215 shift = pin % 16 * 2;
216
Uwe Kleine-Königda6c2ad2017-05-18 11:23:55 +0200217 mxs_pinctrl_rmwl(g->muxsel[i], 0x3, shift, reg);
Shawn Guo17723112012-04-28 13:00:50 +0800218 }
219
220 return 0;
221}
222
Laurent Pinchart022ab142013-02-16 10:25:07 +0100223static const struct pinmux_ops mxs_pinmux_ops = {
Shawn Guo17723112012-04-28 13:00:50 +0800224 .get_functions_count = mxs_pinctrl_get_funcs_count,
225 .get_function_name = mxs_pinctrl_get_func_name,
226 .get_function_groups = mxs_pinctrl_get_func_groups,
Linus Walleij03e9f0c2014-09-03 13:02:56 +0200227 .set_mux = mxs_pinctrl_set_mux,
Shawn Guo17723112012-04-28 13:00:50 +0800228};
229
230static int mxs_pinconf_get(struct pinctrl_dev *pctldev,
231 unsigned pin, unsigned long *config)
232{
233 return -ENOTSUPP;
234}
235
236static int mxs_pinconf_set(struct pinctrl_dev *pctldev,
Sherman Yin03b054e2013-08-27 11:32:12 -0700237 unsigned pin, unsigned long *configs,
238 unsigned num_configs)
Shawn Guo17723112012-04-28 13:00:50 +0800239{
240 return -ENOTSUPP;
241}
242
243static int mxs_pinconf_group_get(struct pinctrl_dev *pctldev,
244 unsigned group, unsigned long *config)
245{
246 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
247
248 *config = d->soc->groups[group].config;
249
250 return 0;
251}
252
253static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev,
Sherman Yin03b054e2013-08-27 11:32:12 -0700254 unsigned group, unsigned long *configs,
255 unsigned num_configs)
Shawn Guo17723112012-04-28 13:00:50 +0800256{
257 struct mxs_pinctrl_data *d = pinctrl_dev_get_drvdata(pctldev);
258 struct mxs_group *g = &d->soc->groups[group];
259 void __iomem *reg;
260 u8 ma, vol, pull, bank, shift;
261 u16 pin;
Fabio Estevam4b090d82013-01-07 22:53:49 -0200262 u32 i;
Sherman Yin03b054e2013-08-27 11:32:12 -0700263 int n;
264 unsigned long config;
Shawn Guo17723112012-04-28 13:00:50 +0800265
Sherman Yin03b054e2013-08-27 11:32:12 -0700266 for (n = 0; n < num_configs; n++) {
267 config = configs[n];
Shawn Guo17723112012-04-28 13:00:50 +0800268
Sherman Yin03b054e2013-08-27 11:32:12 -0700269 ma = CONFIG_TO_MA(config);
270 vol = CONFIG_TO_VOL(config);
271 pull = CONFIG_TO_PULL(config);
Shawn Guo17723112012-04-28 13:00:50 +0800272
Sherman Yin03b054e2013-08-27 11:32:12 -0700273 for (i = 0; i < g->npins; i++) {
274 bank = PINID_TO_BANK(g->pins[i]);
275 pin = PINID_TO_PIN(g->pins[i]);
Shawn Guo17723112012-04-28 13:00:50 +0800276
Sherman Yin03b054e2013-08-27 11:32:12 -0700277 /* drive */
278 reg = d->base + d->soc->regs->drive;
279 reg += bank * 0x40 + pin / 8 * 0x10;
280
281 /* mA */
282 if (config & MA_PRESENT) {
283 shift = pin % 8 * 4;
Uwe Kleine-Königda6c2ad2017-05-18 11:23:55 +0200284 mxs_pinctrl_rmwl(ma, 0x3, shift, reg);
Sherman Yin03b054e2013-08-27 11:32:12 -0700285 }
286
287 /* vol */
288 if (config & VOL_PRESENT) {
289 shift = pin % 8 * 4 + 2;
290 if (vol)
291 writel(1 << shift, reg + SET);
292 else
293 writel(1 << shift, reg + CLR);
294 }
295
296 /* pull */
297 if (config & PULL_PRESENT) {
298 reg = d->base + d->soc->regs->pull;
299 reg += bank * 0x10;
300 shift = pin;
301 if (pull)
302 writel(1 << shift, reg + SET);
303 else
304 writel(1 << shift, reg + CLR);
305 }
Shawn Guo17723112012-04-28 13:00:50 +0800306 }
307
Sherman Yin03b054e2013-08-27 11:32:12 -0700308 /* cache the config value for mxs_pinconf_group_get() */
309 g->config = config;
Shawn Guo17723112012-04-28 13:00:50 +0800310
Sherman Yin03b054e2013-08-27 11:32:12 -0700311 } /* for each config */
Shawn Guo17723112012-04-28 13:00:50 +0800312
313 return 0;
314}
315
316static void mxs_pinconf_dbg_show(struct pinctrl_dev *pctldev,
317 struct seq_file *s, unsigned pin)
318{
319 /* Not support */
320}
321
322static void mxs_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,
323 struct seq_file *s, unsigned group)
324{
325 unsigned long config;
326
327 if (!mxs_pinconf_group_get(pctldev, group, &config))
328 seq_printf(s, "0x%lx", config);
329}
330
Laurent Pinchart022ab142013-02-16 10:25:07 +0100331static const struct pinconf_ops mxs_pinconf_ops = {
Shawn Guo17723112012-04-28 13:00:50 +0800332 .pin_config_get = mxs_pinconf_get,
333 .pin_config_set = mxs_pinconf_set,
334 .pin_config_group_get = mxs_pinconf_group_get,
335 .pin_config_group_set = mxs_pinconf_group_set,
336 .pin_config_dbg_show = mxs_pinconf_dbg_show,
337 .pin_config_group_dbg_show = mxs_pinconf_group_dbg_show,
338};
339
340static struct pinctrl_desc mxs_pinctrl_desc = {
341 .pctlops = &mxs_pinctrl_ops,
342 .pmxops = &mxs_pinmux_ops,
343 .confops = &mxs_pinconf_ops,
344 .owner = THIS_MODULE,
345};
346
Greg Kroah-Hartman150632b2012-12-21 13:10:23 -0800347static int mxs_pinctrl_parse_group(struct platform_device *pdev,
348 struct device_node *np, int idx,
349 const char **out_name)
Shawn Guo17723112012-04-28 13:00:50 +0800350{
351 struct mxs_pinctrl_data *d = platform_get_drvdata(pdev);
352 struct mxs_group *g = &d->soc->groups[idx];
353 struct property *prop;
354 const char *propname = "fsl,pinmux-ids";
355 char *group;
356 int length = strlen(np->name) + SUFFIX_LEN;
Fabio Estevam4b090d82013-01-07 22:53:49 -0200357 u32 val, i;
Shawn Guo17723112012-04-28 13:00:50 +0800358
359 group = devm_kzalloc(&pdev->dev, length, GFP_KERNEL);
360 if (!group)
361 return -ENOMEM;
Shawn Guo3b7ac942012-05-13 23:19:00 +0800362 if (of_property_read_u32(np, "reg", &val))
363 snprintf(group, length, "%s", np->name);
364 else
365 snprintf(group, length, "%s.%d", np->name, val);
Shawn Guo17723112012-04-28 13:00:50 +0800366 g->name = group;
367
368 prop = of_find_property(np, propname, &length);
369 if (!prop)
370 return -EINVAL;
371 g->npins = length / sizeof(u32);
372
Kees Cooka86854d2018-06-12 14:07:58 -0700373 g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins),
Shawn Guo17723112012-04-28 13:00:50 +0800374 GFP_KERNEL);
375 if (!g->pins)
376 return -ENOMEM;
377
Kees Cooka86854d2018-06-12 14:07:58 -0700378 g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel),
Shawn Guo17723112012-04-28 13:00:50 +0800379 GFP_KERNEL);
380 if (!g->muxsel)
381 return -ENOMEM;
382
383 of_property_read_u32_array(np, propname, g->pins, g->npins);
384 for (i = 0; i < g->npins; i++) {
385 g->muxsel[i] = MUXID_TO_MUXSEL(g->pins[i]);
386 g->pins[i] = MUXID_TO_PINID(g->pins[i]);
387 }
388
Shawn Guo3b7ac942012-05-13 23:19:00 +0800389 if (out_name)
390 *out_name = g->name;
Shawn Guo17723112012-04-28 13:00:50 +0800391
392 return 0;
393}
394
Greg Kroah-Hartman150632b2012-12-21 13:10:23 -0800395static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
396 struct mxs_pinctrl_data *d)
Shawn Guo17723112012-04-28 13:00:50 +0800397{
398 struct mxs_pinctrl_soc_data *soc = d->soc;
399 struct device_node *np = pdev->dev.of_node;
400 struct device_node *child;
401 struct mxs_function *f;
Shawn Guo48516802012-05-13 23:19:01 +0800402 const char *gpio_compat = "fsl,mxs-gpio";
Shawn Guo17723112012-04-28 13:00:50 +0800403 const char *fn, *fnull = "";
404 int i = 0, idxf = 0, idxg = 0;
405 int ret;
406 u32 val;
407
408 child = of_get_next_child(np, NULL);
409 if (!child) {
410 dev_err(&pdev->dev, "no group is defined\n");
411 return -ENOENT;
412 }
413
414 /* Count total functions and groups */
415 fn = fnull;
416 for_each_child_of_node(np, child) {
Shawn Guo48516802012-05-13 23:19:01 +0800417 if (of_device_is_compatible(child, gpio_compat))
418 continue;
Shawn Guo3b7ac942012-05-13 23:19:00 +0800419 soc->ngroups++;
Shawn Guo17723112012-04-28 13:00:50 +0800420 /* Skip pure pinconf node */
421 if (of_property_read_u32(child, "reg", &val))
422 continue;
423 if (strcmp(fn, child->name)) {
424 fn = child->name;
425 soc->nfunctions++;
426 }
Shawn Guo17723112012-04-28 13:00:50 +0800427 }
428
Kees Cooka86854d2018-06-12 14:07:58 -0700429 soc->functions = devm_kcalloc(&pdev->dev,
430 soc->nfunctions,
431 sizeof(*soc->functions),
432 GFP_KERNEL);
Shawn Guo17723112012-04-28 13:00:50 +0800433 if (!soc->functions)
434 return -ENOMEM;
435
Kees Cooka86854d2018-06-12 14:07:58 -0700436 soc->groups = devm_kcalloc(&pdev->dev,
437 soc->ngroups, sizeof(*soc->groups),
438 GFP_KERNEL);
Shawn Guo17723112012-04-28 13:00:50 +0800439 if (!soc->groups)
440 return -ENOMEM;
441
442 /* Count groups for each function */
443 fn = fnull;
444 f = &soc->functions[idxf];
445 for_each_child_of_node(np, child) {
Shawn Guo48516802012-05-13 23:19:01 +0800446 if (of_device_is_compatible(child, gpio_compat))
447 continue;
Shawn Guo17723112012-04-28 13:00:50 +0800448 if (of_property_read_u32(child, "reg", &val))
449 continue;
450 if (strcmp(fn, child->name)) {
Uwe Kleine-Königfdaaf6d2014-10-21 11:40:45 +0200451 struct device_node *child2;
452
453 /*
454 * This reference is dropped by
455 * of_get_next_child(np, * child)
456 */
457 of_node_get(child);
458
459 /*
460 * The logic parsing the functions from dt currently
461 * doesn't handle if functions with the same name are
462 * not grouped together. Only the first contiguous
463 * cluster is usable for each function name. This is a
464 * bug that is not trivial to fix, but at least warn
465 * about it.
466 */
467 for (child2 = of_get_next_child(np, child);
468 child2 != NULL;
469 child2 = of_get_next_child(np, child2)) {
470 if (!strcmp(child2->name, fn))
471 dev_warn(&pdev->dev,
472 "function nodes must be grouped by name (failed for: %s)",
473 fn);
474 }
475
Shawn Guo17723112012-04-28 13:00:50 +0800476 f = &soc->functions[idxf++];
477 f->name = fn = child->name;
478 }
479 f->ngroups++;
Javier Martinez Canillas14316c42015-09-16 10:28:28 +0200480 }
Shawn Guo17723112012-04-28 13:00:50 +0800481
482 /* Get groups for each function */
483 idxf = 0;
484 fn = fnull;
485 for_each_child_of_node(np, child) {
Shawn Guo48516802012-05-13 23:19:01 +0800486 if (of_device_is_compatible(child, gpio_compat))
487 continue;
Shawn Guo3b7ac942012-05-13 23:19:00 +0800488 if (of_property_read_u32(child, "reg", &val)) {
489 ret = mxs_pinctrl_parse_group(pdev, child,
490 idxg++, NULL);
491 if (ret)
492 return ret;
Shawn Guo17723112012-04-28 13:00:50 +0800493 continue;
Shawn Guo3b7ac942012-05-13 23:19:00 +0800494 }
495
Shawn Guo17723112012-04-28 13:00:50 +0800496 if (strcmp(fn, child->name)) {
497 f = &soc->functions[idxf++];
Kees Cooka86854d2018-06-12 14:07:58 -0700498 f->groups = devm_kcalloc(&pdev->dev,
499 f->ngroups,
Shawn Guo17723112012-04-28 13:00:50 +0800500 sizeof(*f->groups),
501 GFP_KERNEL);
502 if (!f->groups)
503 return -ENOMEM;
504 fn = child->name;
505 i = 0;
506 }
507 ret = mxs_pinctrl_parse_group(pdev, child, idxg++,
508 &f->groups[i++]);
509 if (ret)
510 return ret;
511 }
512
513 return 0;
514}
515
Greg Kroah-Hartman150632b2012-12-21 13:10:23 -0800516int mxs_pinctrl_probe(struct platform_device *pdev,
517 struct mxs_pinctrl_soc_data *soc)
Shawn Guo17723112012-04-28 13:00:50 +0800518{
519 struct device_node *np = pdev->dev.of_node;
520 struct mxs_pinctrl_data *d;
521 int ret;
522
523 d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
524 if (!d)
525 return -ENOMEM;
526
527 d->dev = &pdev->dev;
528 d->soc = soc;
529
530 d->base = of_iomap(np, 0);
531 if (!d->base)
532 return -EADDRNOTAVAIL;
533
534 mxs_pinctrl_desc.pins = d->soc->pins;
535 mxs_pinctrl_desc.npins = d->soc->npins;
536 mxs_pinctrl_desc.name = dev_name(&pdev->dev);
537
538 platform_set_drvdata(pdev, d);
539
540 ret = mxs_pinctrl_probe_dt(pdev, d);
541 if (ret) {
542 dev_err(&pdev->dev, "dt probe failed: %d\n", ret);
543 goto err;
544 }
545
546 d->pctl = pinctrl_register(&mxs_pinctrl_desc, &pdev->dev, d);
Masahiro Yamada323de9e2015-06-09 13:01:16 +0900547 if (IS_ERR(d->pctl)) {
Shawn Guo17723112012-04-28 13:00:50 +0800548 dev_err(&pdev->dev, "Couldn't register MXS pinctrl driver\n");
Masahiro Yamada323de9e2015-06-09 13:01:16 +0900549 ret = PTR_ERR(d->pctl);
Shawn Guo17723112012-04-28 13:00:50 +0800550 goto err;
551 }
552
553 return 0;
554
555err:
556 iounmap(d->base);
557 return ret;
558}