• Home
  • Raw
  • Download

Lines Matching refs:nhi

29 		bit += ring->nhi->hop_count;  in ring_interrupt_index()
44 old = ioread32(ring->nhi->iobase + reg); in ring_interrupt_active()
50 dev_info(&ring->nhi->pdev->dev, in ring_interrupt_active()
55 dev_WARN(&ring->nhi->pdev->dev, in ring_interrupt_active()
59 iowrite32(new, ring->nhi->iobase + reg); in ring_interrupt_active()
67 static void nhi_disable_interrupts(struct tb_nhi *nhi) in nhi_disable_interrupts() argument
71 for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++) in nhi_disable_interrupts()
72 iowrite32(0, nhi->iobase + REG_RING_INTERRUPT_BASE + 4 * i); in nhi_disable_interrupts()
75 for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++) in nhi_disable_interrupts()
76 ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + 4 * i); in nhi_disable_interrupts()
83 void __iomem *io = ring->nhi->iobase; in ring_desc_base()
91 void __iomem *io = ring->nhi->iobase; in ring_options_base()
193 dev_WARN(&ring->nhi->pdev->dev, in ring_work()
205 dev_WARN(&ring->nhi->pdev->dev, in ring_work()
241 static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size, in ring_alloc() argument
245 dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n", in ring_alloc()
248 mutex_lock(&nhi->lock); in ring_alloc()
249 if (hop >= nhi->hop_count) { in ring_alloc()
250 dev_WARN(&nhi->pdev->dev, "invalid hop: %d\n", hop); in ring_alloc()
253 if (transmit && nhi->tx_rings[hop]) { in ring_alloc()
254 dev_WARN(&nhi->pdev->dev, "TX hop %d already allocated\n", hop); in ring_alloc()
256 } else if (!transmit && nhi->rx_rings[hop]) { in ring_alloc()
257 dev_WARN(&nhi->pdev->dev, "RX hop %d already allocated\n", hop); in ring_alloc()
269 ring->nhi = nhi; in ring_alloc()
276 ring->descriptors = dma_alloc_coherent(&ring->nhi->pdev->dev, in ring_alloc()
283 nhi->tx_rings[hop] = ring; in ring_alloc()
285 nhi->rx_rings[hop] = ring; in ring_alloc()
286 mutex_unlock(&nhi->lock); in ring_alloc()
293 mutex_unlock(&nhi->lock); in ring_alloc()
297 struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size) in ring_alloc_tx() argument
299 return ring_alloc(nhi, hop, size, true); in ring_alloc_tx()
302 struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size) in ring_alloc_rx() argument
304 return ring_alloc(nhi, hop, size, false); in ring_alloc_rx()
314 mutex_lock(&ring->nhi->lock); in ring_start()
317 dev_WARN(&ring->nhi->pdev->dev, "ring already started\n"); in ring_start()
320 dev_info(&ring->nhi->pdev->dev, "starting %s %d\n", in ring_start()
340 mutex_unlock(&ring->nhi->lock); in ring_start()
358 mutex_lock(&ring->nhi->lock); in ring_stop()
360 dev_info(&ring->nhi->pdev->dev, "stopping %s %d\n", in ring_stop()
363 dev_WARN(&ring->nhi->pdev->dev, "%s %d already stopped\n", in ring_stop()
379 mutex_unlock(&ring->nhi->lock); in ring_stop()
400 mutex_lock(&ring->nhi->lock); in ring_free()
406 ring->nhi->tx_rings[ring->hop] = NULL; in ring_free()
408 ring->nhi->rx_rings[ring->hop] = NULL; in ring_free()
411 dev_WARN(&ring->nhi->pdev->dev, "%s %d still running\n", in ring_free()
415 dma_free_coherent(&ring->nhi->pdev->dev, in ring_free()
423 dev_info(&ring->nhi->pdev->dev, in ring_free()
428 mutex_unlock(&ring->nhi->lock); in ring_free()
441 struct tb_nhi *nhi = container_of(work, typeof(*nhi), interrupt_work); in nhi_interrupt_work() local
448 mutex_lock(&nhi->lock); in nhi_interrupt_work()
455 for (bit = 0; bit < 3 * nhi->hop_count; bit++) { in nhi_interrupt_work()
457 value = ioread32(nhi->iobase in nhi_interrupt_work()
460 if (++hop == nhi->hop_count) { in nhi_interrupt_work()
467 dev_warn(&nhi->pdev->dev, in nhi_interrupt_work()
473 ring = nhi->tx_rings[hop]; in nhi_interrupt_work()
475 ring = nhi->rx_rings[hop]; in nhi_interrupt_work()
477 dev_warn(&nhi->pdev->dev, in nhi_interrupt_work()
486 mutex_unlock(&nhi->lock); in nhi_interrupt_work()
491 struct tb_nhi *nhi = data; in nhi_msi() local
492 schedule_work(&nhi->interrupt_work); in nhi_msi()
512 static void nhi_shutdown(struct tb_nhi *nhi) in nhi_shutdown() argument
515 dev_info(&nhi->pdev->dev, "shutdown\n"); in nhi_shutdown()
517 for (i = 0; i < nhi->hop_count; i++) { in nhi_shutdown()
518 if (nhi->tx_rings[i]) in nhi_shutdown()
519 dev_WARN(&nhi->pdev->dev, in nhi_shutdown()
521 if (nhi->rx_rings[i]) in nhi_shutdown()
522 dev_WARN(&nhi->pdev->dev, in nhi_shutdown()
525 nhi_disable_interrupts(nhi); in nhi_shutdown()
530 devm_free_irq(&nhi->pdev->dev, nhi->pdev->irq, nhi); in nhi_shutdown()
531 flush_work(&nhi->interrupt_work); in nhi_shutdown()
532 mutex_destroy(&nhi->lock); in nhi_shutdown()
537 struct tb_nhi *nhi; in nhi_probe() local
559 nhi = devm_kzalloc(&pdev->dev, sizeof(*nhi), GFP_KERNEL); in nhi_probe()
560 if (!nhi) in nhi_probe()
563 nhi->pdev = pdev; in nhi_probe()
565 nhi->iobase = pcim_iomap_table(pdev)[0]; in nhi_probe()
566 nhi->hop_count = ioread32(nhi->iobase + REG_HOP_COUNT) & 0x3ff; in nhi_probe()
567 if (nhi->hop_count != 12) in nhi_probe()
569 nhi->hop_count); in nhi_probe()
570 INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work); in nhi_probe()
572 nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, in nhi_probe()
573 sizeof(*nhi->tx_rings), GFP_KERNEL); in nhi_probe()
574 nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, in nhi_probe()
575 sizeof(*nhi->rx_rings), GFP_KERNEL); in nhi_probe()
576 if (!nhi->tx_rings || !nhi->rx_rings) in nhi_probe()
579 nhi_disable_interrupts(nhi); /* In case someone left them on. */ in nhi_probe()
582 "thunderbolt", nhi); in nhi_probe()
588 mutex_init(&nhi->lock); in nhi_probe()
593 iowrite32(3906250 / 10000, nhi->iobase + 0x38c00); in nhi_probe()
595 dev_info(&nhi->pdev->dev, "NHI initialized, starting thunderbolt\n"); in nhi_probe()
596 tb = thunderbolt_alloc_and_start(nhi); in nhi_probe()
602 nhi_shutdown(nhi); in nhi_probe()
613 struct tb_nhi *nhi = tb->nhi; in nhi_remove() local
615 nhi_shutdown(nhi); in nhi_remove()