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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *  Copyright (C) 2012 John Crispin <john@phrozen.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/of_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <lantiq_soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static unsigned int *cp1_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) unsigned int *ltq_get_cp1_base(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	if (!cp1_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		panic("no cp1 base was set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	return cp1_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) EXPORT_SYMBOL(ltq_get_cp1_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int vmmc_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define CP1_SIZE       (1 << 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	int gpio_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	cp1_base =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		(void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 						    &dma, GFP_KERNEL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	gpio_count = of_gpio_count(pdev->dev.of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	while (gpio_count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		enum of_gpio_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		int gpio = of_get_gpio_flags(pdev->dev.of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 					     --gpio_count, &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		if (gpio_request(gpio, "vmmc-relay"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		gpio_direction_output(gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 				      (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static const struct of_device_id vmmc_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	{ .compatible = "lantiq,vmmc-xway" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static struct platform_driver vmmc_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	.probe = vmmc_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		.name = "lantiq,vmmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		.of_match_table = vmmc_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) builtin_platform_driver(vmmc_driver);