|
9 | 9 | #include <linux/interrupt.h>
|
10 | 10 | #include <linux/of_irq.h>
|
11 | 11 | #include <linux/of_address.h>
|
| 12 | +#include <linux/device.h> |
| 13 | +#include <asm/cacheinfo.h> |
12 | 14 | #include <soc/sifive/sifive_l2_cache.h>
|
13 | 15 |
|
14 | 16 | #define SIFIVE_L2_DIRECCFIX_LOW 0x100
|
|
31 | 33 |
|
32 | 34 | static void __iomem *l2_base;
|
33 | 35 | static int g_irq[SIFIVE_L2_MAX_ECCINTR];
|
| 36 | +static struct riscv_cacheinfo_ops l2_cache_ops; |
34 | 37 |
|
35 | 38 | enum {
|
36 | 39 | DIR_CORR = 0,
|
@@ -107,6 +110,38 @@ int unregister_sifive_l2_error_notifier(struct notifier_block *nb)
|
107 | 110 | }
|
108 | 111 | EXPORT_SYMBOL_GPL(unregister_sifive_l2_error_notifier);
|
109 | 112 |
|
| 113 | +static int l2_largest_wayenabled(void) |
| 114 | +{ |
| 115 | + return readl(l2_base + SIFIVE_L2_WAYENABLE) & 0xFF; |
| 116 | +} |
| 117 | + |
| 118 | +static ssize_t number_of_ways_enabled_show(struct device *dev, |
| 119 | + struct device_attribute *attr, |
| 120 | + char *buf) |
| 121 | +{ |
| 122 | + return sprintf(buf, "%u\n", l2_largest_wayenabled()); |
| 123 | +} |
| 124 | + |
| 125 | +static DEVICE_ATTR_RO(number_of_ways_enabled); |
| 126 | + |
| 127 | +static struct attribute *priv_attrs[] = { |
| 128 | + &dev_attr_number_of_ways_enabled.attr, |
| 129 | + NULL, |
| 130 | +}; |
| 131 | + |
| 132 | +static const struct attribute_group priv_attr_group = { |
| 133 | + .attrs = priv_attrs, |
| 134 | +}; |
| 135 | + |
| 136 | +const struct attribute_group *l2_get_priv_group(struct cacheinfo *this_leaf) |
| 137 | +{ |
| 138 | + /* We want to use private group for L2 cache only */ |
| 139 | + if (this_leaf->level == 2) |
| 140 | + return &priv_attr_group; |
| 141 | + else |
| 142 | + return NULL; |
| 143 | +} |
| 144 | + |
110 | 145 | static irqreturn_t l2_int_handler(int irq, void *device)
|
111 | 146 | {
|
112 | 147 | unsigned int add_h, add_l;
|
@@ -170,6 +205,9 @@ static int __init sifive_l2_init(void)
|
170 | 205 |
|
171 | 206 | l2_config_read();
|
172 | 207 |
|
| 208 | + l2_cache_ops.get_priv_group = l2_get_priv_group; |
| 209 | + riscv_set_cacheinfo_ops(&l2_cache_ops); |
| 210 | + |
173 | 211 | #ifdef CONFIG_DEBUG_FS
|
174 | 212 | setup_sifive_debug();
|
175 | 213 | #endif
|
|
0 commit comments