Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: musb: Add noirq type of dma create interface

Add noirq type of dma create interface for platform which do not
have dedicated DMA interrupt line, move musbhsdma macro definition
to musb_dma.h

Signed-off-by: Min Guo <min.guo@mediatek.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Link: https://lore.kernel.org/r/20200115132547.364-22-b-liu@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Min Guo and committed by
Greg Kroah-Hartman
edce6177 fe3bbd6b

+46 -17
+9
drivers/usb/musb/musb_dma.h
··· 35 35 * whether shared with the Inventra core or separate. 36 36 */ 37 37 38 + #define MUSB_HSDMA_BASE 0x200 39 + #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) 40 + #define MUSB_HSDMA_CONTROL 0x4 41 + #define MUSB_HSDMA_ADDRESS 0x8 42 + #define MUSB_HSDMA_COUNT 0xc 43 + 38 44 #define DMA_ADDR_INVALID (~(dma_addr_t)0) 39 45 40 46 #ifdef CONFIG_MUSB_PIO_ONLY ··· 197 191 extern struct dma_controller * 198 192 musbhs_dma_controller_create(struct musb *musb, void __iomem *base); 199 193 extern void musbhs_dma_controller_destroy(struct dma_controller *c); 194 + extern struct dma_controller * 195 + musbhs_dma_controller_create_noirq(struct musb *musb, void __iomem *base); 196 + extern irqreturn_t dma_controller_irq(int irq, void *private_data); 200 197 201 198 extern struct dma_controller * 202 199 tusb_dma_controller_create(struct musb *musb, void __iomem *base);
+37 -17
drivers/usb/musb/musbhsdma.c
··· 10 10 #include <linux/platform_device.h> 11 11 #include <linux/slab.h> 12 12 #include "musb_core.h" 13 - 14 - #define MUSB_HSDMA_BASE 0x200 15 - #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) 16 - #define MUSB_HSDMA_CONTROL 0x4 17 - #define MUSB_HSDMA_ADDRESS 0x8 18 - #define MUSB_HSDMA_COUNT 0xc 13 + #include "musb_dma.h" 19 14 20 15 #define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \ 21 16 (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset) ··· 263 268 return 0; 264 269 } 265 270 266 - static irqreturn_t dma_controller_irq(int irq, void *private_data) 271 + irqreturn_t dma_controller_irq(int irq, void *private_data) 267 272 { 268 273 struct musb_dma_controller *controller = private_data; 269 274 struct musb *musb = controller->private_data; ··· 378 383 spin_unlock_irqrestore(&musb->lock, flags); 379 384 return retval; 380 385 } 386 + EXPORT_SYMBOL_GPL(dma_controller_irq); 381 387 382 388 void musbhs_dma_controller_destroy(struct dma_controller *c) 383 389 { ··· 394 398 } 395 399 EXPORT_SYMBOL_GPL(musbhs_dma_controller_destroy); 396 400 397 - struct dma_controller *musbhs_dma_controller_create(struct musb *musb, 398 - void __iomem *base) 401 + static struct musb_dma_controller * 402 + dma_controller_alloc(struct musb *musb, void __iomem *base) 399 403 { 400 404 struct musb_dma_controller *controller; 401 - struct device *dev = musb->controller; 402 - struct platform_device *pdev = to_platform_device(dev); 403 - int irq = platform_get_irq_byname(pdev, "dma"); 404 - 405 - if (irq <= 0) { 406 - dev_err(dev, "No DMA interrupt line!\n"); 407 - return NULL; 408 - } 409 405 410 406 controller = kzalloc(sizeof(*controller), GFP_KERNEL); 411 407 if (!controller) ··· 411 423 controller->controller.channel_release = dma_channel_release; 412 424 controller->controller.channel_program = dma_channel_program; 413 425 controller->controller.channel_abort = dma_channel_abort; 426 + return controller; 427 + } 428 + 429 + struct dma_controller * 430 + musbhs_dma_controller_create(struct musb *musb, void __iomem *base) 431 + { 432 + struct musb_dma_controller *controller; 433 + struct device *dev = musb->controller; 434 + struct platform_device *pdev = to_platform_device(dev); 435 + int irq = platform_get_irq_byname(pdev, "dma"); 436 + 437 + if (irq <= 0) { 438 + dev_err(dev, "No DMA interrupt line!\n"); 439 + return NULL; 440 + } 441 + 442 + controller = dma_controller_alloc(musb, base); 443 + if (!controller) 444 + return NULL; 414 445 415 446 if (request_irq(irq, dma_controller_irq, 0, 416 447 dev_name(musb->controller), controller)) { ··· 444 437 return &controller->controller; 445 438 } 446 439 EXPORT_SYMBOL_GPL(musbhs_dma_controller_create); 440 + 441 + struct dma_controller * 442 + musbhs_dma_controller_create_noirq(struct musb *musb, void __iomem *base) 443 + { 444 + struct musb_dma_controller *controller; 445 + 446 + controller = dma_controller_alloc(musb, base); 447 + if (!controller) 448 + return NULL; 449 + 450 + return &controller->controller; 451 + } 452 + EXPORT_SYMBOL_GPL(musbhs_dma_controller_create_noirq);