Linux-libre 4.4.228-gnu
[librecmc/linux-libre.git] / drivers / thunderbolt / nhi.c
1 /*
2  * Thunderbolt Cactus Ridge driver - NHI driver
3  *
4  * The NHI (native host interface) is the pci device that allows us to send and
5  * receive frames from the thunderbolt bus.
6  *
7  * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
8  */
9
10 #include <linux/pm_runtime.h>
11 #include <linux/slab.h>
12 #include <linux/errno.h>
13 #include <linux/pci.h>
14 #include <linux/interrupt.h>
15 #include <linux/module.h>
16 #include <linux/dmi.h>
17
18 #include "nhi.h"
19 #include "nhi_regs.h"
20 #include "tb.h"
21
22 #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring")
23
24
25 static int ring_interrupt_index(struct tb_ring *ring)
26 {
27         int bit = ring->hop;
28         if (!ring->is_tx)
29                 bit += ring->nhi->hop_count;
30         return bit;
31 }
32
33 /**
34  * ring_interrupt_active() - activate/deactivate interrupts for a single ring
35  *
36  * ring->nhi->lock must be held.
37  */
38 static void ring_interrupt_active(struct tb_ring *ring, bool active)
39 {
40         int reg = REG_RING_INTERRUPT_BASE + ring_interrupt_index(ring) / 32;
41         int bit = ring_interrupt_index(ring) & 31;
42         int mask = 1 << bit;
43         u32 old, new;
44         old = ioread32(ring->nhi->iobase + reg);
45         if (active)
46                 new = old | mask;
47         else
48                 new = old & ~mask;
49
50         dev_info(&ring->nhi->pdev->dev,
51                  "%s interrupt at register %#x bit %d (%#x -> %#x)\n",
52                  active ? "enabling" : "disabling", reg, bit, old, new);
53
54         if (new == old)
55                 dev_WARN(&ring->nhi->pdev->dev,
56                                          "interrupt for %s %d is already %s\n",
57                                          RING_TYPE(ring), ring->hop,
58                                          active ? "enabled" : "disabled");
59         iowrite32(new, ring->nhi->iobase + reg);
60 }
61
62 /**
63  * nhi_disable_interrupts() - disable interrupts for all rings
64  *
65  * Use only during init and shutdown.
66  */
67 static void nhi_disable_interrupts(struct tb_nhi *nhi)
68 {
69         int i = 0;
70         /* disable interrupts */
71         for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++)
72                 iowrite32(0, nhi->iobase + REG_RING_INTERRUPT_BASE + 4 * i);
73
74         /* clear interrupt status bits */
75         for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++)
76                 ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + 4 * i);
77 }
78
79 /* ring helper methods */
80
81 static void __iomem *ring_desc_base(struct tb_ring *ring)
82 {
83         void __iomem *io = ring->nhi->iobase;
84         io += ring->is_tx ? REG_TX_RING_BASE : REG_RX_RING_BASE;
85         io += ring->hop * 16;
86         return io;
87 }
88
89 static void __iomem *ring_options_base(struct tb_ring *ring)
90 {
91         void __iomem *io = ring->nhi->iobase;
92         io += ring->is_tx ? REG_TX_OPTIONS_BASE : REG_RX_OPTIONS_BASE;
93         io += ring->hop * 32;
94         return io;
95 }
96
97 static void ring_iowrite_cons(struct tb_ring *ring, u16 cons)
98 {
99         /*
100          * The other 16-bits in the register is read-only and writes to it
101          * are ignored by the hardware so we can save one ioread32() by
102          * filling the read-only bits with zeroes.
103          */
104         iowrite32(cons, ring_desc_base(ring) + 8);
105 }
106
107 static void ring_iowrite_prod(struct tb_ring *ring, u16 prod)
108 {
109         /* See ring_iowrite_cons() above for explanation */
110         iowrite32(prod << 16, ring_desc_base(ring) + 8);
111 }
112
113 static void ring_iowrite32desc(struct tb_ring *ring, u32 value, u32 offset)
114 {
115         iowrite32(value, ring_desc_base(ring) + offset);
116 }
117
118 static void ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset)
119 {
120         iowrite32(value, ring_desc_base(ring) + offset);
121         iowrite32(value >> 32, ring_desc_base(ring) + offset + 4);
122 }
123
124 static void ring_iowrite32options(struct tb_ring *ring, u32 value, u32 offset)
125 {
126         iowrite32(value, ring_options_base(ring) + offset);
127 }
128
129 static bool ring_full(struct tb_ring *ring)
130 {
131         return ((ring->head + 1) % ring->size) == ring->tail;
132 }
133
134 static bool ring_empty(struct tb_ring *ring)
135 {
136         return ring->head == ring->tail;
137 }
138
139 /**
140  * ring_write_descriptors() - post frames from ring->queue to the controller
141  *
142  * ring->lock is held.
143  */
144 static void ring_write_descriptors(struct tb_ring *ring)
145 {
146         struct ring_frame *frame, *n;
147         struct ring_desc *descriptor;
148         list_for_each_entry_safe(frame, n, &ring->queue, list) {
149                 if (ring_full(ring))
150                         break;
151                 list_move_tail(&frame->list, &ring->in_flight);
152                 descriptor = &ring->descriptors[ring->head];
153                 descriptor->phys = frame->buffer_phy;
154                 descriptor->time = 0;
155                 descriptor->flags = RING_DESC_POSTED | RING_DESC_INTERRUPT;
156                 if (ring->is_tx) {
157                         descriptor->length = frame->size;
158                         descriptor->eof = frame->eof;
159                         descriptor->sof = frame->sof;
160                 }
161                 ring->head = (ring->head + 1) % ring->size;
162                 if (ring->is_tx)
163                         ring_iowrite_prod(ring, ring->head);
164                 else
165                         ring_iowrite_cons(ring, ring->head);
166         }
167 }
168
169 /**
170  * ring_work() - progress completed frames
171  *
172  * If the ring is shutting down then all frames are marked as canceled and
173  * their callbacks are invoked.
174  *
175  * Otherwise we collect all completed frame from the ring buffer, write new
176  * frame to the ring buffer and invoke the callbacks for the completed frames.
177  */
178 static void ring_work(struct work_struct *work)
179 {
180         struct tb_ring *ring = container_of(work, typeof(*ring), work);
181         struct ring_frame *frame;
182         bool canceled = false;
183         LIST_HEAD(done);
184         mutex_lock(&ring->lock);
185
186         if (!ring->running) {
187                 /*  Move all frames to done and mark them as canceled. */
188                 list_splice_tail_init(&ring->in_flight, &done);
189                 list_splice_tail_init(&ring->queue, &done);
190                 canceled = true;
191                 goto invoke_callback;
192         }
193
194         while (!ring_empty(ring)) {
195                 if (!(ring->descriptors[ring->tail].flags
196                                 & RING_DESC_COMPLETED))
197                         break;
198                 frame = list_first_entry(&ring->in_flight, typeof(*frame),
199                                          list);
200                 list_move_tail(&frame->list, &done);
201                 if (!ring->is_tx) {
202                         frame->size = ring->descriptors[ring->tail].length;
203                         frame->eof = ring->descriptors[ring->tail].eof;
204                         frame->sof = ring->descriptors[ring->tail].sof;
205                         frame->flags = ring->descriptors[ring->tail].flags;
206                         if (frame->sof != 0)
207                                 dev_WARN(&ring->nhi->pdev->dev,
208                                          "%s %d got unexpected SOF: %#x\n",
209                                          RING_TYPE(ring), ring->hop,
210                                          frame->sof);
211                         /*
212                          * known flags:
213                          * raw not enabled, interupt not set: 0x2=0010
214                          * raw enabled: 0xa=1010
215                          * raw not enabled: 0xb=1011
216                          * partial frame (>MAX_FRAME_SIZE): 0xe=1110
217                          */
218                         if (frame->flags != 0xa)
219                                 dev_WARN(&ring->nhi->pdev->dev,
220                                          "%s %d got unexpected flags: %#x\n",
221                                          RING_TYPE(ring), ring->hop,
222                                          frame->flags);
223                 }
224                 ring->tail = (ring->tail + 1) % ring->size;
225         }
226         ring_write_descriptors(ring);
227
228 invoke_callback:
229         mutex_unlock(&ring->lock); /* allow callbacks to schedule new work */
230         while (!list_empty(&done)) {
231                 frame = list_first_entry(&done, typeof(*frame), list);
232                 /*
233                  * The callback may reenqueue or delete frame.
234                  * Do not hold on to it.
235                  */
236                 list_del_init(&frame->list);
237                 frame->callback(ring, frame, canceled);
238         }
239 }
240
241 int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame)
242 {
243         int ret = 0;
244         mutex_lock(&ring->lock);
245         if (ring->running) {
246                 list_add_tail(&frame->list, &ring->queue);
247                 ring_write_descriptors(ring);
248         } else {
249                 ret = -ESHUTDOWN;
250         }
251         mutex_unlock(&ring->lock);
252         return ret;
253 }
254
255 static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
256                                   bool transmit)
257 {
258         struct tb_ring *ring = NULL;
259         dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n",
260                  transmit ? "TX" : "RX", hop, size);
261
262         mutex_lock(&nhi->lock);
263         if (hop >= nhi->hop_count) {
264                 dev_WARN(&nhi->pdev->dev, "invalid hop: %d\n", hop);
265                 goto err;
266         }
267         if (transmit && nhi->tx_rings[hop]) {
268                 dev_WARN(&nhi->pdev->dev, "TX hop %d already allocated\n", hop);
269                 goto err;
270         } else if (!transmit && nhi->rx_rings[hop]) {
271                 dev_WARN(&nhi->pdev->dev, "RX hop %d already allocated\n", hop);
272                 goto err;
273         }
274         ring = kzalloc(sizeof(*ring), GFP_KERNEL);
275         if (!ring)
276                 goto err;
277
278         mutex_init(&ring->lock);
279         INIT_LIST_HEAD(&ring->queue);
280         INIT_LIST_HEAD(&ring->in_flight);
281         INIT_WORK(&ring->work, ring_work);
282
283         ring->nhi = nhi;
284         ring->hop = hop;
285         ring->is_tx = transmit;
286         ring->size = size;
287         ring->head = 0;
288         ring->tail = 0;
289         ring->running = false;
290         ring->descriptors = dma_alloc_coherent(&ring->nhi->pdev->dev,
291                         size * sizeof(*ring->descriptors),
292                         &ring->descriptors_dma, GFP_KERNEL | __GFP_ZERO);
293         if (!ring->descriptors)
294                 goto err;
295
296         if (transmit)
297                 nhi->tx_rings[hop] = ring;
298         else
299                 nhi->rx_rings[hop] = ring;
300         mutex_unlock(&nhi->lock);
301         return ring;
302
303 err:
304         if (ring)
305                 mutex_destroy(&ring->lock);
306         kfree(ring);
307         mutex_unlock(&nhi->lock);
308         return NULL;
309 }
310
311 struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size)
312 {
313         return ring_alloc(nhi, hop, size, true);
314 }
315
316 struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size)
317 {
318         return ring_alloc(nhi, hop, size, false);
319 }
320
321 /**
322  * ring_start() - enable a ring
323  *
324  * Must not be invoked in parallel with ring_stop().
325  */
326 void ring_start(struct tb_ring *ring)
327 {
328         mutex_lock(&ring->nhi->lock);
329         mutex_lock(&ring->lock);
330         if (ring->running) {
331                 dev_WARN(&ring->nhi->pdev->dev, "ring already started\n");
332                 goto err;
333         }
334         dev_info(&ring->nhi->pdev->dev, "starting %s %d\n",
335                  RING_TYPE(ring), ring->hop);
336
337         ring_iowrite64desc(ring, ring->descriptors_dma, 0);
338         if (ring->is_tx) {
339                 ring_iowrite32desc(ring, ring->size, 12);
340                 ring_iowrite32options(ring, 0, 4); /* time releated ? */
341                 ring_iowrite32options(ring,
342                                       RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
343         } else {
344                 ring_iowrite32desc(ring,
345                                    (TB_FRAME_SIZE << 16) | ring->size, 12);
346                 ring_iowrite32options(ring, 0xffffffff, 4); /* SOF EOF mask */
347                 ring_iowrite32options(ring,
348                                       RING_FLAG_ENABLE | RING_FLAG_RAW, 0);
349         }
350         ring_interrupt_active(ring, true);
351         ring->running = true;
352 err:
353         mutex_unlock(&ring->lock);
354         mutex_unlock(&ring->nhi->lock);
355 }
356
357
358 /**
359  * ring_stop() - shutdown a ring
360  *
361  * Must not be invoked from a callback.
362  *
363  * This method will disable the ring. Further calls to ring_tx/ring_rx will
364  * return -ESHUTDOWN until ring_stop has been called.
365  *
366  * All enqueued frames will be canceled and their callbacks will be executed
367  * with frame->canceled set to true (on the callback thread). This method
368  * returns only after all callback invocations have finished.
369  */
370 void ring_stop(struct tb_ring *ring)
371 {
372         mutex_lock(&ring->nhi->lock);
373         mutex_lock(&ring->lock);
374         dev_info(&ring->nhi->pdev->dev, "stopping %s %d\n",
375                  RING_TYPE(ring), ring->hop);
376         if (!ring->running) {
377                 dev_WARN(&ring->nhi->pdev->dev, "%s %d already stopped\n",
378                          RING_TYPE(ring), ring->hop);
379                 goto err;
380         }
381         ring_interrupt_active(ring, false);
382
383         ring_iowrite32options(ring, 0, 0);
384         ring_iowrite64desc(ring, 0, 0);
385         ring_iowrite32desc(ring, 0, 8);
386         ring_iowrite32desc(ring, 0, 12);
387         ring->head = 0;
388         ring->tail = 0;
389         ring->running = false;
390
391 err:
392         mutex_unlock(&ring->lock);
393         mutex_unlock(&ring->nhi->lock);
394
395         /*
396          * schedule ring->work to invoke callbacks on all remaining frames.
397          */
398         schedule_work(&ring->work);
399         flush_work(&ring->work);
400 }
401
402 /*
403  * ring_free() - free ring
404  *
405  * When this method returns all invocations of ring->callback will have
406  * finished.
407  *
408  * Ring must be stopped.
409  *
410  * Must NOT be called from ring_frame->callback!
411  */
412 void ring_free(struct tb_ring *ring)
413 {
414         mutex_lock(&ring->nhi->lock);
415         /*
416          * Dissociate the ring from the NHI. This also ensures that
417          * nhi_interrupt_work cannot reschedule ring->work.
418          */
419         if (ring->is_tx)
420                 ring->nhi->tx_rings[ring->hop] = NULL;
421         else
422                 ring->nhi->rx_rings[ring->hop] = NULL;
423
424         if (ring->running) {
425                 dev_WARN(&ring->nhi->pdev->dev, "%s %d still running\n",
426                          RING_TYPE(ring), ring->hop);
427         }
428
429         dma_free_coherent(&ring->nhi->pdev->dev,
430                           ring->size * sizeof(*ring->descriptors),
431                           ring->descriptors, ring->descriptors_dma);
432
433         ring->descriptors = NULL;
434         ring->descriptors_dma = 0;
435
436
437         dev_info(&ring->nhi->pdev->dev,
438                  "freeing %s %d\n",
439                  RING_TYPE(ring),
440                  ring->hop);
441
442         mutex_unlock(&ring->nhi->lock);
443         /**
444          * ring->work can no longer be scheduled (it is scheduled only by
445          * nhi_interrupt_work and ring_stop). Wait for it to finish before
446          * freeing the ring.
447          */
448         flush_work(&ring->work);
449         mutex_destroy(&ring->lock);
450         kfree(ring);
451 }
452
453 static void nhi_interrupt_work(struct work_struct *work)
454 {
455         struct tb_nhi *nhi = container_of(work, typeof(*nhi), interrupt_work);
456         int value = 0; /* Suppress uninitialized usage warning. */
457         int bit;
458         int hop = -1;
459         int type = 0; /* current interrupt type 0: TX, 1: RX, 2: RX overflow */
460         struct tb_ring *ring;
461
462         mutex_lock(&nhi->lock);
463
464         /*
465          * Starting at REG_RING_NOTIFY_BASE there are three status bitfields
466          * (TX, RX, RX overflow). We iterate over the bits and read a new
467          * dwords as required. The registers are cleared on read.
468          */
469         for (bit = 0; bit < 3 * nhi->hop_count; bit++) {
470                 if (bit % 32 == 0)
471                         value = ioread32(nhi->iobase
472                                          + REG_RING_NOTIFY_BASE
473                                          + 4 * (bit / 32));
474                 if (++hop == nhi->hop_count) {
475                         hop = 0;
476                         type++;
477                 }
478                 if ((value & (1 << (bit % 32))) == 0)
479                         continue;
480                 if (type == 2) {
481                         dev_warn(&nhi->pdev->dev,
482                                  "RX overflow for ring %d\n",
483                                  hop);
484                         continue;
485                 }
486                 if (type == 0)
487                         ring = nhi->tx_rings[hop];
488                 else
489                         ring = nhi->rx_rings[hop];
490                 if (ring == NULL) {
491                         dev_warn(&nhi->pdev->dev,
492                                  "got interrupt for inactive %s ring %d\n",
493                                  type ? "RX" : "TX",
494                                  hop);
495                         continue;
496                 }
497                 /* we do not check ring->running, this is done in ring->work */
498                 schedule_work(&ring->work);
499         }
500         mutex_unlock(&nhi->lock);
501 }
502
503 static irqreturn_t nhi_msi(int irq, void *data)
504 {
505         struct tb_nhi *nhi = data;
506         schedule_work(&nhi->interrupt_work);
507         return IRQ_HANDLED;
508 }
509
510 static int nhi_suspend_noirq(struct device *dev)
511 {
512         struct pci_dev *pdev = to_pci_dev(dev);
513         struct tb *tb = pci_get_drvdata(pdev);
514         thunderbolt_suspend(tb);
515         return 0;
516 }
517
518 static int nhi_resume_noirq(struct device *dev)
519 {
520         struct pci_dev *pdev = to_pci_dev(dev);
521         struct tb *tb = pci_get_drvdata(pdev);
522         thunderbolt_resume(tb);
523         return 0;
524 }
525
526 static void nhi_shutdown(struct tb_nhi *nhi)
527 {
528         int i;
529         dev_info(&nhi->pdev->dev, "shutdown\n");
530
531         for (i = 0; i < nhi->hop_count; i++) {
532                 if (nhi->tx_rings[i])
533                         dev_WARN(&nhi->pdev->dev,
534                                  "TX ring %d is still active\n", i);
535                 if (nhi->rx_rings[i])
536                         dev_WARN(&nhi->pdev->dev,
537                                  "RX ring %d is still active\n", i);
538         }
539         nhi_disable_interrupts(nhi);
540         /*
541          * We have to release the irq before calling flush_work. Otherwise an
542          * already executing IRQ handler could call schedule_work again.
543          */
544         devm_free_irq(&nhi->pdev->dev, nhi->pdev->irq, nhi);
545         flush_work(&nhi->interrupt_work);
546         mutex_destroy(&nhi->lock);
547 }
548
549 static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
550 {
551         struct tb_nhi *nhi;
552         struct tb *tb;
553         int res;
554
555         res = pcim_enable_device(pdev);
556         if (res) {
557                 dev_err(&pdev->dev, "cannot enable PCI device, aborting\n");
558                 return res;
559         }
560
561         res = pci_enable_msi(pdev);
562         if (res) {
563                 dev_err(&pdev->dev, "cannot enable MSI, aborting\n");
564                 return res;
565         }
566
567         res = pcim_iomap_regions(pdev, 1 << 0, "thunderbolt");
568         if (res) {
569                 dev_err(&pdev->dev, "cannot obtain PCI resources, aborting\n");
570                 return res;
571         }
572
573         nhi = devm_kzalloc(&pdev->dev, sizeof(*nhi), GFP_KERNEL);
574         if (!nhi)
575                 return -ENOMEM;
576
577         nhi->pdev = pdev;
578         /* cannot fail - table is allocated bin pcim_iomap_regions */
579         nhi->iobase = pcim_iomap_table(pdev)[0];
580         nhi->hop_count = ioread32(nhi->iobase + REG_HOP_COUNT) & 0x3ff;
581         if (nhi->hop_count != 12)
582                 dev_warn(&pdev->dev, "unexpected hop count: %d\n",
583                          nhi->hop_count);
584         INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work);
585
586         nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
587                                      sizeof(*nhi->tx_rings), GFP_KERNEL);
588         nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
589                                      sizeof(*nhi->rx_rings), GFP_KERNEL);
590         if (!nhi->tx_rings || !nhi->rx_rings)
591                 return -ENOMEM;
592
593         nhi_disable_interrupts(nhi); /* In case someone left them on. */
594         res = devm_request_irq(&pdev->dev, pdev->irq, nhi_msi,
595                                IRQF_NO_SUSPEND, /* must work during _noirq */
596                                "thunderbolt", nhi);
597         if (res) {
598                 dev_err(&pdev->dev, "request_irq failed, aborting\n");
599                 return res;
600         }
601
602         mutex_init(&nhi->lock);
603
604         pci_set_master(pdev);
605
606         /* magic value - clock related? */
607         iowrite32(3906250 / 10000, nhi->iobase + 0x38c00);
608
609         dev_info(&nhi->pdev->dev, "NHI initialized, starting thunderbolt\n");
610         tb = thunderbolt_alloc_and_start(nhi);
611         if (!tb) {
612                 /*
613                  * At this point the RX/TX rings might already have been
614                  * activated. Do a proper shutdown.
615                  */
616                 nhi_shutdown(nhi);
617                 return -EIO;
618         }
619         pci_set_drvdata(pdev, tb);
620
621         return 0;
622 }
623
624 static void nhi_remove(struct pci_dev *pdev)
625 {
626         struct tb *tb = pci_get_drvdata(pdev);
627         struct tb_nhi *nhi = tb->nhi;
628         thunderbolt_shutdown_and_free(tb);
629         nhi_shutdown(nhi);
630 }
631
632 /*
633  * The tunneled pci bridges are siblings of us. Use resume_noirq to reenable
634  * the tunnels asap. A corresponding pci quirk blocks the downstream bridges
635  * resume_noirq until we are done.
636  */
637 static const struct dev_pm_ops nhi_pm_ops = {
638         .suspend_noirq = nhi_suspend_noirq,
639         .resume_noirq = nhi_resume_noirq,
640         .freeze_noirq = nhi_suspend_noirq, /*
641                                             * we just disable hotplug, the
642                                             * pci-tunnels stay alive.
643                                             */
644         .thaw_noirq = nhi_resume_noirq,
645         .restore_noirq = nhi_resume_noirq,
646 };
647
648 static struct pci_device_id nhi_ids[] = {
649         /*
650          * We have to specify class, the TB bridges use the same device and
651          * vendor (sub)id.
652          */
653         {
654                 .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0,
655                 .vendor = PCI_VENDOR_ID_INTEL, .device = 0x1547,
656                 .subvendor = 0x2222, .subdevice = 0x1111,
657         },
658         {
659                 .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0,
660                 .vendor = PCI_VENDOR_ID_INTEL, .device = 0x156c,
661                 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
662         },
663         { 0,}
664 };
665
666 MODULE_DEVICE_TABLE(pci, nhi_ids);
667 MODULE_LICENSE("GPL");
668
669 static struct pci_driver nhi_driver = {
670         .name = "thunderbolt",
671         .id_table = nhi_ids,
672         .probe = nhi_probe,
673         .remove = nhi_remove,
674         .driver.pm = &nhi_pm_ops,
675 };
676
677 static int __init nhi_init(void)
678 {
679         if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
680                 return -ENOSYS;
681         return pci_register_driver(&nhi_driver);
682 }
683
684 static void __exit nhi_unload(void)
685 {
686         pci_unregister_driver(&nhi_driver);
687 }
688
689 module_init(nhi_init);
690 module_exit(nhi_unload);