Lines Matching refs:lpbfifo
46 } lpbfifo; variable
70 spin_lock_irqsave(&lpbfifo.lock, flags); in mpc512x_lpbfifo_irq()
72 if (!lpbfifo.regs) in mpc512x_lpbfifo_irq()
75 req = lpbfifo.req; in mpc512x_lpbfifo_irq()
81 status = in_be32(&lpbfifo.regs->status); in mpc512x_lpbfifo_irq()
84 out_be32(&lpbfifo.regs->enable, in mpc512x_lpbfifo_irq()
89 out_be32(&lpbfifo.regs->status, MPC512X_SCLPC_SUCCESS); in mpc512x_lpbfifo_irq()
91 lpbfifo.wait_lpbfifo_irq = false; in mpc512x_lpbfifo_irq()
93 if (lpbfifo.wait_lpbfifo_callback) in mpc512x_lpbfifo_irq()
97 lpbfifo.req = NULL; in mpc512x_lpbfifo_irq()
99 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_irq()
107 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_irq()
121 spin_lock_irqsave(&lpbfifo.lock, flags); in mpc512x_lpbfifo_callback()
123 if (!lpbfifo.regs) { in mpc512x_lpbfifo_callback()
124 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_callback()
128 req = lpbfifo.req; in mpc512x_lpbfifo_callback()
131 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_callback()
140 dma_unmap_single(lpbfifo.chan->device->dev, in mpc512x_lpbfifo_callback()
141 lpbfifo.ram_bus_addr, req->size, dir); in mpc512x_lpbfifo_callback()
143 lpbfifo.wait_lpbfifo_callback = false; in mpc512x_lpbfifo_callback()
145 if (!lpbfifo.wait_lpbfifo_irq) { in mpc512x_lpbfifo_callback()
147 lpbfifo.req = NULL; in mpc512x_lpbfifo_callback()
149 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_callback()
154 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_callback()
189 if (lpbfifo.req->size == 0 || !IS_ALIGNED(lpbfifo.req->size, 4)) in mpc512x_lpbfifo_kick()
192 if (lpbfifo.req->portsize != LPB_DEV_PORTSIZE_UNDEFINED) { in mpc512x_lpbfifo_kick()
193 bpt = lpbfifo.req->portsize; in mpc512x_lpbfifo_kick()
198 if (IS_ALIGNED(lpbfifo.req->dev_phys_addr, min(bpt, 0x8u)) && in mpc512x_lpbfifo_kick()
199 IS_ALIGNED(lpbfifo.req->size, bpt)) { in mpc512x_lpbfifo_kick()
211 for (i = 0; i < lpbfifo.cs_n; i++) { in mpc512x_lpbfifo_kick()
212 phys_addr_t cs_start = lpbfifo.cs_ranges[i].addr; in mpc512x_lpbfifo_kick()
213 phys_addr_t cs_end = cs_start + lpbfifo.cs_ranges[i].size; in mpc512x_lpbfifo_kick()
214 phys_addr_t access_start = lpbfifo.req->dev_phys_addr; in mpc512x_lpbfifo_kick()
215 phys_addr_t access_end = access_start + lpbfifo.req->size; in mpc512x_lpbfifo_kick()
218 cs = lpbfifo.cs_ranges[i].csnum; in mpc512x_lpbfifo_kick()
222 if (i == lpbfifo.cs_n) in mpc512x_lpbfifo_kick()
226 dma_dev = lpbfifo.chan->device; in mpc512x_lpbfifo_kick()
228 if (lpbfifo.req->dir == MPC512X_LPBFIFO_REQ_DIR_WRITE) { in mpc512x_lpbfifo_kick()
231 dma_conf.dst_addr = lpbfifo.regs_phys + in mpc512x_lpbfifo_kick()
236 dma_conf.src_addr = lpbfifo.regs_phys + in mpc512x_lpbfifo_kick()
243 if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) { in mpc512x_lpbfifo_kick()
251 lpbfifo.req->ram_virt_addr, lpbfifo.req->size, dir); in mpc512x_lpbfifo_kick()
255 lpbfifo.ram_bus_addr = sg_dma_address(&sg); /* For freeing later */ in mpc512x_lpbfifo_kick()
257 sg_dma_len(&sg) = lpbfifo.req->size; in mpc512x_lpbfifo_kick()
259 dma_tx = dmaengine_prep_slave_sg(lpbfifo.chan, &sg, in mpc512x_lpbfifo_kick()
269 out_be32(&lpbfifo.regs->enable, in mpc512x_lpbfifo_kick()
271 out_be32(&lpbfifo.regs->enable, 0x0); in mpc512x_lpbfifo_kick()
280 out_be32(&lpbfifo.regs->fifo_ctrl, MPC512X_SCLPC_FIFO_CTRL(0x7)); in mpc512x_lpbfifo_kick()
281 out_be32(&lpbfifo.regs->fifo_alarm, MPC512X_SCLPC_FIFO_ALARM(0x200)); in mpc512x_lpbfifo_kick()
287 out_be32(&lpbfifo.regs->start_addr, lpbfifo.req->dev_phys_addr); in mpc512x_lpbfifo_kick()
294 if (lpbfifo.req->dir == MPC512X_LPBFIFO_REQ_DIR_READ) in mpc512x_lpbfifo_kick()
299 out_be32(&lpbfifo.regs->ctrl, bits); in mpc512x_lpbfifo_kick()
303 if (lpbfifo.req->dir == MPC512X_LPBFIFO_REQ_DIR_WRITE) in mpc512x_lpbfifo_kick()
306 lpbfifo.wait_lpbfifo_irq = false; in mpc512x_lpbfifo_kick()
308 out_be32(&lpbfifo.regs->enable, bits); in mpc512x_lpbfifo_kick()
311 bits = lpbfifo.req->size | MPC512X_SCLPC_START; in mpc512x_lpbfifo_kick()
312 out_be32(&lpbfifo.regs->pkt_size, bits); in mpc512x_lpbfifo_kick()
324 out_be32(&lpbfifo.regs->enable, in mpc512x_lpbfifo_kick()
328 lpbfifo.req->size, dir); in mpc512x_lpbfifo_kick()
336 if (!lpbfifo.regs) in mpc512x_lpbfifo_submit_locked()
340 if (lpbfifo.req) in mpc512x_lpbfifo_submit_locked()
343 lpbfifo.wait_lpbfifo_irq = true; in mpc512x_lpbfifo_submit_locked()
344 lpbfifo.wait_lpbfifo_callback = true; in mpc512x_lpbfifo_submit_locked()
345 lpbfifo.req = req; in mpc512x_lpbfifo_submit_locked()
349 lpbfifo.req = NULL; /* Set the FIFO as idle */ in mpc512x_lpbfifo_submit_locked()
359 spin_lock_irqsave(&lpbfifo.lock, flags); in mpc512x_lpbfifo_submit()
361 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_submit()
406 lpbfifo.cs_n = proplen / 4; in get_cs_ranges()
407 lpbfifo.cs_ranges = devm_kcalloc(dev, lpbfifo.cs_n, in get_cs_ranges()
409 if (!lpbfifo.cs_ranges) in get_cs_ranges()
413 (u32 *)lpbfifo.cs_ranges, proplen) != 0) { in get_cs_ranges()
417 for (i = 0; i < lpbfifo.cs_n; i++) { in get_cs_ranges()
418 if (lpbfifo.cs_ranges[i].base != 0) in get_cs_ranges()
434 memset(&lpbfifo, 0, sizeof(struct lpbfifo_data)); in mpc512x_lpbfifo_probe()
435 spin_lock_init(&lpbfifo.lock); in mpc512x_lpbfifo_probe()
437 lpbfifo.chan = dma_request_chan(&pdev->dev, "rx-tx"); in mpc512x_lpbfifo_probe()
438 if (IS_ERR(lpbfifo.chan)) in mpc512x_lpbfifo_probe()
439 return PTR_ERR(lpbfifo.chan); in mpc512x_lpbfifo_probe()
447 lpbfifo.regs_phys = r.start; in mpc512x_lpbfifo_probe()
448 lpbfifo.regs_size = resource_size(&r); in mpc512x_lpbfifo_probe()
450 if (!devm_request_mem_region(&pdev->dev, lpbfifo.regs_phys, in mpc512x_lpbfifo_probe()
451 lpbfifo.regs_size, DRV_NAME)) { in mpc512x_lpbfifo_probe()
457 lpbfifo.regs = devm_ioremap(&pdev->dev, in mpc512x_lpbfifo_probe()
458 lpbfifo.regs_phys, lpbfifo.regs_size); in mpc512x_lpbfifo_probe()
459 if (!lpbfifo.regs) { in mpc512x_lpbfifo_probe()
465 out_be32(&lpbfifo.regs->enable, in mpc512x_lpbfifo_probe()
474 lpbfifo.irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in mpc512x_lpbfifo_probe()
475 if (!lpbfifo.irq) { in mpc512x_lpbfifo_probe()
481 if (request_irq(lpbfifo.irq, mpc512x_lpbfifo_irq, 0, in mpc512x_lpbfifo_probe()
492 irq_dispose_mapping(lpbfifo.irq); in mpc512x_lpbfifo_probe()
494 dma_release_channel(lpbfifo.chan); in mpc512x_lpbfifo_probe()
501 struct dma_device *dma_dev = lpbfifo.chan->device; in mpc512x_lpbfifo_remove()
504 spin_lock_irqsave(&lpbfifo.lock, flags); in mpc512x_lpbfifo_remove()
505 regs = lpbfifo.regs; in mpc512x_lpbfifo_remove()
506 lpbfifo.regs = NULL; in mpc512x_lpbfifo_remove()
507 spin_unlock_irqrestore(&lpbfifo.lock, flags); in mpc512x_lpbfifo_remove()
509 dma_dev->device_terminate_all(lpbfifo.chan); in mpc512x_lpbfifo_remove()
512 free_irq(lpbfifo.irq, &pdev->dev); in mpc512x_lpbfifo_remove()
513 irq_dispose_mapping(lpbfifo.irq); in mpc512x_lpbfifo_remove()
514 dma_release_channel(lpbfifo.chan); in mpc512x_lpbfifo_remove()