summaryrefslogtreecommitdiff
path: root/drivers/dma
Commit message (Collapse)AuthorAgeFilesLines
* dma: use dma/cpu conversions correctly in dma_map/unmap_singleDenis Orlov2023-03-141-6/+4
| | | | | | | | | | | | | We should not treat dma handles as if they correspond one-to-one to the virtual addresses in common code. So make sure that dma handles are properly passed to the dma_sync_single_for_* functions. Otherwise, it just doesn't make much sense, as dma_sync funcs will receive proper dma handles when called directly, and a virtual address treated as one when called from dma_map funcs. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230313105308.3108127-2-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: use virt/phys conversions when no dma_offset is specifiedDenis Orlov2023-02-141-15/+11
| | | | | | | | | | | | The code was assuming that in such cases we can just use cpu addresses as physical ones. This is incorrect on MIPS, the only platform that has its own virt_to_phys/phys_to_virt functions defined. This fixes issues with DMA mappings on MIPS, with e1000 PCI ethernet card now working on Malta in QEMU. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230210143924.915149-3-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-102-5/+6
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh-dma: unify register definesSascha Hauer2022-11-021-27/+0
| | | | | | | | We have different register defines for the apbh-dma controller. One set is used in the regular driver, the other one in the xload code. Move the register defines to a common place and unify their names. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh-dma: Simplify codeSascha Hauer2022-11-021-463/+24
| | | | | | | | | | The apbh-dma driver supports chaining DMA descriptors while the DMA engine is running. This is unused in barebox as well as in the Kernel. We just queue one descriptor chain and wait for its completion, and the MTD layer doesn't even support the more advanced features. Just drop the unused code and greatly simplify it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: mtd: nand: nand_mxs: enable nand_mxs on imx7Johannes Zink2022-08-311-1/+1
| | | | | | | | | | | | | The i.MX7 GPMI NAND controller is completely backwards compatible with the version of the IP on the i.MX6. There are additional features like increased ECC strength, that we may want to use in future, but for now treating it the same as an i.MX6 works without problems. Since the gpmi_nand driver requires the MXS_APBH_DMA driver, also switch it on. Signed-off-by: Johannes Zink <j.zink@pengutronix.de> Link: https://lore.barebox.org/20220830080613.438124-1-j.zink@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-222-2/+2
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-013-5/+3
| | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: move dma_map/unmap_single from ARM to common codeAhmad Fatoum2021-03-042-0/+43
| | | | | | | | | | | | | | There's nothing ARM specific about these functions. Move them to a common location, so other arches can use them as well. This also fixes a bug on ARM MMU=n configurations: Previously these two functions these functions only respected dma-ranges translation when compiled with MMU support. DMA address translation is applicable regardless of CPU use of MMU though. Now, dma-ranges should be respected unconditionally. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: fix out-of-bounds write on 64-bit SoCsAhmad Fatoum2020-10-091-3/+4
| | | | | | | | | | i.MX8 MM & MN are both ARM64 SoCs with a device compatible with "fsl,imx28-dma-apbh". Probing the barebox device driver on these SoCs would invoke undefined behavior however, because of an errant cast. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* apbh: Use dma_alloc_coherent() to get DMA addressAndrey Smirnov2019-05-281-2/+3
| | | | | | | | | Avoid converting virtual address to physical by simple casting by making use of the fact that dma_alloc_coherent() can already return that information to us. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* apbh: Do not zero out DMA coherent memoryAndrey Smirnov2019-05-281-1/+0
| | | | | | | | Memory returned by dma_alloc_coherent() should already be zeroed out, so there's no need to do this explicitly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: make locally used function staticSascha Hauer2018-11-121-1/+1
| | | | | | To avoid missing prototype warning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: Enable clock as a part of probingAndrey Smirnov2018-04-031-0/+13
| | | | | | | | Enable clock as a part of probing in order to avoid problems on SoCs that do not have this block ungated out of reset (e.g. i.MX7). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh_dma: add missing array terminationSascha Hauer2017-03-061-1/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: move DMA alloc functions to dma.hLucas Stach2015-03-061-1/+1
| | | | | | | | | | This better separates the DMA from the MMU functionality. Also move all drivers that only depends on asm/mmu.h for the alloc functions over to the common header. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: change dma_alloc/free_coherent to match other architecturesLucas Stach2015-03-061-1/+2
| | | | | | | | | As a lot drivers currently rely on the 1:1 virt->phys mapping on ARM we define DMA_ADDRESS_BROKEN to mark them. In order to use them on other architectures with a different mapping they need proper fixing. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* resource: Let dev_request_mem_region return an error pointerSascha Hauer2014-09-161-2/+3
| | | | | | For all users fix or add the error check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: mxs-nand: Add i.MX6 supportSascha Hauer2013-07-231-1/+1
| | | | | | | The i.MX6 uses the same GPMI NAND controller as i.MX23/28 do. This adds i.MX6 support to the driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: cleanup includesSascha Hauer2013-07-231-7/+5
| | | | | | Several includes are unused, remove them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: add devicetree probe supportSascha Hauer2013-07-231-0/+13
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: Turn into a driverSascha Hauer2013-07-231-33/+80
| | | | | | This converts the apbh driver into a real driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh-dma: move header file to common locationSascha Hauer2013-07-231-1/+1
| | | | | | | As the apbh dma engine is also found on i.MX6 move the header file out of MXS specific directories. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: introduce private structSascha Hauer2013-07-231-28/+38
| | | | | | | | Currently the apbh driver uses a hardcoded base (MXS_APBH_BASE). As a first step to clean this up add a private data struct which is initialized during startup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: MXS: introduce stmp device supportSascha Hauer2013-07-232-12/+13
| | | | | | | | | | | | MXS specific devices have some common infrastructure in the kernel known as STMP devices. We have the same in barebox, but with a mxs_ prefix instead of a stmp_ prefix. As some STMP devices are also found on i.MX6 move the common infrastructure out of MXS specific files and use the stmp_ prefix. This is done in preparation for i.MX6 NAND support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Cleanup Kconfig filesAlexander Shiyan2012-12-081-1/+1
| | | | | | | | | This patch provides a global cleanup barebox Kconfig files. This includes replacing spaces to tabs, formatting in accordance format, removing extraneous lines and spaces. No functional changes. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: apbh: check for errors when resetting ip coreWolfram Sang2012-10-311-1/+3
| | | | | Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* dma: add mxs-apbh-dma driverWolfram Sang2012-06-303-0/+607
Based on the U-Boot version. Changed to kernel style register layout, added MX23 support, made MMU aware and adapted to barebox. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>