]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/at91/at91_pio.c
Properly support the GPIO_PIN_PRESET_{LOW,HIGH} options when configuring
[FreeBSD/FreeBSD.git] / sys / arm / at91 / at91_pio.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2006 M. Warner Losh.
5  * Copyright (C) 2012 Ian Lepore. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28
29 #include "opt_platform.h"
30
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/bus.h>
37 #include <sys/conf.h>
38 #include <sys/kernel.h>
39 #include <sys/lock.h>
40 #include <sys/mbuf.h>
41 #include <sys/malloc.h>
42 #include <sys/module.h>
43 #include <sys/poll.h>
44 #include <sys/rman.h>
45 #include <sys/selinfo.h>
46 #include <sys/sx.h>
47 #include <sys/uio.h>
48 #include <machine/at91_gpio.h>
49 #include <machine/bus.h>
50
51 #include <arm/at91/at91reg.h>
52 #include <arm/at91/at91_pioreg.h>
53 #include <arm/at91/at91_piovar.h>
54
55 #ifdef FDT
56 #include <dev/ofw/ofw_bus.h>
57 #include <dev/ofw/ofw_bus_subr.h>
58 #endif
59
60 #define MAX_CHANGE      64
61
62 struct at91_pio_softc
63 {
64         device_t dev;                   /* Myself */
65         void *intrhand;                 /* Interrupt handle */
66         struct resource *irq_res;       /* IRQ resource */
67         struct resource *mem_res;       /* Memory resource */
68         struct sx sc_mtx;               /* basically a perimeter lock */
69         struct cdev *cdev;
70         struct selinfo selp;
71         int buflen;
72         uint8_t buf[MAX_CHANGE];
73         int flags;
74 #define OPENED 1
75 };
76
77 static inline uint32_t
78 RD4(struct at91_pio_softc *sc, bus_size_t off)
79 {
80
81         return (bus_read_4(sc->mem_res, off));
82 }
83
84 static inline void
85 WR4(struct at91_pio_softc *sc, bus_size_t off, uint32_t val)
86 {
87
88         bus_write_4(sc->mem_res, off, val);
89 }
90
91 #define AT91_PIO_LOCK(_sc)              sx_xlock(&(_sc)->sc_mtx)
92 #define AT91_PIO_UNLOCK(_sc)            sx_xunlock(&(_sc)->sc_mtx)
93 #define AT91_PIO_LOCK_INIT(_sc) \
94         sx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev))
95 #define AT91_PIO_LOCK_DESTROY(_sc)      sx_destroy(&_sc->sc_mtx);
96 #define AT91_PIO_ASSERT_LOCKED(_sc)     sx_assert(&_sc->sc_mtx, SA_XLOCKED);
97 #define AT91_PIO_ASSERT_UNLOCKED(_sc)   sx_assert(&_sc->sc_mtx, SA_UNLOCKED);
98 #define CDEV2SOFTC(dev)                 ((dev)->si_drv1)
99
100 static devclass_t at91_pio_devclass;
101
102 /* bus entry points */
103
104 static int at91_pio_probe(device_t dev);
105 static int at91_pio_attach(device_t dev);
106 static int at91_pio_detach(device_t dev);
107 static void at91_pio_intr(void *);
108
109 /* helper routines */
110 static int at91_pio_activate(device_t dev);
111 static void at91_pio_deactivate(device_t dev);
112
113 /* cdev routines */
114 static d_open_t at91_pio_open;
115 static d_close_t at91_pio_close;
116 static d_read_t at91_pio_read;
117 static d_poll_t at91_pio_poll;
118 static d_ioctl_t at91_pio_ioctl;
119
120 static struct cdevsw at91_pio_cdevsw =
121 {
122         .d_version = D_VERSION,
123         .d_open = at91_pio_open,
124         .d_close = at91_pio_close,
125         .d_read = at91_pio_read,
126         .d_poll = at91_pio_poll,
127         .d_ioctl = at91_pio_ioctl
128 };
129
130 static int
131 at91_pio_probe(device_t dev)
132 {
133         const char *name;
134 #ifdef FDT
135         if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-gpio"))
136                 return (ENXIO);
137 #endif
138         switch (device_get_unit(dev)) {
139         case 0:
140                 name = "PIOA";
141                 break;
142         case 1:
143                 name = "PIOB";
144                 break;
145         case 2:
146                 name = "PIOC";
147                 break;
148         case 3:
149                 name = "PIOD";
150                 break;
151         case 4:
152                 name = "PIOE";
153                 break;
154         case 5:
155                 name = "PIOF";
156                 break;
157         default:
158                 name = "PIO";
159                 break;
160         }
161         device_set_desc(dev, name);
162         return (0);
163 }
164
165 static int
166 at91_pio_attach(device_t dev)
167 {
168         struct at91_pio_softc *sc;
169         int err;
170
171         sc = device_get_softc(dev);
172         sc->dev = dev;
173         err = at91_pio_activate(dev);
174         if (err)
175                 goto out;
176
177         if (bootverbose)
178                 device_printf(dev, "ABSR: %#x OSR: %#x PSR:%#x ODSR: %#x\n",
179                     RD4(sc, PIO_ABSR), RD4(sc, PIO_OSR), RD4(sc, PIO_PSR),
180                     RD4(sc, PIO_ODSR));
181         AT91_PIO_LOCK_INIT(sc);
182
183         /*
184          * Activate the interrupt, but disable all interrupts in the hardware.
185          */
186         WR4(sc, PIO_IDR, 0xffffffff);
187         err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
188             NULL, at91_pio_intr, sc, &sc->intrhand);
189         if (err) {
190                 AT91_PIO_LOCK_DESTROY(sc);
191                 goto out;
192         }
193         sc->cdev = make_dev(&at91_pio_cdevsw, device_get_unit(dev), UID_ROOT,
194             GID_WHEEL, 0600, "pio%d", device_get_unit(dev));
195         if (sc->cdev == NULL) {
196                 err = ENOMEM;
197                 goto out;
198         }
199         sc->cdev->si_drv1 = sc;
200 out:
201         if (err)
202                 at91_pio_deactivate(dev);
203         return (err);
204 }
205
206 static int
207 at91_pio_detach(device_t dev)
208 {
209
210         return (EBUSY); /* XXX */
211 }
212
213 static int
214 at91_pio_activate(device_t dev)
215 {
216         struct at91_pio_softc *sc;
217         int rid;
218
219         sc = device_get_softc(dev);
220         rid = 0;
221         sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
222             RF_ACTIVE);
223         if (sc->mem_res == NULL)
224                 goto errout;
225         rid = 0;
226         sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
227             RF_ACTIVE | RF_SHAREABLE);
228         if (sc->irq_res == NULL)
229                 goto errout;
230         return (0);
231 errout:
232         at91_pio_deactivate(dev);
233         return (ENOMEM);
234 }
235
236 static void
237 at91_pio_deactivate(device_t dev)
238 {
239         struct at91_pio_softc *sc;
240
241         sc = device_get_softc(dev);
242         if (sc->intrhand)
243                 bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
244         sc->intrhand = NULL;
245         bus_generic_detach(sc->dev);
246         if (sc->mem_res)
247                 bus_release_resource(dev, SYS_RES_MEMORY,
248                     rman_get_rid(sc->mem_res), sc->mem_res);
249         sc->mem_res = NULL;
250         if (sc->irq_res)
251                 bus_release_resource(dev, SYS_RES_IRQ,
252                     rman_get_rid(sc->irq_res), sc->irq_res);
253         sc->irq_res = NULL;
254 }
255
256 static void
257 at91_pio_intr(void *xsc)
258 {
259         struct at91_pio_softc *sc = xsc;
260         uint32_t status;
261         int i;
262
263         /* Reading the status also clears the interrupt. */
264         status = RD4(sc, PIO_ISR) & RD4(sc, PIO_IMR);
265         if (status != 0) {
266                 AT91_PIO_LOCK(sc);
267                 for (i = 0; status != 0 && sc->buflen < MAX_CHANGE; ++i) {
268                         if (status & 1)
269                                 sc->buf[sc->buflen++] = (uint8_t)i;
270                         status >>= 1;
271                 }
272                 AT91_PIO_UNLOCK(sc);
273                 wakeup(sc);
274                 selwakeup(&sc->selp);
275         }
276 }
277
278 static int
279 at91_pio_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
280 {
281         struct at91_pio_softc *sc;
282
283         sc = CDEV2SOFTC(dev);
284         AT91_PIO_LOCK(sc);
285         if (!(sc->flags & OPENED)) {
286                 sc->flags |= OPENED;
287         }
288         AT91_PIO_UNLOCK(sc);
289         return (0);
290 }
291
292 static int
293 at91_pio_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
294 {
295         struct at91_pio_softc *sc;
296
297         sc = CDEV2SOFTC(dev);
298         AT91_PIO_LOCK(sc);
299         sc->flags &= ~OPENED;
300         AT91_PIO_UNLOCK(sc);
301         return (0);
302 }
303
304 static int
305 at91_pio_poll(struct cdev *dev, int events, struct thread *td)
306 {
307         struct at91_pio_softc *sc;
308         int revents = 0;
309
310         sc = CDEV2SOFTC(dev);
311         AT91_PIO_LOCK(sc);
312         if (events & (POLLIN | POLLRDNORM)) {
313                 if (sc->buflen != 0)
314                         revents |= events & (POLLIN | POLLRDNORM);
315                 else
316                         selrecord(td, &sc->selp);
317         }
318         AT91_PIO_UNLOCK(sc);
319
320         return (revents);
321 }
322
323 static int
324 at91_pio_read(struct cdev *dev, struct uio *uio, int flag)
325 {
326         struct at91_pio_softc *sc;
327         int err, ret, len;
328
329         sc = CDEV2SOFTC(dev);
330         AT91_PIO_LOCK(sc);
331         err = 0;
332         ret = 0;
333         while (uio->uio_resid) {
334                 while (sc->buflen == 0 && err == 0)
335                         err = msleep(sc, &sc->sc_mtx, PCATCH | PZERO, "prd", 0);
336                 if (err != 0)
337                         break;
338                 len = MIN(sc->buflen, uio->uio_resid);
339                 err = uiomove(sc->buf, len, uio);
340                 if (err != 0)
341                         break;
342                 /*
343                  * If we read the whole thing no datacopy is needed,
344                  * otherwise we move the data down.
345                  */
346                 ret += len;
347                 if (sc->buflen == len)
348                         sc->buflen = 0;
349                 else {
350                         bcopy(sc->buf + len, sc->buf, sc->buflen - len);
351                         sc->buflen -= len;
352                 }
353                 /* If there's no data left, end the read. */
354                 if (sc->buflen == 0)
355                         break;
356         }
357         AT91_PIO_UNLOCK(sc);
358         return (err);
359 }
360
361 static void
362 at91_pio_bang32(struct at91_pio_softc *sc, uint32_t bits, uint32_t datapin,
363     uint32_t clockpin)
364 {
365         int i;
366
367         for (i = 0; i < 32; i++) {
368                 if (bits & 0x80000000)
369                         WR4(sc, PIO_SODR, datapin);
370                 else
371                         WR4(sc, PIO_CODR, datapin);
372                 bits <<= 1;
373                 WR4(sc, PIO_CODR, clockpin);
374                 WR4(sc, PIO_SODR, clockpin);
375         }
376 }
377
378 static void
379 at91_pio_bang(struct at91_pio_softc *sc, uint8_t bits, uint32_t bitcount, 
380               uint32_t datapin, uint32_t clockpin)
381 {
382         int i;
383
384         for (i = 0; i < bitcount; i++) {
385                 if (bits & 0x80)
386                         WR4(sc, PIO_SODR, datapin);
387                 else
388                         WR4(sc, PIO_CODR, datapin);
389                 bits <<= 1;
390                 WR4(sc, PIO_CODR, clockpin);
391                 WR4(sc, PIO_SODR, clockpin);
392         }
393 }
394
395 static int
396 at91_pio_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
397     struct thread *td)
398 {
399         struct at91_pio_softc *sc;
400         struct at91_gpio_cfg *cfg;
401         struct at91_gpio_info *info;
402         struct at91_gpio_bang *bang;
403         struct at91_gpio_bang_many *bangmany;
404         uint32_t i, num;
405         uint8_t many[1024], *walker;
406         int err;
407         int bitcount;
408
409         sc = CDEV2SOFTC(dev);
410         switch(cmd) {
411         case AT91_GPIO_SET:     /* turn bits on */
412                 WR4(sc, PIO_SODR, *(uint32_t *)data);
413                 return (0);
414         case AT91_GPIO_CLR:     /* turn bits off */
415                 WR4(sc, PIO_CODR, *(uint32_t *)data);
416                 return (0);
417         case AT91_GPIO_READ:    /* Get the status of input bits */
418                 *(uint32_t *)data = RD4(sc, PIO_PDSR);
419                 return (0);
420         case AT91_GPIO_CFG:     /* Configure AT91_GPIO pins */
421                 cfg = (struct at91_gpio_cfg *)data;
422                 if (cfg->cfgmask & AT91_GPIO_CFG_INPUT) {
423                         WR4(sc, PIO_OER, cfg->iomask & ~cfg->input);
424                         WR4(sc, PIO_ODR, cfg->iomask & cfg->input);
425                 }
426                 if (cfg->cfgmask & AT91_GPIO_CFG_HI_Z) {
427                         WR4(sc, PIO_MDDR, cfg->iomask & ~cfg->hi_z);
428                         WR4(sc, PIO_MDER, cfg->iomask & cfg->hi_z);
429                 }
430                 if (cfg->cfgmask & AT91_GPIO_CFG_PULLUP) {
431                         WR4(sc, PIO_PUDR, cfg->iomask & ~cfg->pullup);
432                         WR4(sc, PIO_PUER, cfg->iomask & cfg->pullup);
433                 }
434                 if (cfg->cfgmask & AT91_GPIO_CFG_GLITCH) {
435                         WR4(sc, PIO_IFDR, cfg->iomask & ~cfg->glitch);
436                         WR4(sc, PIO_IFER, cfg->iomask & cfg->glitch);
437                 }
438                 if (cfg->cfgmask & AT91_GPIO_CFG_GPIO) {
439                         WR4(sc, PIO_PDR, cfg->iomask & ~cfg->gpio);
440                         WR4(sc, PIO_PER, cfg->iomask & cfg->gpio);
441                 }
442                 if (cfg->cfgmask & AT91_GPIO_CFG_PERIPH) {
443                         WR4(sc, PIO_ASR, cfg->iomask & ~cfg->periph);
444                         WR4(sc, PIO_BSR, cfg->iomask & cfg->periph);
445                 }
446                 if (cfg->cfgmask & AT91_GPIO_CFG_INTR) {
447                         WR4(sc, PIO_IDR, cfg->iomask & ~cfg->intr);
448                         WR4(sc, PIO_IER, cfg->iomask & cfg->intr);
449                 }
450                 return (0);
451         case AT91_GPIO_BANG:
452                 bang = (struct at91_gpio_bang *)data;
453                 at91_pio_bang32(sc, bang->bits, bang->datapin, bang->clockpin);
454                 return (0);
455         case AT91_GPIO_BANG_MANY:
456                 bangmany = (struct at91_gpio_bang_many *)data;
457                 walker = (uint8_t *)bangmany->bits;
458                 bitcount = bangmany->numbits;
459                 while (bitcount > 0) {
460                         num = MIN((bitcount + 7) / 8, sizeof(many));
461                         err = copyin(walker, many, num);
462                         if (err)
463                                 return err;
464                         for (i = 0; i < num && bitcount > 0; i++, bitcount -= 8) 
465                                 if (bitcount >= 8)
466                                         at91_pio_bang(sc, many[i], 8, bangmany->datapin, bangmany->clockpin);
467                                 else
468                                         at91_pio_bang(sc, many[i], bitcount, bangmany->datapin, bangmany->clockpin);
469                         walker += num;
470                 }
471                 return (0);
472         case AT91_GPIO_INFO:    /* Learn about this device's AT91_GPIO bits */
473                 info = (struct at91_gpio_info *)data;
474                 info->output_status = RD4(sc, PIO_ODSR);
475                 info->input_status = RD4(sc, PIO_OSR);
476                 info->highz_status = RD4(sc, PIO_MDSR);
477                 info->pullup_status = RD4(sc, PIO_PUSR);
478                 info->glitch_status = RD4(sc, PIO_IFSR);
479                 info->enabled_status = RD4(sc, PIO_PSR);
480                 info->periph_status = RD4(sc, PIO_ABSR);
481                 info->intr_status = RD4(sc, PIO_IMR);
482                 memset(info->extra_status, 0, sizeof(info->extra_status));
483                 return (0);
484         }
485         return (ENOTTY);
486 }
487
488 /*
489  * The following functions are called early in the boot process, so
490  * don't use bus_space, as that isn't yet available when we need to use
491  * them.
492  */
493
494 void
495 at91_pio_use_periph_a(uint32_t pio, uint32_t periph_a_mask, int use_pullup)
496 {
497         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
498
499         PIO[PIO_ASR / 4] = periph_a_mask;
500         PIO[PIO_PDR / 4] = periph_a_mask;
501         if (use_pullup)
502                 PIO[PIO_PUER / 4] = periph_a_mask;
503         else
504                 PIO[PIO_PUDR / 4] = periph_a_mask;
505 }
506
507 void
508 at91_pio_use_periph_b(uint32_t pio, uint32_t periph_b_mask, int use_pullup)
509 {
510         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
511
512         PIO[PIO_BSR / 4] = periph_b_mask;
513         PIO[PIO_PDR / 4] = periph_b_mask;
514         if (use_pullup)
515                 PIO[PIO_PUER / 4] = periph_b_mask;
516         else
517                 PIO[PIO_PUDR / 4] = periph_b_mask;
518 }
519
520 void
521 at91_pio_use_gpio(uint32_t pio, uint32_t gpio_mask)
522 {
523         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
524
525         PIO[PIO_PER / 4] = gpio_mask;
526 }
527
528 void
529 at91_pio_gpio_input(uint32_t pio, uint32_t input_enable_mask)
530 {
531         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
532
533         PIO[PIO_ODR / 4] = input_enable_mask;
534 }
535
536 void
537 at91_pio_gpio_output(uint32_t pio, uint32_t output_enable_mask, int use_pullup)
538 {
539         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
540
541         PIO[PIO_OER / 4] = output_enable_mask;
542         if (use_pullup)
543                 PIO[PIO_PUER / 4] = output_enable_mask;
544         else
545                 PIO[PIO_PUDR / 4] = output_enable_mask;
546 }
547
548 void
549 at91_pio_gpio_high_z(uint32_t pio, uint32_t high_z_mask, int enable)
550 {
551         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
552
553         if (enable)
554                 PIO[PIO_MDER / 4] = high_z_mask;
555         else
556                 PIO[PIO_MDDR / 4] = high_z_mask;
557 }
558
559 void
560 at91_pio_gpio_set(uint32_t pio, uint32_t data_mask)
561 {
562         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
563
564         PIO[PIO_SODR / 4] = data_mask;
565 }
566
567 void
568 at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask)
569 {
570         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
571
572         PIO[PIO_CODR / 4] = data_mask;
573 }
574
575 uint32_t
576 at91_pio_gpio_get(uint32_t pio, uint32_t data_mask)
577 {
578         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
579
580         return (PIO[PIO_PDSR / 4] & data_mask);
581 }
582
583 void
584 at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch)
585 {
586         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
587
588         if (use_deglitch)
589                 PIO[PIO_IFER / 4] = data_mask;
590         else
591                 PIO[PIO_IFDR / 4] = data_mask;
592 }
593
594 void
595 at91_pio_gpio_pullup(uint32_t pio, uint32_t data_mask, int do_pullup)
596 {
597         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
598
599         if (do_pullup)
600                 PIO[PIO_PUER / 4] = data_mask;
601         else
602                 PIO[PIO_PUDR / 4] = data_mask;
603 }
604
605 void
606 at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask,
607         int enable_interrupt)
608 {
609         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
610
611         if (enable_interrupt)
612                 PIO[PIO_IER / 4] = data_mask;
613         else
614                 PIO[PIO_IDR / 4] = data_mask;
615 }
616
617 uint32_t
618 at91_pio_gpio_clear_interrupt(uint32_t pio)
619 {
620         uint32_t *PIO = (uint32_t *)(AT91_BASE + pio);
621
622         /* Reading this register will clear the interrupts. */
623         return (PIO[PIO_ISR / 4]);
624 }
625
626 static void
627 at91_pio_new_pass(device_t dev)
628 {
629
630         device_printf(dev, "Pass %d\n", bus_current_pass);
631 }
632
633 static device_method_t at91_pio_methods[] = {
634         /* Device interface */
635         DEVMETHOD(device_probe,         at91_pio_probe),
636         DEVMETHOD(device_attach,        at91_pio_attach),
637         DEVMETHOD(device_detach,        at91_pio_detach),
638
639         DEVMETHOD(bus_new_pass,         at91_pio_new_pass),
640
641         DEVMETHOD_END
642 };
643
644 static driver_t at91_pio_driver = {
645         "at91_pio",
646         at91_pio_methods,
647         sizeof(struct at91_pio_softc),
648 };
649
650 #ifdef FDT
651 EARLY_DRIVER_MODULE(at91_pio, at91_pinctrl, at91_pio_driver, at91_pio_devclass,
652     NULL, NULL, BUS_PASS_INTERRUPT);
653 #else
654 DRIVER_MODULE(at91_pio, atmelarm, at91_pio_driver, at91_pio_devclass, NULL, NULL);
655 #endif