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