Commit 9d9fd887 authored by Anatolij Gustschin's avatar Anatolij Gustschin

powerpc/mpc52xx_lpbfifo: optionally defer fifo transfer start

Currently fifo transfer is started when submitting a transfer
request. Add posibility to defer the fifo transfer and start it
later by calling additional function. This change is backward
compatible, the behaviour of mpc52xx_lpbfifo_submit() is the same
for previous driver users, so there is no need to adapt them.
Signed-off-by: default avatarAnatolij Gustschin <agust@denx.de>
parent 00e4b197
...@@ -307,6 +307,7 @@ struct mpc52xx_lpbfifo_request { ...@@ -307,6 +307,7 @@ struct mpc52xx_lpbfifo_request {
size_t size; size_t size;
size_t pos; /* current position of transfer */ size_t pos; /* current position of transfer */
int flags; int flags;
int defer_xfer_start;
/* What to do when finished */ /* What to do when finished */
void (*callback)(struct mpc52xx_lpbfifo_request *); void (*callback)(struct mpc52xx_lpbfifo_request *);
...@@ -323,6 +324,7 @@ struct mpc52xx_lpbfifo_request { ...@@ -323,6 +324,7 @@ struct mpc52xx_lpbfifo_request {
extern int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req); extern int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req);
extern void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req); extern void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req);
extern void mpc52xx_lpbfifo_poll(void); extern void mpc52xx_lpbfifo_poll(void);
extern int mpc52xx_lpbfifo_start_xfer(struct mpc52xx_lpbfifo_request *req);
/* mpc52xx_pic.c */ /* mpc52xx_pic.c */
extern void mpc52xx_init_irq(void); extern void mpc52xx_init_irq(void);
......
...@@ -170,6 +170,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) ...@@ -170,6 +170,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req)
out_be32(lpbfifo.regs + LPBFIFO_REG_CONTROL, bit_fields); out_be32(lpbfifo.regs + LPBFIFO_REG_CONTROL, bit_fields);
/* Kick it off */ /* Kick it off */
if (!lpbfifo.req->defer_xfer_start)
out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01); out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01);
if (dma) if (dma)
bcom_enable(lpbfifo.bcom_cur_task); bcom_enable(lpbfifo.bcom_cur_task);
...@@ -421,6 +422,38 @@ int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req) ...@@ -421,6 +422,38 @@ int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req)
} }
EXPORT_SYMBOL(mpc52xx_lpbfifo_submit); EXPORT_SYMBOL(mpc52xx_lpbfifo_submit);
int mpc52xx_lpbfifo_start_xfer(struct mpc52xx_lpbfifo_request *req)
{
unsigned long flags;
if (!lpbfifo.regs)
return -ENODEV;
spin_lock_irqsave(&lpbfifo.lock, flags);
/*
* If the req pointer is already set and a transfer was
* started on submit, then this transfer is in progress
*/
if (lpbfifo.req && !lpbfifo.req->defer_xfer_start) {
spin_unlock_irqrestore(&lpbfifo.lock, flags);
return -EBUSY;
}
/*
* If the req was previously submitted but not
* started, start it now
*/
if (lpbfifo.req && lpbfifo.req == req &&
lpbfifo.req->defer_xfer_start) {
out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01);
}
spin_unlock_irqrestore(&lpbfifo.lock, flags);
return 0;
}
EXPORT_SYMBOL(mpc52xx_lpbfifo_start_xfer);
void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req) void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req)
{ {
unsigned long flags; unsigned long flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment