Lines Matching refs:spi_bus

215 static int pci1xxxx_check_spi_can_dma(struct pci1xxxx_spi *spi_bus, int irq)  in pci1xxxx_check_spi_can_dma()  argument
217 struct pci_dev *pdev = spi_bus->dev; in pci1xxxx_check_spi_can_dma()
226 ret = pci1xxxx_acquire_sys_lock(spi_bus); in pci1xxxx_check_spi_can_dma()
232 regval = readl(spi_bus->reg_base + DEV_REV_REG); in pci1xxxx_check_spi_can_dma()
233 spi_bus->dev_rev = regval & DEV_REV_MASK; in pci1xxxx_check_spi_can_dma()
234 if (spi_bus->dev_rev >= 0xC0) { in pci1xxxx_check_spi_can_dma()
235 regval = readl(spi_bus->reg_base + in pci1xxxx_check_spi_can_dma()
240 pci1xxxx_release_sys_lock(spi_bus); in pci1xxxx_check_spi_can_dma()
246 if (spi_bus->dev_rev < 0xC0 || pf_num) in pci1xxxx_check_spi_can_dma()
259 spi_bus->dma_offset_bar = pcim_iomap(pdev, 2, pci_resource_len(pdev, 2)); in pci1xxxx_check_spi_can_dma()
260 if (!spi_bus->dma_offset_bar) { in pci1xxxx_check_spi_can_dma()
267 pcim_iounmap(pdev, spi_bus->dma_offset_bar); in pci1xxxx_check_spi_can_dma()
268 spi_bus->dma_offset_bar = NULL; in pci1xxxx_check_spi_can_dma()
275 static int pci1xxxx_spi_dma_init(struct pci1xxxx_spi *spi_bus, int irq) in pci1xxxx_spi_dma_init() argument
280 ret = pci1xxxx_check_spi_can_dma(spi_bus, irq); in pci1xxxx_spi_dma_init()
284 spin_lock_init(&spi_bus->dma_reg_lock); in pci1xxxx_spi_dma_init()
286 writel(SPI_DMA_ENGINE_EN, spi_bus->dma_offset_bar + SPI_DMA_GLOBAL_WR_ENGINE_EN); in pci1xxxx_spi_dma_init()
287 writel(SPI_DMA_ENGINE_EN, spi_bus->dma_offset_bar + SPI_DMA_GLOBAL_RD_ENGINE_EN); in pci1xxxx_spi_dma_init()
288 writel(msi.address_hi, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_WDONE_HIGH); in pci1xxxx_spi_dma_init()
289 writel(msi.address_hi, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_WABORT_HIGH); in pci1xxxx_spi_dma_init()
290 writel(msi.address_hi, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_RDONE_HIGH); in pci1xxxx_spi_dma_init()
291 writel(msi.address_hi, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_RABORT_HIGH); in pci1xxxx_spi_dma_init()
292 writel(msi.address_lo, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_WDONE_LOW); in pci1xxxx_spi_dma_init()
293 writel(msi.address_lo, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_WABORT_LOW); in pci1xxxx_spi_dma_init()
294 writel(msi.address_lo, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_RDONE_LOW); in pci1xxxx_spi_dma_init()
295 writel(msi.address_lo, spi_bus->dma_offset_bar + SPI_DMA_INTR_IMWR_RABORT_LOW); in pci1xxxx_spi_dma_init()
296 writel(msi.data, spi_bus->dma_offset_bar + SPI_DMA_INTR_WR_IMWR_DATA); in pci1xxxx_spi_dma_init()
297 writel(msi.data, spi_bus->dma_offset_bar + SPI_DMA_INTR_RD_IMWR_DATA); in pci1xxxx_spi_dma_init()
298 dma_set_max_seg_size(&spi_bus->dev->dev, PCI1XXXX_SPI_BUFFER_SIZE); in pci1xxxx_spi_dma_init()
299 spi_bus->can_dma = true; in pci1xxxx_spi_dma_init()
703 struct pci1xxxx_spi *spi_bus; in pci1xxxx_spi_probe() local
715 spi_bus = devm_kzalloc(&pdev->dev, in pci1xxxx_spi_probe()
716 struct_size(spi_bus, spi_int, hw_inst_cnt), in pci1xxxx_spi_probe()
718 if (!spi_bus) in pci1xxxx_spi_probe()
721 spi_bus->dev = pdev; in pci1xxxx_spi_probe()
722 spi_bus->total_hw_instances = hw_inst_cnt; in pci1xxxx_spi_probe()
726 spi_bus->spi_int[iter] = devm_kzalloc(&pdev->dev, in pci1xxxx_spi_probe()
729 if (!spi_bus->spi_int[iter]) in pci1xxxx_spi_probe()
731 spi_sub_ptr = spi_bus->spi_int[iter]; in pci1xxxx_spi_probe()
736 spi_sub_ptr->parent = spi_bus; in pci1xxxx_spi_probe()
748 spi_bus->reg_base = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0)); in pci1xxxx_spi_probe()
749 if (!spi_bus->reg_base) { in pci1xxxx_spi_probe()
763 regval = readl(spi_bus->reg_base + in pci1xxxx_spi_probe()
766 writel(regval, spi_bus->reg_base + in pci1xxxx_spi_probe()
780 ret = pci1xxxx_spi_dma_init(spi_bus, spi_sub_ptr->irq); in pci1xxxx_spi_probe()
785 regval = readl(spi_bus->reg_base + SPI_PCI_CTRL_REG_OFFSET(0)); in pci1xxxx_spi_probe()
791 writel(regval, spi_bus->reg_base + SPI_PCI_CTRL_REG_OFFSET(0)); in pci1xxxx_spi_probe()
799 regval = readl(spi_bus->reg_base + in pci1xxxx_spi_probe()
802 writel(regval, spi_bus->reg_base + in pci1xxxx_spi_probe()
833 pci_set_drvdata(pdev, spi_bus); in pci1xxxx_spi_probe()