Signed-off-by: Roman Fietze <roman.fie...@telemotive.de> --- arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 33 +++++++++++++++---------- 1 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c index 48f2b4f..21b2a40 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c @@ -80,11 +80,11 @@ static inline int mpc52xx_lpbfifo_is_poll_dma(int flags) */ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) { - size_t transfer_size = req->size - req->pos; + size_t tc = req->size - req->pos; struct bcom_bd *bd; void __iomem *reg; u32 *data; - u32 bit_fields; + u32 control; int rflags = req->flags; /* Set and clear the reset bits; is good practice in User Manual */ @@ -93,10 +93,10 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) /* Set width, chip select and READ mode */ out_be32(&lpbfifo.regs->start_address, req->offset + req->pos); - /* Set CS and BPT */ - bit_fields = MPC52xx_SCLPC_CONTROL_CS(req->cs) | 0x8; + /* Setup CS */ + control = MPC52xx_SCLPC_CONTROL_CS(req->cs); if (!(mpc52xx_lpbfifo_is_write(rflags))) - bit_fields |= MPC52xx_SCLPC_CONTROL_RWB_RECEIVE; /* read mode */ + control |= MPC52xx_SCLPC_CONTROL_RWB_RECEIVE; /* read mode */ if (!mpc52xx_lpbfifo_is_dma(rflags)) { /* While the FIFO can be setup for transfer sizes as @@ -112,10 +112,10 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) * The last block of data will be received with the * flush bit set. This avoids stale read data. */ - if (transfer_size > 512) - transfer_size = 512; + if (tc > 512) + tc = 512; else if (!(mpc52xx_lpbfifo_is_write(rflags))) - bit_fields |= MPC52xx_SCLPC_CONTROL_FLUSH; + control |= MPC52xx_SCLPC_CONTROL_FLUSH; /* Load the FIFO with data */ if (mpc52xx_lpbfifo_is_write(rflags)) { @@ -123,7 +123,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) reg = &lpbfifo.regs->fifo_data; data = req->data + req->pos; - for (i = 0; i < transfer_size; i += 4) + for (i = 0; i < tc; i += 4) out_be32(reg, *data++); } @@ -136,7 +136,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) /* In DMA mode we can always set the flush bit to avoid * stale read data. */ if (!(mpc52xx_lpbfifo_is_write(rflags))) - bit_fields |= MPC52xx_SCLPC_CONTROL_FLUSH; + control |= MPC52xx_SCLPC_CONTROL_FLUSH; /* Choose the correct direction * @@ -173,15 +173,17 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) out_be32(&lpbfifo.regs->enable, MPC52xx_SCLPC_ENABLE_AIE | MPC52xx_SCLPC_ENABLE_NIE | MPC52xx_SCLPC_ENABLE_ME); bd = bcom_prepare_next_buffer(lpbfifo.bcom_cur_task); - bd->status = transfer_size; + bd->status = tc; bd->data[0] = req->data_dma + req->pos; bcom_submit_next_buffer(lpbfifo.bcom_cur_task, NULL); } - out_be32(&lpbfifo.regs->control, bit_fields); + /* Setup BPT. tc is already screened and a multiple of 4 */ + control |= tc & 7 ? 4 : 8; + out_be32(&lpbfifo.regs->control, control); /* Set packet size and kick it off */ - out_be32(&lpbfifo.regs->packet_size.packet_size, MPC52xx_SCLPC_PACKET_SIZE_RESTART | transfer_size); + out_be32(&lpbfifo.regs->packet_size.packet_size, MPC52xx_SCLPC_PACKET_SIZE_RESTART | tc); if (mpc52xx_lpbfifo_is_dma(rflags)) bcom_enable(lpbfifo.bcom_cur_task); } @@ -395,6 +397,11 @@ int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req) if (!lpbfifo.regs) return -ENODEV; + /* The gen bd BestComm task currently only allows an increment + * of 4 */ + if (!req->size || req->size & 0x03) + return -EINVAL; + spin_lock_irqsave(&lpbfifo.lock, flags); /* If the req pointer is already set, then a transfer is in progress */ -- 1.6.5.5 -- Roman Fietze Telemotive AG Büro Mühlhausen Breitwiesen 73347 Mühlhausen Tel.: +49(0)7335/18493-45 http://www.telemotive.de _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev