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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Instantiate mmio-mapped RTC chips based on device tree information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/of_address.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static __initdata struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	const char *compatible;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	char *plat_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) } of_rtc_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	{ "ds1743-nvram", "rtc-ds1742" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void __init of_instantiate_rtc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	struct device_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	for (i = 0; i < ARRAY_SIZE(of_rtc_table); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		char *plat_name = of_rtc_table[i].plat_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		for_each_compatible_node(node, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 					 of_rtc_table[i].compatible) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 			struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 			res = kmalloc(sizeof(*res), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 				printk(KERN_ERR "OF RTC: Out of memory "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 				       "allocating resource structure for %pOF\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				       node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 			err = of_address_to_resource(node, 0, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 				printk(KERN_ERR "OF RTC: Error "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 				       "translating resources for %pOF\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				       node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 			printk(KERN_INFO "OF_RTC: %pOF is a %s @ 0x%llx-0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 			       node, plat_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			       (unsigned long long)res->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 			       (unsigned long long)res->end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 			platform_device_register_simple(plat_name, -1, res, 1);
^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) }