/linux-4.4.14/drivers/thunderbolt/ |
H A D | Makefile | 2 thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o
|
H A D | nhi.c | 18 #include "nhi.h" 29 bit += ring->nhi->hop_count; ring_interrupt_index() 36 * ring->nhi->lock must be held. 44 old = ioread32(ring->nhi->iobase + reg); ring_interrupt_active() 50 dev_info(&ring->nhi->pdev->dev, ring_interrupt_active() 55 dev_WARN(&ring->nhi->pdev->dev, ring_interrupt_active() 59 iowrite32(new, ring->nhi->iobase + reg); ring_interrupt_active() 67 static void nhi_disable_interrupts(struct tb_nhi *nhi) nhi_disable_interrupts() argument 71 for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++) nhi_disable_interrupts() 72 iowrite32(0, nhi->iobase + REG_RING_INTERRUPT_BASE + 4 * i); nhi_disable_interrupts() 75 for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++) nhi_disable_interrupts() 76 ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + 4 * i); nhi_disable_interrupts() 83 void __iomem *io = ring->nhi->iobase; ring_desc_base() 91 void __iomem *io = ring->nhi->iobase; ring_options_base() 193 dev_WARN(&ring->nhi->pdev->dev, ring_work() 205 dev_WARN(&ring->nhi->pdev->dev, ring_work() 241 static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size, ring_alloc() argument 245 dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n", ring_alloc() 248 mutex_lock(&nhi->lock); ring_alloc() 249 if (hop >= nhi->hop_count) { ring_alloc() 250 dev_WARN(&nhi->pdev->dev, "invalid hop: %d\n", hop); ring_alloc() 253 if (transmit && nhi->tx_rings[hop]) { ring_alloc() 254 dev_WARN(&nhi->pdev->dev, "TX hop %d already allocated\n", hop); ring_alloc() 256 } else if (!transmit && nhi->rx_rings[hop]) { ring_alloc() 257 dev_WARN(&nhi->pdev->dev, "RX hop %d already allocated\n", hop); ring_alloc() 269 ring->nhi = nhi; ring_alloc() 276 ring->descriptors = dma_alloc_coherent(&ring->nhi->pdev->dev, ring_alloc() 283 nhi->tx_rings[hop] = ring; ring_alloc() 285 nhi->rx_rings[hop] = ring; ring_alloc() 286 mutex_unlock(&nhi->lock); ring_alloc() 293 mutex_unlock(&nhi->lock); ring_alloc() 297 struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size) ring_alloc_tx() argument 299 return ring_alloc(nhi, hop, size, true); ring_alloc_tx() 302 struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size) ring_alloc_rx() argument 304 return ring_alloc(nhi, hop, size, false); ring_alloc_rx() 314 mutex_lock(&ring->nhi->lock); ring_start() 317 dev_WARN(&ring->nhi->pdev->dev, "ring already started\n"); ring_start() 320 dev_info(&ring->nhi->pdev->dev, "starting %s %d\n", ring_start() 340 mutex_unlock(&ring->nhi->lock); ring_start() 358 mutex_lock(&ring->nhi->lock); ring_stop() 360 dev_info(&ring->nhi->pdev->dev, "stopping %s %d\n", ring_stop() 363 dev_WARN(&ring->nhi->pdev->dev, "%s %d already stopped\n", ring_stop() 379 mutex_unlock(&ring->nhi->lock); ring_stop() 400 mutex_lock(&ring->nhi->lock); ring_free() 406 ring->nhi->tx_rings[ring->hop] = NULL; ring_free() 408 ring->nhi->rx_rings[ring->hop] = NULL; ring_free() 411 dev_WARN(&ring->nhi->pdev->dev, "%s %d still running\n", ring_free() 415 dma_free_coherent(&ring->nhi->pdev->dev, ring_free() 423 dev_info(&ring->nhi->pdev->dev, ring_free() 428 mutex_unlock(&ring->nhi->lock); ring_free() 441 struct tb_nhi *nhi = container_of(work, typeof(*nhi), interrupt_work); nhi_interrupt_work() local 448 mutex_lock(&nhi->lock); nhi_interrupt_work() 455 for (bit = 0; bit < 3 * nhi->hop_count; bit++) { nhi_interrupt_work() 457 value = ioread32(nhi->iobase nhi_interrupt_work() 460 if (++hop == nhi->hop_count) { nhi_interrupt_work() 467 dev_warn(&nhi->pdev->dev, nhi_interrupt_work() 473 ring = nhi->tx_rings[hop]; nhi_interrupt_work() 475 ring = nhi->rx_rings[hop]; nhi_interrupt_work() 477 dev_warn(&nhi->pdev->dev, nhi_interrupt_work() 486 mutex_unlock(&nhi->lock); nhi_interrupt_work() 491 struct tb_nhi *nhi = data; nhi_msi() local 492 schedule_work(&nhi->interrupt_work); nhi_msi() 512 static void nhi_shutdown(struct tb_nhi *nhi) nhi_shutdown() argument 515 dev_info(&nhi->pdev->dev, "shutdown\n"); nhi_shutdown() 517 for (i = 0; i < nhi->hop_count; i++) { nhi_shutdown() 518 if (nhi->tx_rings[i]) nhi_shutdown() 519 dev_WARN(&nhi->pdev->dev, nhi_shutdown() 521 if (nhi->rx_rings[i]) nhi_shutdown() 522 dev_WARN(&nhi->pdev->dev, nhi_shutdown() 525 nhi_disable_interrupts(nhi); nhi_shutdown() 530 devm_free_irq(&nhi->pdev->dev, nhi->pdev->irq, nhi); nhi_shutdown() 531 flush_work(&nhi->interrupt_work); nhi_shutdown() 532 mutex_destroy(&nhi->lock); nhi_shutdown() 537 struct tb_nhi *nhi; nhi_probe() local 559 nhi = devm_kzalloc(&pdev->dev, sizeof(*nhi), GFP_KERNEL); nhi_probe() 560 if (!nhi) nhi_probe() 563 nhi->pdev = pdev; nhi_probe() 565 nhi->iobase = pcim_iomap_table(pdev)[0]; nhi_probe() 566 nhi->hop_count = ioread32(nhi->iobase + REG_HOP_COUNT) & 0x3ff; nhi_probe() 567 if (nhi->hop_count != 12) nhi_probe() 569 nhi->hop_count); nhi_probe() 570 INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work); nhi_probe() 572 nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, nhi_probe() 573 sizeof(*nhi->tx_rings), GFP_KERNEL); nhi_probe() 574 nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, nhi_probe() 575 sizeof(*nhi->rx_rings), GFP_KERNEL); nhi_probe() 576 if (!nhi->tx_rings || !nhi->rx_rings) nhi_probe() 579 nhi_disable_interrupts(nhi); /* In case someone left them on. */ nhi_probe() 582 "thunderbolt", nhi); nhi_probe() 588 mutex_init(&nhi->lock); nhi_probe() 593 iowrite32(3906250 / 10000, nhi->iobase + 0x38c00); nhi_probe() 595 dev_info(&nhi->pdev->dev, "NHI initialized, starting thunderbolt\n"); nhi_probe() 596 tb = thunderbolt_alloc_and_start(nhi); nhi_probe() 602 nhi_shutdown(nhi); nhi_probe() 613 struct tb_nhi *nhi = tb->nhi; nhi_remove() local 615 nhi_shutdown(nhi); nhi_remove()
|
H A D | nhi_regs.h | 88 #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32) 96 #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
|
H A D | nhi.h | 34 struct mutex lock; /* must be acquired after nhi->lock */ 35 struct tb_nhi *nhi; member in struct:tb_ring 67 struct tb_ring *ring_alloc_tx(struct tb_nhi *nhi, int hop, int size); 68 struct tb_ring *ring_alloc_rx(struct tb_nhi *nhi, int hop, int size);
|
H A D | ctl.h | 10 #include "nhi.h" 17 struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data);
|
H A D | tb.h | 104 struct tb_nhi *nhi; member in struct:tb 188 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg) 189 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg) 190 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg) 191 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg) 219 struct tb *thunderbolt_alloc_and_start(struct tb_nhi *nhi);
|
H A D | ctl.c | 29 struct tb_nhi *nhi; member in struct:tb_ctl 44 dev_WARN(&(ctl)->nhi->pdev->dev, format, ## arg) 47 dev_err(&(ctl)->nhi->pdev->dev, format, ## arg) 50 dev_warn(&(ctl)->nhi->pdev->dev, format, ## arg) 53 dev_info(&(ctl)->nhi->pdev->dev, format, ## arg) 474 struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data) tb_ctl_alloc() argument 480 ctl->nhi = nhi; tb_ctl_alloc() 486 ctl->frame_pool = dma_pool_create("thunderbolt_ctl", &nhi->pdev->dev, tb_ctl_alloc() 491 ctl->tx = ring_alloc_tx(nhi, 0, 10); tb_ctl_alloc() 495 ctl->rx = ring_alloc_rx(nhi, 0, 10); tb_ctl_alloc()
|
H A D | tb.c | 349 struct tb *thunderbolt_alloc_and_start(struct tb_nhi *nhi) thunderbolt_alloc_and_start() argument 361 tb->nhi = nhi; thunderbolt_alloc_and_start() 370 tb->ctl = tb_ctl_alloc(tb->nhi, tb_schedule_hotplug_handler, tb); thunderbolt_alloc_and_start()
|
/linux-4.4.14/drivers/pci/ |
H A D | quirks.c | 3209 struct pci_dev *nhi = NULL; quirk_apple_wait_for_thunderbolt() local 3224 nhi = pci_get_slot(sibling->subordinate, 0x0); quirk_apple_wait_for_thunderbolt() 3225 if (!nhi) quirk_apple_wait_for_thunderbolt() 3227 if (nhi->vendor != PCI_VENDOR_ID_INTEL quirk_apple_wait_for_thunderbolt() 3228 || (nhi->device != 0x1547 && nhi->device != 0x156c) quirk_apple_wait_for_thunderbolt() 3229 || nhi->subsystem_vendor != 0x2222 quirk_apple_wait_for_thunderbolt() 3230 || nhi->subsystem_device != 0x1111) quirk_apple_wait_for_thunderbolt() 3233 device_pm_wait_for_dev(&dev->dev, &nhi->dev); quirk_apple_wait_for_thunderbolt() 3235 pci_dev_put(nhi); quirk_apple_wait_for_thunderbolt()
|