blob: 296ae3c8b48e737411aabfaa4530c6e5f3196fca [file] [log] [blame]
Dinh Nguyen84b124d2019-04-23 16:55:03 -05001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2019 Intel Corporation <www.intel.com>
4 */
5
6#ifndef __CACHE_H
7#define __CACHE_H
8
Tom Rini12c00f92023-10-12 19:03:54 -04009#include <linux/types.h>
10
Simon Glass401d1c42020-10-30 21:38:53 -060011struct udevice;
12
Dinh Nguyen84b124d2019-04-23 16:55:03 -050013/*
14 * Structure for the cache controller
15 */
16struct cache_info {
17 phys_addr_t base; /* Base physical address of cache device. */
18};
19
20struct cache_ops {
21 /**
22 * get_info() - Get basic cache info
23 *
24 * @dev: Device to check (UCLASS_CACHE)
25 * @info: Place to put info
26 * @return 0 if OK, -ve on error
27 */
28 int (*get_info)(struct udevice *dev, struct cache_info *info);
Rick Chen4d0140e2019-08-28 18:46:04 +080029
30 /**
31 * enable() - Enable cache
32 *
33 * @dev: Device to check (UCLASS_CACHE)
34 * @return 0 if OK, -ve on error
35 */
36 int (*enable)(struct udevice *dev);
37
38 /**
39 * disable() - Flush and disable cache
40 *
41 * @dev: Device to check (UCLASS_CACHE)
42 * @return 0 if OK, -ve on error
43 */
44 int (*disable)(struct udevice *dev);
Dinh Nguyen84b124d2019-04-23 16:55:03 -050045};
46
47#define cache_get_ops(dev) ((struct cache_ops *)(dev)->driver->ops)
48
49/**
50 * cache_get_info() - Get information about a cache controller
51 *
52 * @dev: Device to check (UCLASS_CACHE)
53 * @info: Returns cache info
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010054 * Return: 0 if OK, -ve on error
Dinh Nguyen84b124d2019-04-23 16:55:03 -050055 */
56int cache_get_info(struct udevice *dev, struct cache_info *info);
57
Rick Chen4d0140e2019-08-28 18:46:04 +080058/**
59 * cache_enable() - Enable cache
60 *
61 * @dev: Device to check (UCLASS_CACHE)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010062 * Return: 0 if OK, -ve on error
Rick Chen4d0140e2019-08-28 18:46:04 +080063 */
64int cache_enable(struct udevice *dev);
65
66/**
67 * cache_disable() - Flush and disable cache
68 *
69 * @dev: Device to check (UCLASS_CACHE)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010070 * Return: 0 if OK, -ve on error
Rick Chen4d0140e2019-08-28 18:46:04 +080071 */
72int cache_disable(struct udevice *dev);
Dinh Nguyen84b124d2019-04-23 16:55:03 -050073#endif