1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2015 Imagination Technologies
4 * Author: Paul Burton <paul.burton@mips.com>
7 #include <asm/bcache.h>
9 #include <linux/uaccess.h>
10 #include <linux/debugfs.h>
11 #include <linux/init.h>
13 static ssize_t
sc_prefetch_read(struct file
*file
, char __user
*user_buf
,
14 size_t count
, loff_t
*ppos
)
16 bool enabled
= bc_prefetch_is_enabled();
19 buf
[0] = enabled
? 'Y' : 'N';
23 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, 2);
26 static ssize_t
sc_prefetch_write(struct file
*file
,
27 const char __user
*user_buf
,
28 size_t count
, loff_t
*ppos
)
33 err
= kstrtobool_from_user(user_buf
, count
, &enabled
);
40 bc_prefetch_disable();
45 static const struct file_operations sc_prefetch_fops
= {
47 .llseek
= default_llseek
,
48 .read
= sc_prefetch_read
,
49 .write
= sc_prefetch_write
,
52 static int __init
sc_debugfs_init(void)
56 dir
= debugfs_create_dir("l2cache", mips_debugfs_dir
);
57 debugfs_create_file("prefetch", S_IRUGO
| S_IWUSR
, dir
, NULL
,
61 late_initcall(sc_debugfs_init
);