pinmux.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Interface the pinmux subsystem
  3. *
  4. * Copyright (C) 2011 ST-Ericsson SA
  5. * Written on behalf of Linaro for ST-Ericsson
  6. * Based on bits of regulator core, gpio core and clk core
  7. *
  8. * Author: Linus Walleij <linus.walleij@linaro.org>
  9. *
  10. * License terms: GNU General Public License (GPL) version 2
  11. */
  12. #ifndef __LINUX_PINCTRL_PINMUX_H
  13. #define __LINUX_PINCTRL_PINMUX_H
  14. #include <linux/list.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/pinctrl/pinctrl.h>
  17. #ifdef CONFIG_PINMUX
  18. struct pinctrl_dev;
  19. /**
  20. * struct pinmux_ops - pinmux operations, to be implemented by pin controller
  21. * drivers that support pinmuxing
  22. * @request: called by the core to see if a certain pin can be made
  23. * available for muxing. This is called by the core to acquire the pins
  24. * before selecting any actual mux setting across a function. The driver
  25. * is allowed to answer "no" by returning a negative error code
  26. * @free: the reverse function of the request() callback, frees a pin after
  27. * being requested
  28. * @get_functions_count: returns number of selectable named functions available
  29. * in this pinmux driver
  30. * @get_function_name: return the function name of the muxing selector,
  31. * called by the core to figure out which mux setting it shall map a
  32. * certain device to
  33. * @get_function_groups: return an array of groups names (in turn
  34. * referencing pins) connected to a certain function selector. The group
  35. * name can be used with the generic @pinctrl_ops to retrieve the
  36. * actual pins affected. The applicable groups will be returned in
  37. * @groups and the number of groups in @num_groups
  38. * @set_mux: enable a certain muxing function with a certain pin group. The
  39. * driver does not need to figure out whether enabling this function
  40. * conflicts some other use of the pins in that group, such collisions
  41. * are handled by the pinmux subsystem. The @func_selector selects a
  42. * certain function whereas @group_selector selects a certain set of pins
  43. * to be used. On simple controllers the latter argument may be ignored
  44. * @gpio_request_enable: requests and enables GPIO on a certain pin.
  45. * Implement this only if you can mux every pin individually as GPIO. The
  46. * affected GPIO range is passed along with an offset(pin number) into that
  47. * specific GPIO range - function selectors and pin groups are orthogonal
  48. * to this, the core will however make sure the pins do not collide.
  49. * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
  50. * @gpio_request_enable
  51. * @gpio_set_direction: Since controllers may need different configurations
  52. * depending on whether the GPIO is configured as input or output,
  53. * a direction selector function may be implemented as a backing
  54. * to the GPIO controllers that need pin muxing.
  55. */
  56. struct pinmux_ops {
  57. int (*request) (struct pinctrl_dev *pctldev, unsigned offset);
  58. int (*free) (struct pinctrl_dev *pctldev, unsigned offset);
  59. int (*get_functions_count) (struct pinctrl_dev *pctldev);
  60. const char *(*get_function_name) (struct pinctrl_dev *pctldev,
  61. unsigned selector);
  62. int (*get_function_groups) (struct pinctrl_dev *pctldev,
  63. unsigned selector,
  64. const char * const **groups,
  65. unsigned * const num_groups);
  66. int (*set_mux) (struct pinctrl_dev *pctldev, unsigned func_selector,
  67. unsigned group_selector);
  68. int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
  69. struct pinctrl_gpio_range *range,
  70. unsigned offset);
  71. void (*gpio_disable_free) (struct pinctrl_dev *pctldev,
  72. struct pinctrl_gpio_range *range,
  73. unsigned offset);
  74. int (*gpio_set_direction) (struct pinctrl_dev *pctldev,
  75. struct pinctrl_gpio_range *range,
  76. unsigned offset,
  77. bool input);
  78. };
  79. #endif /* CONFIG_PINMUX */
  80. #endif /* __LINUX_PINCTRL_PINMUX_H */