]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/atheros/ar71xx_gpio.c
MFV r362082:
[FreeBSD/FreeBSD.git] / sys / mips / atheros / ar71xx_gpio.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
5  * Copyright (c) 2009, Luiz Otavio O Souza. 
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice unmodified, this list of conditions, and the following
13  *    disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30
31 /*
32  * GPIO driver for AR71xx 
33  */
34
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/bus.h>
41
42 #include <sys/kernel.h>
43 #include <sys/module.h>
44 #include <sys/rman.h>
45 #include <sys/lock.h>
46 #include <sys/malloc.h>
47 #include <sys/mutex.h>
48 #include <sys/gpio.h>
49
50 #include <machine/bus.h>
51 #include <machine/resource.h>
52 #include <mips/atheros/ar71xxreg.h>
53 #include <mips/atheros/ar71xx_setup.h>
54 #include <mips/atheros/ar71xx_cpudef.h>
55 #include <mips/atheros/ar71xx_gpiovar.h>
56 #include <dev/gpio/gpiobusvar.h>
57 #include <mips/atheros/ar933xreg.h>
58 #include <mips/atheros/ar934xreg.h>
59 #include <mips/atheros/qca953xreg.h>
60 #include <mips/atheros/qca955xreg.h>
61
62 #include "gpio_if.h"
63
64 #define DEFAULT_CAPS    (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)
65
66 /*
67  * Helpers
68  */
69 static void ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, 
70     uint32_t mask);
71 static void ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, 
72     uint32_t mask);
73 static void ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, 
74     struct gpio_pin *pin, uint32_t flags);
75
76 /*
77  * Driver stuff
78  */
79 static int ar71xx_gpio_probe(device_t dev);
80 static int ar71xx_gpio_attach(device_t dev);
81 static int ar71xx_gpio_detach(device_t dev);
82 static int ar71xx_gpio_filter(void *arg);
83 static void ar71xx_gpio_intr(void *arg);
84
85 /*
86  * GPIO interface
87  */
88 static device_t ar71xx_gpio_get_bus(device_t);
89 static int ar71xx_gpio_pin_max(device_t dev, int *maxpin);
90 static int ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps);
91 static int ar71xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t
92     *flags);
93 static int ar71xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name);
94 static int ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
95 static int ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
96 static int ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);
97 static int ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin);
98
99 /*
100  * Enable/disable the GPIO function control space.
101  *
102  * This is primarily for the AR71xx, which has SPI CS1/CS2, UART, SLIC, I2S
103  * as GPIO pin options.
104  */
105 static void
106 ar71xx_gpio_function_enable(struct ar71xx_gpio_softc *sc, uint32_t mask)
107 {
108
109         /*
110          * XXX TODO: refactor this out into a per-chipset method.
111          */
112         if (ar71xx_soc == AR71XX_SOC_AR9341 ||
113             ar71xx_soc == AR71XX_SOC_AR9342 ||
114             ar71xx_soc == AR71XX_SOC_AR9344 ||
115             ar71xx_soc == AR71XX_SOC_QCA9533 ||
116             ar71xx_soc == AR71XX_SOC_QCA9533_V2 ||
117             ar71xx_soc == AR71XX_SOC_QCA9556 ||
118             ar71xx_soc == AR71XX_SOC_QCA9558)
119                 GPIO_SET_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
120         else
121                 GPIO_SET_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
122 }
123
124 static void
125 ar71xx_gpio_function_disable(struct ar71xx_gpio_softc *sc, uint32_t mask)
126 {
127
128         /*
129          * XXX TODO: refactor this out into a per-chipset method.
130          */
131         if (ar71xx_soc == AR71XX_SOC_AR9341 ||
132             ar71xx_soc == AR71XX_SOC_AR9342 ||
133             ar71xx_soc == AR71XX_SOC_AR9344 ||
134             ar71xx_soc == AR71XX_SOC_QCA9533 ||
135             ar71xx_soc == AR71XX_SOC_QCA9533_V2 ||
136             ar71xx_soc == AR71XX_SOC_QCA9556 ||
137             ar71xx_soc == AR71XX_SOC_QCA9558)
138                 GPIO_CLEAR_BITS(sc, AR934X_GPIO_REG_FUNC, mask);
139         else
140                 GPIO_CLEAR_BITS(sc, AR71XX_GPIO_FUNCTION, mask);
141 }
142
143 /*
144  * On most platforms, GPIO_OE is a bitmap where the bit set
145  * means "enable output."
146  *
147  * On AR934x and QCA953x, it's the opposite - the bit set means
148  * "input enable".
149  */
150 static int
151 ar71xx_gpio_oe_is_high(void)
152 {
153         switch (ar71xx_soc) {
154         case AR71XX_SOC_AR9341:
155         case AR71XX_SOC_AR9342:
156         case AR71XX_SOC_AR9344:
157         case AR71XX_SOC_QCA9533:
158         case AR71XX_SOC_QCA9533_V2:
159                 return 0;
160         default:
161                 return 1;
162         }
163 }
164
165 static void
166 ar71xx_gpio_oe_set_output(struct ar71xx_gpio_softc *sc, int b)
167 {
168         uint32_t mask;
169
170         mask = 1 << b;
171
172         if (ar71xx_gpio_oe_is_high())
173                 GPIO_SET_BITS(sc, AR71XX_GPIO_OE, mask);
174         else
175                 GPIO_CLEAR_BITS(sc, AR71XX_GPIO_OE, mask);
176 }
177
178 static void
179 ar71xx_gpio_oe_set_input(struct ar71xx_gpio_softc *sc, int b)
180 {
181         uint32_t mask;
182
183         mask = 1 << b;
184
185         if (ar71xx_gpio_oe_is_high())
186                 GPIO_CLEAR_BITS(sc, AR71XX_GPIO_OE, mask);
187         else
188                 GPIO_SET_BITS(sc, AR71XX_GPIO_OE, mask);
189 }
190
191 static void
192 ar71xx_gpio_pin_configure(struct ar71xx_gpio_softc *sc, struct gpio_pin *pin,
193     unsigned int flags)
194 {
195
196         /*
197          * Manage input/output
198          */
199         if (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
200                 pin->gp_flags &= ~(GPIO_PIN_INPUT|GPIO_PIN_OUTPUT);
201                 if (flags & GPIO_PIN_OUTPUT) {
202                         pin->gp_flags |= GPIO_PIN_OUTPUT;
203                         ar71xx_gpio_oe_set_output(sc, pin->gp_pin);
204                 } else {
205                         pin->gp_flags |= GPIO_PIN_INPUT;
206                         ar71xx_gpio_oe_set_input(sc, pin->gp_pin);
207                 }
208         }
209 }
210
211 static device_t
212 ar71xx_gpio_get_bus(device_t dev)
213 {
214         struct ar71xx_gpio_softc *sc;
215
216         sc = device_get_softc(dev);
217
218         return (sc->busdev);
219 }
220
221 static int
222 ar71xx_gpio_pin_max(device_t dev, int *maxpin)
223 {
224
225         switch (ar71xx_soc) {
226                 case AR71XX_SOC_AR9130:
227                 case AR71XX_SOC_AR9132:
228                         *maxpin = AR91XX_GPIO_PINS - 1;
229                         break;
230                 case AR71XX_SOC_AR7240:
231                 case AR71XX_SOC_AR7242:
232                         *maxpin = AR724X_GPIO_PINS - 1;
233                         break;
234                 case AR71XX_SOC_AR7241:
235                         *maxpin = AR7241_GPIO_PINS - 1;
236                         break;
237                 case AR71XX_SOC_AR9330:
238                 case AR71XX_SOC_AR9331:
239                         *maxpin = AR933X_GPIO_COUNT - 1;
240                         break;
241                 case AR71XX_SOC_AR9341:
242                 case AR71XX_SOC_AR9342:
243                 case AR71XX_SOC_AR9344:
244                         *maxpin = AR934X_GPIO_COUNT - 1;
245                         break;
246                 case AR71XX_SOC_QCA9533:
247                 case AR71XX_SOC_QCA9533_V2:
248                         *maxpin = QCA953X_GPIO_COUNT - 1;
249                         break;
250                 case AR71XX_SOC_QCA9556:
251                 case AR71XX_SOC_QCA9558:
252                         *maxpin = QCA955X_GPIO_COUNT - 1;
253                         break;
254                 default:
255                         *maxpin = AR71XX_GPIO_PINS - 1;
256         }
257         return (0);
258 }
259
260 static int
261 ar71xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)
262 {
263         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
264         int i;
265
266         for (i = 0; i < sc->gpio_npins; i++) {
267                 if (sc->gpio_pins[i].gp_pin == pin)
268                         break;
269         }
270
271         if (i >= sc->gpio_npins)
272                 return (EINVAL);
273
274         GPIO_LOCK(sc);
275         *caps = sc->gpio_pins[i].gp_caps;
276         GPIO_UNLOCK(sc);
277
278         return (0);
279 }
280
281 static int
282 ar71xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
283 {
284         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
285         int i;
286
287         for (i = 0; i < sc->gpio_npins; i++) {
288                 if (sc->gpio_pins[i].gp_pin == pin)
289                         break;
290         }
291
292         if (i >= sc->gpio_npins)
293                 return (EINVAL);
294
295         GPIO_LOCK(sc);
296         *flags = sc->gpio_pins[i].gp_flags;
297         GPIO_UNLOCK(sc);
298
299         return (0);
300 }
301
302 static int
303 ar71xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
304 {
305         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
306         int i;
307
308         for (i = 0; i < sc->gpio_npins; i++) {
309                 if (sc->gpio_pins[i].gp_pin == pin)
310                         break;
311         }
312
313         if (i >= sc->gpio_npins)
314                 return (EINVAL);
315
316         GPIO_LOCK(sc);
317         memcpy(name, sc->gpio_pins[i].gp_name, GPIOMAXNAME);
318         GPIO_UNLOCK(sc);
319
320         return (0);
321 }
322
323 static int
324 ar71xx_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
325 {
326         int i;
327         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
328
329         for (i = 0; i < sc->gpio_npins; i++) {
330                 if (sc->gpio_pins[i].gp_pin == pin)
331                         break;
332         }
333
334         if (i >= sc->gpio_npins)
335                 return (EINVAL);
336
337         ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], flags);
338
339         return (0);
340 }
341
342 static int
343 ar71xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
344 {
345         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
346         int i;
347
348         for (i = 0; i < sc->gpio_npins; i++) {
349                 if (sc->gpio_pins[i].gp_pin == pin)
350                         break;
351         }
352
353         if (i >= sc->gpio_npins)
354                 return (EINVAL);
355
356         if (value)
357                 GPIO_WRITE(sc, AR71XX_GPIO_SET, (1 << pin));
358         else
359                 GPIO_WRITE(sc, AR71XX_GPIO_CLEAR, (1 << pin));
360
361         return (0);
362 }
363
364 static int
365 ar71xx_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val)
366 {
367         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
368         int i;
369
370         for (i = 0; i < sc->gpio_npins; i++) {
371                 if (sc->gpio_pins[i].gp_pin == pin)
372                         break;
373         }
374
375         if (i >= sc->gpio_npins)
376                 return (EINVAL);
377
378         *val = (GPIO_READ(sc, AR71XX_GPIO_IN) & (1 << pin)) ? 1 : 0;
379
380         return (0);
381 }
382
383 static int
384 ar71xx_gpio_pin_toggle(device_t dev, uint32_t pin)
385 {
386         int res, i;
387         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
388
389         for (i = 0; i < sc->gpio_npins; i++) {
390                 if (sc->gpio_pins[i].gp_pin == pin)
391                         break;
392         }
393
394         if (i >= sc->gpio_npins)
395                 return (EINVAL);
396
397         res = (GPIO_READ(sc, AR71XX_GPIO_IN) & (1 << pin)) ? 1 : 0;
398         if (res)
399                 GPIO_WRITE(sc, AR71XX_GPIO_CLEAR, (1 << pin));
400         else
401                 GPIO_WRITE(sc, AR71XX_GPIO_SET, (1 << pin));
402
403         return (0);
404 }
405
406 static int
407 ar71xx_gpio_filter(void *arg)
408 {
409
410         /* TODO: something useful */
411         return (FILTER_STRAY);
412 }
413
414
415
416 static void
417 ar71xx_gpio_intr(void *arg)
418 {
419         struct ar71xx_gpio_softc *sc = arg;
420         GPIO_LOCK(sc);
421         /* TODO: something useful */
422         GPIO_UNLOCK(sc);
423 }
424
425 static int
426 ar71xx_gpio_probe(device_t dev)
427 {
428
429         device_set_desc(dev, "Atheros AR71XX GPIO driver");
430         return (0);
431 }
432
433 static int
434 ar71xx_gpio_attach(device_t dev)
435 {
436         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
437         int i, j, maxpin;
438         int mask, pinon;
439         uint32_t oe;
440
441         KASSERT((device_get_unit(dev) == 0),
442             ("ar71xx_gpio: Only one gpio module supported"));
443
444         mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
445
446         /* Map control/status registers. */
447         sc->gpio_mem_rid = 0;
448         sc->gpio_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
449             &sc->gpio_mem_rid, RF_ACTIVE);
450
451         if (sc->gpio_mem_res == NULL) {
452                 device_printf(dev, "couldn't map memory\n");
453                 ar71xx_gpio_detach(dev);
454                 return (ENXIO);
455         }
456
457         if ((sc->gpio_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, 
458             &sc->gpio_irq_rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) {
459                 device_printf(dev, "unable to allocate IRQ resource\n");
460                 ar71xx_gpio_detach(dev);
461                 return (ENXIO);
462         }
463
464         if ((bus_setup_intr(dev, sc->gpio_irq_res, INTR_TYPE_MISC, 
465             ar71xx_gpio_filter, ar71xx_gpio_intr, sc, &sc->gpio_ih))) {
466                 device_printf(dev,
467                     "WARNING: unable to register interrupt handler\n");
468                 ar71xx_gpio_detach(dev);
469                 return (ENXIO);
470         }
471
472         sc->dev = dev;
473
474         /* Enable function bits that are required */
475         if (resource_int_value(device_get_name(dev), device_get_unit(dev),
476             "function_set", &mask) == 0) {
477                 device_printf(dev, "function_set: 0x%x\n", mask);
478                 ar71xx_gpio_function_enable(sc, mask);
479         }
480         /* Disable function bits that are required */
481         if (resource_int_value(device_get_name(dev), device_get_unit(dev),
482             "function_clear", &mask) == 0) {
483                 device_printf(dev, "function_clear: 0x%x\n", mask);
484                 ar71xx_gpio_function_disable(sc, mask);
485         }
486
487         /* Disable interrupts for all pins. */
488         GPIO_WRITE(sc, AR71XX_GPIO_INT_MASK, 0);
489
490         /* Initialise all pins specified in the mask, up to the pin count */
491         (void) ar71xx_gpio_pin_max(dev, &maxpin);
492         if (resource_int_value(device_get_name(dev), device_get_unit(dev),
493             "pinmask", &mask) != 0)
494                 mask = 0;
495         if (resource_int_value(device_get_name(dev), device_get_unit(dev),
496             "pinon", &pinon) != 0)
497                 pinon = 0;
498         device_printf(dev, "gpio pinmask=0x%x\n", mask);
499         for (j = 0; j <= maxpin; j++) {
500                 if ((mask & (1 << j)) == 0)
501                         continue;
502                 sc->gpio_npins++;
503         }
504         /* Iniatilize the GPIO pins, keep the loader settings. */
505         oe = GPIO_READ(sc, AR71XX_GPIO_OE);
506         /*
507          * For AR934x and QCA953x, the meaning of oe is inverted;
508          * so flip it the right way around so we can parse the GPIO
509          * state.
510          */
511         if (!ar71xx_gpio_oe_is_high())
512                 oe = ~oe;
513
514         sc->gpio_pins = malloc(sizeof(*sc->gpio_pins) * sc->gpio_npins,
515             M_DEVBUF, M_WAITOK | M_ZERO);
516         for (i = 0, j = 0; j <= maxpin; j++) {
517                 if ((mask & (1 << j)) == 0)
518                         continue;
519                 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
520                     "pin %d", j);
521                 sc->gpio_pins[i].gp_pin = j;
522                 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
523                 if (oe & (1 << j))
524                         sc->gpio_pins[i].gp_flags = GPIO_PIN_OUTPUT;
525                 else
526                         sc->gpio_pins[i].gp_flags = GPIO_PIN_INPUT;
527                 i++;
528         }
529
530         /* Turn on the hinted pins. */
531         for (i = 0; i < sc->gpio_npins; i++) {
532                 j = sc->gpio_pins[i].gp_pin;
533                 if ((pinon & (1 << j)) != 0) {
534                         ar71xx_gpio_pin_setflags(dev, j, GPIO_PIN_OUTPUT);
535                         ar71xx_gpio_pin_set(dev, j, 1);
536                 }
537         }
538
539         /*
540          * Search through the function hints, in case there's some
541          * overrides such as LNA control.
542          *
543          * hint.gpio.X.func.<pin>.gpiofunc=<func value>
544          * hint.gpio.X.func.<pin>.gpiomode=1 (for output, default low)
545          */
546         for (i = 0; i <= maxpin; i++) {
547                 char buf[32];
548                 int gpiofunc, gpiomode;
549
550                 snprintf(buf, 32, "func.%d.gpiofunc", i);
551                 if (resource_int_value(device_get_name(dev),
552                     device_get_unit(dev),
553                     buf,
554                     &gpiofunc) != 0)
555                         continue;
556                 /* Get the mode too */
557                 snprintf(buf, 32, "func.%d.gpiomode", i);
558                 if (resource_int_value(device_get_name(dev),
559                     device_get_unit(dev),
560                     buf,
561                     &gpiomode) != 0)
562                         continue;
563
564                 /* We only handle mode=1 (output) for now */
565                 if (gpiomode != 1)
566                         continue;
567
568                 device_printf(dev, "%s: GPIO %d: func=%d, mode=%d\n",
569                     __func__,
570                     i,
571                     gpiofunc,
572                     gpiomode);
573
574                 /* Set pin value = 0, so it stays low by default */
575                 oe = GPIO_READ(sc, AR71XX_GPIO_OUT);
576                 oe &= ~ (1 << i);
577                 GPIO_WRITE(sc, AR71XX_GPIO_OUT, oe);
578
579                 /* Set output */
580                 ar71xx_gpio_oe_set_output(sc, i);
581
582                 /* Finally: Set the output config */
583                 ar71xx_gpio_ouput_configure(i, gpiofunc);
584         }
585
586         sc->busdev = gpiobus_attach_bus(dev);
587         if (sc->busdev == NULL) {
588                 ar71xx_gpio_detach(dev);
589                 return (ENXIO);
590         }
591
592         return (0);
593 }
594
595 static int
596 ar71xx_gpio_detach(device_t dev)
597 {
598         struct ar71xx_gpio_softc *sc = device_get_softc(dev);
599
600         KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized"));
601
602         gpiobus_detach_bus(dev);
603         if (sc->gpio_ih)
604                 bus_teardown_intr(dev, sc->gpio_irq_res, sc->gpio_ih);
605         if (sc->gpio_irq_res)
606                 bus_release_resource(dev, SYS_RES_IRQ, sc->gpio_irq_rid,
607                     sc->gpio_irq_res);
608         if (sc->gpio_mem_res)
609                 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
610                     sc->gpio_mem_res);
611         if (sc->gpio_pins)
612                 free(sc->gpio_pins, M_DEVBUF);
613         mtx_destroy(&sc->gpio_mtx);
614
615         return(0);
616 }
617
618 static device_method_t ar71xx_gpio_methods[] = {
619         DEVMETHOD(device_probe, ar71xx_gpio_probe),
620         DEVMETHOD(device_attach, ar71xx_gpio_attach),
621         DEVMETHOD(device_detach, ar71xx_gpio_detach),
622
623         /* GPIO protocol */
624         DEVMETHOD(gpio_get_bus, ar71xx_gpio_get_bus),
625         DEVMETHOD(gpio_pin_max, ar71xx_gpio_pin_max),
626         DEVMETHOD(gpio_pin_getname, ar71xx_gpio_pin_getname),
627         DEVMETHOD(gpio_pin_getflags, ar71xx_gpio_pin_getflags),
628         DEVMETHOD(gpio_pin_getcaps, ar71xx_gpio_pin_getcaps),
629         DEVMETHOD(gpio_pin_setflags, ar71xx_gpio_pin_setflags),
630         DEVMETHOD(gpio_pin_get, ar71xx_gpio_pin_get),
631         DEVMETHOD(gpio_pin_set, ar71xx_gpio_pin_set),
632         DEVMETHOD(gpio_pin_toggle, ar71xx_gpio_pin_toggle),
633         {0, 0},
634 };
635
636 static driver_t ar71xx_gpio_driver = {
637         "gpio",
638         ar71xx_gpio_methods,
639         sizeof(struct ar71xx_gpio_softc),
640 };
641 static devclass_t ar71xx_gpio_devclass;
642
643 DRIVER_MODULE(ar71xx_gpio, apb, ar71xx_gpio_driver, ar71xx_gpio_devclass, 0, 0);