Dinh Nguyen | 84b124d | 2019-04-23 16:55:03 -0500 | [diff] [blame] | 1 | // 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 Rini | 12c00f9 | 2023-10-12 19:03:54 -0400 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | struct udevice; |
| 12 | |
Dinh Nguyen | 84b124d | 2019-04-23 16:55:03 -0500 | [diff] [blame] | 13 | /* |
| 14 | * Structure for the cache controller |
| 15 | */ |
| 16 | struct cache_info { |
| 17 | phys_addr_t base; /* Base physical address of cache device. */ |
| 18 | }; |
| 19 | |
| 20 | struct 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 Chen | 4d0140e | 2019-08-28 18:46:04 +0800 | [diff] [blame] | 29 | |
| 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 Nguyen | 84b124d | 2019-04-23 16:55:03 -0500 | [diff] [blame] | 45 | }; |
| 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 Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 54 | * Return: 0 if OK, -ve on error |
Dinh Nguyen | 84b124d | 2019-04-23 16:55:03 -0500 | [diff] [blame] | 55 | */ |
| 56 | int cache_get_info(struct udevice *dev, struct cache_info *info); |
| 57 | |
Rick Chen | 4d0140e | 2019-08-28 18:46:04 +0800 | [diff] [blame] | 58 | /** |
| 59 | * cache_enable() - Enable cache |
| 60 | * |
| 61 | * @dev: Device to check (UCLASS_CACHE) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 62 | * Return: 0 if OK, -ve on error |
Rick Chen | 4d0140e | 2019-08-28 18:46:04 +0800 | [diff] [blame] | 63 | */ |
| 64 | int cache_enable(struct udevice *dev); |
| 65 | |
| 66 | /** |
| 67 | * cache_disable() - Flush and disable cache |
| 68 | * |
| 69 | * @dev: Device to check (UCLASS_CACHE) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 70 | * Return: 0 if OK, -ve on error |
Rick Chen | 4d0140e | 2019-08-28 18:46:04 +0800 | [diff] [blame] | 71 | */ |
| 72 | int cache_disable(struct udevice *dev); |
Dinh Nguyen | 84b124d | 2019-04-23 16:55:03 -0500 | [diff] [blame] | 73 | #endif |