shdmac.c (597473720f4dc69749542bfcfed4a927a43d935e) shdmac.c (8b229a01a5b846bf7a45c8ef11bc3b81326c9409)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Renesas SuperH DMA Engine support
4 *
5 * base is drivers/dma/flsdma.c
6 *
7 * Copyright (C) 2011-2012 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
8 * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>

--- 664 unchanged lines hidden (view full) ---

673 DMA_SLAVE_BUSWIDTH_16_BYTES | DMA_SLAVE_BUSWIDTH_32_BYTES;
674 const struct sh_dmae_pdata *pdata;
675 unsigned long chan_flag[SH_DMAE_MAX_CHANNELS] = {};
676 int chan_irq[SH_DMAE_MAX_CHANNELS];
677 unsigned long irqflags = 0;
678 int err, errirq, i, irq_cnt = 0, irqres = 0, irq_cap = 0;
679 struct sh_dmae_device *shdev;
680 struct dma_device *dma_dev;
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Renesas SuperH DMA Engine support
4 *
5 * base is drivers/dma/flsdma.c
6 *
7 * Copyright (C) 2011-2012 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
8 * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>

--- 664 unchanged lines hidden (view full) ---

673 DMA_SLAVE_BUSWIDTH_16_BYTES | DMA_SLAVE_BUSWIDTH_32_BYTES;
674 const struct sh_dmae_pdata *pdata;
675 unsigned long chan_flag[SH_DMAE_MAX_CHANNELS] = {};
676 int chan_irq[SH_DMAE_MAX_CHANNELS];
677 unsigned long irqflags = 0;
678 int err, errirq, i, irq_cnt = 0, irqres = 0, irq_cap = 0;
679 struct sh_dmae_device *shdev;
680 struct dma_device *dma_dev;
681 struct resource *chan, *dmars, *errirq_res, *chanirq_res;
681 struct resource *dmars, *errirq_res, *chanirq_res;
682
683 if (pdev->dev.of_node)
684 pdata = of_device_get_match_data(&pdev->dev);
685 else
686 pdata = dev_get_platdata(&pdev->dev);
687
688 /* get platform data */
689 if (!pdata || !pdata->channel_num)
690 return -ENODEV;
691
682
683 if (pdev->dev.of_node)
684 pdata = of_device_get_match_data(&pdev->dev);
685 else
686 pdata = dev_get_platdata(&pdev->dev);
687
688 /* get platform data */
689 if (!pdata || !pdata->channel_num)
690 return -ENODEV;
691
692 chan = platform_get_resource(pdev, IORESOURCE_MEM, 0);
693 /* DMARS area is optional */
694 dmars = platform_get_resource(pdev, IORESOURCE_MEM, 1);
695 /*
696 * IRQ resources:
697 * 1. there always must be at least one IRQ IO-resource. On SH4 it is
698 * the error IRQ, in which case it is the only IRQ in this resource:
699 * start == end. If it is the only IRQ resource, all channels also
700 * use the same IRQ.
701 * 2. DMA channel IRQ resources can be specified one per resource or in
702 * ranges (start != end)
703 * 3. iff all events (channels and, optionally, error) on this
704 * controller use the same IRQ, only one IRQ resource can be
705 * specified, otherwise there must be one IRQ per channel, even if
706 * some of them are equal
707 * 4. if all IRQs on this controller are equal or if some specific IRQs
708 * specify IORESOURCE_IRQ_SHAREABLE in their resources, they will be
709 * requested with the IRQF_SHARED flag
710 */
711 errirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
692 /* DMARS area is optional */
693 dmars = platform_get_resource(pdev, IORESOURCE_MEM, 1);
694 /*
695 * IRQ resources:
696 * 1. there always must be at least one IRQ IO-resource. On SH4 it is
697 * the error IRQ, in which case it is the only IRQ in this resource:
698 * start == end. If it is the only IRQ resource, all channels also
699 * use the same IRQ.
700 * 2. DMA channel IRQ resources can be specified one per resource or in
701 * ranges (start != end)
702 * 3. iff all events (channels and, optionally, error) on this
703 * controller use the same IRQ, only one IRQ resource can be
704 * specified, otherwise there must be one IRQ per channel, even if
705 * some of them are equal
706 * 4. if all IRQs on this controller are equal or if some specific IRQs
707 * specify IORESOURCE_IRQ_SHAREABLE in their resources, they will be
708 * requested with the IRQF_SHARED flag
709 */
710 errirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
712 if (!chan || !errirq_res)
711 if (!errirq_res)
713 return -ENODEV;
714
715 shdev = devm_kzalloc(&pdev->dev, sizeof(struct sh_dmae_device),
716 GFP_KERNEL);
717 if (!shdev)
718 return -ENOMEM;
719
720 dma_dev = &shdev->shdma_dev.dma_dev;
721
712 return -ENODEV;
713
714 shdev = devm_kzalloc(&pdev->dev, sizeof(struct sh_dmae_device),
715 GFP_KERNEL);
716 if (!shdev)
717 return -ENOMEM;
718
719 dma_dev = &shdev->shdma_dev.dma_dev;
720
722 shdev->chan_reg = devm_ioremap_resource(&pdev->dev, chan);
721 shdev->chan_reg = devm_platform_ioremap_resource(pdev, 0);
723 if (IS_ERR(shdev->chan_reg))
724 return PTR_ERR(shdev->chan_reg);
725 if (dmars) {
726 shdev->dmars = devm_ioremap_resource(&pdev->dev, dmars);
727 if (IS_ERR(shdev->dmars))
728 return PTR_ERR(shdev->dmars);
729 }
730

--- 208 unchanged lines hidden ---
722 if (IS_ERR(shdev->chan_reg))
723 return PTR_ERR(shdev->chan_reg);
724 if (dmars) {
725 shdev->dmars = devm_ioremap_resource(&pdev->dev, dmars);
726 if (IS_ERR(shdev->dmars))
727 return PTR_ERR(shdev->dmars);
728 }
729

--- 208 unchanged lines hidden ---