Lines Matching refs:priv
43 static void tsi721_omsg_handler(struct tsi721_device *priv, int ch);
44 static void tsi721_imsg_handler(struct tsi721_device *priv, int ch);
61 struct tsi721_device *priv = mport->priv; in tsi721_lcread() local
66 *data = ioread32(priv->regs + offset); in tsi721_lcread()
86 struct tsi721_device *priv = mport->priv; in tsi721_lcwrite() local
91 iowrite32(data, priv->regs + offset); in tsi721_lcwrite()
111 static int tsi721_maint_dma(struct tsi721_device *priv, u32 sys_size, in tsi721_maint_dma() argument
115 void __iomem *regs = priv->regs + TSI721_DMAC_BASE(priv->mdma.ch_id); in tsi721_maint_dma()
127 bd_ptr = priv->mdma.bd_base; in tsi721_maint_dma()
153 tsi_debug(MAINT, &priv->pdev->dev, in tsi721_maint_dma()
155 priv->mdma.ch_id, ch_stat); in tsi721_maint_dma()
167 tsi_debug(MAINT, &priv->pdev->dev, "DMA ABORT ch_stat=%x", in tsi721_maint_dma()
169 tsi_debug(MAINT, &priv->pdev->dev, in tsi721_maint_dma()
218 struct tsi721_device *priv = mport->priv; in tsi721_cread_dma() local
220 return tsi721_maint_dma(priv, mport->sys_size, destid, hopcount, in tsi721_cread_dma()
241 struct tsi721_device *priv = mport->priv; in tsi721_cwrite_dma() local
244 return tsi721_maint_dma(priv, mport->sys_size, destid, hopcount, in tsi721_cwrite_dma()
259 tsi721_pw_handler(struct tsi721_device *priv) in tsi721_pw_handler() argument
265 pw_stat = ioread32(priv->regs + TSI721_RIO_PW_RX_STAT); in tsi721_pw_handler()
268 pw_buf[0] = ioread32(priv->regs + TSI721_RIO_PW_RX_CAPT(0)); in tsi721_pw_handler()
269 pw_buf[1] = ioread32(priv->regs + TSI721_RIO_PW_RX_CAPT(1)); in tsi721_pw_handler()
270 pw_buf[2] = ioread32(priv->regs + TSI721_RIO_PW_RX_CAPT(2)); in tsi721_pw_handler()
271 pw_buf[3] = ioread32(priv->regs + TSI721_RIO_PW_RX_CAPT(3)); in tsi721_pw_handler()
276 spin_lock(&priv->pw_fifo_lock); in tsi721_pw_handler()
277 if (kfifo_avail(&priv->pw_fifo) >= TSI721_RIO_PW_MSG_SIZE) in tsi721_pw_handler()
278 kfifo_in(&priv->pw_fifo, pw_buf, in tsi721_pw_handler()
281 priv->pw_discard_count++; in tsi721_pw_handler()
282 spin_unlock(&priv->pw_fifo_lock); in tsi721_pw_handler()
287 priv->regs + TSI721_RIO_PW_RX_STAT); in tsi721_pw_handler()
289 schedule_work(&priv->pw_work); in tsi721_pw_handler()
296 struct tsi721_device *priv = container_of(work, struct tsi721_device, in tsi721_pw_dpc() local
303 while (kfifo_out_spinlocked(&priv->pw_fifo, (unsigned char *)&pwmsg, in tsi721_pw_dpc()
304 TSI721_RIO_PW_MSG_SIZE, &priv->pw_fifo_lock)) { in tsi721_pw_dpc()
306 rio_inb_pwrite_handler(&priv->mport, &pwmsg); in tsi721_pw_dpc()
319 struct tsi721_device *priv = mport->priv; in tsi721_pw_enable() local
322 rval = ioread32(priv->regs + TSI721_RIO_EM_INT_ENABLE); in tsi721_pw_enable()
331 priv->regs + TSI721_RIO_PW_RX_STAT); in tsi721_pw_enable()
333 iowrite32(rval, priv->regs + TSI721_RIO_EM_INT_ENABLE); in tsi721_pw_enable()
352 struct tsi721_device *priv = mport->priv; in tsi721_dsend() local
358 tsi_debug(DBELL, &priv->pdev->dev, in tsi721_dsend()
360 iowrite16be(data, priv->odb_base + offset); in tsi721_dsend()
376 tsi721_dbell_handler(struct tsi721_device *priv) in tsi721_dbell_handler() argument
381 regval = ioread32(priv->regs + TSI721_SR_CHINTE(IDB_QUEUE)); in tsi721_dbell_handler()
384 priv->regs + TSI721_SR_CHINTE(IDB_QUEUE)); in tsi721_dbell_handler()
386 schedule_work(&priv->idb_work); in tsi721_dbell_handler()
393 struct tsi721_device *priv = container_of(work, struct tsi721_device, in tsi721_db_dpc() local
409 mport = &priv->mport; in tsi721_db_dpc()
411 wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE; in tsi721_db_dpc()
412 rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE)) % IDB_QSIZE; in tsi721_db_dpc()
415 idb_entry = (u64 *)(priv->idb_base + in tsi721_db_dpc()
435 tsi_debug(DBELL, &priv->pdev->dev, in tsi721_db_dpc()
441 wr_ptr = ioread32(priv->regs + in tsi721_db_dpc()
446 priv->regs + TSI721_IDQ_RP(IDB_QUEUE)); in tsi721_db_dpc()
449 regval = ioread32(priv->regs + TSI721_SR_CHINTE(IDB_QUEUE)); in tsi721_db_dpc()
452 priv->regs + TSI721_SR_CHINTE(IDB_QUEUE)); in tsi721_db_dpc()
454 wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE; in tsi721_db_dpc()
456 schedule_work(&priv->idb_work); in tsi721_db_dpc()
471 struct tsi721_device *priv = (struct tsi721_device *)ptr; in tsi721_irqhandler() local
478 if (priv->flags & TSI721_USING_MSI) in tsi721_irqhandler()
479 iowrite32(0, priv->regs + TSI721_DEV_INTE); in tsi721_irqhandler()
481 dev_int = ioread32(priv->regs + TSI721_DEV_INT); in tsi721_irqhandler()
485 dev_ch_int = ioread32(priv->regs + TSI721_DEV_CHAN_INT); in tsi721_irqhandler()
491 intval = ioread32(priv->regs + in tsi721_irqhandler()
494 tsi721_dbell_handler(priv); in tsi721_irqhandler()
496 tsi_info(&priv->pdev->dev, in tsi721_irqhandler()
501 priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_irqhandler()
502 ioread32(priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_irqhandler()
515 ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_irqhandler()
517 iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_irqhandler()
525 tsi721_imsg_handler(priv, ch); in tsi721_irqhandler()
531 ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_irqhandler()
533 iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_irqhandler()
542 tsi721_omsg_handler(priv, ch); in tsi721_irqhandler()
549 intval = ioread32(priv->regs + TSI721_RIO_EM_INT_STAT); in tsi721_irqhandler()
551 tsi721_pw_handler(priv); in tsi721_irqhandler()
559 tsi_debug(DMA, &priv->pdev->dev, in tsi721_irqhandler()
565 tsi721_bdma_handler(&priv->bdma[ch]); in tsi721_irqhandler()
572 if (priv->flags & TSI721_USING_MSI) { in tsi721_irqhandler()
575 iowrite32(dev_int, priv->regs + TSI721_DEV_INTE); in tsi721_irqhandler()
581 static void tsi721_interrupts_init(struct tsi721_device *priv) in tsi721_interrupts_init() argument
587 priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_interrupts_init()
589 priv->regs + TSI721_SR_CHINTE(IDB_QUEUE)); in tsi721_interrupts_init()
593 priv->regs + TSI721_RIO_EM_DEV_INT_EN); in tsi721_interrupts_init()
603 iowrite32(intr, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_interrupts_init()
605 if (priv->flags & TSI721_USING_MSIX) in tsi721_interrupts_init()
611 iowrite32(intr, priv->regs + TSI721_DEV_INTE); in tsi721_interrupts_init()
612 ioread32(priv->regs + TSI721_DEV_INTE); in tsi721_interrupts_init()
627 struct tsi721_device *priv = (struct tsi721_device *)ptr; in tsi721_omsg_msix() local
630 mbox = (irq - priv->msix[TSI721_VECT_OMB0_DONE].vector) % RIO_MAX_MBOX; in tsi721_omsg_msix()
631 tsi721_omsg_handler(priv, mbox); in tsi721_omsg_msix()
646 struct tsi721_device *priv = (struct tsi721_device *)ptr; in tsi721_imsg_msix() local
649 mbox = (irq - priv->msix[TSI721_VECT_IMB0_RCV].vector) % RIO_MAX_MBOX; in tsi721_imsg_msix()
650 tsi721_imsg_handler(priv, mbox + 4); in tsi721_imsg_msix()
665 struct tsi721_device *priv = (struct tsi721_device *)ptr; in tsi721_srio_msix() local
669 srio_int = ioread32(priv->regs + TSI721_RIO_EM_INT_STAT); in tsi721_srio_msix()
671 tsi721_pw_handler(priv); in tsi721_srio_msix()
689 struct tsi721_device *priv = (struct tsi721_device *)ptr; in tsi721_sr2pc_ch_msix() local
693 sr_ch_int = ioread32(priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_sr2pc_ch_msix()
695 tsi721_dbell_handler(priv); in tsi721_sr2pc_ch_msix()
698 iowrite32(sr_ch_int, priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_sr2pc_ch_msix()
700 sr_ch_int = ioread32(priv->regs + TSI721_SR_CHINT(IDB_QUEUE)); in tsi721_sr2pc_ch_msix()
715 static int tsi721_request_msix(struct tsi721_device *priv) in tsi721_request_msix() argument
719 err = request_irq(priv->msix[TSI721_VECT_IDB].vector, in tsi721_request_msix()
721 priv->msix[TSI721_VECT_IDB].irq_name, (void *)priv); in tsi721_request_msix()
725 err = request_irq(priv->msix[TSI721_VECT_PWRX].vector, in tsi721_request_msix()
727 priv->msix[TSI721_VECT_PWRX].irq_name, (void *)priv); in tsi721_request_msix()
729 free_irq(priv->msix[TSI721_VECT_IDB].vector, (void *)priv); in tsi721_request_msix()
745 static int tsi721_enable_msix(struct tsi721_device *priv) in tsi721_enable_msix() argument
785 err = pci_enable_msix_exact(priv->pdev, entries, ARRAY_SIZE(entries)); in tsi721_enable_msix()
787 tsi_err(&priv->pdev->dev, in tsi721_enable_msix()
795 priv->msix[TSI721_VECT_IDB].vector = entries[TSI721_VECT_IDB].vector; in tsi721_enable_msix()
796 snprintf(priv->msix[TSI721_VECT_IDB].irq_name, IRQ_DEVICE_NAME_MAX, in tsi721_enable_msix()
797 DRV_NAME "-idb@pci:%s", pci_name(priv->pdev)); in tsi721_enable_msix()
798 priv->msix[TSI721_VECT_PWRX].vector = entries[TSI721_VECT_PWRX].vector; in tsi721_enable_msix()
799 snprintf(priv->msix[TSI721_VECT_PWRX].irq_name, IRQ_DEVICE_NAME_MAX, in tsi721_enable_msix()
800 DRV_NAME "-pwrx@pci:%s", pci_name(priv->pdev)); in tsi721_enable_msix()
803 priv->msix[TSI721_VECT_IMB0_RCV + i].vector = in tsi721_enable_msix()
805 snprintf(priv->msix[TSI721_VECT_IMB0_RCV + i].irq_name, in tsi721_enable_msix()
807 i, pci_name(priv->pdev)); in tsi721_enable_msix()
809 priv->msix[TSI721_VECT_IMB0_INT + i].vector = in tsi721_enable_msix()
811 snprintf(priv->msix[TSI721_VECT_IMB0_INT + i].irq_name, in tsi721_enable_msix()
813 i, pci_name(priv->pdev)); in tsi721_enable_msix()
815 priv->msix[TSI721_VECT_OMB0_DONE + i].vector = in tsi721_enable_msix()
817 snprintf(priv->msix[TSI721_VECT_OMB0_DONE + i].irq_name, in tsi721_enable_msix()
819 i, pci_name(priv->pdev)); in tsi721_enable_msix()
821 priv->msix[TSI721_VECT_OMB0_INT + i].vector = in tsi721_enable_msix()
823 snprintf(priv->msix[TSI721_VECT_OMB0_INT + i].irq_name, in tsi721_enable_msix()
825 i, pci_name(priv->pdev)); in tsi721_enable_msix()
830 priv->msix[TSI721_VECT_DMA0_DONE + i].vector = in tsi721_enable_msix()
832 snprintf(priv->msix[TSI721_VECT_DMA0_DONE + i].irq_name, in tsi721_enable_msix()
834 i, pci_name(priv->pdev)); in tsi721_enable_msix()
836 priv->msix[TSI721_VECT_DMA0_INT + i].vector = in tsi721_enable_msix()
838 snprintf(priv->msix[TSI721_VECT_DMA0_INT + i].irq_name, in tsi721_enable_msix()
840 i, pci_name(priv->pdev)); in tsi721_enable_msix()
848 static int tsi721_request_irq(struct tsi721_device *priv) in tsi721_request_irq() argument
853 if (priv->flags & TSI721_USING_MSIX) in tsi721_request_irq()
854 err = tsi721_request_msix(priv); in tsi721_request_irq()
857 err = request_irq(priv->pdev->irq, tsi721_irqhandler, in tsi721_request_irq()
858 (priv->flags & TSI721_USING_MSI) ? 0 : IRQF_SHARED, in tsi721_request_irq()
859 DRV_NAME, (void *)priv); in tsi721_request_irq()
862 tsi_err(&priv->pdev->dev, in tsi721_request_irq()
868 static void tsi721_free_irq(struct tsi721_device *priv) in tsi721_free_irq() argument
871 if (priv->flags & TSI721_USING_MSIX) { in tsi721_free_irq()
872 free_irq(priv->msix[TSI721_VECT_IDB].vector, (void *)priv); in tsi721_free_irq()
873 free_irq(priv->msix[TSI721_VECT_PWRX].vector, (void *)priv); in tsi721_free_irq()
876 free_irq(priv->pdev->irq, (void *)priv); in tsi721_free_irq()
880 tsi721_obw_alloc(struct tsi721_device *priv, struct tsi721_obw_bar *pbar, in tsi721_obw_alloc() argument
899 if (!priv->ob_win[i].active) { in tsi721_obw_alloc()
901 new_win = &priv->ob_win[i]; in tsi721_obw_alloc()
911 win = &priv->ob_win[i]; in tsi721_obw_alloc()
929 tsi_err(&priv->pdev->dev, "OBW count tracking failed"); in tsi721_obw_alloc()
937 priv->obwin_cnt--; in tsi721_obw_alloc()
946 struct tsi721_device *priv = mport->priv; in tsi721_map_outb_win() local
956 tsi_debug(OBW, &priv->pdev->dev, in tsi721_map_outb_win()
962 if (priv->obwin_cnt == 0) in tsi721_map_outb_win()
966 if (priv->p2r_bar[i].free >= size) { in tsi721_map_outb_win()
967 pbar = &priv->p2r_bar[i]; in tsi721_map_outb_win()
968 ret = tsi721_obw_alloc(priv, pbar, size, &obw); in tsi721_map_outb_win()
978 ob_win = &priv->ob_win[obw]; in tsi721_map_outb_win()
981 tsi_debug(OBW, &priv->pdev->dev, in tsi721_map_outb_win()
997 while (ioread32(priv->regs + TSI721_ZONE_SEL) & in tsi721_map_outb_win()
1004 iowrite32(rval, priv->regs + TSI721_LUT_DATA0); in tsi721_map_outb_win()
1006 iowrite32(rval, priv->regs + TSI721_LUT_DATA1); in tsi721_map_outb_win()
1008 iowrite32(rval, priv->regs + TSI721_LUT_DATA2); in tsi721_map_outb_win()
1011 iowrite32(rval, priv->regs + TSI721_ZONE_SEL); in tsi721_map_outb_win()
1017 priv->regs + TSI721_OBWINSZ(obw)); in tsi721_map_outb_win()
1018 iowrite32((u32)(ob_win->base >> 32), priv->regs + TSI721_OBWINUB(obw)); in tsi721_map_outb_win()
1020 priv->regs + TSI721_OBWINLB(obw)); in tsi721_map_outb_win()
1029 struct tsi721_device *priv = mport->priv; in tsi721_unmap_outb_win() local
1033 tsi_debug(OBW, &priv->pdev->dev, "did=%d ra=0x%llx", destid, rstart); in tsi721_unmap_outb_win()
1036 ob_win = &priv->ob_win[i]; in tsi721_unmap_outb_win()
1040 tsi_debug(OBW, &priv->pdev->dev, in tsi721_unmap_outb_win()
1043 iowrite32(0, priv->regs + TSI721_OBWINLB(i)); in tsi721_unmap_outb_win()
1045 priv->obwin_cnt++; in tsi721_unmap_outb_win()
1058 static void tsi721_init_pc2sr_mapping(struct tsi721_device *priv) in tsi721_init_pc2sr_mapping() argument
1065 iowrite32(0, priv->regs + TSI721_OBWINLB(i)); in tsi721_init_pc2sr_mapping()
1068 iowrite32(0, priv->regs + TSI721_LUT_DATA0); in tsi721_init_pc2sr_mapping()
1069 iowrite32(0, priv->regs + TSI721_LUT_DATA1); in tsi721_init_pc2sr_mapping()
1070 iowrite32(0, priv->regs + TSI721_LUT_DATA2); in tsi721_init_pc2sr_mapping()
1074 while (ioread32(priv->regs + TSI721_ZONE_SEL) & in tsi721_init_pc2sr_mapping()
1079 iowrite32(rval, priv->regs + TSI721_ZONE_SEL); in tsi721_init_pc2sr_mapping()
1083 if (priv->p2r_bar[0].size == 0 && priv->p2r_bar[1].size == 0) { in tsi721_init_pc2sr_mapping()
1084 priv->obwin_cnt = 0; in tsi721_init_pc2sr_mapping()
1088 priv->p2r_bar[0].free = priv->p2r_bar[0].size; in tsi721_init_pc2sr_mapping()
1089 priv->p2r_bar[1].free = priv->p2r_bar[1].size; in tsi721_init_pc2sr_mapping()
1092 priv->ob_win[i].active = false; in tsi721_init_pc2sr_mapping()
1094 priv->obwin_cnt = TSI721_OBWIN_NUM; in tsi721_init_pc2sr_mapping()
1113 struct tsi721_device *priv = mport->priv; in tsi721_rio_map_inb_mem() local
1134 tsi_debug(IBW, &priv->pdev->dev, in tsi721_rio_map_inb_mem()
1153 tsi_debug(IBW, &priv->pdev->dev, in tsi721_rio_map_inb_mem()
1160 if (priv->ibwin_cnt == 0) in tsi721_rio_map_inb_mem()
1172 ib_win = &priv->ib_win[i]; in tsi721_rio_map_inb_mem()
1211 regval = ioread32(priv->regs + TSI721_IBWIN_LB(i)); in tsi721_rio_map_inb_mem()
1217 ib_win = &priv->ib_win[i]; in tsi721_rio_map_inb_mem()
1236 priv->regs + TSI721_IBWIN_SZ(i)); in tsi721_rio_map_inb_mem()
1238 iowrite32(((u64)loc_start >> 32), priv->regs + TSI721_IBWIN_TUA(i)); in tsi721_rio_map_inb_mem()
1240 priv->regs + TSI721_IBWIN_TLA(i)); in tsi721_rio_map_inb_mem()
1242 iowrite32(ibw_start >> 32, priv->regs + TSI721_IBWIN_UB(i)); in tsi721_rio_map_inb_mem()
1244 priv->regs + TSI721_IBWIN_LB(i)); in tsi721_rio_map_inb_mem()
1246 priv->ibwin_cnt--; in tsi721_rio_map_inb_mem()
1248 tsi_debug(IBW, &priv->pdev->dev, in tsi721_rio_map_inb_mem()
1266 struct tsi721_device *priv = mport->priv; in tsi721_rio_unmap_inb_mem() local
1270 tsi_debug(IBW, &priv->pdev->dev, in tsi721_rio_unmap_inb_mem()
1275 ib_win = &priv->ib_win[i]; in tsi721_rio_unmap_inb_mem()
1306 tsi_debug(IBW, &priv->pdev->dev, "Disable IBWIN_%d", i); in tsi721_rio_unmap_inb_mem()
1307 iowrite32(0, priv->regs + TSI721_IBWIN_LB(i)); in tsi721_rio_unmap_inb_mem()
1309 priv->ibwin_cnt++; in tsi721_rio_unmap_inb_mem()
1315 tsi_debug(IBW, &priv->pdev->dev, in tsi721_rio_unmap_inb_mem()
1326 static void tsi721_init_sr2pc_mapping(struct tsi721_device *priv) in tsi721_init_sr2pc_mapping() argument
1332 iowrite32(0, priv->regs + TSI721_IBWIN_LB(i)); in tsi721_init_sr2pc_mapping()
1333 priv->ibwin_cnt = TSI721_IBWIN_NUM; in tsi721_init_sr2pc_mapping()
1341 static void tsi721_close_sr2pc_mapping(struct tsi721_device *priv) in tsi721_close_sr2pc_mapping() argument
1348 ib_win = &priv->ib_win[i]; in tsi721_close_sr2pc_mapping()
1350 iowrite32(0, priv->regs + TSI721_IBWIN_LB(i)); in tsi721_close_sr2pc_mapping()
1363 static int tsi721_port_write_init(struct tsi721_device *priv) in tsi721_port_write_init() argument
1365 priv->pw_discard_count = 0; in tsi721_port_write_init()
1366 INIT_WORK(&priv->pw_work, tsi721_pw_dpc); in tsi721_port_write_init()
1367 spin_lock_init(&priv->pw_fifo_lock); in tsi721_port_write_init()
1368 if (kfifo_alloc(&priv->pw_fifo, in tsi721_port_write_init()
1370 tsi_err(&priv->pdev->dev, "PW FIFO allocation failed"); in tsi721_port_write_init()
1375 iowrite32(TSI721_RIO_PW_CTL_PWC_REL, priv->regs + TSI721_RIO_PW_CTL); in tsi721_port_write_init()
1379 static void tsi721_port_write_free(struct tsi721_device *priv) in tsi721_port_write_free() argument
1381 kfifo_free(&priv->pw_fifo); in tsi721_port_write_free()
1384 static int tsi721_doorbell_init(struct tsi721_device *priv) in tsi721_doorbell_init() argument
1392 priv->db_discard_count = 0; in tsi721_doorbell_init()
1393 INIT_WORK(&priv->idb_work, tsi721_db_dpc); in tsi721_doorbell_init()
1396 priv->idb_base = dma_alloc_coherent(&priv->pdev->dev, in tsi721_doorbell_init()
1398 &priv->idb_dma, GFP_KERNEL); in tsi721_doorbell_init()
1399 if (!priv->idb_base) in tsi721_doorbell_init()
1402 tsi_debug(DBELL, &priv->pdev->dev, in tsi721_doorbell_init()
1404 priv->idb_base, &priv->idb_dma); in tsi721_doorbell_init()
1407 priv->regs + TSI721_IDQ_SIZE(IDB_QUEUE)); in tsi721_doorbell_init()
1408 iowrite32(((u64)priv->idb_dma >> 32), in tsi721_doorbell_init()
1409 priv->regs + TSI721_IDQ_BASEU(IDB_QUEUE)); in tsi721_doorbell_init()
1410 iowrite32(((u64)priv->idb_dma & TSI721_IDQ_BASEL_ADDR), in tsi721_doorbell_init()
1411 priv->regs + TSI721_IDQ_BASEL(IDB_QUEUE)); in tsi721_doorbell_init()
1413 iowrite32(0, priv->regs + TSI721_IDQ_MASK(IDB_QUEUE)); in tsi721_doorbell_init()
1415 iowrite32(TSI721_IDQ_INIT, priv->regs + TSI721_IDQ_CTL(IDB_QUEUE)); in tsi721_doorbell_init()
1417 iowrite32(0, priv->regs + TSI721_IDQ_RP(IDB_QUEUE)); in tsi721_doorbell_init()
1422 static void tsi721_doorbell_free(struct tsi721_device *priv) in tsi721_doorbell_free() argument
1424 if (priv->idb_base == NULL) in tsi721_doorbell_free()
1428 dma_free_coherent(&priv->pdev->dev, IDB_QSIZE * TSI721_IDB_ENTRY_SIZE, in tsi721_doorbell_free()
1429 priv->idb_base, priv->idb_dma); in tsi721_doorbell_free()
1430 priv->idb_base = NULL; in tsi721_doorbell_free()
1442 static int tsi721_bdma_maint_init(struct tsi721_device *priv) in tsi721_bdma_maint_init() argument
1451 tsi_debug(MAINT, &priv->pdev->dev, in tsi721_bdma_maint_init()
1458 priv->mdma.ch_id = TSI721_DMACH_MAINT; in tsi721_bdma_maint_init()
1459 regs = priv->regs + TSI721_DMAC_BASE(TSI721_DMACH_MAINT); in tsi721_bdma_maint_init()
1462 bd_ptr = dma_alloc_coherent(&priv->pdev->dev, in tsi721_bdma_maint_init()
1468 priv->mdma.bd_num = bd_num; in tsi721_bdma_maint_init()
1469 priv->mdma.bd_phys = bd_phys; in tsi721_bdma_maint_init()
1470 priv->mdma.bd_base = bd_ptr; in tsi721_bdma_maint_init()
1472 tsi_debug(MAINT, &priv->pdev->dev, "DMA descriptors @ %p (phys = %pad)", in tsi721_bdma_maint_init()
1479 sts_ptr = dma_alloc_coherent(&priv->pdev->dev, in tsi721_bdma_maint_init()
1484 dma_free_coherent(&priv->pdev->dev, in tsi721_bdma_maint_init()
1487 priv->mdma.bd_base = NULL; in tsi721_bdma_maint_init()
1491 priv->mdma.sts_phys = sts_phys; in tsi721_bdma_maint_init()
1492 priv->mdma.sts_base = sts_ptr; in tsi721_bdma_maint_init()
1493 priv->mdma.sts_size = sts_size; in tsi721_bdma_maint_init()
1495 tsi_debug(MAINT, &priv->pdev->dev, in tsi721_bdma_maint_init()
1530 static int tsi721_bdma_maint_free(struct tsi721_device *priv) in tsi721_bdma_maint_free() argument
1533 struct tsi721_bdma_maint *mdma = &priv->mdma; in tsi721_bdma_maint_free()
1534 void __iomem *regs = priv->regs + TSI721_DMAC_BASE(mdma->ch_id); in tsi721_bdma_maint_free()
1548 dma_free_coherent(&priv->pdev->dev, in tsi721_bdma_maint_free()
1554 dma_free_coherent(&priv->pdev->dev, in tsi721_bdma_maint_free()
1563 tsi721_imsg_interrupt_enable(struct tsi721_device *priv, int ch, in tsi721_imsg_interrupt_enable() argument
1572 iowrite32(inte_mask, priv->regs + TSI721_IBDMAC_INT(ch)); in tsi721_imsg_interrupt_enable()
1575 rval = ioread32(priv->regs + TSI721_IBDMAC_INTE(ch)); in tsi721_imsg_interrupt_enable()
1576 iowrite32(rval | inte_mask, priv->regs + TSI721_IBDMAC_INTE(ch)); in tsi721_imsg_interrupt_enable()
1578 if (priv->flags & TSI721_USING_MSIX) in tsi721_imsg_interrupt_enable()
1586 rval = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_interrupt_enable()
1588 priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_interrupt_enable()
1593 tsi721_imsg_interrupt_disable(struct tsi721_device *priv, int ch, in tsi721_imsg_interrupt_disable() argument
1602 iowrite32(inte_mask, priv->regs + TSI721_IBDMAC_INT(ch)); in tsi721_imsg_interrupt_disable()
1605 rval = ioread32(priv->regs + TSI721_IBDMAC_INTE(ch)); in tsi721_imsg_interrupt_disable()
1607 iowrite32(rval, priv->regs + TSI721_IBDMAC_INTE(ch)); in tsi721_imsg_interrupt_disable()
1609 if (priv->flags & TSI721_USING_MSIX) in tsi721_imsg_interrupt_disable()
1617 rval = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_interrupt_disable()
1619 iowrite32(rval, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_interrupt_disable()
1624 tsi721_omsg_interrupt_enable(struct tsi721_device *priv, int ch, in tsi721_omsg_interrupt_enable() argument
1633 iowrite32(inte_mask, priv->regs + TSI721_OBDMAC_INT(ch)); in tsi721_omsg_interrupt_enable()
1636 rval = ioread32(priv->regs + TSI721_OBDMAC_INTE(ch)); in tsi721_omsg_interrupt_enable()
1637 iowrite32(rval | inte_mask, priv->regs + TSI721_OBDMAC_INTE(ch)); in tsi721_omsg_interrupt_enable()
1639 if (priv->flags & TSI721_USING_MSIX) in tsi721_omsg_interrupt_enable()
1647 rval = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_interrupt_enable()
1649 priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_interrupt_enable()
1654 tsi721_omsg_interrupt_disable(struct tsi721_device *priv, int ch, in tsi721_omsg_interrupt_disable() argument
1663 iowrite32(inte_mask, priv->regs + TSI721_OBDMAC_INT(ch)); in tsi721_omsg_interrupt_disable()
1666 rval = ioread32(priv->regs + TSI721_OBDMAC_INTE(ch)); in tsi721_omsg_interrupt_disable()
1668 iowrite32(rval, priv->regs + TSI721_OBDMAC_INTE(ch)); in tsi721_omsg_interrupt_disable()
1670 if (priv->flags & TSI721_USING_MSIX) in tsi721_omsg_interrupt_disable()
1678 rval = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_interrupt_disable()
1680 iowrite32(rval, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_interrupt_disable()
1697 struct tsi721_device *priv = mport->priv; in tsi721_add_outb_message() local
1702 if (!priv->omsg_init[mbox] || in tsi721_add_outb_message()
1706 spin_lock_irqsave(&priv->omsg_ring[mbox].lock, flags); in tsi721_add_outb_message()
1708 tx_slot = priv->omsg_ring[mbox].tx_slot; in tsi721_add_outb_message()
1711 memcpy(priv->omsg_ring[mbox].omq_base[tx_slot], buffer, len); in tsi721_add_outb_message()
1717 desc = priv->omsg_ring[mbox].omd_base; in tsi721_add_outb_message()
1728 cpu_to_le32((u64)priv->omsg_ring[mbox].omq_phys[tx_slot] & in tsi721_add_outb_message()
1731 cpu_to_le32((u64)priv->omsg_ring[mbox].omq_phys[tx_slot] >> 32); in tsi721_add_outb_message()
1733 priv->omsg_ring[mbox].wr_count++; in tsi721_add_outb_message()
1736 if (++priv->omsg_ring[mbox].tx_slot == priv->omsg_ring[mbox].size) { in tsi721_add_outb_message()
1737 priv->omsg_ring[mbox].tx_slot = 0; in tsi721_add_outb_message()
1739 priv->omsg_ring[mbox].wr_count++; in tsi721_add_outb_message()
1745 iowrite32(priv->omsg_ring[mbox].wr_count, in tsi721_add_outb_message()
1746 priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_add_outb_message()
1747 ioread32(priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_add_outb_message()
1749 spin_unlock_irqrestore(&priv->omsg_ring[mbox].lock, flags); in tsi721_add_outb_message()
1761 static void tsi721_omsg_handler(struct tsi721_device *priv, int ch) in tsi721_omsg_handler() argument
1764 struct rio_mport *mport = &priv->mport; in tsi721_omsg_handler()
1769 spin_lock(&priv->omsg_ring[ch].lock); in tsi721_omsg_handler()
1771 omsg_int = ioread32(priv->regs + TSI721_OBDMAC_INT(ch)); in tsi721_omsg_handler()
1774 tsi_info(&priv->pdev->dev, in tsi721_omsg_handler()
1787 srd_ptr = priv->omsg_ring[ch].sts_rdptr; in tsi721_omsg_handler()
1788 sts_ptr = priv->omsg_ring[ch].sts_base; in tsi721_omsg_handler()
1798 srd_ptr %= priv->omsg_ring[ch].sts_size; in tsi721_omsg_handler()
1805 priv->omsg_ring[ch].sts_rdptr = srd_ptr; in tsi721_omsg_handler()
1806 iowrite32(srd_ptr, priv->regs + TSI721_OBDMAC_DSRP(ch)); in tsi721_omsg_handler()
1813 tx_slot = (last_ptr - (u64)priv->omsg_ring[ch].omd_phys)/ in tsi721_omsg_handler()
1821 if (tx_slot == priv->omsg_ring[ch].size) { in tsi721_omsg_handler()
1824 (u64)priv->omsg_ring[ch].omd_phys)/ in tsi721_omsg_handler()
1830 if (tx_slot >= priv->omsg_ring[ch].size) in tsi721_omsg_handler()
1831 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_omsg_handler()
1833 tx_slot, priv->omsg_ring[ch].size); in tsi721_omsg_handler()
1834 WARN_ON(tx_slot >= priv->omsg_ring[ch].size); in tsi721_omsg_handler()
1838 if (tx_slot == priv->omsg_ring[ch].size) in tsi721_omsg_handler()
1841 dev_id = priv->omsg_ring[ch].dev_id; in tsi721_omsg_handler()
1853 tsi_debug(OMSG, &priv->pdev->dev, "OB MSG ABORT ch_stat=%x", in tsi721_omsg_handler()
1854 ioread32(priv->regs + TSI721_OBDMAC_STS(ch))); in tsi721_omsg_handler()
1857 priv->regs + TSI721_OBDMAC_INT(ch)); in tsi721_omsg_handler()
1859 priv->regs + TSI721_OBDMAC_CTL(ch)); in tsi721_omsg_handler()
1860 ioread32(priv->regs + TSI721_OBDMAC_CTL(ch)); in tsi721_omsg_handler()
1863 dev_id = priv->omsg_ring[ch].dev_id; in tsi721_omsg_handler()
1864 tx_slot = priv->omsg_ring[ch].tx_slot; in tsi721_omsg_handler()
1868 iowrite32(priv->omsg_ring[ch].tx_slot, in tsi721_omsg_handler()
1869 priv->regs + TSI721_OBDMAC_DRDCNT(ch)); in tsi721_omsg_handler()
1870 ioread32(priv->regs + TSI721_OBDMAC_DRDCNT(ch)); in tsi721_omsg_handler()
1871 priv->omsg_ring[ch].wr_count = priv->omsg_ring[ch].tx_slot; in tsi721_omsg_handler()
1872 priv->omsg_ring[ch].sts_rdptr = 0; in tsi721_omsg_handler()
1876 iowrite32(omsg_int, priv->regs + TSI721_OBDMAC_INT(ch)); in tsi721_omsg_handler()
1878 if (!(priv->flags & TSI721_USING_MSIX)) { in tsi721_omsg_handler()
1882 ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_handler()
1884 iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_omsg_handler()
1887 spin_unlock(&priv->omsg_ring[ch].lock); in tsi721_omsg_handler()
1905 struct tsi721_device *priv = mport->priv; in tsi721_open_outb_mbox() local
1921 priv->omsg_ring[mbox].dev_id = dev_id; in tsi721_open_outb_mbox()
1922 priv->omsg_ring[mbox].size = entries; in tsi721_open_outb_mbox()
1923 priv->omsg_ring[mbox].sts_rdptr = 0; in tsi721_open_outb_mbox()
1924 spin_lock_init(&priv->omsg_ring[mbox].lock); in tsi721_open_outb_mbox()
1929 priv->omsg_ring[mbox].omq_base[i] = in tsi721_open_outb_mbox()
1931 &priv->pdev->dev, TSI721_MSG_BUFFER_SIZE, in tsi721_open_outb_mbox()
1932 &priv->omsg_ring[mbox].omq_phys[i], in tsi721_open_outb_mbox()
1934 if (priv->omsg_ring[mbox].omq_base[i] == NULL) { in tsi721_open_outb_mbox()
1935 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_open_outb_mbox()
1943 priv->omsg_ring[mbox].omd_base = dma_alloc_coherent( in tsi721_open_outb_mbox()
1944 &priv->pdev->dev, in tsi721_open_outb_mbox()
1946 &priv->omsg_ring[mbox].omd_phys, GFP_KERNEL); in tsi721_open_outb_mbox()
1947 if (priv->omsg_ring[mbox].omd_base == NULL) { in tsi721_open_outb_mbox()
1948 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_open_outb_mbox()
1954 priv->omsg_ring[mbox].tx_slot = 0; in tsi721_open_outb_mbox()
1957 priv->omsg_ring[mbox].sts_size = roundup_pow_of_two(entries + 1); in tsi721_open_outb_mbox()
1958 priv->omsg_ring[mbox].sts_base = dma_alloc_coherent(&priv->pdev->dev, in tsi721_open_outb_mbox()
1959 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_open_outb_mbox()
1960 &priv->omsg_ring[mbox].sts_phys, in tsi721_open_outb_mbox()
1962 if (priv->omsg_ring[mbox].sts_base == NULL) { in tsi721_open_outb_mbox()
1963 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_open_outb_mbox()
1974 iowrite32(((u64)priv->omsg_ring[mbox].omd_phys >> 32), in tsi721_open_outb_mbox()
1975 priv->regs + TSI721_OBDMAC_DPTRH(mbox)); in tsi721_open_outb_mbox()
1976 iowrite32(((u64)priv->omsg_ring[mbox].omd_phys & in tsi721_open_outb_mbox()
1978 priv->regs + TSI721_OBDMAC_DPTRL(mbox)); in tsi721_open_outb_mbox()
1981 iowrite32(((u64)priv->omsg_ring[mbox].sts_phys >> 32), in tsi721_open_outb_mbox()
1982 priv->regs + TSI721_OBDMAC_DSBH(mbox)); in tsi721_open_outb_mbox()
1983 iowrite32(((u64)priv->omsg_ring[mbox].sts_phys & in tsi721_open_outb_mbox()
1985 priv->regs + TSI721_OBDMAC_DSBL(mbox)); in tsi721_open_outb_mbox()
1986 iowrite32(TSI721_DMAC_DSSZ_SIZE(priv->omsg_ring[mbox].sts_size), in tsi721_open_outb_mbox()
1987 priv->regs + (u32)TSI721_OBDMAC_DSSZ(mbox)); in tsi721_open_outb_mbox()
1992 if (priv->flags & TSI721_USING_MSIX) { in tsi721_open_outb_mbox()
1996 rc = request_irq(priv->msix[idx].vector, tsi721_omsg_msix, 0, in tsi721_open_outb_mbox()
1997 priv->msix[idx].irq_name, (void *)priv); in tsi721_open_outb_mbox()
2000 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_open_outb_mbox()
2007 rc = request_irq(priv->msix[idx].vector, tsi721_omsg_msix, 0, in tsi721_open_outb_mbox()
2008 priv->msix[idx].irq_name, (void *)priv); in tsi721_open_outb_mbox()
2011 tsi_debug(OMSG, &priv->pdev->dev, in tsi721_open_outb_mbox()
2014 free_irq(priv->msix[idx].vector, (void *)priv); in tsi721_open_outb_mbox()
2020 tsi721_omsg_interrupt_enable(priv, mbox, TSI721_OBDMAC_INT_ALL); in tsi721_open_outb_mbox()
2023 bd_ptr = priv->omsg_ring[mbox].omd_base; in tsi721_open_outb_mbox()
2027 cpu_to_le32((u64)priv->omsg_ring[mbox].omd_phys & in tsi721_open_outb_mbox()
2030 cpu_to_le32((u64)priv->omsg_ring[mbox].omd_phys >> 32); in tsi721_open_outb_mbox()
2031 priv->omsg_ring[mbox].wr_count = 0; in tsi721_open_outb_mbox()
2036 priv->regs + TSI721_OBDMAC_CTL(mbox)); in tsi721_open_outb_mbox()
2037 ioread32(priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_open_outb_mbox()
2040 priv->omsg_init[mbox] = 1; in tsi721_open_outb_mbox()
2046 dma_free_coherent(&priv->pdev->dev, in tsi721_open_outb_mbox()
2047 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_open_outb_mbox()
2048 priv->omsg_ring[mbox].sts_base, in tsi721_open_outb_mbox()
2049 priv->omsg_ring[mbox].sts_phys); in tsi721_open_outb_mbox()
2051 priv->omsg_ring[mbox].sts_base = NULL; in tsi721_open_outb_mbox()
2055 dma_free_coherent(&priv->pdev->dev, in tsi721_open_outb_mbox()
2057 priv->omsg_ring[mbox].omd_base, in tsi721_open_outb_mbox()
2058 priv->omsg_ring[mbox].omd_phys); in tsi721_open_outb_mbox()
2060 priv->omsg_ring[mbox].omd_base = NULL; in tsi721_open_outb_mbox()
2063 for (i = 0; i < priv->omsg_ring[mbox].size; i++) { in tsi721_open_outb_mbox()
2064 if (priv->omsg_ring[mbox].omq_base[i]) { in tsi721_open_outb_mbox()
2065 dma_free_coherent(&priv->pdev->dev, in tsi721_open_outb_mbox()
2067 priv->omsg_ring[mbox].omq_base[i], in tsi721_open_outb_mbox()
2068 priv->omsg_ring[mbox].omq_phys[i]); in tsi721_open_outb_mbox()
2070 priv->omsg_ring[mbox].omq_base[i] = NULL; in tsi721_open_outb_mbox()
2085 struct tsi721_device *priv = mport->priv; in tsi721_close_outb_mbox() local
2088 if (!priv->omsg_init[mbox]) in tsi721_close_outb_mbox()
2090 priv->omsg_init[mbox] = 0; in tsi721_close_outb_mbox()
2094 tsi721_omsg_interrupt_disable(priv, mbox, TSI721_OBDMAC_INT_ALL); in tsi721_close_outb_mbox()
2097 if (priv->flags & TSI721_USING_MSIX) { in tsi721_close_outb_mbox()
2098 free_irq(priv->msix[TSI721_VECT_OMB0_DONE + mbox].vector, in tsi721_close_outb_mbox()
2099 (void *)priv); in tsi721_close_outb_mbox()
2100 free_irq(priv->msix[TSI721_VECT_OMB0_INT + mbox].vector, in tsi721_close_outb_mbox()
2101 (void *)priv); in tsi721_close_outb_mbox()
2106 dma_free_coherent(&priv->pdev->dev, in tsi721_close_outb_mbox()
2107 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_close_outb_mbox()
2108 priv->omsg_ring[mbox].sts_base, in tsi721_close_outb_mbox()
2109 priv->omsg_ring[mbox].sts_phys); in tsi721_close_outb_mbox()
2111 priv->omsg_ring[mbox].sts_base = NULL; in tsi721_close_outb_mbox()
2114 dma_free_coherent(&priv->pdev->dev, in tsi721_close_outb_mbox()
2115 (priv->omsg_ring[mbox].size + 1) * in tsi721_close_outb_mbox()
2117 priv->omsg_ring[mbox].omd_base, in tsi721_close_outb_mbox()
2118 priv->omsg_ring[mbox].omd_phys); in tsi721_close_outb_mbox()
2120 priv->omsg_ring[mbox].omd_base = NULL; in tsi721_close_outb_mbox()
2123 for (i = 0; i < priv->omsg_ring[mbox].size; i++) { in tsi721_close_outb_mbox()
2124 if (priv->omsg_ring[mbox].omq_base[i]) { in tsi721_close_outb_mbox()
2125 dma_free_coherent(&priv->pdev->dev, in tsi721_close_outb_mbox()
2127 priv->omsg_ring[mbox].omq_base[i], in tsi721_close_outb_mbox()
2128 priv->omsg_ring[mbox].omq_phys[i]); in tsi721_close_outb_mbox()
2130 priv->omsg_ring[mbox].omq_base[i] = NULL; in tsi721_close_outb_mbox()
2142 static void tsi721_imsg_handler(struct tsi721_device *priv, int ch) in tsi721_imsg_handler() argument
2146 struct rio_mport *mport = &priv->mport; in tsi721_imsg_handler()
2148 spin_lock(&priv->imsg_ring[mbox].lock); in tsi721_imsg_handler()
2150 imsg_int = ioread32(priv->regs + TSI721_IBDMAC_INT(ch)); in tsi721_imsg_handler()
2153 tsi_info(&priv->pdev->dev, "IB MBOX%d SRIO timeout", mbox); in tsi721_imsg_handler()
2156 tsi_info(&priv->pdev->dev, "IB MBOX%d PCIe error", mbox); in tsi721_imsg_handler()
2159 tsi_info(&priv->pdev->dev, "IB MBOX%d IB free queue low", mbox); in tsi721_imsg_handler()
2162 iowrite32(imsg_int, priv->regs + TSI721_IBDMAC_INT(ch)); in tsi721_imsg_handler()
2168 priv->imsg_ring[mbox].dev_id, mbox, -1); in tsi721_imsg_handler()
2170 if (!(priv->flags & TSI721_USING_MSIX)) { in tsi721_imsg_handler()
2174 ch_inte = ioread32(priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_handler()
2176 iowrite32(ch_inte, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_imsg_handler()
2179 spin_unlock(&priv->imsg_ring[mbox].lock); in tsi721_imsg_handler()
2194 struct tsi721_device *priv = mport->priv; in tsi721_open_inb_mbox() local
2213 priv->imsg_ring[mbox].dev_id = dev_id; in tsi721_open_inb_mbox()
2214 priv->imsg_ring[mbox].size = entries; in tsi721_open_inb_mbox()
2215 priv->imsg_ring[mbox].rx_slot = 0; in tsi721_open_inb_mbox()
2216 priv->imsg_ring[mbox].desc_rdptr = 0; in tsi721_open_inb_mbox()
2217 priv->imsg_ring[mbox].fq_wrptr = 0; in tsi721_open_inb_mbox()
2218 for (i = 0; i < priv->imsg_ring[mbox].size; i++) in tsi721_open_inb_mbox()
2219 priv->imsg_ring[mbox].imq_base[i] = NULL; in tsi721_open_inb_mbox()
2220 spin_lock_init(&priv->imsg_ring[mbox].lock); in tsi721_open_inb_mbox()
2223 priv->imsg_ring[mbox].buf_base = in tsi721_open_inb_mbox()
2224 dma_alloc_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2226 &priv->imsg_ring[mbox].buf_phys, in tsi721_open_inb_mbox()
2229 if (priv->imsg_ring[mbox].buf_base == NULL) { in tsi721_open_inb_mbox()
2230 tsi_err(&priv->pdev->dev, in tsi721_open_inb_mbox()
2237 priv->imsg_ring[mbox].imfq_base = in tsi721_open_inb_mbox()
2238 dma_alloc_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2240 &priv->imsg_ring[mbox].imfq_phys, in tsi721_open_inb_mbox()
2243 if (priv->imsg_ring[mbox].imfq_base == NULL) { in tsi721_open_inb_mbox()
2244 tsi_err(&priv->pdev->dev, in tsi721_open_inb_mbox()
2251 priv->imsg_ring[mbox].imd_base = in tsi721_open_inb_mbox()
2252 dma_alloc_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2254 &priv->imsg_ring[mbox].imd_phys, GFP_KERNEL); in tsi721_open_inb_mbox()
2256 if (priv->imsg_ring[mbox].imd_base == NULL) { in tsi721_open_inb_mbox()
2257 tsi_err(&priv->pdev->dev, in tsi721_open_inb_mbox()
2265 free_ptr = priv->imsg_ring[mbox].imfq_base; in tsi721_open_inb_mbox()
2268 (u64)(priv->imsg_ring[mbox].buf_phys) + in tsi721_open_inb_mbox()
2278 if (!(priv->flags & TSI721_IMSGID_SET)) { in tsi721_open_inb_mbox()
2279 iowrite32((u32)priv->mport.host_deviceid, in tsi721_open_inb_mbox()
2280 priv->regs + TSI721_IB_DEVID); in tsi721_open_inb_mbox()
2281 priv->flags |= TSI721_IMSGID_SET; in tsi721_open_inb_mbox()
2289 iowrite32(((u64)priv->imsg_ring[mbox].imfq_phys >> 32), in tsi721_open_inb_mbox()
2290 priv->regs + TSI721_IBDMAC_FQBH(ch)); in tsi721_open_inb_mbox()
2291 iowrite32(((u64)priv->imsg_ring[mbox].imfq_phys & in tsi721_open_inb_mbox()
2293 priv->regs+TSI721_IBDMAC_FQBL(ch)); in tsi721_open_inb_mbox()
2295 priv->regs + TSI721_IBDMAC_FQSZ(ch)); in tsi721_open_inb_mbox()
2298 iowrite32(((u64)priv->imsg_ring[mbox].imd_phys >> 32), in tsi721_open_inb_mbox()
2299 priv->regs + TSI721_IBDMAC_DQBH(ch)); in tsi721_open_inb_mbox()
2300 iowrite32(((u32)priv->imsg_ring[mbox].imd_phys & in tsi721_open_inb_mbox()
2302 priv->regs+TSI721_IBDMAC_DQBL(ch)); in tsi721_open_inb_mbox()
2304 priv->regs + TSI721_IBDMAC_DQSZ(ch)); in tsi721_open_inb_mbox()
2309 if (priv->flags & TSI721_USING_MSIX) { in tsi721_open_inb_mbox()
2313 rc = request_irq(priv->msix[idx].vector, tsi721_imsg_msix, 0, in tsi721_open_inb_mbox()
2314 priv->msix[idx].irq_name, (void *)priv); in tsi721_open_inb_mbox()
2317 tsi_debug(IMSG, &priv->pdev->dev, in tsi721_open_inb_mbox()
2324 rc = request_irq(priv->msix[idx].vector, tsi721_imsg_msix, 0, in tsi721_open_inb_mbox()
2325 priv->msix[idx].irq_name, (void *)priv); in tsi721_open_inb_mbox()
2328 tsi_debug(IMSG, &priv->pdev->dev, in tsi721_open_inb_mbox()
2331 priv->msix[TSI721_VECT_IMB0_RCV + mbox].vector, in tsi721_open_inb_mbox()
2332 (void *)priv); in tsi721_open_inb_mbox()
2338 tsi721_imsg_interrupt_enable(priv, ch, TSI721_IBDMAC_INT_ALL); in tsi721_open_inb_mbox()
2341 iowrite32(TSI721_IBDMAC_CTL_INIT, priv->regs + TSI721_IBDMAC_CTL(ch)); in tsi721_open_inb_mbox()
2342 ioread32(priv->regs + TSI721_IBDMAC_CTL(ch)); in tsi721_open_inb_mbox()
2344 priv->imsg_ring[mbox].fq_wrptr = entries - 1; in tsi721_open_inb_mbox()
2345 iowrite32(entries - 1, priv->regs + TSI721_IBDMAC_FQWP(ch)); in tsi721_open_inb_mbox()
2347 priv->imsg_init[mbox] = 1; in tsi721_open_inb_mbox()
2352 dma_free_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2353 priv->imsg_ring[mbox].size * sizeof(struct tsi721_imsg_desc), in tsi721_open_inb_mbox()
2354 priv->imsg_ring[mbox].imd_base, in tsi721_open_inb_mbox()
2355 priv->imsg_ring[mbox].imd_phys); in tsi721_open_inb_mbox()
2357 priv->imsg_ring[mbox].imd_base = NULL; in tsi721_open_inb_mbox()
2361 dma_free_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2362 priv->imsg_ring[mbox].size * 8, in tsi721_open_inb_mbox()
2363 priv->imsg_ring[mbox].imfq_base, in tsi721_open_inb_mbox()
2364 priv->imsg_ring[mbox].imfq_phys); in tsi721_open_inb_mbox()
2366 priv->imsg_ring[mbox].imfq_base = NULL; in tsi721_open_inb_mbox()
2369 dma_free_coherent(&priv->pdev->dev, in tsi721_open_inb_mbox()
2370 priv->imsg_ring[mbox].size * TSI721_MSG_BUFFER_SIZE, in tsi721_open_inb_mbox()
2371 priv->imsg_ring[mbox].buf_base, in tsi721_open_inb_mbox()
2372 priv->imsg_ring[mbox].buf_phys); in tsi721_open_inb_mbox()
2374 priv->imsg_ring[mbox].buf_base = NULL; in tsi721_open_inb_mbox()
2387 struct tsi721_device *priv = mport->priv; in tsi721_close_inb_mbox() local
2391 if (!priv->imsg_init[mbox]) /* mbox isn't initialized yet */ in tsi721_close_inb_mbox()
2393 priv->imsg_init[mbox] = 0; in tsi721_close_inb_mbox()
2398 tsi721_imsg_interrupt_disable(priv, ch, TSI721_OBDMAC_INT_MASK); in tsi721_close_inb_mbox()
2401 if (priv->flags & TSI721_USING_MSIX) { in tsi721_close_inb_mbox()
2402 free_irq(priv->msix[TSI721_VECT_IMB0_RCV + mbox].vector, in tsi721_close_inb_mbox()
2403 (void *)priv); in tsi721_close_inb_mbox()
2404 free_irq(priv->msix[TSI721_VECT_IMB0_INT + mbox].vector, in tsi721_close_inb_mbox()
2405 (void *)priv); in tsi721_close_inb_mbox()
2410 for (rx_slot = 0; rx_slot < priv->imsg_ring[mbox].size; rx_slot++) in tsi721_close_inb_mbox()
2411 priv->imsg_ring[mbox].imq_base[rx_slot] = NULL; in tsi721_close_inb_mbox()
2414 dma_free_coherent(&priv->pdev->dev, in tsi721_close_inb_mbox()
2415 priv->imsg_ring[mbox].size * TSI721_MSG_BUFFER_SIZE, in tsi721_close_inb_mbox()
2416 priv->imsg_ring[mbox].buf_base, in tsi721_close_inb_mbox()
2417 priv->imsg_ring[mbox].buf_phys); in tsi721_close_inb_mbox()
2419 priv->imsg_ring[mbox].buf_base = NULL; in tsi721_close_inb_mbox()
2422 dma_free_coherent(&priv->pdev->dev, in tsi721_close_inb_mbox()
2423 priv->imsg_ring[mbox].size * 8, in tsi721_close_inb_mbox()
2424 priv->imsg_ring[mbox].imfq_base, in tsi721_close_inb_mbox()
2425 priv->imsg_ring[mbox].imfq_phys); in tsi721_close_inb_mbox()
2427 priv->imsg_ring[mbox].imfq_base = NULL; in tsi721_close_inb_mbox()
2430 dma_free_coherent(&priv->pdev->dev, in tsi721_close_inb_mbox()
2431 priv->imsg_ring[mbox].size * sizeof(struct tsi721_imsg_desc), in tsi721_close_inb_mbox()
2432 priv->imsg_ring[mbox].imd_base, in tsi721_close_inb_mbox()
2433 priv->imsg_ring[mbox].imd_phys); in tsi721_close_inb_mbox()
2435 priv->imsg_ring[mbox].imd_base = NULL; in tsi721_close_inb_mbox()
2448 struct tsi721_device *priv = mport->priv; in tsi721_add_inb_buffer() local
2452 rx_slot = priv->imsg_ring[mbox].rx_slot; in tsi721_add_inb_buffer()
2453 if (priv->imsg_ring[mbox].imq_base[rx_slot]) { in tsi721_add_inb_buffer()
2454 tsi_err(&priv->pdev->dev, in tsi721_add_inb_buffer()
2461 priv->imsg_ring[mbox].imq_base[rx_slot] = buf; in tsi721_add_inb_buffer()
2463 if (++priv->imsg_ring[mbox].rx_slot == priv->imsg_ring[mbox].size) in tsi721_add_inb_buffer()
2464 priv->imsg_ring[mbox].rx_slot = 0; in tsi721_add_inb_buffer()
2479 struct tsi721_device *priv = mport->priv; in tsi721_get_inb_message() local
2489 if (!priv->imsg_init[mbox]) in tsi721_get_inb_message()
2492 desc = priv->imsg_ring[mbox].imd_base; in tsi721_get_inb_message()
2493 desc += priv->imsg_ring[mbox].desc_rdptr; in tsi721_get_inb_message()
2498 rx_slot = priv->imsg_ring[mbox].rx_slot; in tsi721_get_inb_message()
2499 while (priv->imsg_ring[mbox].imq_base[rx_slot] == NULL) { in tsi721_get_inb_message()
2500 if (++rx_slot == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2507 rx_virt = priv->imsg_ring[mbox].buf_base + in tsi721_get_inb_message()
2508 (rx_phys - (u64)priv->imsg_ring[mbox].buf_phys); in tsi721_get_inb_message()
2510 buf = priv->imsg_ring[mbox].imq_base[rx_slot]; in tsi721_get_inb_message()
2516 priv->imsg_ring[mbox].imq_base[rx_slot] = NULL; in tsi721_get_inb_message()
2519 if (++priv->imsg_ring[mbox].desc_rdptr == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2520 priv->imsg_ring[mbox].desc_rdptr = 0; in tsi721_get_inb_message()
2522 iowrite32(priv->imsg_ring[mbox].desc_rdptr, in tsi721_get_inb_message()
2523 priv->regs + TSI721_IBDMAC_DQRP(ch)); in tsi721_get_inb_message()
2526 free_ptr = priv->imsg_ring[mbox].imfq_base; in tsi721_get_inb_message()
2527 free_ptr[priv->imsg_ring[mbox].fq_wrptr] = cpu_to_le64(rx_phys); in tsi721_get_inb_message()
2529 if (++priv->imsg_ring[mbox].fq_wrptr == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2530 priv->imsg_ring[mbox].fq_wrptr = 0; in tsi721_get_inb_message()
2532 iowrite32(priv->imsg_ring[mbox].fq_wrptr, in tsi721_get_inb_message()
2533 priv->regs + TSI721_IBDMAC_FQWP(ch)); in tsi721_get_inb_message()
2546 static int tsi721_messages_init(struct tsi721_device *priv) in tsi721_messages_init() argument
2550 iowrite32(0, priv->regs + TSI721_SMSG_ECC_LOG); in tsi721_messages_init()
2551 iowrite32(0, priv->regs + TSI721_RETRY_GEN_CNT); in tsi721_messages_init()
2552 iowrite32(0, priv->regs + TSI721_RETRY_RX_CNT); in tsi721_messages_init()
2555 iowrite32(TSI721_RQRPTO_VAL, priv->regs + TSI721_RQRPTO); in tsi721_messages_init()
2561 priv->regs + TSI721_IBDMAC_INT(ch)); in tsi721_messages_init()
2563 iowrite32(0, priv->regs + TSI721_IBDMAC_STS(ch)); in tsi721_messages_init()
2566 priv->regs + TSI721_SMSG_ECC_COR_LOG(ch)); in tsi721_messages_init()
2568 priv->regs + TSI721_SMSG_ECC_NCOR(ch)); in tsi721_messages_init()
2584 struct tsi721_device *priv = mport->priv; in tsi721_query_mport() local
2587 rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_ERR_STS_CSR(0, 0)); in tsi721_query_mport()
2589 rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_CTL2_CSR(0, 0)); in tsi721_query_mport()
2591 rval = ioread32(priv->regs + 0x100 + RIO_PORT_N_CTL_CSR(0, 0)); in tsi721_query_mport()
2611 static void tsi721_disable_ints(struct tsi721_device *priv) in tsi721_disable_ints() argument
2616 iowrite32(0, priv->regs + TSI721_DEV_INTE); in tsi721_disable_ints()
2619 iowrite32(0, priv->regs + TSI721_DEV_CHAN_INTE); in tsi721_disable_ints()
2623 iowrite32(0, priv->regs + TSI721_IBDMAC_INTE(ch)); in tsi721_disable_ints()
2627 iowrite32(0, priv->regs + TSI721_OBDMAC_INTE(ch)); in tsi721_disable_ints()
2630 iowrite32(0, priv->regs + TSI721_SMSG_INTE); in tsi721_disable_ints()
2635 priv->regs + TSI721_DMAC_BASE(ch) + TSI721_DMAC_INTE); in tsi721_disable_ints()
2638 iowrite32(0, priv->regs + TSI721_BDMA_INTE); in tsi721_disable_ints()
2642 iowrite32(0, priv->regs + TSI721_SR_CHINTE(ch)); in tsi721_disable_ints()
2645 iowrite32(0, priv->regs + TSI721_SR2PC_GEN_INTE); in tsi721_disable_ints()
2648 iowrite32(0, priv->regs + TSI721_PC2SR_INTE); in tsi721_disable_ints()
2651 iowrite32(0, priv->regs + TSI721_I2C_INT_ENABLE); in tsi721_disable_ints()
2654 iowrite32(0, priv->regs + TSI721_RIO_EM_INT_ENABLE); in tsi721_disable_ints()
2655 iowrite32(0, priv->regs + TSI721_RIO_EM_DEV_INT_EN); in tsi721_disable_ints()
2694 static int tsi721_setup_mport(struct tsi721_device *priv) in tsi721_setup_mport() argument
2696 struct pci_dev *pdev = priv->pdev; in tsi721_setup_mport()
2698 struct rio_mport *mport = &priv->mport; in tsi721_setup_mport()
2707 mport->priv = (void *)priv; in tsi721_setup_mport()
2724 if (!tsi721_enable_msix(priv)) in tsi721_setup_mport()
2725 priv->flags |= TSI721_USING_MSIX; in tsi721_setup_mport()
2727 priv->flags |= TSI721_USING_MSI; in tsi721_setup_mport()
2733 err = tsi721_request_irq(priv); in tsi721_setup_mport()
2742 err = tsi721_register_dma(priv); in tsi721_setup_mport()
2747 iowrite32(ioread32(priv->regs + TSI721_DEVCTL) | in tsi721_setup_mport()
2749 priv->regs + TSI721_DEVCTL); in tsi721_setup_mport()
2754 priv->regs + (0x100 + RIO_PORT_GEN_CTL_CSR)); in tsi721_setup_mport()
2756 iowrite32(0, priv->regs + (0x100 + RIO_PORT_GEN_CTL_CSR)); in tsi721_setup_mport()
2760 tsi721_unregister_dma(priv); in tsi721_setup_mport()
2767 tsi721_free_irq(priv); in tsi721_setup_mport()
2774 struct tsi721_device *priv; in tsi721_probe() local
2777 priv = kzalloc(sizeof(struct tsi721_device), GFP_KERNEL); in tsi721_probe()
2778 if (!priv) { in tsi721_probe()
2789 priv->pdev = pdev; in tsi721_probe()
2831 priv->p2r_bar[0].size = priv->p2r_bar[1].size = 0; in tsi721_probe()
2838 priv->p2r_bar[0].base = pci_resource_start(pdev, BAR_2); in tsi721_probe()
2839 priv->p2r_bar[0].size = pci_resource_len(pdev, BAR_2); in tsi721_probe()
2848 priv->p2r_bar[1].base = pci_resource_start(pdev, BAR_4); in tsi721_probe()
2849 priv->p2r_bar[1].size = pci_resource_len(pdev, BAR_4); in tsi721_probe()
2861 priv->regs = pci_ioremap_bar(pdev, BAR_0); in tsi721_probe()
2862 if (!priv->regs) { in tsi721_probe()
2868 priv->odb_base = pci_ioremap_bar(pdev, BAR_1); in tsi721_probe()
2869 if (!priv->odb_base) { in tsi721_probe()
2922 tsi721_disable_ints(priv); in tsi721_probe()
2924 tsi721_init_pc2sr_mapping(priv); in tsi721_probe()
2925 tsi721_init_sr2pc_mapping(priv); in tsi721_probe()
2927 if (tsi721_bdma_maint_init(priv)) { in tsi721_probe()
2933 err = tsi721_doorbell_init(priv); in tsi721_probe()
2937 tsi721_port_write_init(priv); in tsi721_probe()
2939 err = tsi721_messages_init(priv); in tsi721_probe()
2943 err = tsi721_setup_mport(priv); in tsi721_probe()
2947 pci_set_drvdata(pdev, priv); in tsi721_probe()
2948 tsi721_interrupts_init(priv); in tsi721_probe()
2953 tsi721_port_write_free(priv); in tsi721_probe()
2954 tsi721_doorbell_free(priv); in tsi721_probe()
2956 tsi721_bdma_maint_free(priv); in tsi721_probe()
2958 if (priv->regs) in tsi721_probe()
2959 iounmap(priv->regs); in tsi721_probe()
2960 if (priv->odb_base) in tsi721_probe()
2961 iounmap(priv->odb_base); in tsi721_probe()
2967 kfree(priv); in tsi721_probe()
2974 struct tsi721_device *priv = pci_get_drvdata(pdev); in tsi721_remove() local
2978 tsi721_disable_ints(priv); in tsi721_remove()
2979 tsi721_free_irq(priv); in tsi721_remove()
2980 flush_work(&priv->idb_work); in tsi721_remove()
2981 flush_work(&priv->pw_work); in tsi721_remove()
2982 rio_unregister_mport(&priv->mport); in tsi721_remove()
2984 tsi721_unregister_dma(priv); in tsi721_remove()
2985 tsi721_bdma_maint_free(priv); in tsi721_remove()
2986 tsi721_doorbell_free(priv); in tsi721_remove()
2987 tsi721_port_write_free(priv); in tsi721_remove()
2988 tsi721_close_sr2pc_mapping(priv); in tsi721_remove()
2990 if (priv->regs) in tsi721_remove()
2991 iounmap(priv->regs); in tsi721_remove()
2992 if (priv->odb_base) in tsi721_remove()
2993 iounmap(priv->odb_base); in tsi721_remove()
2995 if (priv->flags & TSI721_USING_MSIX) in tsi721_remove()
2996 pci_disable_msix(priv->pdev); in tsi721_remove()
2997 else if (priv->flags & TSI721_USING_MSI) in tsi721_remove()
2998 pci_disable_msi(priv->pdev); in tsi721_remove()
3003 kfree(priv); in tsi721_remove()
3009 struct tsi721_device *priv = pci_get_drvdata(pdev); in tsi721_shutdown() local
3013 tsi721_disable_ints(priv); in tsi721_shutdown()
3014 tsi721_dma_stop_all(priv); in tsi721_shutdown()