Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * SHDMA Device Tree glue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2013 Renesas Electronics Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/dmaengine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/of_dma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/shdma-base.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 				       struct of_dma *ofdma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	u32 id = dma_spec->args[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	dma_cap_mask_t mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	struct dma_chan *chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	if (dma_spec->args_count != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	dma_cap_zero(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	/* Only slave DMA channels can be allocated via DT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	dma_cap_set(DMA_SLAVE, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	chan = dma_request_channel(mask, shdma_chan_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 				   (void *)(uintptr_t)id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		to_shdma_chan(chan)->hw_req = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static int shdma_of_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	const struct of_dev_auxdata *lookup = dev_get_platdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	ret = of_dma_controller_register(pdev->dev.of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 					 shdma_of_xlate, pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	ret = of_platform_populate(pdev->dev.of_node, NULL, lookup, &pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		of_dma_controller_free(pdev->dev.of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static const struct of_device_id shdma_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	{ .compatible = "renesas,shdma-mux", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) MODULE_DEVICE_TABLE(of, sh_dmae_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static struct platform_driver shdma_of = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		.name	= "shdma-of",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		.of_match_table = shdma_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	.probe		= shdma_of_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) module_platform_driver(shdma_of);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MODULE_DESCRIPTION("SH-DMA driver DT glue");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");