Commit 28a8d14cc74a0180323d9150c3d3dbf9dd60d55a

Authored by Linus Walleij
1 parent f4e6698329

pinctrl: break out a pinctrl consumer header

This breaks out a <linux/pinctrl/consumer.h> header to be used by
all pinmux and pinconfig alike, so drivers needing services from
pinctrl does not need to include different headers. This is similar
to the approach taken by the regulator API.

Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Showing 6 changed files with 125 additions and 94 deletions Side-by-side Diff

Documentation/pinctrl.txt
... ... @@ -208,6 +208,8 @@
208 208  
209 209 For example, a platform may do this:
210 210  
  211 +#include <linux/pinctrl/consumer.h>
  212 +
211 213 ret = pin_config_set("foo-dev", "FOO_GPIO_PIN", PLATFORM_X_PULL_UP);
212 214  
213 215 To pull up a pin to VDD. The pin configuration driver implements callbacks for
... ... @@ -920,7 +922,7 @@
920 922 A driver may request a certain mux to be activated, usually just the default
921 923 mux like this:
922 924  
923   -#include <linux/pinctrl/pinmux.h>
  925 +#include <linux/pinctrl/consumer.h>
924 926  
925 927 struct foo_state {
926 928 struct pinmux *pmx;
... ... @@ -1018,6 +1020,8 @@
1018 1020  
1019 1021 This snippet first muxes the function in the pins defined by group A, enables
1020 1022 it, disables and releases it, and muxes it in on the pins defined by group B:
  1023 +
  1024 +#include <linux/pinctrl/consumer.h>
1021 1025  
1022 1026 foo_switch()
1023 1027 {
arch/arm/mach-u300/core.c
... ... @@ -26,7 +26,7 @@
26 26 #include <linux/mtd/nand.h>
27 27 #include <linux/mtd/fsmc.h>
28 28 #include <linux/pinctrl/machine.h>
29   -#include <linux/pinctrl/pinmux.h>
  29 +#include <linux/pinctrl/consumer.h>
30 30 #include <linux/dma-mapping.h>
31 31  
32 32 #include <asm/types.h>
drivers/pinctrl/pinctrl-coh901.c
... ... @@ -22,7 +22,7 @@
22 22 #include <linux/gpio.h>
23 23 #include <linux/list.h>
24 24 #include <linux/slab.h>
25   -#include <linux/pinctrl/pinmux.h>
  25 +#include <linux/pinctrl/consumer.h>
26 26 #include <mach/gpio-u300.h>
27 27  
28 28 /*
include/linux/pinctrl/consumer.h
  1 +/*
  2 + * Consumer interface the pin control subsystem
  3 + *
  4 + * Copyright (C) 2012 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_CONSUMER_H
  13 +#define __LINUX_PINCTRL_CONSUMER_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 +/* External interface to pinmux */
  25 +extern int pinmux_request_gpio(unsigned gpio);
  26 +extern void pinmux_free_gpio(unsigned gpio);
  27 +extern int pinmux_gpio_direction_input(unsigned gpio);
  28 +extern int pinmux_gpio_direction_output(unsigned gpio);
  29 +extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name);
  30 +extern void pinmux_put(struct pinmux *pmx);
  31 +extern int pinmux_enable(struct pinmux *pmx);
  32 +extern void pinmux_disable(struct pinmux *pmx);
  33 +
  34 +#else /* !CONFIG_PINMUX */
  35 +
  36 +static inline int pinmux_request_gpio(unsigned gpio)
  37 +{
  38 + return 0;
  39 +}
  40 +
  41 +static inline void pinmux_free_gpio(unsigned gpio)
  42 +{
  43 +}
  44 +
  45 +static inline int pinmux_gpio_direction_input(unsigned gpio)
  46 +{
  47 + return 0;
  48 +}
  49 +
  50 +static inline int pinmux_gpio_direction_output(unsigned gpio)
  51 +{
  52 + return 0;
  53 +}
  54 +
  55 +static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name)
  56 +{
  57 + return NULL;
  58 +}
  59 +
  60 +static inline void pinmux_put(struct pinmux *pmx)
  61 +{
  62 +}
  63 +
  64 +static inline int pinmux_enable(struct pinmux *pmx)
  65 +{
  66 + return 0;
  67 +}
  68 +
  69 +static inline void pinmux_disable(struct pinmux *pmx)
  70 +{
  71 +}
  72 +
  73 +#endif /* CONFIG_PINMUX */
  74 +
  75 +#ifdef CONFIG_PINCONF
  76 +
  77 +extern int pin_config_get(const char *dev_name, const char *name,
  78 + unsigned long *config);
  79 +extern int pin_config_set(const char *dev_name, const char *name,
  80 + unsigned long config);
  81 +extern int pin_config_group_get(const char *dev_name,
  82 + const char *pin_group,
  83 + unsigned long *config);
  84 +extern int pin_config_group_set(const char *dev_name,
  85 + const char *pin_group,
  86 + unsigned long config);
  87 +
  88 +#else
  89 +
  90 +static inline int pin_config_get(const char *dev_name, const char *name,
  91 + unsigned long *config)
  92 +{
  93 + return 0;
  94 +}
  95 +
  96 +static inline int pin_config_set(const char *dev_name, const char *name,
  97 + unsigned long config)
  98 +{
  99 + return 0;
  100 +}
  101 +
  102 +static inline int pin_config_group_get(const char *dev_name,
  103 + const char *pin_group,
  104 + unsigned long *config)
  105 +{
  106 + return 0;
  107 +}
  108 +
  109 +static inline int pin_config_group_set(const char *dev_name,
  110 + const char *pin_group,
  111 + unsigned long config)
  112 +{
  113 + return 0;
  114 +}
  115 +
  116 +#endif
  117 +
  118 +#endif /* __LINUX_PINCTRL_CONSUMER_H */
