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) 2015 Imagination Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Author: Paul Burton <paul.burton@mips.com>
^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 <asm/bcache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 				size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	bool enabled = bc_prefetch_is_enabled();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	char buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	buf[0] = enabled ? 'Y' : 'N';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	buf[1] = '\n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	buf[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static ssize_t sc_prefetch_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 				 const char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 				 size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	bool enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	err = kstrtobool_from_user(user_buf, count, &enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		bc_prefetch_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		bc_prefetch_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static const struct file_operations sc_prefetch_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	.read = sc_prefetch_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	.write = sc_prefetch_write,
^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 int __init sc_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	struct dentry *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	dir = debugfs_create_dir("l2cache", mips_debugfs_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			    &sc_prefetch_fops);
^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) late_initcall(sc_debugfs_init);