Lines Matching refs:mbox

614 	int mbox;  in tsi721_omsg_msix()  local
616 mbox = (irq - priv->msix[TSI721_VECT_OMB0_DONE].vector) % RIO_MAX_MBOX; in tsi721_omsg_msix()
617 tsi721_omsg_handler(priv, mbox); in tsi721_omsg_msix()
631 int mbox; in tsi721_imsg_msix() local
633 mbox = (irq - priv->msix[TSI721_VECT_IMB0_RCV].vector) % RIO_MAX_MBOX; in tsi721_imsg_msix()
634 tsi721_imsg_handler(priv, mbox + 4); in tsi721_imsg_msix()
1667 tsi721_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, in tsi721_add_outb_message() argument
1675 if (!priv->omsg_init[mbox] || in tsi721_add_outb_message()
1679 spin_lock_irqsave(&priv->omsg_ring[mbox].lock, flags); in tsi721_add_outb_message()
1681 tx_slot = priv->omsg_ring[mbox].tx_slot; in tsi721_add_outb_message()
1684 memcpy(priv->omsg_ring[mbox].omq_base[tx_slot], buffer, len); in tsi721_add_outb_message()
1690 desc = priv->omsg_ring[mbox].omd_base; in tsi721_add_outb_message()
1698 cpu_to_le32((mport->sys_size << 26) | (mbox << 22) | in tsi721_add_outb_message()
1701 cpu_to_le32((u64)priv->omsg_ring[mbox].omq_phys[tx_slot] & in tsi721_add_outb_message()
1704 cpu_to_le32((u64)priv->omsg_ring[mbox].omq_phys[tx_slot] >> 32); in tsi721_add_outb_message()
1706 priv->omsg_ring[mbox].wr_count++; in tsi721_add_outb_message()
1709 if (++priv->omsg_ring[mbox].tx_slot == priv->omsg_ring[mbox].size) { in tsi721_add_outb_message()
1710 priv->omsg_ring[mbox].tx_slot = 0; in tsi721_add_outb_message()
1712 priv->omsg_ring[mbox].wr_count++; in tsi721_add_outb_message()
1718 iowrite32(priv->omsg_ring[mbox].wr_count, in tsi721_add_outb_message()
1719 priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_add_outb_message()
1720 ioread32(priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_add_outb_message()
1722 spin_unlock_irqrestore(&priv->omsg_ring[mbox].lock, flags); in tsi721_add_outb_message()
1874 int mbox, int entries) in tsi721_open_outb_mbox() argument
1882 (!is_power_of_2(entries)) || mbox >= RIO_MAX_MBOX) { in tsi721_open_outb_mbox()
1887 if ((mbox_sel & (1 << mbox)) == 0) { in tsi721_open_outb_mbox()
1892 priv->omsg_ring[mbox].dev_id = dev_id; in tsi721_open_outb_mbox()
1893 priv->omsg_ring[mbox].size = entries; in tsi721_open_outb_mbox()
1894 priv->omsg_ring[mbox].sts_rdptr = 0; in tsi721_open_outb_mbox()
1895 spin_lock_init(&priv->omsg_ring[mbox].lock); in tsi721_open_outb_mbox()
1900 priv->omsg_ring[mbox].omq_base[i] = in tsi721_open_outb_mbox()
1903 &priv->omsg_ring[mbox].omq_phys[i], in tsi721_open_outb_mbox()
1905 if (priv->omsg_ring[mbox].omq_base[i] == NULL) { in tsi721_open_outb_mbox()
1907 "ENOMEM for OB_MSG_%d data buffer", mbox); in tsi721_open_outb_mbox()
1914 priv->omsg_ring[mbox].omd_base = dma_alloc_coherent( in tsi721_open_outb_mbox()
1917 &priv->omsg_ring[mbox].omd_phys, GFP_KERNEL); in tsi721_open_outb_mbox()
1918 if (priv->omsg_ring[mbox].omd_base == NULL) { in tsi721_open_outb_mbox()
1920 "ENOMEM for OB_MSG_%d descriptor memory", mbox); in tsi721_open_outb_mbox()
1925 priv->omsg_ring[mbox].tx_slot = 0; in tsi721_open_outb_mbox()
1928 priv->omsg_ring[mbox].sts_size = roundup_pow_of_two(entries + 1); in tsi721_open_outb_mbox()
1929 priv->omsg_ring[mbox].sts_base = dma_alloc_coherent(&priv->pdev->dev, in tsi721_open_outb_mbox()
1930 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_open_outb_mbox()
1931 &priv->omsg_ring[mbox].sts_phys, in tsi721_open_outb_mbox()
1933 if (priv->omsg_ring[mbox].sts_base == NULL) { in tsi721_open_outb_mbox()
1935 "ENOMEM for OB_MSG_%d status FIFO", mbox); in tsi721_open_outb_mbox()
1945 iowrite32(((u64)priv->omsg_ring[mbox].omd_phys >> 32), in tsi721_open_outb_mbox()
1946 priv->regs + TSI721_OBDMAC_DPTRH(mbox)); in tsi721_open_outb_mbox()
1947 iowrite32(((u64)priv->omsg_ring[mbox].omd_phys & in tsi721_open_outb_mbox()
1949 priv->regs + TSI721_OBDMAC_DPTRL(mbox)); in tsi721_open_outb_mbox()
1952 iowrite32(((u64)priv->omsg_ring[mbox].sts_phys >> 32), in tsi721_open_outb_mbox()
1953 priv->regs + TSI721_OBDMAC_DSBH(mbox)); in tsi721_open_outb_mbox()
1954 iowrite32(((u64)priv->omsg_ring[mbox].sts_phys & in tsi721_open_outb_mbox()
1956 priv->regs + TSI721_OBDMAC_DSBL(mbox)); in tsi721_open_outb_mbox()
1957 iowrite32(TSI721_DMAC_DSSZ_SIZE(priv->omsg_ring[mbox].sts_size), in tsi721_open_outb_mbox()
1958 priv->regs + (u32)TSI721_OBDMAC_DSSZ(mbox)); in tsi721_open_outb_mbox()
1964 int idx = TSI721_VECT_OMB0_DONE + mbox; in tsi721_open_outb_mbox()
1973 mbox); in tsi721_open_outb_mbox()
1977 idx = TSI721_VECT_OMB0_INT + mbox; in tsi721_open_outb_mbox()
1983 "Unable to get MSI-X IRQ for MBOX%d-INT", mbox); in tsi721_open_outb_mbox()
1984 idx = TSI721_VECT_OMB0_DONE + mbox; in tsi721_open_outb_mbox()
1991 tsi721_omsg_interrupt_enable(priv, mbox, TSI721_OBDMAC_INT_ALL); in tsi721_open_outb_mbox()
1994 bd_ptr = priv->omsg_ring[mbox].omd_base; in tsi721_open_outb_mbox()
1998 cpu_to_le32((u64)priv->omsg_ring[mbox].omd_phys & in tsi721_open_outb_mbox()
2001 cpu_to_le32((u64)priv->omsg_ring[mbox].omd_phys >> 32); in tsi721_open_outb_mbox()
2002 priv->omsg_ring[mbox].wr_count = 0; in tsi721_open_outb_mbox()
2007 priv->regs + TSI721_OBDMAC_CTL(mbox)); in tsi721_open_outb_mbox()
2008 ioread32(priv->regs + TSI721_OBDMAC_DWRCNT(mbox)); in tsi721_open_outb_mbox()
2011 priv->omsg_init[mbox] = 1; in tsi721_open_outb_mbox()
2018 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_open_outb_mbox()
2019 priv->omsg_ring[mbox].sts_base, in tsi721_open_outb_mbox()
2020 priv->omsg_ring[mbox].sts_phys); in tsi721_open_outb_mbox()
2022 priv->omsg_ring[mbox].sts_base = NULL; in tsi721_open_outb_mbox()
2028 priv->omsg_ring[mbox].omd_base, in tsi721_open_outb_mbox()
2029 priv->omsg_ring[mbox].omd_phys); in tsi721_open_outb_mbox()
2031 priv->omsg_ring[mbox].omd_base = NULL; in tsi721_open_outb_mbox()
2034 for (i = 0; i < priv->omsg_ring[mbox].size; i++) { in tsi721_open_outb_mbox()
2035 if (priv->omsg_ring[mbox].omq_base[i]) { in tsi721_open_outb_mbox()
2038 priv->omsg_ring[mbox].omq_base[i], in tsi721_open_outb_mbox()
2039 priv->omsg_ring[mbox].omq_phys[i]); in tsi721_open_outb_mbox()
2041 priv->omsg_ring[mbox].omq_base[i] = NULL; in tsi721_open_outb_mbox()
2054 static void tsi721_close_outb_mbox(struct rio_mport *mport, int mbox) in tsi721_close_outb_mbox() argument
2059 if (!priv->omsg_init[mbox]) in tsi721_close_outb_mbox()
2061 priv->omsg_init[mbox] = 0; in tsi721_close_outb_mbox()
2065 tsi721_omsg_interrupt_disable(priv, mbox, TSI721_OBDMAC_INT_ALL); in tsi721_close_outb_mbox()
2069 free_irq(priv->msix[TSI721_VECT_OMB0_DONE + mbox].vector, in tsi721_close_outb_mbox()
2071 free_irq(priv->msix[TSI721_VECT_OMB0_INT + mbox].vector, in tsi721_close_outb_mbox()
2078 priv->omsg_ring[mbox].sts_size * sizeof(struct tsi721_dma_sts), in tsi721_close_outb_mbox()
2079 priv->omsg_ring[mbox].sts_base, in tsi721_close_outb_mbox()
2080 priv->omsg_ring[mbox].sts_phys); in tsi721_close_outb_mbox()
2082 priv->omsg_ring[mbox].sts_base = NULL; in tsi721_close_outb_mbox()
2086 (priv->omsg_ring[mbox].size + 1) * in tsi721_close_outb_mbox()
2088 priv->omsg_ring[mbox].omd_base, in tsi721_close_outb_mbox()
2089 priv->omsg_ring[mbox].omd_phys); in tsi721_close_outb_mbox()
2091 priv->omsg_ring[mbox].omd_base = NULL; in tsi721_close_outb_mbox()
2094 for (i = 0; i < priv->omsg_ring[mbox].size; i++) { in tsi721_close_outb_mbox()
2095 if (priv->omsg_ring[mbox].omq_base[i]) { in tsi721_close_outb_mbox()
2098 priv->omsg_ring[mbox].omq_base[i], in tsi721_close_outb_mbox()
2099 priv->omsg_ring[mbox].omq_phys[i]); in tsi721_close_outb_mbox()
2101 priv->omsg_ring[mbox].omq_base[i] = NULL; in tsi721_close_outb_mbox()
2115 u32 mbox = ch - 4; in tsi721_imsg_handler() local
2119 spin_lock(&priv->imsg_ring[mbox].lock); in tsi721_imsg_handler()
2124 tsi_info(&priv->pdev->dev, "IB MBOX%d SRIO timeout", mbox); in tsi721_imsg_handler()
2127 tsi_info(&priv->pdev->dev, "IB MBOX%d PCIe error", mbox); in tsi721_imsg_handler()
2130 tsi_info(&priv->pdev->dev, "IB MBOX%d IB free queue low", mbox); in tsi721_imsg_handler()
2137 mport->inb_msg[mbox].mcback) in tsi721_imsg_handler()
2138 mport->inb_msg[mbox].mcback(mport, in tsi721_imsg_handler()
2139 priv->imsg_ring[mbox].dev_id, mbox, -1); in tsi721_imsg_handler()
2150 spin_unlock(&priv->imsg_ring[mbox].lock); in tsi721_imsg_handler()
2161 int mbox, int entries) in tsi721_open_inb_mbox() argument
2164 int ch = mbox + 4; in tsi721_open_inb_mbox()
2171 (!is_power_of_2(entries)) || mbox >= RIO_MAX_MBOX) { in tsi721_open_inb_mbox()
2176 if ((mbox_sel & (1 << mbox)) == 0) { in tsi721_open_inb_mbox()
2182 priv->imsg_ring[mbox].dev_id = dev_id; in tsi721_open_inb_mbox()
2183 priv->imsg_ring[mbox].size = entries; in tsi721_open_inb_mbox()
2184 priv->imsg_ring[mbox].rx_slot = 0; in tsi721_open_inb_mbox()
2185 priv->imsg_ring[mbox].desc_rdptr = 0; in tsi721_open_inb_mbox()
2186 priv->imsg_ring[mbox].fq_wrptr = 0; in tsi721_open_inb_mbox()
2187 for (i = 0; i < priv->imsg_ring[mbox].size; i++) in tsi721_open_inb_mbox()
2188 priv->imsg_ring[mbox].imq_base[i] = NULL; in tsi721_open_inb_mbox()
2189 spin_lock_init(&priv->imsg_ring[mbox].lock); in tsi721_open_inb_mbox()
2192 priv->imsg_ring[mbox].buf_base = in tsi721_open_inb_mbox()
2195 &priv->imsg_ring[mbox].buf_phys, in tsi721_open_inb_mbox()
2198 if (priv->imsg_ring[mbox].buf_base == NULL) { in tsi721_open_inb_mbox()
2200 "Failed to allocate buffers for IB MBOX%d", mbox); in tsi721_open_inb_mbox()
2206 priv->imsg_ring[mbox].imfq_base = in tsi721_open_inb_mbox()
2209 &priv->imsg_ring[mbox].imfq_phys, in tsi721_open_inb_mbox()
2212 if (priv->imsg_ring[mbox].imfq_base == NULL) { in tsi721_open_inb_mbox()
2214 "Failed to allocate free queue for IB MBOX%d", mbox); in tsi721_open_inb_mbox()
2220 priv->imsg_ring[mbox].imd_base = in tsi721_open_inb_mbox()
2223 &priv->imsg_ring[mbox].imd_phys, GFP_KERNEL); in tsi721_open_inb_mbox()
2225 if (priv->imsg_ring[mbox].imd_base == NULL) { in tsi721_open_inb_mbox()
2228 mbox); in tsi721_open_inb_mbox()
2234 free_ptr = priv->imsg_ring[mbox].imfq_base; in tsi721_open_inb_mbox()
2237 (u64)(priv->imsg_ring[mbox].buf_phys) + in tsi721_open_inb_mbox()
2258 iowrite32(((u64)priv->imsg_ring[mbox].imfq_phys >> 32), in tsi721_open_inb_mbox()
2260 iowrite32(((u64)priv->imsg_ring[mbox].imfq_phys & in tsi721_open_inb_mbox()
2267 iowrite32(((u64)priv->imsg_ring[mbox].imd_phys >> 32), in tsi721_open_inb_mbox()
2269 iowrite32(((u32)priv->imsg_ring[mbox].imd_phys & in tsi721_open_inb_mbox()
2279 int idx = TSI721_VECT_IMB0_RCV + mbox; in tsi721_open_inb_mbox()
2288 mbox); in tsi721_open_inb_mbox()
2292 idx = TSI721_VECT_IMB0_INT + mbox; in tsi721_open_inb_mbox()
2298 "Unable to get MSI-X IRQ for IBOX%d-INT", mbox); in tsi721_open_inb_mbox()
2300 priv->msix[TSI721_VECT_IMB0_RCV + mbox].vector, in tsi721_open_inb_mbox()
2313 priv->imsg_ring[mbox].fq_wrptr = entries - 1; in tsi721_open_inb_mbox()
2316 priv->imsg_init[mbox] = 1; in tsi721_open_inb_mbox()
2322 priv->imsg_ring[mbox].size * sizeof(struct tsi721_imsg_desc), in tsi721_open_inb_mbox()
2323 priv->imsg_ring[mbox].imd_base, in tsi721_open_inb_mbox()
2324 priv->imsg_ring[mbox].imd_phys); in tsi721_open_inb_mbox()
2326 priv->imsg_ring[mbox].imd_base = NULL; in tsi721_open_inb_mbox()
2331 priv->imsg_ring[mbox].size * 8, in tsi721_open_inb_mbox()
2332 priv->imsg_ring[mbox].imfq_base, in tsi721_open_inb_mbox()
2333 priv->imsg_ring[mbox].imfq_phys); in tsi721_open_inb_mbox()
2335 priv->imsg_ring[mbox].imfq_base = NULL; in tsi721_open_inb_mbox()
2339 priv->imsg_ring[mbox].size * TSI721_MSG_BUFFER_SIZE, in tsi721_open_inb_mbox()
2340 priv->imsg_ring[mbox].buf_base, in tsi721_open_inb_mbox()
2341 priv->imsg_ring[mbox].buf_phys); in tsi721_open_inb_mbox()
2343 priv->imsg_ring[mbox].buf_base = NULL; in tsi721_open_inb_mbox()
2354 static void tsi721_close_inb_mbox(struct rio_mport *mport, int mbox) in tsi721_close_inb_mbox() argument
2358 int ch = mbox + 4; in tsi721_close_inb_mbox()
2360 if (!priv->imsg_init[mbox]) /* mbox isn't initialized yet */ in tsi721_close_inb_mbox()
2362 priv->imsg_init[mbox] = 0; in tsi721_close_inb_mbox()
2371 free_irq(priv->msix[TSI721_VECT_IMB0_RCV + mbox].vector, in tsi721_close_inb_mbox()
2373 free_irq(priv->msix[TSI721_VECT_IMB0_INT + mbox].vector, in tsi721_close_inb_mbox()
2379 for (rx_slot = 0; rx_slot < priv->imsg_ring[mbox].size; rx_slot++) in tsi721_close_inb_mbox()
2380 priv->imsg_ring[mbox].imq_base[rx_slot] = NULL; in tsi721_close_inb_mbox()
2384 priv->imsg_ring[mbox].size * TSI721_MSG_BUFFER_SIZE, in tsi721_close_inb_mbox()
2385 priv->imsg_ring[mbox].buf_base, in tsi721_close_inb_mbox()
2386 priv->imsg_ring[mbox].buf_phys); in tsi721_close_inb_mbox()
2388 priv->imsg_ring[mbox].buf_base = NULL; in tsi721_close_inb_mbox()
2392 priv->imsg_ring[mbox].size * 8, in tsi721_close_inb_mbox()
2393 priv->imsg_ring[mbox].imfq_base, in tsi721_close_inb_mbox()
2394 priv->imsg_ring[mbox].imfq_phys); in tsi721_close_inb_mbox()
2396 priv->imsg_ring[mbox].imfq_base = NULL; in tsi721_close_inb_mbox()
2400 priv->imsg_ring[mbox].size * sizeof(struct tsi721_imsg_desc), in tsi721_close_inb_mbox()
2401 priv->imsg_ring[mbox].imd_base, in tsi721_close_inb_mbox()
2402 priv->imsg_ring[mbox].imd_phys); in tsi721_close_inb_mbox()
2404 priv->imsg_ring[mbox].imd_base = NULL; in tsi721_close_inb_mbox()
2413 static int tsi721_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) in tsi721_add_inb_buffer() argument
2419 rx_slot = priv->imsg_ring[mbox].rx_slot; in tsi721_add_inb_buffer()
2420 if (priv->imsg_ring[mbox].imq_base[rx_slot]) { in tsi721_add_inb_buffer()
2428 priv->imsg_ring[mbox].imq_base[rx_slot] = buf; in tsi721_add_inb_buffer()
2430 if (++priv->imsg_ring[mbox].rx_slot == priv->imsg_ring[mbox].size) in tsi721_add_inb_buffer()
2431 priv->imsg_ring[mbox].rx_slot = 0; in tsi721_add_inb_buffer()
2444 static void *tsi721_get_inb_message(struct rio_mport *mport, int mbox) in tsi721_get_inb_message() argument
2453 int ch = mbox + 4; in tsi721_get_inb_message()
2456 if (!priv->imsg_init[mbox]) in tsi721_get_inb_message()
2459 desc = priv->imsg_ring[mbox].imd_base; in tsi721_get_inb_message()
2460 desc += priv->imsg_ring[mbox].desc_rdptr; in tsi721_get_inb_message()
2465 rx_slot = priv->imsg_ring[mbox].rx_slot; in tsi721_get_inb_message()
2466 while (priv->imsg_ring[mbox].imq_base[rx_slot] == NULL) { in tsi721_get_inb_message()
2467 if (++rx_slot == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2474 rx_virt = priv->imsg_ring[mbox].buf_base + in tsi721_get_inb_message()
2475 (rx_phys - (u64)priv->imsg_ring[mbox].buf_phys); in tsi721_get_inb_message()
2477 buf = priv->imsg_ring[mbox].imq_base[rx_slot]; in tsi721_get_inb_message()
2483 priv->imsg_ring[mbox].imq_base[rx_slot] = NULL; in tsi721_get_inb_message()
2486 if (++priv->imsg_ring[mbox].desc_rdptr == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2487 priv->imsg_ring[mbox].desc_rdptr = 0; in tsi721_get_inb_message()
2489 iowrite32(priv->imsg_ring[mbox].desc_rdptr, in tsi721_get_inb_message()
2493 free_ptr = priv->imsg_ring[mbox].imfq_base; in tsi721_get_inb_message()
2494 free_ptr[priv->imsg_ring[mbox].fq_wrptr] = cpu_to_le64(rx_phys); in tsi721_get_inb_message()
2496 if (++priv->imsg_ring[mbox].fq_wrptr == priv->imsg_ring[mbox].size) in tsi721_get_inb_message()
2497 priv->imsg_ring[mbox].fq_wrptr = 0; in tsi721_get_inb_message()
2499 iowrite32(priv->imsg_ring[mbox].fq_wrptr, in tsi721_get_inb_message()