diff options
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r-- | drivers/pinctrl/pinmux.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 4e62783a573a..fa0357bd88ff 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -33,10 +33,12 @@ | |||
33 | int pinmux_check_ops(struct pinctrl_dev *pctldev) | 33 | int pinmux_check_ops(struct pinctrl_dev *pctldev) |
34 | { | 34 | { |
35 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 35 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
36 | unsigned nfuncs; | ||
36 | unsigned selector = 0; | 37 | unsigned selector = 0; |
37 | 38 | ||
38 | /* Check that we implement required operations */ | 39 | /* Check that we implement required operations */ |
39 | if (!ops->list_functions || | 40 | if (!ops || |
41 | !ops->get_functions_count || | ||
40 | !ops->get_function_name || | 42 | !ops->get_function_name || |
41 | !ops->get_function_groups || | 43 | !ops->get_function_groups || |
42 | !ops->enable || | 44 | !ops->enable || |
@@ -44,11 +46,12 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) | |||
44 | return -EINVAL; | 46 | return -EINVAL; |
45 | 47 | ||
46 | /* Check that all functions registered have names */ | 48 | /* Check that all functions registered have names */ |
47 | while (ops->list_functions(pctldev, selector) >= 0) { | 49 | nfuncs = ops->get_functions_count(pctldev); |
50 | while (selector < nfuncs) { | ||
48 | const char *fname = ops->get_function_name(pctldev, | 51 | const char *fname = ops->get_function_name(pctldev, |
49 | selector); | 52 | selector); |
50 | if (!fname) { | 53 | if (!fname) { |
51 | pr_err("pinmux ops has no name for function%u\n", | 54 | dev_err(pctldev->dev, "pinmux ops has no name for function%u\n", |
52 | selector); | 55 | selector); |
53 | return -EINVAL; | 56 | return -EINVAL; |
54 | } | 57 | } |
@@ -85,8 +88,6 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
85 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 88 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
86 | int status = -EINVAL; | 89 | int status = -EINVAL; |
87 | 90 | ||
88 | dev_dbg(pctldev->dev, "request pin %d for %s\n", pin, owner); | ||
89 | |||
90 | desc = pin_desc_get(pctldev, pin); | 91 | desc = pin_desc_get(pctldev, pin); |
91 | if (desc == NULL) { | 92 | if (desc == NULL) { |
92 | dev_err(pctldev->dev, | 93 | dev_err(pctldev->dev, |
@@ -94,6 +95,9 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
94 | goto out; | 95 | goto out; |
95 | } | 96 | } |
96 | 97 | ||
98 | dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n", | ||
99 | pin, desc->name, owner); | ||
100 | |||
97 | if (gpio_range) { | 101 | if (gpio_range) { |
98 | /* There's no need to support multiple GPIO requests */ | 102 | /* There's no need to support multiple GPIO requests */ |
99 | if (desc->gpio_owner) { | 103 | if (desc->gpio_owner) { |
@@ -287,10 +291,11 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev, | |||
287 | const char *function) | 291 | const char *function) |
288 | { | 292 | { |
289 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 293 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
294 | unsigned nfuncs = ops->get_functions_count(pctldev); | ||
290 | unsigned selector = 0; | 295 | unsigned selector = 0; |
291 | 296 | ||
292 | /* See if this pctldev has this function */ | 297 | /* See if this pctldev has this function */ |
293 | while (ops->list_functions(pctldev, selector) >= 0) { | 298 | while (selector < nfuncs) { |
294 | const char *fname = ops->get_function_name(pctldev, | 299 | const char *fname = ops->get_function_name(pctldev, |
295 | selector); | 300 | selector); |
296 | 301 | ||
@@ -319,6 +324,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
319 | const unsigned *pins; | 324 | const unsigned *pins; |
320 | unsigned num_pins; | 325 | unsigned num_pins; |
321 | 326 | ||
327 | if (!pmxops) { | ||
328 | dev_err(pctldev->dev, "does not support mux function\n"); | ||
329 | return -EINVAL; | ||
330 | } | ||
331 | |||
322 | setting->data.mux.func = | 332 | setting->data.mux.func = |
323 | pinmux_func_name_to_selector(pctldev, map->data.mux.function); | 333 | pinmux_func_name_to_selector(pctldev, map->data.mux.function); |
324 | if (setting->data.mux.func < 0) | 334 | if (setting->data.mux.func < 0) |
@@ -477,11 +487,15 @@ static int pinmux_functions_show(struct seq_file *s, void *what) | |||
477 | { | 487 | { |
478 | struct pinctrl_dev *pctldev = s->private; | 488 | struct pinctrl_dev *pctldev = s->private; |
479 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; | 489 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; |
490 | unsigned nfuncs; | ||
480 | unsigned func_selector = 0; | 491 | unsigned func_selector = 0; |
481 | 492 | ||
482 | mutex_lock(&pinctrl_mutex); | 493 | if (!pmxops) |
494 | return 0; | ||
483 | 495 | ||
484 | while (pmxops->list_functions(pctldev, func_selector) >= 0) { | 496 | mutex_lock(&pinctrl_mutex); |
497 | nfuncs = pmxops->get_functions_count(pctldev); | ||
498 | while (func_selector < nfuncs) { | ||
485 | const char *func = pmxops->get_function_name(pctldev, | 499 | const char *func = pmxops->get_function_name(pctldev, |
486 | func_selector); | 500 | func_selector); |
487 | const char * const *groups; | 501 | const char * const *groups; |
@@ -515,6 +529,9 @@ static int pinmux_pins_show(struct seq_file *s, void *what) | |||
515 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; | 529 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; |
516 | unsigned i, pin; | 530 | unsigned i, pin; |
517 | 531 | ||
532 | if (!pmxops) | ||
533 | return 0; | ||
534 | |||
518 | seq_puts(s, "Pinmux settings per pin\n"); | 535 | seq_puts(s, "Pinmux settings per pin\n"); |
519 | seq_puts(s, "Format: pin (name): mux_owner gpio_owner hog?\n"); | 536 | seq_puts(s, "Format: pin (name): mux_owner gpio_owner hog?\n"); |
520 | 537 | ||