Bartosz Golaszewski | 058de34 | 2018-04-26 22:12:36 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 2 | /* |
| 3 | * GPIO Testing Device Driver |
| 4 | * |
| 5 | * Copyright (C) 2014 Kamlakant Patel <kamlakant.patel@broadcom.com> |
Linus Walleij | 4f9a4cd | 2018-03-06 09:04:15 +0100 | [diff] [blame] | 6 | * Copyright (C) 2015-2016 Bamvor Jian Zhang <bamv2005@gmail.com> |
Bartosz Golaszewski | c60c7f4 | 2017-06-09 13:41:31 +0200 | [diff] [blame] | 7 | * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl> |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/gpio/driver.h> |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 13 | #include <linux/gpio/consumer.h> |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Bartosz Golaszewski | 8a68ea0 | 2017-02-06 13:10:37 +0100 | [diff] [blame] | 15 | #include <linux/slab.h> |
Bartosz Golaszewski | e2ff740 | 2017-02-06 15:11:07 +0100 | [diff] [blame] | 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/irq.h> |
Bartosz Golaszewski | b4c495f | 2017-08-14 13:20:56 +0200 | [diff] [blame] | 18 | #include <linux/irq_sim.h> |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 19 | #include <linux/debugfs.h> |
| 20 | #include <linux/uaccess.h> |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 21 | #include <linux/property.h> |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 22 | |
| 23 | #include "gpiolib.h" |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 24 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 25 | #define GPIO_MOCKUP_NAME "gpio-mockup" |
Bartosz Golaszewski | b9576d0 | 2017-11-27 11:48:42 +0100 | [diff] [blame] | 26 | #define GPIO_MOCKUP_MAX_GC 10 |
Bartosz Golaszewski | b652336 | 2017-06-09 13:41:28 +0200 | [diff] [blame] | 27 | /* |
| 28 | * We're storing two values per chip: the GPIO base and the number |
| 29 | * of GPIO lines. |
| 30 | */ |
| 31 | #define GPIO_MOCKUP_MAX_RANGES (GPIO_MOCKUP_MAX_GC * 2) |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 32 | /* Maximum of three properties + the sentinel. */ |
| 33 | #define GPIO_MOCKUP_MAX_PROP 4 |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 34 | |
Bartosz Golaszewski | f1bec99 | 2017-11-27 11:48:41 +0100 | [diff] [blame] | 35 | #define gpio_mockup_err(...) pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__) |
| 36 | |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 37 | /* |
| 38 | * struct gpio_pin_status - structure describing a GPIO status |
Matti Vaittinen | e42615e | 2019-11-06 10:54:12 +0200 | [diff] [blame] | 39 | * @dir: Configures direction of gpio as "in" or "out" |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 40 | * @value: Configures status of the gpio as 0(low) or 1(high) |
| 41 | */ |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 42 | struct gpio_mockup_line_status { |
| 43 | int dir; |
Bartosz Golaszewski | 5b7908c | 2017-11-27 11:48:46 +0100 | [diff] [blame] | 44 | int value; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 45 | int pull; |
Bartosz Golaszewski | e2ff740 | 2017-02-06 15:11:07 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 48 | struct gpio_mockup_chip { |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 49 | struct gpio_chip gc; |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 50 | struct gpio_mockup_line_status *lines; |
Bartosz Golaszewski | b4c495f | 2017-08-14 13:20:56 +0200 | [diff] [blame] | 51 | struct irq_sim irqsim; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 52 | struct dentry *dbg_dir; |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 53 | struct mutex lock; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct gpio_mockup_dbgfs_private { |
| 57 | struct gpio_mockup_chip *chip; |
| 58 | struct gpio_desc *desc; |
Bartosz Golaszewski | 83336668 | 2019-01-18 18:08:59 +0100 | [diff] [blame] | 59 | unsigned int offset; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 60 | }; |
| 61 | |
Bartosz Golaszewski | b652336 | 2017-06-09 13:41:28 +0200 | [diff] [blame] | 62 | static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_RANGES]; |
Bartosz Golaszewski | e63a006 | 2017-11-27 11:48:53 +0100 | [diff] [blame] | 63 | static int gpio_mockup_num_ranges; |
| 64 | module_param_array(gpio_mockup_ranges, int, &gpio_mockup_num_ranges, 0400); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 65 | |
Bartosz Golaszewski | 8a68ea0 | 2017-02-06 13:10:37 +0100 | [diff] [blame] | 66 | static bool gpio_mockup_named_lines; |
| 67 | module_param_named(gpio_mockup_named_lines, |
| 68 | gpio_mockup_named_lines, bool, 0400); |
| 69 | |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 70 | static struct dentry *gpio_mockup_dbg_dir; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 71 | |
Bartosz Golaszewski | cd9835f | 2017-11-27 11:48:54 +0100 | [diff] [blame] | 72 | static int gpio_mockup_range_base(unsigned int index) |
| 73 | { |
| 74 | return gpio_mockup_ranges[index * 2]; |
| 75 | } |
| 76 | |
| 77 | static int gpio_mockup_range_ngpio(unsigned int index) |
| 78 | { |
| 79 | return gpio_mockup_ranges[index * 2 + 1]; |
| 80 | } |
| 81 | |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 82 | static int __gpio_mockup_get(struct gpio_mockup_chip *chip, |
| 83 | unsigned int offset) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 84 | { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 85 | return chip->lines[offset].value; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 86 | } |
| 87 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 88 | static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) |
| 89 | { |
| 90 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 91 | int val; |
| 92 | |
| 93 | mutex_lock(&chip->lock); |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 94 | val = __gpio_mockup_get(chip, offset); |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 95 | mutex_unlock(&chip->lock); |
| 96 | |
| 97 | return val; |
| 98 | } |
| 99 | |
Bartosz Golaszewski | cbf1e09 | 2018-10-31 15:01:40 +0100 | [diff] [blame] | 100 | static int gpio_mockup_get_multiple(struct gpio_chip *gc, |
| 101 | unsigned long *mask, unsigned long *bits) |
| 102 | { |
| 103 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 104 | unsigned int bit, val; |
| 105 | |
| 106 | mutex_lock(&chip->lock); |
| 107 | for_each_set_bit(bit, mask, gc->ngpio) { |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 108 | val = __gpio_mockup_get(chip, bit); |
Bartosz Golaszewski | cbf1e09 | 2018-10-31 15:01:40 +0100 | [diff] [blame] | 109 | __assign_bit(bit, bits, val); |
| 110 | } |
| 111 | mutex_unlock(&chip->lock); |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 116 | static void __gpio_mockup_set(struct gpio_mockup_chip *chip, |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 117 | unsigned int offset, int value) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 118 | { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 119 | chip->lines[offset].value = !!value; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 120 | } |
| 121 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 122 | static void gpio_mockup_set(struct gpio_chip *gc, |
| 123 | unsigned int offset, int value) |
| 124 | { |
| 125 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 126 | |
| 127 | mutex_lock(&chip->lock); |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 128 | __gpio_mockup_set(chip, offset, value); |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 129 | mutex_unlock(&chip->lock); |
| 130 | } |
| 131 | |
Bartosz Golaszewski | c47bee9 | 2017-11-27 11:48:51 +0100 | [diff] [blame] | 132 | static void gpio_mockup_set_multiple(struct gpio_chip *gc, |
| 133 | unsigned long *mask, unsigned long *bits) |
| 134 | { |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 135 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
Bartosz Golaszewski | c47bee9 | 2017-11-27 11:48:51 +0100 | [diff] [blame] | 136 | unsigned int bit; |
| 137 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 138 | mutex_lock(&chip->lock); |
Bartosz Golaszewski | c47bee9 | 2017-11-27 11:48:51 +0100 | [diff] [blame] | 139 | for_each_set_bit(bit, mask, gc->ngpio) |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 140 | __gpio_mockup_set(chip, bit, test_bit(bit, bits)); |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 141 | mutex_unlock(&chip->lock); |
Bartosz Golaszewski | c47bee9 | 2017-11-27 11:48:51 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Kent Gibson | 64e7112 | 2019-11-05 10:04:27 +0800 | [diff] [blame] | 144 | static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, |
| 145 | unsigned int offset, int value) |
| 146 | { |
| 147 | struct gpio_desc *desc; |
| 148 | struct gpio_chip *gc; |
| 149 | struct irq_sim *sim; |
| 150 | int curr, irq, irq_type; |
| 151 | |
| 152 | gc = &chip->gc; |
| 153 | desc = &gc->gpiodev->descs[offset]; |
| 154 | sim = &chip->irqsim; |
| 155 | |
| 156 | mutex_lock(&chip->lock); |
| 157 | |
| 158 | if (test_bit(FLAG_REQUESTED, &desc->flags) && |
| 159 | !test_bit(FLAG_IS_OUT, &desc->flags)) { |
| 160 | curr = __gpio_mockup_get(chip, offset); |
| 161 | if (curr == value) |
| 162 | goto out; |
| 163 | |
| 164 | irq = irq_sim_irqnum(sim, offset); |
| 165 | irq_type = irq_get_trigger_type(irq); |
| 166 | |
| 167 | if ((value == 1 && (irq_type & IRQ_TYPE_EDGE_RISING)) || |
| 168 | (value == 0 && (irq_type & IRQ_TYPE_EDGE_FALLING))) |
| 169 | irq_sim_fire(sim, offset); |
| 170 | } |
| 171 | |
| 172 | /* Change the value unless we're actively driving the line. */ |
| 173 | if (!test_bit(FLAG_REQUESTED, &desc->flags) || |
| 174 | !test_bit(FLAG_IS_OUT, &desc->flags)) |
| 175 | __gpio_mockup_set(chip, offset, value); |
| 176 | |
| 177 | out: |
| 178 | chip->lines[offset].pull = value; |
| 179 | mutex_unlock(&chip->lock); |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | static int gpio_mockup_set_config(struct gpio_chip *gc, |
| 184 | unsigned int offset, unsigned long config) |
| 185 | { |
| 186 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 187 | |
| 188 | switch (pinconf_to_config_param(config)) { |
| 189 | case PIN_CONFIG_BIAS_PULL_UP: |
| 190 | return gpio_mockup_apply_pull(chip, offset, 1); |
| 191 | case PIN_CONFIG_BIAS_PULL_DOWN: |
| 192 | return gpio_mockup_apply_pull(chip, offset, 0); |
| 193 | default: |
| 194 | break; |
| 195 | } |
| 196 | return -ENOTSUPP; |
| 197 | } |
| 198 | |
Bartosz Golaszewski | 2a9d742 | 2017-11-27 11:48:50 +0100 | [diff] [blame] | 199 | static int gpio_mockup_dirout(struct gpio_chip *gc, |
| 200 | unsigned int offset, int value) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 201 | { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 202 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 203 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 204 | mutex_lock(&chip->lock); |
Matti Vaittinen | e42615e | 2019-11-06 10:54:12 +0200 | [diff] [blame] | 205 | chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT; |
Bartosz Golaszewski | e09313c | 2019-01-23 09:34:15 +0100 | [diff] [blame] | 206 | __gpio_mockup_set(chip, offset, value); |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 207 | mutex_unlock(&chip->lock); |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 208 | |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 209 | return 0; |
| 210 | } |
| 211 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 212 | static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 213 | { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 214 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 215 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 216 | mutex_lock(&chip->lock); |
Matti Vaittinen | e42615e | 2019-11-06 10:54:12 +0200 | [diff] [blame] | 217 | chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN; |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 218 | mutex_unlock(&chip->lock); |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 219 | |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 220 | return 0; |
| 221 | } |
| 222 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 223 | static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 224 | { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 225 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 226 | int direction; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 227 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 228 | mutex_lock(&chip->lock); |
| 229 | direction = !chip->lines[offset].dir; |
| 230 | mutex_unlock(&chip->lock); |
| 231 | |
| 232 | return direction; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 233 | } |
| 234 | |
Bartosz Golaszewski | b4c495f | 2017-08-14 13:20:56 +0200 | [diff] [blame] | 235 | static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset) |
Bartosz Golaszewski | e2ff740 | 2017-02-06 15:11:07 +0100 | [diff] [blame] | 236 | { |
Bartosz Golaszewski | c7f5326 | 2017-05-25 10:33:41 +0200 | [diff] [blame] | 237 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 238 | |
Bartosz Golaszewski | b4c495f | 2017-08-14 13:20:56 +0200 | [diff] [blame] | 239 | return irq_sim_irqnum(&chip->irqsim, offset); |
Bartosz Golaszewski | e2ff740 | 2017-02-06 15:11:07 +0100 | [diff] [blame] | 240 | } |
| 241 | |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 242 | static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset) |
| 243 | { |
| 244 | struct gpio_mockup_chip *chip = gpiochip_get_data(gc); |
| 245 | |
| 246 | __gpio_mockup_set(chip, offset, chip->lines[offset].pull); |
| 247 | } |
| 248 | |
| 249 | static ssize_t gpio_mockup_debugfs_read(struct file *file, |
| 250 | char __user *usr_buf, |
| 251 | size_t size, loff_t *ppos) |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 252 | { |
| 253 | struct gpio_mockup_dbgfs_private *priv; |
| 254 | struct gpio_mockup_chip *chip; |
| 255 | struct seq_file *sfile; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 256 | struct gpio_chip *gc; |
Bartosz Golaszewski | ce9fb53 | 2019-03-28 11:38:06 +0100 | [diff] [blame] | 257 | int val, cnt; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 258 | char buf[3]; |
Bartosz Golaszewski | 2583303 | 2019-03-22 18:27:12 +0100 | [diff] [blame] | 259 | |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 260 | if (*ppos != 0) |
| 261 | return 0; |
| 262 | |
| 263 | sfile = file->private_data; |
| 264 | priv = sfile->private; |
| 265 | chip = priv->chip; |
| 266 | gc = &chip->gc; |
| 267 | |
| 268 | val = gpio_mockup_get(gc, priv->offset); |
Bartosz Golaszewski | 2583303 | 2019-03-22 18:27:12 +0100 | [diff] [blame] | 269 | cnt = snprintf(buf, sizeof(buf), "%d\n", val); |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 270 | |
Bartosz Golaszewski | ce9fb53 | 2019-03-28 11:38:06 +0100 | [diff] [blame] | 271 | return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt); |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | static ssize_t gpio_mockup_debugfs_write(struct file *file, |
| 275 | const char __user *usr_buf, |
| 276 | size_t size, loff_t *ppos) |
| 277 | { |
| 278 | struct gpio_mockup_dbgfs_private *priv; |
Kent Gibson | 64e7112 | 2019-11-05 10:04:27 +0800 | [diff] [blame] | 279 | int rv, val; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 280 | struct seq_file *sfile; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 281 | |
| 282 | if (*ppos != 0) |
| 283 | return -EINVAL; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 284 | |
Bartosz Golaszewski | 6f9b3e7 | 2017-06-09 13:41:25 +0200 | [diff] [blame] | 285 | rv = kstrtoint_from_user(usr_buf, size, 0, &val); |
| 286 | if (rv) |
| 287 | return rv; |
| 288 | if (val != 0 && val != 1) |
| 289 | return -EINVAL; |
| 290 | |
Bartosz Golaszewski | 650b57b | 2017-06-09 13:41:26 +0200 | [diff] [blame] | 291 | sfile = file->private_data; |
| 292 | priv = sfile->private; |
Kent Gibson | 64e7112 | 2019-11-05 10:04:27 +0800 | [diff] [blame] | 293 | rv = gpio_mockup_apply_pull(priv->chip, priv->offset, val); |
| 294 | if (rv) |
| 295 | return rv; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 296 | |
| 297 | return size; |
| 298 | } |
| 299 | |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 300 | static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file) |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 301 | { |
| 302 | return single_open(file, NULL, inode->i_private); |
| 303 | } |
| 304 | |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 305 | /* |
| 306 | * Each mockup chip is represented by a directory named after the chip's device |
| 307 | * name under /sys/kernel/debug/gpio-mockup/. Each line is represented by |
| 308 | * a file using the line's offset as the name under the chip's directory. |
| 309 | * |
| 310 | * Reading from the line's file yields the current *value*, writing to the |
| 311 | * line's file changes the current *pull*. Default pull for mockup lines is |
| 312 | * down. |
| 313 | * |
| 314 | * Examples: |
| 315 | * - when a line pulled down is requested in output mode and driven high, its |
| 316 | * value will return to 0 once it's released |
| 317 | * - when the line is requested in output mode and driven high, writing 0 to |
| 318 | * the corresponding debugfs file will change the pull to down but the |
| 319 | * reported value will still be 1 until the line is released |
| 320 | * - line requested in input mode always reports the same value as its pull |
| 321 | * configuration |
| 322 | * - when the line is requested in input mode and monitored for events, writing |
| 323 | * the same value to the debugfs file will be a noop, while writing the |
| 324 | * opposite value will generate a dummy interrupt with an appropriate edge |
| 325 | */ |
| 326 | static const struct file_operations gpio_mockup_debugfs_ops = { |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 327 | .owner = THIS_MODULE, |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 328 | .open = gpio_mockup_debugfs_open, |
| 329 | .read = gpio_mockup_debugfs_read, |
| 330 | .write = gpio_mockup_debugfs_write, |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 331 | .llseek = no_llseek, |
Wei Yongjun | 59929d3 | 2019-09-04 14:18:34 +0000 | [diff] [blame] | 332 | .release = single_release, |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 333 | }; |
| 334 | |
| 335 | static void gpio_mockup_debugfs_setup(struct device *dev, |
| 336 | struct gpio_mockup_chip *chip) |
| 337 | { |
| 338 | struct gpio_mockup_dbgfs_private *priv; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 339 | struct gpio_chip *gc; |
Bartosz Golaszewski | ca8792a | 2017-11-27 11:48:45 +0100 | [diff] [blame] | 340 | const char *devname; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 341 | char *name; |
| 342 | int i; |
| 343 | |
| 344 | gc = &chip->gc; |
Bartosz Golaszewski | ca8792a | 2017-11-27 11:48:45 +0100 | [diff] [blame] | 345 | devname = dev_name(&gc->gpiodev->dev); |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 346 | |
Bartosz Golaszewski | ca8792a | 2017-11-27 11:48:45 +0100 | [diff] [blame] | 347 | chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 348 | |
| 349 | for (i = 0; i < gc->ngpio; i++) { |
| 350 | name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); |
| 351 | if (!name) |
Greg Kroah-Hartman | f360dcd | 2019-06-26 10:45:57 +0200 | [diff] [blame] | 352 | return; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 353 | |
| 354 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 355 | if (!priv) |
Greg Kroah-Hartman | f360dcd | 2019-06-26 10:45:57 +0200 | [diff] [blame] | 356 | return; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 357 | |
| 358 | priv->chip = chip; |
| 359 | priv->offset = i; |
| 360 | priv->desc = &gc->gpiodev->descs[i]; |
| 361 | |
Greg Kroah-Hartman | f360dcd | 2019-06-26 10:45:57 +0200 | [diff] [blame] | 362 | debugfs_create_file(name, 0200, chip->dbg_dir, priv, |
| 363 | &gpio_mockup_debugfs_ops); |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | return; |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 367 | } |
| 368 | |
Bartosz Golaszewski | 1cea473 | 2017-11-27 11:48:47 +0100 | [diff] [blame] | 369 | static int gpio_mockup_name_lines(struct device *dev, |
| 370 | struct gpio_mockup_chip *chip) |
| 371 | { |
| 372 | struct gpio_chip *gc = &chip->gc; |
| 373 | char **names; |
| 374 | int i; |
| 375 | |
| 376 | names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL); |
| 377 | if (!names) |
| 378 | return -ENOMEM; |
| 379 | |
| 380 | for (i = 0; i < gc->ngpio; i++) { |
| 381 | names[i] = devm_kasprintf(dev, GFP_KERNEL, |
| 382 | "%s-%d", gc->label, i); |
| 383 | if (!names[i]) |
| 384 | return -ENOMEM; |
| 385 | } |
| 386 | |
| 387 | gc->names = (const char *const *)names; |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 392 | static int gpio_mockup_probe(struct platform_device *pdev) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 393 | { |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 394 | struct gpio_mockup_chip *chip; |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 395 | struct gpio_chip *gc; |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 396 | struct device *dev; |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 397 | const char *name; |
| 398 | int rv, base; |
| 399 | u16 ngpio; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 400 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 401 | dev = &pdev->dev; |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 402 | |
| 403 | rv = device_property_read_u32(dev, "gpio-base", &base); |
| 404 | if (rv) |
| 405 | base = -1; |
| 406 | |
| 407 | rv = device_property_read_u16(dev, "nr-gpios", &ngpio); |
| 408 | if (rv) |
| 409 | return rv; |
| 410 | |
| 411 | rv = device_property_read_string(dev, "chip-name", &name); |
| 412 | if (rv) |
| 413 | name = NULL; |
Bartosz Golaszewski | b652336 | 2017-06-09 13:41:28 +0200 | [diff] [blame] | 414 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 415 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 416 | if (!chip) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 417 | return -ENOMEM; |
| 418 | |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 419 | if (!name) { |
| 420 | name = devm_kasprintf(dev, GFP_KERNEL, |
| 421 | "%s-%c", pdev->name, pdev->id + 'A'); |
| 422 | if (!name) |
| 423 | return -ENOMEM; |
| 424 | } |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 425 | |
Bartosz Golaszewski | 9212492 | 2018-10-31 14:55:47 +0100 | [diff] [blame] | 426 | mutex_init(&chip->lock); |
| 427 | |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 428 | gc = &chip->gc; |
| 429 | gc->base = base; |
| 430 | gc->ngpio = ngpio; |
| 431 | gc->label = name; |
| 432 | gc->owner = THIS_MODULE; |
| 433 | gc->parent = dev; |
| 434 | gc->get = gpio_mockup_get; |
| 435 | gc->set = gpio_mockup_set; |
Bartosz Golaszewski | cbf1e09 | 2018-10-31 15:01:40 +0100 | [diff] [blame] | 436 | gc->get_multiple = gpio_mockup_get_multiple; |
Bartosz Golaszewski | c47bee9 | 2017-11-27 11:48:51 +0100 | [diff] [blame] | 437 | gc->set_multiple = gpio_mockup_set_multiple; |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 438 | gc->direction_output = gpio_mockup_dirout; |
| 439 | gc->direction_input = gpio_mockup_dirin; |
| 440 | gc->get_direction = gpio_mockup_get_direction; |
Kent Gibson | 64e7112 | 2019-11-05 10:04:27 +0800 | [diff] [blame] | 441 | gc->set_config = gpio_mockup_set_config; |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 442 | gc->to_irq = gpio_mockup_to_irq; |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 443 | gc->free = gpio_mockup_free; |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 444 | |
| 445 | chip->lines = devm_kcalloc(dev, gc->ngpio, |
| 446 | sizeof(*chip->lines), GFP_KERNEL); |
| 447 | if (!chip->lines) |
| 448 | return -ENOMEM; |
| 449 | |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 450 | if (device_property_read_bool(dev, "named-gpio-lines")) { |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 451 | rv = gpio_mockup_name_lines(dev, chip); |
| 452 | if (rv) |
| 453 | return rv; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 454 | } |
| 455 | |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 456 | rv = devm_irq_sim_init(dev, &chip->irqsim, gc->ngpio); |
Bartosz Golaszewski | 1e0dca6 | 2017-11-27 11:48:52 +0100 | [diff] [blame] | 457 | if (rv < 0) |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 458 | return rv; |
| 459 | |
| 460 | rv = devm_gpiochip_add_data(dev, &chip->gc, chip); |
| 461 | if (rv) |
| 462 | return rv; |
| 463 | |
Greg Kroah-Hartman | f360dcd | 2019-06-26 10:45:57 +0200 | [diff] [blame] | 464 | gpio_mockup_debugfs_setup(dev, chip); |
Bartosz Golaszewski | 6d974d3 | 2017-11-27 11:48:43 +0100 | [diff] [blame] | 465 | |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 469 | static struct platform_driver gpio_mockup_driver = { |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 470 | .driver = { |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 471 | .name = GPIO_MOCKUP_NAME, |
Bartosz Golaszewski | 364ac45 | 2016-12-20 12:28:20 +0100 | [diff] [blame] | 472 | }, |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 473 | .probe = gpio_mockup_probe, |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 474 | }; |
| 475 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 476 | static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC]; |
| 477 | |
| 478 | static void gpio_mockup_unregister_pdevs(void) |
| 479 | { |
| 480 | struct platform_device *pdev; |
| 481 | int i; |
| 482 | |
| 483 | for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) { |
| 484 | pdev = gpio_mockup_pdevs[i]; |
| 485 | |
| 486 | if (pdev) |
| 487 | platform_device_unregister(pdev); |
| 488 | } |
| 489 | } |
Bartosz Golaszewski | f3b4717 | 2017-11-27 11:48:37 +0100 | [diff] [blame] | 490 | |
| 491 | static int __init gpio_mockup_init(void) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 492 | { |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 493 | struct property_entry properties[GPIO_MOCKUP_MAX_PROP]; |
| 494 | int i, prop, num_chips, err = 0, base; |
| 495 | struct platform_device_info pdevinfo; |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 496 | struct platform_device *pdev; |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 497 | u16 ngpio; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 498 | |
Bartosz Golaszewski | e63a006 | 2017-11-27 11:48:53 +0100 | [diff] [blame] | 499 | if ((gpio_mockup_num_ranges < 2) || |
| 500 | (gpio_mockup_num_ranges % 2) || |
| 501 | (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES)) |
Bartosz Golaszewski | 20c35ac | 2017-11-27 11:48:38 +0100 | [diff] [blame] | 502 | return -EINVAL; |
| 503 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 504 | /* Each chip is described by two values. */ |
Bartosz Golaszewski | e63a006 | 2017-11-27 11:48:53 +0100 | [diff] [blame] | 505 | num_chips = gpio_mockup_num_ranges / 2; |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 506 | |
Bartosz Golaszewski | fa86963 | 2017-11-27 11:48:49 +0100 | [diff] [blame] | 507 | /* |
| 508 | * The second value in the <base GPIO - number of GPIOS> pair must |
| 509 | * always be greater than 0. |
| 510 | */ |
| 511 | for (i = 0; i < num_chips; i++) { |
Bartosz Golaszewski | cd9835f | 2017-11-27 11:48:54 +0100 | [diff] [blame] | 512 | if (gpio_mockup_range_ngpio(i) < 0) |
Bartosz Golaszewski | fa86963 | 2017-11-27 11:48:49 +0100 | [diff] [blame] | 513 | return -EINVAL; |
| 514 | } |
| 515 | |
Bartosz Golaszewski | 2a9e274 | 2019-01-17 16:30:27 +0100 | [diff] [blame] | 516 | gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 517 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 518 | err = platform_driver_register(&gpio_mockup_driver); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 519 | if (err) { |
Bartosz Golaszewski | f1bec99 | 2017-11-27 11:48:41 +0100 | [diff] [blame] | 520 | gpio_mockup_err("error registering platform driver\n"); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 521 | return err; |
| 522 | } |
| 523 | |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 524 | for (i = 0; i < num_chips; i++) { |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 525 | memset(properties, 0, sizeof(properties)); |
| 526 | memset(&pdevinfo, 0, sizeof(pdevinfo)); |
| 527 | prop = 0; |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 528 | |
Bartosz Golaszewski | 3ea47b4 | 2018-09-25 13:29:46 +0200 | [diff] [blame] | 529 | base = gpio_mockup_range_base(i); |
| 530 | if (base >= 0) |
| 531 | properties[prop++] = PROPERTY_ENTRY_U32("gpio-base", |
| 532 | base); |
| 533 | |
| 534 | ngpio = base < 0 ? gpio_mockup_range_ngpio(i) |
| 535 | : gpio_mockup_range_ngpio(i) - base; |
| 536 | properties[prop++] = PROPERTY_ENTRY_U16("nr-gpios", ngpio); |
| 537 | |
| 538 | if (gpio_mockup_named_lines) |
| 539 | properties[prop++] = PROPERTY_ENTRY_BOOL( |
| 540 | "named-gpio-lines"); |
| 541 | |
| 542 | pdevinfo.name = GPIO_MOCKUP_NAME; |
| 543 | pdevinfo.id = i; |
| 544 | pdevinfo.properties = properties; |
| 545 | |
| 546 | pdev = platform_device_register_full(&pdevinfo); |
Bartosz Golaszewski | c4b54e1 | 2017-12-06 17:30:02 +0100 | [diff] [blame] | 547 | if (IS_ERR(pdev)) { |
Bartosz Golaszewski | f1bec99 | 2017-11-27 11:48:41 +0100 | [diff] [blame] | 548 | gpio_mockup_err("error registering device"); |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 549 | platform_driver_unregister(&gpio_mockup_driver); |
| 550 | gpio_mockup_unregister_pdevs(); |
Bartosz Golaszewski | c4b54e1 | 2017-12-06 17:30:02 +0100 | [diff] [blame] | 551 | return PTR_ERR(pdev); |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | gpio_mockup_pdevs[i] = pdev; |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
Bartosz Golaszewski | f3b4717 | 2017-11-27 11:48:37 +0100 | [diff] [blame] | 560 | static void __exit gpio_mockup_exit(void) |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 561 | { |
Bartosz Golaszewski | 9202ba2 | 2017-02-06 15:11:08 +0100 | [diff] [blame] | 562 | debugfs_remove_recursive(gpio_mockup_dbg_dir); |
Bartosz Golaszewski | ca409160 | 2017-02-06 13:10:35 +0100 | [diff] [blame] | 563 | platform_driver_unregister(&gpio_mockup_driver); |
Bartosz Golaszewski | 8a39f59 | 2017-11-27 11:48:40 +0100 | [diff] [blame] | 564 | gpio_mockup_unregister_pdevs(); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 565 | } |
| 566 | |
Bartosz Golaszewski | f3b4717 | 2017-11-27 11:48:37 +0100 | [diff] [blame] | 567 | module_init(gpio_mockup_init); |
| 568 | module_exit(gpio_mockup_exit); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 569 | |
| 570 | MODULE_AUTHOR("Kamlakant Patel <kamlakant.patel@broadcom.com>"); |
Linus Walleij | 4f9a4cd | 2018-03-06 09:04:15 +0100 | [diff] [blame] | 571 | MODULE_AUTHOR("Bamvor Jian Zhang <bamv2005@gmail.com>"); |
Bartosz Golaszewski | c60c7f4 | 2017-06-09 13:41:31 +0200 | [diff] [blame] | 572 | MODULE_AUTHOR("Bartosz Golaszewski <brgl@bgdev.pl>"); |
Bamvor Jian Zhang | 0f98dd1 | 2016-08-31 11:45:46 +0200 | [diff] [blame] | 573 | MODULE_DESCRIPTION("GPIO Testing driver"); |
| 574 | MODULE_LICENSE("GPL v2"); |