diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-05-02 14:50:54 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@stericsson.com> | 2011-10-13 06:49:17 -0400 |
commit | 2744e8afb3b76343e7eb8197e8b3e085036010a5 (patch) | |
tree | 2a96122ef4a6114483bda0fe9696d61a6e6f1bb5 /include/linux | |
parent | a102a9ece5489e1718cd7543aa079082450ac3a2 (diff) |
drivers: create a pin control subsystem
This creates a subsystem for handling of pin control devices.
These are devices that control different aspects of package
pins.
Currently it handles pinmuxing, i.e. assigning electronic
functions to groups of pins on primarily PGA and BGA type of
chip packages which are common in embedded systems.
The plan is to also handle other I/O pin control aspects
such as biasing, driving, input properties such as
schmitt-triggering, load capacitance etc within this
subsystem, to remove a lot of ARM arch code as well as
feature-creepy GPIO drivers which are implementing the same
thing over and over again.
This is being done to depopulate the arch/arm/* directory
of such custom drivers and try to abstract the infrastructure
they all need. See the Documentation/pinctrl.txt file that is
part of this patch for more details.
ChangeLog v1->v2:
- Various minor fixes from Joe's and Stephens review comments
- Added a pinmux_config() that can invoke custom configuration
with arbitrary data passed in or out to/from the pinmux driver
ChangeLog v2->v3:
- Renamed subsystem folder to "pinctrl" since we will likely
want to keep other pin control such as biasing in this
subsystem too, so let us keep to something generic even though
we're mainly doing pinmux now.
- As a consequence, register pins as an abstract entity separate
from the pinmux. The muxing functions will claim pins out of the
pin pool and make sure they do not collide. Pins can now be
named by the pinctrl core.
- Converted the pin lookup from a static array into a radix tree,
I agreed with Grant Likely to try to avoid any static allocation
(which is crap for device tree stuff) so I just rewrote this
to be dynamic, just like irq number descriptors. The
platform-wide definition of number of pins goes away - this is
now just the sum total of the pins registered to the subsystem.
- Make sure mappings with only a function name and no device
works properly.
ChangeLog v3->v4:
- Define a number space per controller instead of globally,
Stephen and Grant requested the same thing so now maps need to
define target controller, and the radix tree of pin descriptors
is a property on each pin controller device.
- Add a compulsory pinctrl device entry to the pinctrl mapping
table. This must match the pinctrl device, like "pinctrl.0"
- Split the file core.c in two: core.c and pinmux.c where the
latter carry all pinmux stuff, the core is for generic pin
control, and use local headers to access functionality between
files. It is now possible to implement a "blank" pin controller
without pinmux capabilities. This split will make new additions
like pindrive.c, pinbias.c etc possible for combined drivers
and chunks of functionality which is a GoodThing(TM).
- Rewrite the interaction with the GPIO subsystem - the pin
controller descriptor now handles this by defining an offset
into the GPIO numberspace for its handled pin range. This is
used to look up the apropriate pin controller for a GPIO pin.
Then that specific GPIO range is matched 1-1 for the target
controller instance.
- Fixed a number of review comments from Joe Perches.
- Broke out a header file pinctrl.h for the core pin handling
stuff that will be reused by other stuff than pinmux.
- Fixed some erroneous EXPORT() stuff.
- Remove mispatched U300 Kconfig and Makefile entries
- Fixed a number of review comments from Stephen Warren, not all
of them - still WIP. But I think the new mapping that will
specify which function goes to which pin mux controller address
50% of your concerns (else beat me up).
ChangeLog v4->v5:
- Defined a "position" for each function, so the pin controller now
tracks a function in a certain position, and the pinmux maps define
what position you want the function in. (Feedback from Stephen
Warren and Sascha Hauer).
- Since we now need to request a combined function+position from
the machine mapping table that connect mux settings to drivers,
it was extended with a position field and a name field. The
name field is now used if you e.g. need to switch between two
mux map settings at runtime.
- Switched from a class device to using struct bus_type for this
subsystem. Verified sysfs functionality: seems to work fine.
(Feedback from Arnd Bergmann and Greg Kroah-Hartman)
- Define a per pincontroller list of GPIO ranges from the GPIO
pin space that can be handled by the pin controller. These can
be added one by one at runtime. (Feedback from Barry Song)
- Expanded documentation of regulator_[get|enable|disable|put]
semantics.
- Fixed a number of review comments from Barry Song. (Thanks!)
ChangeLog v5->v6:
- Create an abstract pin group concept that can sort pins into
named and enumerated groups no matter what the use of these
groups may be, one possible usecase is a group of pins being
muxed in or so. The intention is however to also use these
groups for other pin control activities.
- Make it compulsory for pinmux functions to associate with
at least one group, so the abstract pin group concept is used
to define the groups of pins affected by a pinmux function.
The pinmux driver interface has been altered so as to enforce
a function to list applicable groups per function.
- Provide an optional .group entry in the pinmux machine map
so the map can select beteween different available groups
to be used with a certain function.
- Consequent changes all over the place so that e.g. debugfs
present reasonable information about the world.
- Drop the per-pin mux (*config) function in the pinmux_ops
struct - I was afraid that this would start to be used for
things totally unrelated to muxing, we can introduce that to
the generic struct pinctrl_ops if needed. I want to keep
muxing orthogonal to other pin control subjects and not mix
these things up.
ChangeLog v6->v7:
- Make it possible to have several map entries matching the
same device, pin controller and function, but using
a different group, and alter the semantics so that
pinmux_get() will pick all matching map entries, and
store the associated groups in a list. The list will
then be iterated over at pinmux_enable()/pinmux_disable()
and corresponding driver functions called for each
defined group. Notice that you're only allowed to map
multiple *groups* to the same
{ device, pin controller, function } triplet, attempts
to map the same device to multiple pin controllers will
for example fail. This is hopefully the crucial feature
requested by Stephen Warren.
- Add a pinmux hogging field to the pinmux mapping entries,
and enable the pinmux core to hog pinmux map entries.
This currently only works for pinmuxes without assigned
devices as it looks now, but with device trees we can
look up the corresponding struct device * entries when
we register the pinmux driver, and have it hog each
pinmux map in turn, for a simple approach to
non-dynamic pin muxing. This addresses an issue from
Grant Likely that the machine should take care of as
much of the pinmux setup as possible, not the devices.
By supplying a list of hogs, it can now instruct the
core to take care of any static mappings.
- Switch pinmux group retrieveal function to grab an
array of strings representing the groups rather than an
array of unsigned and rewrite accordingly.
- Alter debugfs to show the grouplist handled by each
pinmux. Also add a list of hogs.
- Dynamically allocate a struct pinmux at pinmux_get() and
free it at pinmux_put(), then add these to the global
list of pinmuxes active as we go along.
- Go over the list of pinmux maps at pinmux_get() time
and repeatedly apply matches.
- Retrieve applicable groups per function from the driver
as a string array rather than a unsigned array, then
lookup the enumerators.
- Make the device to pinmux map a singleton - only allow the
mapping table to be registered once and even tag the
registration function with __init so it surely won't be
abused.
- Create a separate debugfs file to view the pinmux map at
runtime.
- Introduce a spin lock to the pin descriptor struct, lock it
when modifying pin status entries. Reported by Stijn Devriendt.
- Fix up the documentation after review from Stephen Warren.
- Let the GPIO ranges give names as const char * instead of some
fixed-length string.
- add a function to unregister GPIO ranges to mirror the
registration function.
- Privatized the struct pinctrl_device and removed it from the
<linux/pinctrl/pinctrl.h> API, the drivers do not need to know
the members of this struct. It is now in the local header
"core.h".
- Rename the concept of "anonymous" mux maps to "system" muxes
and add convenience macros and documentation.
ChangeLog v7->v8:
- Delete the leftover pinmux_config() function from the
<linux/pinctrl/pinmux.h> header.
- Fix a race condition found by Stijn Devriendt in pin_request()
ChangeLog v8->v9:
- Drop the bus_type and the sysfs attributes and all, we're not on
the clear about how this should be used for e.g. userspace
interfaces so let us save this for the future.
- Use the right name in MAINTAINERS, PIN CONTROL rather than
PINMUX
- Don't kfree() the device state holder, let the .remove() callback
handle this.
- Fix up numerous kerneldoc headers to have one line for the function
description and more verbose documentation below the parameters
ChangeLog v9->v10:
- pinctrl: EXPORT_SYMBOL needs export.h, folded in a patch
from Steven Rothwell
- fix pinctrl_register error handling, folded in a patch from
Axel Lin
- Various fixes to documentation text so that it's consistent.
- Removed pointless comment from drivers/Kconfig
- Removed dependency on SYSFS since we removed the bus in
v9.
- Renamed hopelessly abbreviated pctldev_* functions to the
more verbose pinctrl_dev_*
- Drop mutex properly when looking up GPIO ranges
- Return NULL instead of ERR_PTR() errors on registration of
pin controllers, using cast pointers is fragile. We can
live without the detailed error codes for sure.
Cc: Stijn Devriendt <highguy@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Barry Song <21cnbao@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/pinctrl/machine.h | 107 | ||||
-rw-r--r-- | include/linux/pinctrl/pinctrl.h | 133 | ||||
-rw-r--r-- | include/linux/pinctrl/pinmux.h | 117 |
3 files changed, 357 insertions, 0 deletions
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h new file mode 100644 index 000000000000..88863531d862 --- /dev/null +++ b/include/linux/pinctrl/machine.h | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * Machine interface for the pinctrl 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_PINMUX_MACHINE_H | ||
13 | #define __LINUX_PINMUX_MACHINE_H | ||
14 | |||
15 | /** | ||
16 | * struct pinmux_map - boards/machines shall provide this map for devices | ||
17 | * @name: the name of this specific map entry for the particular machine. | ||
18 | * This is the second parameter passed to pinmux_get() when you want | ||
19 | * to have several mappings to the same device | ||
20 | * @ctrl_dev: the pin control device to be used by this mapping, may be NULL | ||
21 | * if you provide .ctrl_dev_name instead (this is more common) | ||
22 | * @ctrl_dev_name: the name of the device controlling this specific mapping, | ||
23 | * the name must be the same as in your struct device*, may be NULL if | ||
24 | * you provide .ctrl_dev instead | ||
25 | * @function: a function in the driver to use for this mapping, the driver | ||
26 | * will lookup the function referenced by this ID on the specified | ||
27 | * pin control device | ||
28 | * @group: sometimes a function can map to different pin groups, so this | ||
29 | * selects a certain specific pin group to activate for the function, if | ||
30 | * left as NULL, the first applicable group will be used | ||
31 | * @dev: the device using this specific mapping, may be NULL if you provide | ||
32 | * .dev_name instead (this is more common) | ||
33 | * @dev_name: the name of the device using this specific mapping, the name | ||
34 | * must be the same as in your struct device*, may be NULL if you | ||
35 | * provide .dev instead | ||
36 | * @hog_on_boot: if this is set to true, the pin control subsystem will itself | ||
37 | * hog the mappings as the pinmux device drivers are attached, so this is | ||
38 | * typically used with system maps (mux mappings without an assigned | ||
39 | * device) that you want to get hogged and enabled by default as soon as | ||
40 | * a pinmux device supporting it is registered. These maps will not be | ||
41 | * disabled and put until the system shuts down. | ||
42 | */ | ||
43 | struct pinmux_map { | ||
44 | const char *name; | ||
45 | struct device *ctrl_dev; | ||
46 | const char *ctrl_dev_name; | ||
47 | const char *function; | ||
48 | const char *group; | ||
49 | struct device *dev; | ||
50 | const char *dev_name; | ||
51 | const bool hog_on_boot; | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * Convenience macro to set a simple map from a certain pin controller and a | ||
56 | * certain function to a named device | ||
57 | */ | ||
58 | #define PINMUX_MAP(a, b, c, d) \ | ||
59 | { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d } | ||
60 | |||
61 | /* | ||
62 | * Convenience macro to map a system function onto a certain pinctrl device. | ||
63 | * System functions are not assigned to a particular device. | ||
64 | */ | ||
65 | #define PINMUX_MAP_SYS(a, b, c) \ | ||
66 | { .name = a, .ctrl_dev_name = b, .function = c } | ||
67 | |||
68 | /* | ||
69 | * Convenience macro to map a function onto the primary device pinctrl device | ||
70 | * this is especially helpful on systems that have only one pin controller | ||
71 | * or need to set up a lot of mappings on the primary controller. | ||
72 | */ | ||
73 | #define PINMUX_MAP_PRIMARY(a, b, c) \ | ||
74 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \ | ||
75 | .dev_name = c } | ||
76 | |||
77 | /* | ||
78 | * Convenience macro to map a system function onto the primary pinctrl device. | ||
79 | * System functions are not assigned to a particular device. | ||
80 | */ | ||
81 | #define PINMUX_MAP_PRIMARY_SYS(a, b) \ | ||
82 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b } | ||
83 | |||
84 | /* | ||
85 | * Convenience macro to map a system function onto the primary pinctrl device, | ||
86 | * to be hogged by the pinmux core until the system shuts down. | ||
87 | */ | ||
88 | #define PINMUX_MAP_PRIMARY_SYS_HOG(a, b) \ | ||
89 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \ | ||
90 | .hog_on_boot = true } | ||
91 | |||
92 | |||
93 | #ifdef CONFIG_PINMUX | ||
94 | |||
95 | extern int pinmux_register_mappings(struct pinmux_map const *map, | ||
96 | unsigned num_maps); | ||
97 | |||
98 | #else | ||
99 | |||
100 | static inline int pinmux_register_mappings(struct pinmux_map const *map, | ||
101 | unsigned num_maps) | ||
102 | { | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | #endif /* !CONFIG_PINMUX */ | ||
107 | #endif | ||
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h new file mode 100644 index 000000000000..4f8d2089acce --- /dev/null +++ b/include/linux/pinctrl/pinctrl.h | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Interface the pinctrl subsystem | ||
3 | * | ||
4 | * Copyright (C) 2011 ST-Ericsson SA | ||
5 | * Written on behalf of Linaro for ST-Ericsson | ||
6 | * This interface is used in the core to keep track of pins. | ||
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_PINCTRL_H | ||
13 | #define __LINUX_PINCTRL_PINCTRL_H | ||
14 | |||
15 | #ifdef CONFIG_PINCTRL | ||
16 | |||
17 | #include <linux/radix-tree.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | #include <linux/list.h> | ||
20 | #include <linux/seq_file.h> | ||
21 | |||
22 | struct pinctrl_dev; | ||
23 | struct pinmux_ops; | ||
24 | struct gpio_chip; | ||
25 | |||
26 | /** | ||
27 | * struct pinctrl_pin_desc - boards/machines provide information on their | ||
28 | * pins, pads or other muxable units in this struct | ||
29 | * @number: unique pin number from the global pin number space | ||
30 | * @name: a name for this pin | ||
31 | */ | ||
32 | struct pinctrl_pin_desc { | ||
33 | unsigned number; | ||
34 | const char *name; | ||
35 | }; | ||
36 | |||
37 | /* Convenience macro to define a single named or anonymous pin descriptor */ | ||
38 | #define PINCTRL_PIN(a, b) { .number = a, .name = b } | ||
39 | #define PINCTRL_PIN_ANON(a) { .number = a } | ||
40 | |||
41 | /** | ||
42 | * struct pinctrl_gpio_range - each pin controller can provide subranges of | ||
43 | * the GPIO number space to be handled by the controller | ||
44 | * @node: list node for internal use | ||
45 | * @name: a name for the chip in this range | ||
46 | * @id: an ID number for the chip in this range | ||
47 | * @base: base offset of the GPIO range | ||
48 | * @npins: number of pins in the GPIO range, including the base number | ||
49 | * @gc: an optional pointer to a gpio_chip | ||
50 | */ | ||
51 | struct pinctrl_gpio_range { | ||
52 | struct list_head node; | ||
53 | const char *name; | ||
54 | unsigned int id; | ||
55 | unsigned int base; | ||
56 | unsigned int npins; | ||
57 | struct gpio_chip *gc; | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * struct pinctrl_ops - global pin control operations, to be implemented by | ||
62 | * pin controller drivers. | ||
63 | * @list_groups: list the number of selectable named groups available | ||
64 | * in this pinmux driver, the core will begin on 0 and call this | ||
65 | * repeatedly as long as it returns >= 0 to enumerate the groups | ||
66 | * @get_group_name: return the group name of the pin group | ||
67 | * @get_group_pins: return an array of pins corresponding to a certain | ||
68 | * group selector @pins, and the size of the array in @num_pins | ||
69 | * @pin_dbg_show: optional debugfs display hook that will provide per-device | ||
70 | * info for a certain pin in debugfs | ||
71 | */ | ||
72 | struct pinctrl_ops { | ||
73 | int (*list_groups) (struct pinctrl_dev *pctldev, unsigned selector); | ||
74 | const char *(*get_group_name) (struct pinctrl_dev *pctldev, | ||
75 | unsigned selector); | ||
76 | int (*get_group_pins) (struct pinctrl_dev *pctldev, | ||
77 | unsigned selector, | ||
78 | unsigned ** const pins, | ||
79 | unsigned * const num_pins); | ||
80 | void (*pin_dbg_show) (struct pinctrl_dev *pctldev, struct seq_file *s, | ||
81 | unsigned offset); | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * struct pinctrl_desc - pin controller descriptor, register this to pin | ||
86 | * control subsystem | ||
87 | * @name: name for the pin controller | ||
88 | * @pins: an array of pin descriptors describing all the pins handled by | ||
89 | * this pin controller | ||
90 | * @npins: number of descriptors in the array, usually just ARRAY_SIZE() | ||
91 | * of the pins field above | ||
92 | * @maxpin: since pin spaces may be sparse, there can he "holes" in the | ||
93 | * pin range, this attribute gives the maximum pin number in the | ||
94 | * total range. This should not be lower than npins for example, | ||
95 | * but may be equal to npins if you have no holes in the pin range. | ||
96 | * @pctlops: pin control operation vtable, to support global concepts like | ||
97 | * grouping of pins, this is optional. | ||
98 | * @pmxops: pinmux operation vtable, if you support pinmuxing in your driver | ||
99 | * @owner: module providing the pin controller, used for refcounting | ||
100 | */ | ||
101 | struct pinctrl_desc { | ||
102 | const char *name; | ||
103 | struct pinctrl_pin_desc const *pins; | ||
104 | unsigned int npins; | ||
105 | unsigned int maxpin; | ||
106 | struct pinctrl_ops *pctlops; | ||
107 | struct pinmux_ops *pmxops; | ||
108 | struct module *owner; | ||
109 | }; | ||
110 | |||
111 | /* External interface to pin controller */ | ||
112 | extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | ||
113 | struct device *dev, void *driver_data); | ||
114 | extern void pinctrl_unregister(struct pinctrl_dev *pctldev); | ||
115 | extern bool pin_is_valid(struct pinctrl_dev *pctldev, int pin); | ||
116 | extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev, | ||
117 | struct pinctrl_gpio_range *range); | ||
118 | extern void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev, | ||
119 | struct pinctrl_gpio_range *range); | ||
120 | extern const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev); | ||
121 | extern void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev); | ||
122 | #else | ||
123 | |||
124 | |||
125 | /* Sufficiently stupid default function when pinctrl is not in use */ | ||
126 | static inline bool pin_is_valid(struct pinctrl_dev *pctldev, int pin) | ||
127 | { | ||
128 | return pin >= 0; | ||
129 | } | ||
130 | |||
131 | #endif /* !CONFIG_PINCTRL */ | ||
132 | |||
133 | #endif /* __LINUX_PINCTRL_PINCTRL_H */ | ||
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h new file mode 100644 index 000000000000..3c430e797efc --- /dev/null +++ b/include/linux/pinctrl/pinmux.h | |||
@@ -0,0 +1,117 @@ | |||
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 | |||
15 | #include <linux/list.h> | ||
16 | #include <linux/seq_file.h> | ||
17 | #include "pinctrl.h" | ||
18 | |||
19 | /* This struct is private to the core and should be regarded as a cookie */ | ||
20 | struct pinmux; | ||
21 | |||
22 | #ifdef CONFIG_PINMUX | ||
23 | |||
24 | struct pinctrl_dev; | ||
25 | |||
26 | /** | ||
27 | * struct pinmux_ops - pinmux operations, to be implemented by pin controller | ||
28 | * drivers that support pinmuxing | ||
29 | * @request: called by the core to see if a certain pin can be made available | ||
30 | * available for muxing. This is called by the core to acquire the pins | ||
31 | * before selecting any actual mux setting across a function. The driver | ||
32 | * is allowed to answer "no" by returning a negative error code | ||
33 | * @free: the reverse function of the request() callback, frees a pin after | ||
34 | * being requested | ||
35 | * @list_functions: list the number of selectable named functions available | ||
36 | * in this pinmux driver, the core will begin on 0 and call this | ||
37 | * repeatedly as long as it returns >= 0 to enumerate mux settings | ||
38 | * @get_function_name: return the function name of the muxing selector, | ||
39 | * called by the core to figure out which mux setting it shall map a | ||
40 | * certain device to | ||
41 | * @get_function_groups: return an array of groups names (in turn | ||
42 | * referencing pins) connected to a certain function selector. The group | ||
43 | * name can be used with the generic @pinctrl_ops to retrieve the | ||
44 | * actual pins affected. The applicable groups will be returned in | ||
45 | * @groups and the number of groups in @num_groups | ||
46 | * @enable: enable a certain muxing function with a certain pin group. The | ||
47 | * driver does not need to figure out whether enabling this function | ||
48 | * conflicts some other use of the pins in that group, such collisions | ||
49 | * are handled by the pinmux subsystem. The @func_selector selects a | ||
50 | * certain function whereas @group_selector selects a certain set of pins | ||
51 | * to be used. On simple controllers the latter argument may be ignored | ||
52 | * @disable: disable a certain muxing selector with a certain pin group | ||
53 | * @gpio_request_enable: requests and enables GPIO on a certain pin. | ||
54 | * Implement this only if you can mux every pin individually as GPIO. The | ||
55 | * affected GPIO range is passed along with an offset into that | ||
56 | * specific GPIO range - function selectors and pin groups are orthogonal | ||
57 | * to this, the core will however make sure the pins do not collide | ||
58 | */ | ||
59 | struct pinmux_ops { | ||
60 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); | ||
61 | int (*free) (struct pinctrl_dev *pctldev, unsigned offset); | ||
62 | int (*list_functions) (struct pinctrl_dev *pctldev, unsigned selector); | ||
63 | const char *(*get_function_name) (struct pinctrl_dev *pctldev, | ||
64 | unsigned selector); | ||
65 | int (*get_function_groups) (struct pinctrl_dev *pctldev, | ||
66 | unsigned selector, | ||
67 | const char * const **groups, | ||
68 | unsigned * const num_groups); | ||
69 | int (*enable) (struct pinctrl_dev *pctldev, unsigned func_selector, | ||
70 | unsigned group_selector); | ||
71 | void (*disable) (struct pinctrl_dev *pctldev, unsigned func_selector, | ||
72 | unsigned group_selector); | ||
73 | int (*gpio_request_enable) (struct pinctrl_dev *pctldev, | ||
74 | struct pinctrl_gpio_range *range, | ||
75 | unsigned offset); | ||
76 | }; | ||
77 | |||
78 | /* External interface to pinmux */ | ||
79 | extern int pinmux_request_gpio(unsigned gpio); | ||
80 | extern void pinmux_free_gpio(unsigned gpio); | ||
81 | extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); | ||
82 | extern void pinmux_put(struct pinmux *pmx); | ||
83 | extern int pinmux_enable(struct pinmux *pmx); | ||
84 | extern void pinmux_disable(struct pinmux *pmx); | ||
85 | |||
86 | #else /* !CONFIG_PINMUX */ | ||
87 | |||
88 | static inline int pinmux_request_gpio(unsigned gpio) | ||
89 | { | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static inline void pinmux_free_gpio(unsigned gpio) | ||
94 | { | ||
95 | } | ||
96 | |||
97 | static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) | ||
98 | { | ||
99 | return NULL; | ||
100 | } | ||
101 | |||
102 | static inline void pinmux_put(struct pinmux *pmx) | ||
103 | { | ||
104 | } | ||
105 | |||
106 | static inline int pinmux_enable(struct pinmux *pmx) | ||
107 | { | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static inline void pinmux_disable(struct pinmux *pmx) | ||
112 | { | ||
113 | } | ||
114 | |||
115 | #endif /* CONFIG_PINMUX */ | ||
116 | |||
117 | #endif /* __LINUX_PINCTRL_PINMUX_H */ | ||