John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 1 | /* |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 2 | * Xilinx gpio driver for xps/axi_gpio IP. |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 3 | * |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 4 | * Copyright 2008 - 2013 Xilinx, Inc. |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 |
| 8 | * as published by the Free Software Foundation. |
| 9 | * |
| 10 | * You should have received a copy of the GNU General Public License |
| 11 | * along with this program; if not, write to the Free Software |
| 12 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 13 | */ |
| 14 | |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 15 | #include <linux/bitops.h> |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 16 | #include <linux/init.h> |
| 17 | #include <linux/errno.h> |
Paul Gortmaker | bb207ef | 2011-07-03 13:38:09 -0400 | [diff] [blame] | 18 | #include <linux/module.h> |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 19 | #include <linux/of_device.h> |
| 20 | #include <linux/of_platform.h> |
| 21 | #include <linux/of_gpio.h> |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/gpio.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 25 | |
| 26 | /* Register Offset Definitions */ |
| 27 | #define XGPIO_DATA_OFFSET (0x0) /* Data register */ |
| 28 | #define XGPIO_TRI_OFFSET (0x4) /* I/O direction register */ |
| 29 | |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 30 | #define XGPIO_CHANNEL_OFFSET 0x8 |
| 31 | |
| 32 | /* Read/Write access to the GPIO registers */ |
Ricardo Ribalda Delgado | c54c58b | 2014-12-17 16:51:10 +0100 | [diff] [blame] | 33 | #if defined(CONFIG_ARCH_ZYNQ) || defined(CONFIG_X86) |
Michal Simek | cc090d6 | 2013-06-03 14:31:18 +0200 | [diff] [blame] | 34 | # define xgpio_readreg(offset) readl(offset) |
| 35 | # define xgpio_writereg(offset, val) writel(val, offset) |
| 36 | #else |
| 37 | # define xgpio_readreg(offset) __raw_readl(offset) |
| 38 | # define xgpio_writereg(offset, val) __raw_writel(val, offset) |
| 39 | #endif |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * struct xgpio_instance - Stores information about GPIO device |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 43 | * @mmchip: OF GPIO chip for memory mapped banks |
| 44 | * @gpio_state: GPIO state shadow register |
| 45 | * @gpio_dir: GPIO direction shadow register |
| 46 | * @gpio_lock: Lock used for synchronization |
| 47 | * @inited: True if the port has been inited |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 48 | */ |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 49 | struct xgpio_instance { |
| 50 | struct of_mm_gpio_chip mmchip; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 51 | u32 gpio_state; |
| 52 | u32 gpio_dir; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 53 | spinlock_t gpio_lock; |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 54 | bool inited; |
| 55 | }; |
| 56 | |
| 57 | struct xgpio { |
| 58 | struct xgpio_instance port[2]; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * xgpio_get - Read the specified signal of the GPIO device. |
| 63 | * @gc: Pointer to gpio_chip device structure. |
| 64 | * @gpio: GPIO signal number. |
| 65 | * |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 66 | * This function reads the specified signal of the GPIO device. |
| 67 | * |
| 68 | * Return: |
| 69 | * 0 if direction of GPIO signals is set as input otherwise it |
| 70 | * returns negative error value. |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 71 | */ |
| 72 | static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) |
| 73 | { |
| 74 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); |
| 75 | |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 76 | return !!(xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET) & BIT(gpio)); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /** |
| 80 | * xgpio_set - Write the specified signal of the GPIO device. |
| 81 | * @gc: Pointer to gpio_chip device structure. |
| 82 | * @gpio: GPIO signal number. |
| 83 | * @val: Value to be written to specified signal. |
| 84 | * |
| 85 | * This function writes the specified value in to the specified signal of the |
| 86 | * GPIO device. |
| 87 | */ |
| 88 | static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |
| 89 | { |
| 90 | unsigned long flags; |
| 91 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); |
| 92 | struct xgpio_instance *chip = |
| 93 | container_of(mm_gc, struct xgpio_instance, mmchip); |
| 94 | |
| 95 | spin_lock_irqsave(&chip->gpio_lock, flags); |
| 96 | |
| 97 | /* Write to GPIO signal and set its direction to output */ |
| 98 | if (val) |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 99 | chip->gpio_state |= BIT(gpio); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 100 | else |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 101 | chip->gpio_state &= ~BIT(gpio); |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 102 | |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 103 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 104 | |
| 105 | spin_unlock_irqrestore(&chip->gpio_lock, flags); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * xgpio_dir_in - Set the direction of the specified GPIO signal as input. |
| 110 | * @gc: Pointer to gpio_chip device structure. |
| 111 | * @gpio: GPIO signal number. |
| 112 | * |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 113 | * Return: |
| 114 | * 0 - if direction of GPIO signals is set as input |
| 115 | * otherwise it returns negative error value. |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 116 | */ |
| 117 | static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) |
| 118 | { |
| 119 | unsigned long flags; |
| 120 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); |
| 121 | struct xgpio_instance *chip = |
| 122 | container_of(mm_gc, struct xgpio_instance, mmchip); |
| 123 | |
| 124 | spin_lock_irqsave(&chip->gpio_lock, flags); |
| 125 | |
| 126 | /* Set the GPIO bit in shadow register and set direction as input */ |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 127 | chip->gpio_dir |= BIT(gpio); |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 128 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 129 | |
| 130 | spin_unlock_irqrestore(&chip->gpio_lock, flags); |
| 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * xgpio_dir_out - Set the direction of the specified GPIO signal as output. |
| 137 | * @gc: Pointer to gpio_chip device structure. |
| 138 | * @gpio: GPIO signal number. |
| 139 | * @val: Value to be written to specified signal. |
| 140 | * |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 141 | * This function sets the direction of specified GPIO signal as output. |
| 142 | * |
| 143 | * Return: |
| 144 | * If all GPIO signals of GPIO chip is configured as input then it returns |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 145 | * error otherwise it returns 0. |
| 146 | */ |
| 147 | static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) |
| 148 | { |
| 149 | unsigned long flags; |
| 150 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); |
| 151 | struct xgpio_instance *chip = |
| 152 | container_of(mm_gc, struct xgpio_instance, mmchip); |
| 153 | |
| 154 | spin_lock_irqsave(&chip->gpio_lock, flags); |
| 155 | |
| 156 | /* Write state of GPIO signal */ |
| 157 | if (val) |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 158 | chip->gpio_state |= BIT(gpio); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 159 | else |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 160 | chip->gpio_state &= ~BIT(gpio); |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 161 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 162 | |
| 163 | /* Clear the GPIO bit in shadow register and set direction as output */ |
Michal Simek | 9f7f0b2 | 2013-06-03 14:31:19 +0200 | [diff] [blame] | 164 | chip->gpio_dir &= ~BIT(gpio); |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 165 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 166 | |
| 167 | spin_unlock_irqrestore(&chip->gpio_lock, flags); |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * xgpio_save_regs - Set initial values of GPIO pins |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 174 | * @mm_gc: Pointer to memory mapped GPIO chip structure |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 175 | */ |
| 176 | static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) |
| 177 | { |
| 178 | struct xgpio_instance *chip = |
| 179 | container_of(mm_gc, struct xgpio_instance, mmchip); |
| 180 | |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 181 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state); |
| 182 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /** |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 186 | * xgpio_remove - Remove method for the GPIO device. |
| 187 | * @pdev: pointer to the platform device |
| 188 | * |
| 189 | * This function remove gpiochips and frees all the allocated resources. |
| 190 | */ |
| 191 | static int xgpio_remove(struct platform_device *pdev) |
| 192 | { |
| 193 | struct xgpio *xgpio = platform_get_drvdata(pdev); |
| 194 | int i; |
| 195 | |
| 196 | for (i = 0; i < 2; i++) { |
| 197 | if (!xgpio->port[i].inited) |
| 198 | continue; |
| 199 | gpiochip_remove(&xgpio->port[i].mmchip.gc); |
| 200 | |
| 201 | if (i == 1) |
| 202 | xgpio->port[i].mmchip.regs -= XGPIO_CHANNEL_OFFSET; |
| 203 | |
| 204 | iounmap(xgpio->port[i].mmchip.regs); |
| 205 | kfree(xgpio->port[i].mmchip.gc.label); |
| 206 | } |
| 207 | |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | /** |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 212 | * xgpio_of_probe - Probe method for the GPIO device. |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 213 | * @pdev: pointer to the platform device |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 214 | * |
Ricardo Ribalda Delgado | 4ae798f | 2014-12-17 16:51:11 +0100 | [diff] [blame^] | 215 | * Return: |
| 216 | * It returns 0, if the driver is bound to the GPIO device, or |
| 217 | * a negative value if there is an error. |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 218 | */ |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 219 | static int xgpio_probe(struct platform_device *pdev) |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 220 | { |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 221 | struct xgpio *xgpio; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 222 | struct xgpio_instance *chip; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 223 | int status = 0; |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 224 | struct device_node *np = pdev->dev.of_node; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 225 | const u32 *tree_info; |
Gernot Vormayr | 1b4c5a6 | 2014-09-24 00:58:45 +0200 | [diff] [blame] | 226 | u32 ngpio; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 227 | |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 228 | xgpio = devm_kzalloc(&pdev->dev, sizeof(*xgpio), GFP_KERNEL); |
| 229 | if (!xgpio) |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 230 | return -ENOMEM; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 231 | |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 232 | platform_set_drvdata(pdev, xgpio); |
| 233 | |
| 234 | chip = &xgpio->port[0]; |
| 235 | |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 236 | /* Update GPIO state shadow register with default value */ |
Michal Simek | 6f8bf50 | 2013-06-03 14:31:16 +0200 | [diff] [blame] | 237 | of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state); |
| 238 | |
| 239 | /* By default, all pins are inputs */ |
| 240 | chip->gpio_dir = 0xFFFFFFFF; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 241 | |
| 242 | /* Update GPIO direction shadow register with default value */ |
Michal Simek | 6f8bf50 | 2013-06-03 14:31:16 +0200 | [diff] [blame] | 243 | of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir); |
| 244 | |
Gernot Vormayr | 1b4c5a6 | 2014-09-24 00:58:45 +0200 | [diff] [blame] | 245 | /* |
| 246 | * Check device node and parent device node for device width |
| 247 | * and assume default width of 32 |
| 248 | */ |
| 249 | if (of_property_read_u32(np, "xlnx,gpio-width", &ngpio)) |
| 250 | ngpio = 32; |
| 251 | chip->mmchip.gc.ngpio = (u16)ngpio; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 252 | |
| 253 | spin_lock_init(&chip->gpio_lock); |
| 254 | |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 255 | chip->mmchip.gc.dev = &pdev->dev; |
Anton Vorontsov | a19e3da | 2010-06-08 07:48:16 -0600 | [diff] [blame] | 256 | chip->mmchip.gc.direction_input = xgpio_dir_in; |
| 257 | chip->mmchip.gc.direction_output = xgpio_dir_out; |
| 258 | chip->mmchip.gc.get = xgpio_get; |
| 259 | chip->mmchip.gc.set = xgpio_set; |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 260 | |
| 261 | chip->mmchip.save_regs = xgpio_save_regs; |
| 262 | |
| 263 | /* Call the OF gpio helper to setup and register the GPIO device */ |
| 264 | status = of_mm_gpiochip_add(np, &chip->mmchip); |
| 265 | if (status) { |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 266 | pr_err("%s: error in probe function with status %d\n", |
| 267 | np->full_name, status); |
| 268 | return status; |
| 269 | } |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 270 | chip->inited = true; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 271 | |
| 272 | pr_info("XGpio: %s: registered, base is %d\n", np->full_name, |
| 273 | chip->mmchip.gc.base); |
| 274 | |
| 275 | tree_info = of_get_property(np, "xlnx,is-dual", NULL); |
| 276 | if (tree_info && be32_to_cpup(tree_info)) { |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 277 | chip = &xgpio->port[1]; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 278 | |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 279 | /* Update GPIO state shadow register with default value */ |
| 280 | of_property_read_u32(np, "xlnx,dout-default-2", |
| 281 | &chip->gpio_state); |
| 282 | |
| 283 | /* By default, all pins are inputs */ |
| 284 | chip->gpio_dir = 0xFFFFFFFF; |
| 285 | |
| 286 | /* Update GPIO direction shadow register with default value */ |
| 287 | of_property_read_u32(np, "xlnx,tri-default-2", &chip->gpio_dir); |
| 288 | |
Gernot Vormayr | 1b4c5a6 | 2014-09-24 00:58:45 +0200 | [diff] [blame] | 289 | /* |
| 290 | * Check device node and parent device node for device width |
| 291 | * and assume default width of 32 |
| 292 | */ |
| 293 | if (of_property_read_u32(np, "xlnx,gpio2-width", &ngpio)) |
| 294 | ngpio = 32; |
| 295 | chip->mmchip.gc.ngpio = (u16)ngpio; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 296 | |
| 297 | spin_lock_init(&chip->gpio_lock); |
| 298 | |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 299 | chip->mmchip.gc.dev = &pdev->dev; |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 300 | chip->mmchip.gc.direction_input = xgpio_dir_in; |
| 301 | chip->mmchip.gc.direction_output = xgpio_dir_out; |
| 302 | chip->mmchip.gc.get = xgpio_get; |
| 303 | chip->mmchip.gc.set = xgpio_set; |
| 304 | |
| 305 | chip->mmchip.save_regs = xgpio_save_regs; |
| 306 | |
| 307 | /* Call the OF gpio helper to setup and register the GPIO dev */ |
| 308 | status = of_mm_gpiochip_add(np, &chip->mmchip); |
| 309 | if (status) { |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 310 | xgpio_remove(pdev); |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 311 | pr_err("%s: error in probe function with status %d\n", |
| 312 | np->full_name, status); |
| 313 | return status; |
| 314 | } |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 315 | |
| 316 | /* Add dual channel offset */ |
| 317 | chip->mmchip.regs += XGPIO_CHANNEL_OFFSET; |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 318 | chip->inited = true; |
Ricardo Ribalda Delgado | bc2f3dc | 2014-12-17 16:51:08 +0100 | [diff] [blame] | 319 | |
Michal Simek | 74600ee | 2013-06-03 14:31:17 +0200 | [diff] [blame] | 320 | pr_info("XGpio: %s: dual channel registered, base is %d\n", |
| 321 | np->full_name, chip->mmchip.gc.base); |
| 322 | } |
| 323 | |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 324 | return 0; |
| 325 | } |
| 326 | |
Jingoo Han | 9992bc9 | 2014-05-07 18:08:20 +0900 | [diff] [blame] | 327 | static const struct of_device_id xgpio_of_match[] = { |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 328 | { .compatible = "xlnx,xps-gpio-1.00.a", }, |
| 329 | { /* end of list */ }, |
| 330 | }; |
| 331 | |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 332 | MODULE_DEVICE_TABLE(of, xgpio_of_match); |
| 333 | |
| 334 | static struct platform_driver xgpio_plat_driver = { |
| 335 | .probe = xgpio_probe, |
| 336 | .remove = xgpio_remove, |
| 337 | .driver = { |
| 338 | .name = "gpio-xilinx", |
| 339 | .of_match_table = xgpio_of_match, |
| 340 | }, |
| 341 | }; |
| 342 | |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 343 | static int __init xgpio_init(void) |
| 344 | { |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 345 | return platform_driver_register(&xgpio_plat_driver); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 346 | } |
| 347 | |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 348 | subsys_initcall(xgpio_init); |
Ricardo Ribalda Delgado | 749564f | 2014-12-17 16:51:09 +0100 | [diff] [blame] | 349 | |
| 350 | static void __exit xgpio_exit(void) |
| 351 | { |
| 352 | platform_driver_unregister(&xgpio_plat_driver); |
| 353 | } |
| 354 | module_exit(xgpio_exit); |
John Linn | 0bcb606 | 2008-11-12 13:25:38 -0800 | [diff] [blame] | 355 | |
| 356 | MODULE_AUTHOR("Xilinx, Inc."); |
| 357 | MODULE_DESCRIPTION("Xilinx GPIO driver"); |
| 358 | MODULE_LICENSE("GPL"); |