Lines Matching +full:controller +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0+
8 * Copyright (C) 2011 ST-Ericsson SA
18 #include <linux/dma-mapping.h>
22 #include <linux/platform_data/usb-musb-ux500.h>
32 struct ux500_dma_controller *controller; member
43 struct dma_controller controller; member
54 struct ux500_dma_channel *ux500_channel = channel->private_data; in ux500_dma_callback()
55 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; in ux500_dma_callback()
56 struct musb *musb = hw_ep->musb; in ux500_dma_callback()
59 dev_dbg(musb->controller, "DMA rx transfer done on hw_ep=%d\n", in ux500_dma_callback()
60 hw_ep->epnum); in ux500_dma_callback()
62 spin_lock_irqsave(&musb->lock, flags); in ux500_dma_callback()
63 ux500_channel->channel.actual_len = ux500_channel->cur_len; in ux500_dma_callback()
64 ux500_channel->channel.status = MUSB_DMA_STATUS_FREE; in ux500_dma_callback()
65 musb_dma_completion(musb, hw_ep->epnum, ux500_channel->is_tx); in ux500_dma_callback()
66 spin_unlock_irqrestore(&musb->lock, flags); in ux500_dma_callback()
74 struct ux500_dma_channel *ux500_channel = channel->private_data; in ux500_configure_channel()
75 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; in ux500_configure_channel()
76 struct dma_chan *dma_chan = ux500_channel->dma_chan; in ux500_configure_channel()
82 struct musb *musb = ux500_channel->controller->private_data; in ux500_configure_channel()
83 dma_addr_t usb_fifo_addr = (musb->io.fifo_offset(hw_ep->epnum) + in ux500_configure_channel()
84 ux500_channel->controller->phy_base); in ux500_configure_channel()
86 dev_dbg(musb->controller, in ux500_configure_channel()
89 len, ux500_channel->is_tx); in ux500_configure_channel()
91 ux500_channel->cur_len = len; in ux500_configure_channel()
99 direction = ux500_channel->is_tx ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; in ux500_configure_channel()
119 dma_desc->callback = ux500_dma_callback; in ux500_configure_channel()
120 dma_desc->callback_param = channel; in ux500_configure_channel()
121 ux500_channel->cookie = dma_desc->tx_submit(dma_desc); in ux500_configure_channel()
131 struct ux500_dma_controller *controller = container_of(c, in ux500_dma_channel_allocate() local
132 struct ux500_dma_controller, controller); in ux500_dma_channel_allocate()
134 struct musb *musb = controller->private_data; in ux500_dma_channel_allocate()
135 u8 ch_num = hw_ep->epnum - 1; in ux500_dma_channel_allocate()
137 /* 8 DMA channels (0 - 7). Each DMA channel can only be allocated in ux500_dma_channel_allocate()
142 ch_num -= 8; in ux500_dma_channel_allocate()
147 ux500_channel = is_tx ? &(controller->tx_channel[ch_num]) : in ux500_dma_channel_allocate()
148 &(controller->rx_channel[ch_num]) ; in ux500_dma_channel_allocate()
151 if (ux500_channel->is_allocated) in ux500_dma_channel_allocate()
154 ux500_channel->hw_ep = hw_ep; in ux500_dma_channel_allocate()
155 ux500_channel->is_allocated = 1; in ux500_dma_channel_allocate()
157 dev_dbg(musb->controller, "hw_ep=%d, is_tx=0x%x, channel=%d\n", in ux500_dma_channel_allocate()
158 hw_ep->epnum, is_tx, ch_num); in ux500_dma_channel_allocate()
160 return &(ux500_channel->channel); in ux500_dma_channel_allocate()
165 struct ux500_dma_channel *ux500_channel = channel->private_data; in ux500_dma_channel_release()
166 struct musb *musb = ux500_channel->controller->private_data; in ux500_dma_channel_release()
168 dev_dbg(musb->controller, "channel=%d\n", ux500_channel->ch_num); in ux500_dma_channel_release()
170 if (ux500_channel->is_allocated) { in ux500_dma_channel_release()
171 ux500_channel->is_allocated = 0; in ux500_dma_channel_release()
172 channel->status = MUSB_DMA_STATUS_FREE; in ux500_dma_channel_release()
173 channel->actual_len = 0; in ux500_dma_channel_release()
195 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || in ux500_dma_channel_program()
196 channel->status == MUSB_DMA_STATUS_BUSY); in ux500_dma_channel_program()
198 channel->status = MUSB_DMA_STATUS_BUSY; in ux500_dma_channel_program()
199 channel->actual_len = 0; in ux500_dma_channel_program()
202 channel->status = MUSB_DMA_STATUS_FREE; in ux500_dma_channel_program()
209 struct ux500_dma_channel *ux500_channel = channel->private_data; in ux500_dma_channel_abort()
210 struct ux500_dma_controller *controller = ux500_channel->controller; in ux500_dma_channel_abort() local
211 struct musb *musb = controller->private_data; in ux500_dma_channel_abort()
212 void __iomem *epio = musb->endpoints[ux500_channel->hw_ep->epnum].regs; in ux500_dma_channel_abort()
215 dev_dbg(musb->controller, "channel=%d, is_tx=%d\n", in ux500_dma_channel_abort()
216 ux500_channel->ch_num, ux500_channel->is_tx); in ux500_dma_channel_abort()
218 if (channel->status == MUSB_DMA_STATUS_BUSY) { in ux500_dma_channel_abort()
219 if (ux500_channel->is_tx) { in ux500_dma_channel_abort()
233 dmaengine_terminate_all(ux500_channel->dma_chan); in ux500_dma_channel_abort()
234 channel->status = MUSB_DMA_STATUS_FREE; in ux500_dma_channel_abort()
239 static void ux500_dma_controller_stop(struct ux500_dma_controller *controller) in ux500_dma_controller_stop() argument
246 channel = &controller->rx_channel[ch_num].channel; in ux500_dma_controller_stop()
247 ux500_channel = channel->private_data; in ux500_dma_controller_stop()
251 if (ux500_channel->dma_chan) in ux500_dma_controller_stop()
252 dma_release_channel(ux500_channel->dma_chan); in ux500_dma_controller_stop()
256 channel = &controller->tx_channel[ch_num].channel; in ux500_dma_controller_stop()
257 ux500_channel = channel->private_data; in ux500_dma_controller_stop()
261 if (ux500_channel->dma_chan) in ux500_dma_controller_stop()
262 dma_release_channel(ux500_channel->dma_chan); in ux500_dma_controller_stop()
266 static int ux500_dma_controller_start(struct ux500_dma_controller *controller) in ux500_dma_controller_start() argument
269 struct musb *musb = controller->private_data; in ux500_dma_controller_start()
270 struct device *dev = musb->controller; in ux500_dma_controller_start()
272 struct ux500_musb_board_data *data; in ux500_dma_controller_start() local
284 dev_err(musb->controller, "No platform data\n"); in ux500_dma_controller_start()
285 return -EINVAL; in ux500_dma_controller_start()
288 data = plat->board_data; in ux500_dma_controller_start()
294 channel_array = controller->rx_channel; in ux500_dma_controller_start()
295 param_array = data ? data->dma_rx_param_array : NULL; in ux500_dma_controller_start()
303 ux500_channel->controller = controller; in ux500_dma_controller_start()
304 ux500_channel->ch_num = ch_num; in ux500_dma_controller_start()
305 ux500_channel->is_tx = is_tx; in ux500_dma_controller_start()
307 dma_channel = &(ux500_channel->channel); in ux500_dma_controller_start()
308 dma_channel->private_data = ux500_channel; in ux500_dma_controller_start()
309 dma_channel->status = MUSB_DMA_STATUS_FREE; in ux500_dma_controller_start()
310 dma_channel->max_len = SZ_16M; in ux500_dma_controller_start()
312 ux500_channel->dma_chan = in ux500_dma_controller_start()
315 if (IS_ERR(ux500_channel->dma_chan)) in ux500_dma_controller_start()
316 ux500_channel->dma_chan = in ux500_dma_controller_start()
318 data ? in ux500_dma_controller_start()
319 data->dma_filter : in ux500_dma_controller_start()
325 if (!ux500_channel->dma_chan) { in ux500_dma_controller_start()
330 ux500_dma_controller_stop(controller); in ux500_dma_controller_start()
332 return -EBUSY; in ux500_dma_controller_start()
338 channel_array = controller->tx_channel; in ux500_dma_controller_start()
339 param_array = data ? data->dma_tx_param_array : NULL; in ux500_dma_controller_start()
349 struct ux500_dma_controller *controller = container_of(c, in ux500_dma_controller_destroy() local
350 struct ux500_dma_controller, controller); in ux500_dma_controller_destroy()
352 ux500_dma_controller_stop(controller); in ux500_dma_controller_destroy()
353 kfree(controller); in ux500_dma_controller_destroy()
360 struct ux500_dma_controller *controller; in ux500_dma_controller_create() local
361 struct platform_device *pdev = to_platform_device(musb->controller); in ux500_dma_controller_create()
365 controller = kzalloc(sizeof(*controller), GFP_KERNEL); in ux500_dma_controller_create()
366 if (!controller) in ux500_dma_controller_create()
369 controller->private_data = musb; in ux500_dma_controller_create()
371 /* Save physical address for DMA controller. */ in ux500_dma_controller_create()
374 dev_err(musb->controller, "no memory resource defined\n"); in ux500_dma_controller_create()
378 controller->phy_base = (dma_addr_t) iomem->start; in ux500_dma_controller_create()
380 controller->controller.channel_alloc = ux500_dma_channel_allocate; in ux500_dma_controller_create()
381 controller->controller.channel_release = ux500_dma_channel_release; in ux500_dma_controller_create()
382 controller->controller.channel_program = ux500_dma_channel_program; in ux500_dma_controller_create()
383 controller->controller.channel_abort = ux500_dma_channel_abort; in ux500_dma_controller_create()
384 controller->controller.is_compatible = ux500_dma_is_compatible; in ux500_dma_controller_create()
386 ret = ux500_dma_controller_start(controller); in ux500_dma_controller_create()
389 return &controller->controller; in ux500_dma_controller_create()
392 kfree(controller); in ux500_dma_controller_create()