// SPDX-License-Identifier: GPL-2.0-only /* * The driver for Freescale MPC512x LocalPlus Bus FIFO * (called SCLPC in the Reference Manual). * * Copyright (C) 2013-2015 Alexander Popov <alex.popov@linux.com>.
*/
/* * A data transfer from RAM to some device on LPB is finished * when both mpc512x_lpbfifo_irq() and mpc512x_lpbfifo_callback() * have been called. We execute the callback registered in * mpc512x_lpbfifo_request just after that. * But for a data transfer from some device on LPB to RAM we don't enable * LPBFIFO interrupt because clearing MPC512X_SCLPC_SUCCESS interrupt flag * automatically disables LPBFIFO reading request to the DMA controller * and the data transfer hangs. So the callback registered in * mpc512x_lpbfifo_request is executed at the end of mpc512x_lpbfifo_callback().
*/
status = in_be32(&lpbfifo.regs->status); if (status != MPC512X_SCLPC_SUCCESS) {
dev_err(dev, "DMA transfer from RAM to peripheral failed\n");
out_be32(&lpbfifo.regs->enable,
MPC512X_SCLPC_RESET | MPC512X_SCLPC_FIFO_RESET); goto end;
} /* Clear the interrupt flag */
out_be32(&lpbfifo.regs->status, MPC512X_SCLPC_SUCCESS);
lpbfifo.wait_lpbfifo_irq = false;
if (lpbfifo.wait_lpbfifo_callback) goto end;
/* Transfer is finished, set the FIFO as idle */
lpbfifo.req = NULL;
/* Release the mapping */ if (req->dir == MPC512X_LPBFIFO_REQ_DIR_WRITE)
dir = DMA_TO_DEVICE; else
dir = DMA_FROM_DEVICE;
dma_unmap_single(lpbfifo.chan->device->dev,
lpbfifo.ram_bus_addr, req->size, dir);
lpbfifo.wait_lpbfifo_callback = false;
if (!lpbfifo.wait_lpbfifo_irq) { /* Transfer is finished, set the FIFO as idle */
lpbfifo.req = NULL;
spin_unlock_irqrestore(&lpbfifo.lock, flags);
if (req->callback)
req->callback(req);
} else {
spin_unlock_irqrestore(&lpbfifo.lock, flags);
}
}
/* * 1. Fit the requirements: * - the packet size must be a multiple of 4 since FIFO Data Word * Register allows only full-word access according the Reference * Manual; * - the physical address of the device on LPB and the packet size * must be aligned on BPT (bytes per transaction) or 8-bytes * boundary according the Reference Manual; * - but we choose DMA maxburst equal (or very close to) BPT to prevent * DMA controller from overtaking FIFO and causing FIFO underflow * error. So we force the packet size to be aligned on BPT boundary * not to confuse DMA driver which requires the packet size to be * aligned on maxburst boundary; * - BPT should be set to the LPB device port size for operation with * disabled auto-incrementing according Reference Manual.
*/ if (lpbfifo.req->size == 0 || !IS_ALIGNED(lpbfifo.req->size, 4)) return -EINVAL;
/* * Configure the watermarks for write operation (RAM->DMA->FIFO->dev): * - high watermark 7 words according the Reference Manual, * - low watermark 512 bytes (half of the FIFO). * These watermarks don't work for read operation since the * MPC512X_SCLPC_FLUSH bit is set (according the Reference Manual).
*/
out_be32(&lpbfifo.regs->fifo_ctrl, MPC512X_SCLPC_FIFO_CTRL(0x7));
out_be32(&lpbfifo.regs->fifo_alarm, MPC512X_SCLPC_FIFO_ALARM(0x200));
/* * Start address is a physical address of the region which belongs * to the device on the LocalPlus Bus
*/
out_be32(&lpbfifo.regs->start_addr, lpbfifo.req->dev_phys_addr);
/* * Configure chip select, transfer direction, address increment option * and bytes per transaction option
*/
bits = MPC512X_SCLPC_CS(cs); if (lpbfifo.req->dir == MPC512X_LPBFIFO_REQ_DIR_READ)
bits |= MPC512X_SCLPC_READ | MPC512X_SCLPC_FLUSH; if (no_incr)
bits |= MPC512X_SCLPC_DAI;
bits |= MPC512X_SCLPC_BPT(bpt);
out_be32(&lpbfifo.regs->ctrl, bits);
/* * LPBFIFO driver uses "ranges" property of "localbus" device tree node * for being able to determine the chip select number of a client device * ordering a DMA transfer.
*/ staticint get_cs_ranges(struct device *dev)
{ int ret = -ENODEV; struct device_node *lb_node;
size_t i = 0; struct of_range_parser parser; struct of_range range;
lb_node = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-localbus"); if (!lb_node) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.