From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx> Remove original filter from usbhsf_dma_init(), and use SH-DMA suitable filter. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx> --- drivers/usb/renesas_usbhs/fifo.c | 76 +++++++++++++++++++------------------- drivers/usb/renesas_usbhs/fifo.h | 3 -- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index d49f9c3..7f4aec4 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -981,23 +981,6 @@ struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler = { /* * DMA setting */ -static bool usbhsf_dma_filter(struct dma_chan *chan, void *param) -{ - struct sh_dmae_slave *slave = param; - - /* - * FIXME - * - * usbhs doesn't recognize id = 0 as valid DMA - */ - if (0 == slave->shdma_slave.slave_id) - return false; - - chan->private = slave; - - return true; -} - static void usbhsf_dma_quit(struct usbhs_priv *priv, struct usbhs_fifo *fifo) { if (fifo->tx_chan) @@ -1009,27 +992,46 @@ static void usbhsf_dma_quit(struct usbhs_priv *priv, struct usbhs_fifo *fifo) fifo->rx_chan = NULL; } -static void usbhsf_dma_init(struct usbhs_priv *priv, - struct usbhs_fifo *fifo) +static struct dma_chan* +__usbhsf_dma_init(struct usbhs_priv *priv, int id, char *name, + enum dma_transfer_direction direction) { struct device *dev = usbhs_priv_to_dev(priv); + struct dma_slave_config cfg; + struct dma_chan *chan; dma_cap_mask_t mask; + int ret; - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - fifo->tx_chan = dma_request_channel(mask, usbhsf_dma_filter, - &fifo->tx_slave); + if (!id) + return NULL; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - fifo->rx_chan = dma_request_channel(mask, usbhsf_dma_filter, - &fifo->rx_slave); - - if (fifo->tx_chan || fifo->rx_chan) - dev_dbg(dev, "enable DMAEngine (%s%s%s)\n", - fifo->name, - fifo->tx_chan ? "[TX]" : " ", - fifo->rx_chan ? "[RX]" : " "); + + chan = dma_request_slave_channel_compat(mask, + shdma_chan_filter, (void *)id, dev, name); + if (!chan) + return NULL; + + cfg.slave_id = id; + cfg.dst_addr = 0; /* use default addr */ + cfg.src_addr = 0; /* use default addr */ + cfg.direction = direction; + + ret = dmaengine_slave_config(chan, &cfg); + if (ret < 0) { + dma_release_channel(chan); + return NULL; + } + + return chan; +} + +static void usbhsf_dma_init(struct usbhs_priv *priv, struct usbhs_fifo *fifo, + int tx_id, int rx_id) +{ + fifo->tx_chan = __usbhsf_dma_init(priv, tx_id, "tx", DMA_MEM_TO_DEV); + fifo->rx_chan = __usbhsf_dma_init(priv, rx_id, "rx", DMA_DEV_TO_MEM); } /* @@ -1155,9 +1157,9 @@ int usbhs_fifo_probe(struct usbhs_priv *priv) fifo->port = D0FIFO; fifo->sel = D0FIFOSEL; fifo->ctr = D0FIFOCTR; - fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_tx_id); - fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_rx_id); - usbhsf_dma_init(priv, fifo); + usbhsf_dma_init(priv, fifo, + usbhs_get_dparam(priv, d0_tx_id), + usbhs_get_dparam(priv, d0_rx_id)); /* D1FIFO */ fifo = usbhsf_get_d1fifo(priv); @@ -1165,9 +1167,9 @@ int usbhs_fifo_probe(struct usbhs_priv *priv) fifo->port = D1FIFO; fifo->sel = D1FIFOSEL; fifo->ctr = D1FIFOCTR; - fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_tx_id); - fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_rx_id); - usbhsf_dma_init(priv, fifo); + usbhsf_dma_init(priv, fifo, + usbhs_get_dparam(priv, d1_tx_id), + usbhs_get_dparam(priv, d1_rx_id)); return 0; } diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h index a168a17..7c5706a 100644 --- a/drivers/usb/renesas_usbhs/fifo.h +++ b/drivers/usb/renesas_usbhs/fifo.h @@ -33,9 +33,6 @@ struct usbhs_fifo { struct dma_chan *tx_chan; struct dma_chan *rx_chan; - - struct sh_dmae_slave tx_slave; - struct sh_dmae_slave rx_slave; }; struct usbhs_fifo_info { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html