diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-21 16:48:47 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-04-23 09:36:13 +0200 |
commit | 7f63c0a246751e5424e7916fd1e20fe479a1dcfa (patch) | |
tree | 7a36d43619d95818b14365cf2f428c9169b3265d /include/pinctrl.h | |
parent | cd23160af8b4e342bb3af116d8e5b4e262ac9083 (diff) | |
download | barebox-7f63c0a246751e5424e7916fd1e20fe479a1dcfa.tar.gz barebox-7f63c0a246751e5424e7916fd1e20fe479a1dcfa.tar.xz |
Add initial pinctrl support
This is a massively stripped down pinctrl support. The upper API
consists of only of:
int pinctrl_select_state(struct device_d *dev, const char *state);
This is used to setup the pinmux for a device to a certain state.
This function normally does not need to be called manually. The
device core will setup the default state before probing a device.
The pinctrl core has the job of handling the devicetree. It parses
the pinctrl phandles for a device from devicetree, finds the correct
pinctrl device and calls its set_state callback with the pinctrl
setup device node.
The simplicity of this pinctrl framework comes from the fact that
we:
- Limit usage to devicetree only for now. For non devicetree use the
old legacy SoC specific APIs still can be used.
- Do not parse the devicetree into internal data structures which
are used by the drivers later. This adds the overhead that we
may parse the devicetree multiple times for more dynamic setups,
but on the other hand we do not need to parse devices from the
devicetree we don't use in barebox
- Do not detect resource conflicts. Since the framework mainly is
a devicetree parser this would be hard to implement. It should
be easy for board maintainers to avoid resource conflicts though.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/pinctrl.h')
-rw-r--r-- | include/pinctrl.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/pinctrl.h b/include/pinctrl.h new file mode 100644 index 0000000000..7323f8b2f2 --- /dev/null +++ b/include/pinctrl.h @@ -0,0 +1,35 @@ +#ifndef PINCTRL_H +#define PINCTRL_H + +struct pinctrl_device; + +struct pinctrl_ops { + int (*set_state)(struct pinctrl_device *, struct device_node *); +}; + +struct pinctrl_device { + struct device_d *dev; + struct pinctrl_ops *ops; + struct list_head list; + struct device_node *node; +}; + +int pinctrl_register(struct pinctrl_device *pdev); +void pinctrl_unregister(struct pinctrl_device *pdev); + +#ifdef CONFIG_PINCTRL +int pinctrl_select_state(struct device_d *dev, const char *state); +int pinctrl_select_state_default(struct device_d *dev); +#else +static inline int pinctrl_select_state(struct device_d *dev, const char *state) +{ + return -ENODEV; +} + +static inline int pinctrl_select_state_default(struct device_d *dev) +{ + return -ENODEV; +} +#endif + +#endif /* PINCTRL_H */ |