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)  * Copyright (c) 2015, Christoph Hellwig.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (c) 2015, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/memory_hotplug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/libnvdimm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/numa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static int e820_pmem_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	nvdimm_bus_unregister(nvdimm_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static int e820_register_one(struct resource *res, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	struct nd_region_desc ndr_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	struct nvdimm_bus *nvdimm_bus = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	int nid = phys_to_target_node(res->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	memset(&ndr_desc, 0, sizeof(ndr_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	ndr_desc.res = res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	ndr_desc.numa_node = numa_map_to_online_node(nid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	ndr_desc.target_node = nid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (!nvdimm_pmem_region_create(nvdimm_bus, &ndr_desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int e820_pmem_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	static struct nvdimm_bus_descriptor nd_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	struct nvdimm_bus *nvdimm_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	int rc = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	nd_desc.provider_name = "e820";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	nd_desc.module = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	nvdimm_bus = nvdimm_bus_register(dev, &nd_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (!nvdimm_bus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	platform_set_drvdata(pdev, nvdimm_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 			IORESOURCE_MEM, 0, -1, nvdimm_bus, e820_register_one);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	nvdimm_bus_unregister(nvdimm_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	dev_err(dev, "failed to register legacy persistent memory ranges\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static struct platform_driver e820_pmem_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	.probe = e820_pmem_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	.remove = e820_pmem_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		.name = "e820_pmem",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) module_platform_driver(e820_pmem_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) MODULE_ALIAS("platform:e820_pmem*");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) MODULE_AUTHOR("Intel Corporation");