Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Core driver for the pin config portions of the pin control subsystem |
| 3 | * |
| 4 | * Copyright (C) 2011 ST-Ericsson SA |
| 5 | * Written on behalf of Linaro for ST-Ericsson |
| 6 | * |
| 7 | * Author: Linus Walleij <linus.walleij@linaro.org> |
| 8 | * |
| 9 | * License terms: GNU General Public License (GPL) version 2 |
| 10 | */ |
| 11 | #define pr_fmt(fmt) "pinconfig core: " fmt |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/slab.h> |
| 18 | #include <linux/debugfs.h> |
| 19 | #include <linux/seq_file.h> |
| 20 | #include <linux/pinctrl/machine.h> |
| 21 | #include <linux/pinctrl/pinctrl.h> |
| 22 | #include <linux/pinctrl/pinconf.h> |
| 23 | #include "core.h" |
| 24 | #include "pinconf.h" |
| 25 | |
Stephen Warren | 2b69425 | 2012-02-19 23:45:46 -0700 | [diff] [blame] | 26 | int pinconf_check_ops(struct pinctrl_dev *pctldev) |
| 27 | { |
| 28 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 29 | |
| 30 | /* We must be able to read out pin status */ |
| 31 | if (!ops->pin_config_get && !ops->pin_config_group_get) |
| 32 | return -EINVAL; |
| 33 | /* We have to be able to config the pins in SOME way */ |
| 34 | if (!ops->pin_config_set && !ops->pin_config_group_set) |
| 35 | return -EINVAL; |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 40 | unsigned long *config) |
| 41 | { |
| 42 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 43 | |
| 44 | if (!ops || !ops->pin_config_get) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 45 | dev_err(pctldev->dev, "cannot get pin configuration, missing " |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 46 | "pin_config_get() function in driver\n"); |
| 47 | return -EINVAL; |
| 48 | } |
| 49 | |
| 50 | return ops->pin_config_get(pctldev, pin, config); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * pin_config_get() - get the configuration of a single pin parameter |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 55 | * @dev_name: name of the pin controller device for this pin |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 56 | * @name: name of the pin to get the config for |
| 57 | * @config: the config pointed to by this argument will be filled in with the |
| 58 | * current pin state, it can be used directly by drivers as a numeral, or |
| 59 | * it can be dereferenced to any struct. |
| 60 | */ |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 61 | int pin_config_get(const char *dev_name, const char *name, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 62 | unsigned long *config) |
| 63 | { |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 64 | struct pinctrl_dev *pctldev; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 65 | int pin; |
| 66 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 67 | mutex_lock(&pinctrl_mutex); |
| 68 | |
Linus Walleij | 9dfac4f | 2012-02-01 18:02:47 +0100 | [diff] [blame] | 69 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 70 | if (!pctldev) { |
| 71 | pin = -EINVAL; |
| 72 | goto unlock; |
| 73 | } |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 74 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 75 | pin = pin_get_from_name(pctldev, name); |
| 76 | if (pin < 0) |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 77 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 78 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 79 | pin = pin_config_get_for_pin(pctldev, pin, config); |
| 80 | |
| 81 | unlock: |
| 82 | mutex_unlock(&pinctrl_mutex); |
| 83 | return pin; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 84 | } |
| 85 | EXPORT_SYMBOL(pin_config_get); |
| 86 | |
Stephen Warren | 2b69425 | 2012-02-19 23:45:46 -0700 | [diff] [blame] | 87 | static int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 88 | unsigned long config) |
| 89 | { |
| 90 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 91 | int ret; |
| 92 | |
| 93 | if (!ops || !ops->pin_config_set) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 94 | dev_err(pctldev->dev, "cannot configure pin, missing " |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 95 | "config function in driver\n"); |
| 96 | return -EINVAL; |
| 97 | } |
| 98 | |
| 99 | ret = ops->pin_config_set(pctldev, pin, config); |
| 100 | if (ret) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 101 | dev_err(pctldev->dev, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 102 | "unable to set pin configuration on pin %d\n", pin); |
| 103 | return ret; |
| 104 | } |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * pin_config_set() - set the configuration of a single pin parameter |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 111 | * @dev_name: name of pin controller device for this pin |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 112 | * @name: name of the pin to set the config for |
| 113 | * @config: the config in this argument will contain the desired pin state, it |
| 114 | * can be used directly by drivers as a numeral, or it can be dereferenced |
| 115 | * to any struct. |
| 116 | */ |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 117 | int pin_config_set(const char *dev_name, const char *name, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 118 | unsigned long config) |
| 119 | { |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 120 | struct pinctrl_dev *pctldev; |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 121 | int pin, ret; |
| 122 | |
| 123 | mutex_lock(&pinctrl_mutex); |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 124 | |
Linus Walleij | 9dfac4f | 2012-02-01 18:02:47 +0100 | [diff] [blame] | 125 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 126 | if (!pctldev) { |
| 127 | ret = -EINVAL; |
| 128 | goto unlock; |
| 129 | } |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 130 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 131 | pin = pin_get_from_name(pctldev, name); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 132 | if (pin < 0) { |
| 133 | ret = pin; |
| 134 | goto unlock; |
| 135 | } |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 136 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 137 | ret = pin_config_set_for_pin(pctldev, pin, config); |
| 138 | |
| 139 | unlock: |
| 140 | mutex_unlock(&pinctrl_mutex); |
| 141 | return ret; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 142 | } |
| 143 | EXPORT_SYMBOL(pin_config_set); |
| 144 | |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 145 | int pin_config_group_get(const char *dev_name, const char *pin_group, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 146 | unsigned long *config) |
| 147 | { |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 148 | struct pinctrl_dev *pctldev; |
| 149 | const struct pinconf_ops *ops; |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 150 | int selector, ret; |
| 151 | |
| 152 | mutex_lock(&pinctrl_mutex); |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 153 | |
Linus Walleij | 9dfac4f | 2012-02-01 18:02:47 +0100 | [diff] [blame] | 154 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 155 | if (!pctldev) { |
| 156 | ret = -EINVAL; |
| 157 | goto unlock; |
| 158 | } |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 159 | ops = pctldev->desc->confops; |
| 160 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 161 | if (!ops || !ops->pin_config_group_get) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 162 | dev_err(pctldev->dev, "cannot get configuration for pin " |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 163 | "group, missing group config get function in " |
| 164 | "driver\n"); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 165 | ret = -EINVAL; |
| 166 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | selector = pinctrl_get_group_selector(pctldev, pin_group); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 170 | if (selector < 0) { |
| 171 | ret = selector; |
| 172 | goto unlock; |
| 173 | } |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 174 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 175 | ret = ops->pin_config_group_get(pctldev, selector, config); |
| 176 | |
| 177 | unlock: |
| 178 | mutex_unlock(&pinctrl_mutex); |
| 179 | return ret; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 180 | } |
| 181 | EXPORT_SYMBOL(pin_config_group_get); |
| 182 | |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 183 | int pin_config_group_set(const char *dev_name, const char *pin_group, |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 184 | unsigned long config) |
| 185 | { |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 186 | struct pinctrl_dev *pctldev; |
| 187 | const struct pinconf_ops *ops; |
| 188 | const struct pinctrl_ops *pctlops; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 189 | int selector; |
| 190 | const unsigned *pins; |
| 191 | unsigned num_pins; |
| 192 | int ret; |
| 193 | int i; |
| 194 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 195 | mutex_lock(&pinctrl_mutex); |
| 196 | |
Linus Walleij | 9dfac4f | 2012-02-01 18:02:47 +0100 | [diff] [blame] | 197 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 198 | if (!pctldev) { |
| 199 | ret = -EINVAL; |
| 200 | goto unlock; |
| 201 | } |
Stephen Warren | 43699de | 2011-12-15 16:57:17 -0700 | [diff] [blame] | 202 | ops = pctldev->desc->confops; |
| 203 | pctlops = pctldev->desc->pctlops; |
| 204 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 205 | if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 206 | dev_err(pctldev->dev, "cannot configure pin group, missing " |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 207 | "config function in driver\n"); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 208 | ret = -EINVAL; |
| 209 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | selector = pinctrl_get_group_selector(pctldev, pin_group); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 213 | if (selector < 0) { |
| 214 | ret = selector; |
| 215 | goto unlock; |
| 216 | } |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 217 | |
| 218 | ret = pctlops->get_group_pins(pctldev, selector, &pins, &num_pins); |
| 219 | if (ret) { |
Stephen Warren | 51cd24e | 2011-12-09 16:59:05 -0700 | [diff] [blame] | 220 | dev_err(pctldev->dev, "cannot configure pin group, error " |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 221 | "getting pins\n"); |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 222 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /* |
| 226 | * If the pin controller supports handling entire groups we use that |
| 227 | * capability. |
| 228 | */ |
| 229 | if (ops->pin_config_group_set) { |
| 230 | ret = ops->pin_config_group_set(pctldev, selector, config); |
| 231 | /* |
| 232 | * If the pin controller prefer that a certain group be handled |
| 233 | * pin-by-pin as well, it returns -EAGAIN. |
| 234 | */ |
| 235 | if (ret != -EAGAIN) |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 236 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /* |
| 240 | * If the controller cannot handle entire groups, we configure each pin |
| 241 | * individually. |
| 242 | */ |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 243 | if (!ops->pin_config_set) { |
| 244 | ret = 0; |
| 245 | goto unlock; |
| 246 | } |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 247 | |
| 248 | for (i = 0; i < num_pins; i++) { |
| 249 | ret = ops->pin_config_set(pctldev, pins[i], config); |
| 250 | if (ret < 0) |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 251 | goto unlock; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 252 | } |
| 253 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 254 | ret = 0; |
| 255 | |
| 256 | unlock: |
| 257 | mutex_unlock(&pinctrl_mutex); |
| 258 | |
| 259 | return ret; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 260 | } |
| 261 | EXPORT_SYMBOL(pin_config_group_set); |
| 262 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 263 | #ifdef CONFIG_DEBUG_FS |
| 264 | |
| 265 | static void pinconf_dump_pin(struct pinctrl_dev *pctldev, |
| 266 | struct seq_file *s, int pin) |
| 267 | { |
| 268 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 269 | |
| 270 | if (ops && ops->pin_config_dbg_show) |
| 271 | ops->pin_config_dbg_show(pctldev, s, pin); |
| 272 | } |
| 273 | |
| 274 | static int pinconf_pins_show(struct seq_file *s, void *what) |
| 275 | { |
| 276 | struct pinctrl_dev *pctldev = s->private; |
Chanho Park | 706e852 | 2012-01-03 16:47:50 +0900 | [diff] [blame] | 277 | unsigned i, pin; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 278 | |
| 279 | seq_puts(s, "Pin config settings per pin\n"); |
| 280 | seq_puts(s, "Format: pin (name): pinmux setting array\n"); |
| 281 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 282 | mutex_lock(&pinctrl_mutex); |
| 283 | |
Chanho Park | 706e852 | 2012-01-03 16:47:50 +0900 | [diff] [blame] | 284 | /* The pin number can be retrived from the pin controller descriptor */ |
Stephen Warren | 546edd8 | 2012-01-06 13:38:31 -0700 | [diff] [blame] | 285 | for (i = 0; i < pctldev->desc->npins; i++) { |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 286 | struct pin_desc *desc; |
| 287 | |
Chanho Park | 706e852 | 2012-01-03 16:47:50 +0900 | [diff] [blame] | 288 | pin = pctldev->desc->pins[i].number; |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 289 | desc = pin_desc_get(pctldev, pin); |
Chanho Park | 706e852 | 2012-01-03 16:47:50 +0900 | [diff] [blame] | 290 | /* Skip if we cannot search the pin */ |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 291 | if (desc == NULL) |
| 292 | continue; |
| 293 | |
| 294 | seq_printf(s, "pin %d (%s):", pin, |
| 295 | desc->name ? desc->name : "unnamed"); |
| 296 | |
| 297 | pinconf_dump_pin(pctldev, s, pin); |
| 298 | |
| 299 | seq_printf(s, "\n"); |
| 300 | } |
| 301 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 302 | mutex_unlock(&pinctrl_mutex); |
| 303 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | static void pinconf_dump_group(struct pinctrl_dev *pctldev, |
| 308 | struct seq_file *s, unsigned selector, |
| 309 | const char *gname) |
| 310 | { |
| 311 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 312 | |
| 313 | if (ops && ops->pin_config_group_dbg_show) |
| 314 | ops->pin_config_group_dbg_show(pctldev, s, selector); |
| 315 | } |
| 316 | |
| 317 | static int pinconf_groups_show(struct seq_file *s, void *what) |
| 318 | { |
| 319 | struct pinctrl_dev *pctldev = s->private; |
| 320 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
| 321 | const struct pinconf_ops *ops = pctldev->desc->confops; |
| 322 | unsigned selector = 0; |
| 323 | |
| 324 | if (!ops || !ops->pin_config_group_get) |
| 325 | return 0; |
| 326 | |
| 327 | seq_puts(s, "Pin config settings per pin group\n"); |
| 328 | seq_puts(s, "Format: group (name): pinmux setting array\n"); |
| 329 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 330 | mutex_lock(&pinctrl_mutex); |
| 331 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 332 | while (pctlops->list_groups(pctldev, selector) >= 0) { |
| 333 | const char *gname = pctlops->get_group_name(pctldev, selector); |
| 334 | |
| 335 | seq_printf(s, "%u (%s):", selector, gname); |
| 336 | pinconf_dump_group(pctldev, s, selector, gname); |
Stephen Warren | f7b9006 | 2012-02-19 23:45:58 -0700 | [diff] [blame] | 337 | seq_printf(s, "\n"); |
| 338 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 339 | selector++; |
| 340 | } |
| 341 | |
Stephen Warren | 57b676f | 2012-03-02 13:05:44 -0700 | [diff] [blame^] | 342 | mutex_unlock(&pinctrl_mutex); |
| 343 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | static int pinconf_pins_open(struct inode *inode, struct file *file) |
| 348 | { |
| 349 | return single_open(file, pinconf_pins_show, inode->i_private); |
| 350 | } |
| 351 | |
| 352 | static int pinconf_groups_open(struct inode *inode, struct file *file) |
| 353 | { |
| 354 | return single_open(file, pinconf_groups_show, inode->i_private); |
| 355 | } |
| 356 | |
| 357 | static const struct file_operations pinconf_pins_ops = { |
| 358 | .open = pinconf_pins_open, |
| 359 | .read = seq_read, |
| 360 | .llseek = seq_lseek, |
| 361 | .release = single_release, |
| 362 | }; |
| 363 | |
| 364 | static const struct file_operations pinconf_groups_ops = { |
| 365 | .open = pinconf_groups_open, |
| 366 | .read = seq_read, |
| 367 | .llseek = seq_lseek, |
| 368 | .release = single_release, |
| 369 | }; |
| 370 | |
| 371 | void pinconf_init_device_debugfs(struct dentry *devroot, |
| 372 | struct pinctrl_dev *pctldev) |
| 373 | { |
| 374 | debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO, |
| 375 | devroot, pctldev, &pinconf_pins_ops); |
| 376 | debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO, |
| 377 | devroot, pctldev, &pinconf_groups_ops); |
| 378 | } |
| 379 | |
| 380 | #endif |