mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-26 16:41:42 +00:00
dm: cache: Add enable and disable ops for cache uclass
Add cache enable/disable ops to the DM cache uclass driver Signed-off-by: Rick Chen <rick@andestech.com> Cc: KC Lin <kclin@andestech.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
d58b0a6ee1
commit
4d0140ee1a
2 changed files with 51 additions and 0 deletions
20
drivers/cache/cache-uclass.c
vendored
20
drivers/cache/cache-uclass.c
vendored
|
@ -17,6 +17,26 @@ int cache_get_info(struct udevice *dev, struct cache_info *info)
|
||||||
return ops->get_info(dev, info);
|
return ops->get_info(dev, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cache_enable(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct cache_ops *ops = cache_get_ops(dev);
|
||||||
|
|
||||||
|
if (!ops->enable)
|
||||||
|
return -ENOSYS;
|
||||||
|
|
||||||
|
return ops->enable(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cache_disable(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct cache_ops *ops = cache_get_ops(dev);
|
||||||
|
|
||||||
|
if (!ops->disable)
|
||||||
|
return -ENOSYS;
|
||||||
|
|
||||||
|
return ops->disable(dev);
|
||||||
|
}
|
||||||
|
|
||||||
UCLASS_DRIVER(cache) = {
|
UCLASS_DRIVER(cache) = {
|
||||||
.id = UCLASS_CACHE,
|
.id = UCLASS_CACHE,
|
||||||
.name = "cache",
|
.name = "cache",
|
||||||
|
|
|
@ -22,6 +22,22 @@ struct cache_ops {
|
||||||
* @return 0 if OK, -ve on error
|
* @return 0 if OK, -ve on error
|
||||||
*/
|
*/
|
||||||
int (*get_info)(struct udevice *dev, struct cache_info *info);
|
int (*get_info)(struct udevice *dev, struct cache_info *info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enable() - Enable cache
|
||||||
|
*
|
||||||
|
* @dev: Device to check (UCLASS_CACHE)
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int (*enable)(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* disable() - Flush and disable cache
|
||||||
|
*
|
||||||
|
* @dev: Device to check (UCLASS_CACHE)
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int (*disable)(struct udevice *dev);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define cache_get_ops(dev) ((struct cache_ops *)(dev)->driver->ops)
|
#define cache_get_ops(dev) ((struct cache_ops *)(dev)->driver->ops)
|
||||||
|
@ -35,4 +51,19 @@ struct cache_ops {
|
||||||
*/
|
*/
|
||||||
int cache_get_info(struct udevice *dev, struct cache_info *info);
|
int cache_get_info(struct udevice *dev, struct cache_info *info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache_enable() - Enable cache
|
||||||
|
*
|
||||||
|
* @dev: Device to check (UCLASS_CACHE)
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int cache_enable(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache_disable() - Flush and disable cache
|
||||||
|
*
|
||||||
|
* @dev: Device to check (UCLASS_CACHE)
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int cache_disable(struct udevice *dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue