Lines Matching refs:pctldev

35 int pinmux_check_ops(struct pinctrl_dev *pctldev)  in pinmux_check_ops()  argument
37 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pinmux_check_ops()
47 dev_err(pctldev->dev, "pinmux ops lacks necessary functions\n"); in pinmux_check_ops()
51 nfuncs = ops->get_functions_count(pctldev); in pinmux_check_ops()
53 const char *fname = ops->get_function_name(pctldev, in pinmux_check_ops()
56 dev_err(pctldev->dev, "pinmux ops has no name for function%u\n", in pinmux_check_ops()
87 bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin) in pinmux_can_be_used_for_gpio() argument
89 struct pin_desc *desc = pin_desc_get(pctldev, pin); in pinmux_can_be_used_for_gpio()
90 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pinmux_can_be_used_for_gpio()
111 static int pin_request(struct pinctrl_dev *pctldev, in pin_request() argument
116 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pin_request()
119 desc = pin_desc_get(pctldev, pin); in pin_request()
121 dev_err(pctldev->dev, in pin_request()
127 dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n", in pin_request()
132 dev_err(pctldev->dev, in pin_request()
139 dev_err(pctldev->dev, in pin_request()
156 if (!try_module_get(pctldev->owner)) { in pin_request()
157 dev_err(pctldev->dev, in pin_request()
170 status = ops->gpio_request_enable(pctldev, gpio_range, pin); in pin_request()
172 status = ops->request(pctldev, pin); in pin_request()
177 dev_err(pctldev->dev, "request() failed for pin %d\n", pin); in pin_request()
178 module_put(pctldev->owner); in pin_request()
193 dev_err(pctldev->dev, "pin-%d (%s) status %d\n", in pin_request()
210 static const char *pin_free(struct pinctrl_dev *pctldev, int pin, in pin_free() argument
213 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pin_free()
217 desc = pin_desc_get(pctldev, pin); in pin_free()
219 dev_err(pctldev->dev, in pin_free()
240 ops->gpio_disable_free(pctldev, gpio_range, pin); in pin_free()
242 ops->free(pctldev, pin); in pin_free()
253 module_put(pctldev->owner); in pin_free()
265 int pinmux_request_gpio(struct pinctrl_dev *pctldev, in pinmux_request_gpio() argument
277 ret = pin_request(pctldev, pin, owner, range); in pinmux_request_gpio()
290 void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin, in pinmux_free_gpio() argument
295 owner = pin_free(pctldev, pin, range); in pinmux_free_gpio()
306 int pinmux_gpio_direction(struct pinctrl_dev *pctldev, in pinmux_gpio_direction() argument
313 ops = pctldev->desc->pmxops; in pinmux_gpio_direction()
316 ret = ops->gpio_set_direction(pctldev, range, pin, input); in pinmux_gpio_direction()
323 static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev, in pinmux_func_name_to_selector() argument
326 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pinmux_func_name_to_selector()
327 unsigned nfuncs = ops->get_functions_count(pctldev); in pinmux_func_name_to_selector()
332 const char *fname = ops->get_function_name(pctldev, selector); in pinmux_func_name_to_selector()
346 struct pinctrl_dev *pctldev = setting->pctldev; in pinmux_map_to_setting() local
347 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; in pinmux_map_to_setting()
354 dev_err(pctldev->dev, "does not support mux function\n"); in pinmux_map_to_setting()
358 ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function); in pinmux_map_to_setting()
360 dev_err(pctldev->dev, "invalid function %s in map table\n", in pinmux_map_to_setting()
366 ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, in pinmux_map_to_setting()
369 dev_err(pctldev->dev, "can't query groups for function %s\n", in pinmux_map_to_setting()
374 dev_err(pctldev->dev, in pinmux_map_to_setting()
383 dev_err(pctldev->dev, in pinmux_map_to_setting()
392 ret = pinctrl_get_group_selector(pctldev, group); in pinmux_map_to_setting()
394 dev_err(pctldev->dev, "invalid group %s in map table\n", in pinmux_map_to_setting()
410 struct pinctrl_dev *pctldev = setting->pctldev; in pinmux_enable_setting() local
411 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinmux_enable_setting()
412 const struct pinmux_ops *ops = pctldev->desc->pmxops; in pinmux_enable_setting()
420 ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, in pinmux_enable_setting()
427 gname = pctlops->get_group_name(pctldev, in pinmux_enable_setting()
429 dev_warn(pctldev->dev, in pinmux_enable_setting()
437 ret = pin_request(pctldev, pins[i], setting->dev_name, NULL); in pinmux_enable_setting()
442 desc = pin_desc_get(pctldev, pins[i]); in pinmux_enable_setting()
444 gname = pctlops->get_group_name(pctldev, in pinmux_enable_setting()
446 dev_err(pctldev->dev, in pinmux_enable_setting()
450 pinctrl_dev_get_name(pctldev)); in pinmux_enable_setting()
457 desc = pin_desc_get(pctldev, pins[i]); in pinmux_enable_setting()
459 dev_warn(pctldev->dev, in pinmux_enable_setting()
467 ret = ops->set_mux(pctldev, setting->data.mux.func, in pinmux_enable_setting()
477 desc = pin_desc_get(pctldev, pins[i]); in pinmux_enable_setting()
484 pin_free(pctldev, pins[i], NULL); in pinmux_enable_setting()
491 struct pinctrl_dev *pctldev = setting->pctldev; in pinmux_disable_setting() local
492 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinmux_disable_setting()
500 ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, in pinmux_disable_setting()
506 gname = pctlops->get_group_name(pctldev, in pinmux_disable_setting()
508 dev_warn(pctldev->dev, in pinmux_disable_setting()
516 desc = pin_desc_get(pctldev, pins[i]); in pinmux_disable_setting()
518 dev_warn(pctldev->dev, in pinmux_disable_setting()
524 pin_free(pctldev, pins[i], NULL); in pinmux_disable_setting()
528 gname = pctlops->get_group_name(pctldev, in pinmux_disable_setting()
530 dev_warn(pctldev->dev, in pinmux_disable_setting()
544 struct pinctrl_dev *pctldev = s->private; in pinmux_functions_show() local
545 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; in pinmux_functions_show()
552 mutex_lock(&pctldev->mutex); in pinmux_functions_show()
553 nfuncs = pmxops->get_functions_count(pctldev); in pinmux_functions_show()
555 const char *func = pmxops->get_function_name(pctldev, in pinmux_functions_show()
562 ret = pmxops->get_function_groups(pctldev, func_selector, in pinmux_functions_show()
579 mutex_unlock(&pctldev->mutex); in pinmux_functions_show()
586 struct pinctrl_dev *pctldev = s->private; in pinmux_pins_show() local
587 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinmux_pins_show()
588 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; in pinmux_pins_show()
602 mutex_lock(&pctldev->mutex); in pinmux_pins_show()
605 for (i = 0; i < pctldev->desc->npins; i++) { in pinmux_pins_show()
609 pin = pctldev->desc->pins[i].number; in pinmux_pins_show()
610 desc = pin_desc_get(pctldev, pin); in pinmux_pins_show()
616 !strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev))) in pinmux_pins_show()
643 pmxops->get_function_name(pctldev, in pinmux_pins_show()
645 pctlops->get_group_name(pctldev, in pinmux_pins_show()
651 mutex_unlock(&pctldev->mutex); in pinmux_pins_show()
666 struct pinctrl_dev *pctldev = setting->pctldev; in pinmux_show_setting() local
667 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; in pinmux_show_setting()
668 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinmux_show_setting()
671 pctlops->get_group_name(pctldev, setting->data.mux.group), in pinmux_show_setting()
673 pmxops->get_function_name(pctldev, setting->data.mux.func), in pinmux_show_setting()
684 struct pinctrl_dev *pctldev = sfile->private; in pinmux_select() local
685 const struct pinmux_ops *pmxops = pctldev->desc->pmxops; in pinmux_select()
718 ret = pinmux_func_name_to_selector(pctldev, fname); in pinmux_select()
720 dev_err(pctldev->dev, "invalid function %s in map table\n", fname); in pinmux_select()
725 ret = pmxops->get_function_groups(pctldev, fsel, &groups, &num_groups); in pinmux_select()
727 dev_err(pctldev->dev, "no groups for function %d (%s)", fsel, fname); in pinmux_select()
733 dev_err(pctldev->dev, "invalid group %s", gname); in pinmux_select()
737 ret = pinctrl_get_group_selector(pctldev, gname); in pinmux_select()
742 ret = pmxops->set_mux(pctldev, fsel, gsel); in pinmux_select()
744 dev_err(pctldev->dev, "set_mux() failed: %d", ret); in pinmux_select()
769 struct pinctrl_dev *pctldev) in pinmux_init_device_debugfs() argument
772 devroot, pctldev, &pinmux_functions_fops); in pinmux_init_device_debugfs()
774 devroot, pctldev, &pinmux_pins_fops); in pinmux_init_device_debugfs()
776 devroot, pctldev, &pinmux_select_ops); in pinmux_init_device_debugfs()
787 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev) in pinmux_generic_get_function_count() argument
789 return pctldev->num_functions; in pinmux_generic_get_function_count()
799 pinmux_generic_get_function_name(struct pinctrl_dev *pctldev, in pinmux_generic_get_function_name() argument
804 function = radix_tree_lookup(&pctldev->pin_function_tree, in pinmux_generic_get_function_name()
820 int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev, in pinmux_generic_get_function_groups() argument
827 function = radix_tree_lookup(&pctldev->pin_function_tree, in pinmux_generic_get_function_groups()
830 dev_err(pctldev->dev, "%s could not find function%i\n", in pinmux_generic_get_function_groups()
846 struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev, in pinmux_generic_get_function() argument
851 function = radix_tree_lookup(&pctldev->pin_function_tree, in pinmux_generic_get_function()
868 int pinmux_generic_add_function(struct pinctrl_dev *pctldev, in pinmux_generic_add_function() argument
880 selector = pinmux_func_name_to_selector(pctldev, name); in pinmux_generic_add_function()
884 selector = pctldev->num_functions; in pinmux_generic_add_function()
886 function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL); in pinmux_generic_add_function()
895 error = radix_tree_insert(&pctldev->pin_function_tree, selector, function); in pinmux_generic_add_function()
899 pctldev->num_functions++; in pinmux_generic_add_function()
912 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev, in pinmux_generic_remove_function() argument
917 function = radix_tree_lookup(&pctldev->pin_function_tree, in pinmux_generic_remove_function()
922 radix_tree_delete(&pctldev->pin_function_tree, selector); in pinmux_generic_remove_function()
923 devm_kfree(pctldev->dev, function); in pinmux_generic_remove_function()
925 pctldev->num_functions--; in pinmux_generic_remove_function()
939 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev) in pinmux_generic_free_functions() argument
944 radix_tree_for_each_slot(slot, &pctldev->pin_function_tree, &iter, 0) in pinmux_generic_free_functions()
945 radix_tree_delete(&pctldev->pin_function_tree, iter.index); in pinmux_generic_free_functions()
947 pctldev->num_functions = 0; in pinmux_generic_free_functions()