summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Fu <wefu@redhat.com>2021-09-19 09:12:45 +0300
committerTekkaman Ninja <tekkamanninja@163.com>2022-02-15 12:48:24 +0300
commit28db513a7dd4dd56eb40f764aa674308c97f21ee (patch)
treece80753f014c512fe94b2aadeb5565e6be35aee1
parentae8609677b36ea881352fdd6610acdc6294f8333 (diff)
downloadu-boot-28db513a7dd4dd56eb40f764aa674308c97f21ee.tar.xz
cache: add flush_range interface in cache_ops struct
Signed-off-by: Wei Fu <wefu@redhat.com>
-rw-r--r--drivers/cache/cache-uclass.c11
-rw-r--r--include/cache.h21
2 files changed, 32 insertions, 0 deletions
diff --git a/drivers/cache/cache-uclass.c b/drivers/cache/cache-uclass.c
index 0c13dbdb75..399db84fb7 100644
--- a/drivers/cache/cache-uclass.c
+++ b/drivers/cache/cache-uclass.c
@@ -39,6 +39,17 @@ int cache_disable(struct udevice *dev)
return ops->disable(dev);
}
+
+int flush_range(struct udevice *dev, unsigned long start, unsigned long end)
+{
+ struct cache_ops *ops = cache_get_ops(dev);
+
+ if (!ops->flush_range)
+ return -ENOSYS;
+
+ return ops->flush_range(dev, start, end);
+}
+
UCLASS_DRIVER(cache) = {
.id = UCLASS_CACHE,
.name = "cache",
diff --git a/include/cache.h b/include/cache.h
index b12fec2591..52835d236f 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -40,6 +40,17 @@ struct cache_ops {
* @return 0 if OK, -ve on error
*/
int (*disable)(struct udevice *dev);
+
+ /**
+ * flush_range() - Flush cache in a range
+ *
+ * @dev: Device to check (UCLASS_CACHE)
+ * @start: start address of the range
+ * @end: end address of the range
+ * @return 0 if OK, -ve on error
+ */
+ int (*flush_range)(struct udevice *dev,
+ unsigned long start, unsigned long end);
};
#define cache_get_ops(dev) ((struct cache_ops *)(dev)->driver->ops)
@@ -68,4 +79,14 @@ int cache_enable(struct udevice *dev);
* Return: 0 if OK, -ve on error
*/
int cache_disable(struct udevice *dev);
+
+/**
+ * flush_range() - Flush cache
+ *
+ * @dev: Device to check (UCLASS_CACHE)
+ * @start: start address of the range
+ * @end: end address of the range
+ * @return 0 if OK, -ve on error
+ */
+int flush_range(struct udevice *dev, unsigned long start, unsigned long end);
#endif