Commit | Line | Data |
---|---|---|
d478b088 PB |
1 | /* |
2 | * Copyright (C) 2015 Imagination Technologies | |
fb615d61 | 3 | * Author: Paul Burton <paul.burton@mips.com> |
d478b088 PB |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License as published by the | |
7 | * Free Software Foundation; either version 2 of the License, or (at your | |
8 | * option) any later version. | |
9 | */ | |
10 | ||
11 | #include <asm/bcache.h> | |
12 | #include <asm/debug.h> | |
7c0f6ba6 | 13 | #include <linux/uaccess.h> |
d478b088 PB |
14 | #include <linux/debugfs.h> |
15 | #include <linux/init.h> | |
16 | ||
17 | static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf, | |
18 | size_t count, loff_t *ppos) | |
19 | { | |
20 | bool enabled = bc_prefetch_is_enabled(); | |
21 | char buf[3]; | |
22 | ||
23 | buf[0] = enabled ? 'Y' : 'N'; | |
24 | buf[1] = '\n'; | |
25 | buf[2] = 0; | |
26 | ||
27 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | |
28 | } | |
29 | ||
30 | static ssize_t sc_prefetch_write(struct file *file, | |
31 | const char __user *user_buf, | |
32 | size_t count, loff_t *ppos) | |
33 | { | |
d478b088 PB |
34 | bool enabled; |
35 | int err; | |
36 | ||
f83e4e1e | 37 | err = kstrtobool_from_user(user_buf, count, &enabled); |
d478b088 PB |
38 | if (err) |
39 | return err; | |
40 | ||
41 | if (enabled) | |
42 | bc_prefetch_enable(); | |
43 | else | |
44 | bc_prefetch_disable(); | |
45 | ||
46 | return count; | |
47 | } | |
48 | ||
49 | static const struct file_operations sc_prefetch_fops = { | |
50 | .open = simple_open, | |
51 | .llseek = default_llseek, | |
52 | .read = sc_prefetch_read, | |
53 | .write = sc_prefetch_write, | |
54 | }; | |
55 | ||
56 | static int __init sc_debugfs_init(void) | |
57 | { | |
864cc363 | 58 | struct dentry *dir; |
d478b088 PB |
59 | |
60 | dir = debugfs_create_dir("l2cache", mips_debugfs_dir); | |
864cc363 GKH |
61 | debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL, |
62 | &sc_prefetch_fops); | |
d478b088 PB |
63 | return 0; |
64 | } | |
65 | late_initcall(sc_debugfs_init); |