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)  * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/machdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/vdso_datapage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/rtas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static loff_t page_map_seek(struct file *file, loff_t off, int whence)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	return fixed_size_llseek(file, off, whence, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static ssize_t page_map_read( struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 			      loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	return simple_read_from_buffer(buf, nbytes, ppos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 			PDE_DATA(file_inode(file)), PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static int page_map_mmap( struct file *file, struct vm_area_struct *vma )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if ((vma->vm_end - vma->vm_start) > PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	remap_pfn_range(vma, vma->vm_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			__pa(PDE_DATA(file_inode(file))) >> PAGE_SHIFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 			PAGE_SIZE, vma->vm_page_prot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	return 0;
^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) static const struct proc_ops page_map_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	.proc_lseek	= page_map_seek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	.proc_read	= page_map_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	.proc_mmap	= page_map_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static int __init proc_ppc64_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct proc_dir_entry *pde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	pde = proc_create_data("powerpc/systemcfg", S_IFREG | 0444, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 			       &page_map_proc_ops, vdso_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	if (!pde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	proc_set_size(pde, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __initcall(proc_ppc64_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #endif /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  * Create the ppc64 and ppc64/rtas directories early. This allows us to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)  * assume that they have been previously created in drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static int __init proc_ppc64_create(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	struct proc_dir_entry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	root = proc_mkdir("powerpc", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	if (!root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	if (!proc_symlink("ppc64", NULL, "powerpc"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 		pr_err("Failed to create link /proc/ppc64 -> /proc/powerpc\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	if (!of_find_node_by_path("/rtas"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	if (!proc_mkdir("rtas", root))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 	if (!proc_symlink("rtas", NULL, "powerpc/rtas"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) core_initcall(proc_ppc64_create);