include/linux/pinctrl/pinconf.h
... ... @@ -53,45 +53,6 @@
53 53 unsigned selector);
54 54 };
55 55  
56   -extern int pin_config_get(const char *dev_name, const char *name,
57   - unsigned long *config);
58   -extern int pin_config_set(const char *dev_name, const char *name,
59   - unsigned long config);
60   -extern int pin_config_group_get(const char *dev_name,
61   - const char *pin_group,
62   - unsigned long *config);
63   -extern int pin_config_group_set(const char *dev_name,
64   - const char *pin_group,
65   - unsigned long config);
66   -
67   -#else
68   -
69   -static inline int pin_config_get(const char *dev_name, const char *name,
70   - unsigned long *config)
71   -{
72   - return 0;
73   -}
74   -
75   -static inline int pin_config_set(const char *dev_name, const char *name,
76   - unsigned long config)
77   -{
78   - return 0;
79   -}
80   -
81   -static inline int pin_config_group_get(const char *dev_name,
82   - const char *pin_group,
83   - unsigned long *config)
84   -{
85   - return 0;
86   -}
87   -
88   -static inline int pin_config_group_set(const char *dev_name,
89   - const char *pin_group,
90   - unsigned long config)
91   -{
92   - return 0;
93   -}
94   -
95 56 #endif
96 57  
97 58 #endif /* __LINUX_PINCTRL_PINCONF_H */
include/linux/pinctrl/pinmux.h
... ... @@ -16,9 +16,6 @@
16 16 #include <linux/seq_file.h>
17 17 #include "pinctrl.h"
18 18  
19   -/* This struct is private to the core and should be regarded as a cookie */
20   -struct pinmux;
21   -
22 19 #ifdef CONFIG_PINMUX
23 20  
24 21 struct pinctrl_dev;
... ... @@ -87,55 +84,6 @@
87 84 unsigned offset,
88 85 bool input);
89 86 };
90   -
91   -/* External interface to pinmux */
92   -extern int pinmux_request_gpio(unsigned gpio);
93   -extern void pinmux_free_gpio(unsigned gpio);
94   -extern int pinmux_gpio_direction_input(unsigned gpio);
95   -extern int pinmux_gpio_direction_output(unsigned gpio);
96   -extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name);
97   -extern void pinmux_put(struct pinmux *pmx);
98   -extern int pinmux_enable(struct pinmux *pmx);
99   -extern void pinmux_disable(struct pinmux *pmx);
100   -
101   -#else /* !CONFIG_PINMUX */
102   -
103   -static inline int pinmux_request_gpio(unsigned gpio)
104   -{
105   - return 0;
106   -}
107   -
108   -static inline void pinmux_free_gpio(unsigned gpio)
109   -{
110   -}
111   -
112   -static inline int pinmux_gpio_direction_input(unsigned gpio)
113   -{
114   - return 0;
115   -}
116   -
117   -static inline int pinmux_gpio_direction_output(unsigned gpio)
118   -{
119   - return 0;
120   -}
121   -
122   -static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name)
123   -{
124   - return NULL;
125   -}
126   -
127   -static inline void pinmux_put(struct pinmux *pmx)
128   -{
129   -}
130   -
131   -static inline int pinmux_enable(struct pinmux *pmx)
132   -{
133   - return 0;
134   -}
135   -
136   -static inline void pinmux_disable(struct pinmux *pmx)
137   -{
138   -}
139 87  
140 88 #endif /* CONFIG_PINMUX */
141 89