blob: 4dea5cc4bf1c03737cc2d8b0867343bc20c5be08 [file] [log] [blame]
Ramon Friedcf1e49f2018-07-02 02:57:55 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com>
4 */
5
Patrick Delaunay81313352021-04-27 11:02:19 +02006#define LOG_CATEGORY UCLASS_SMEM
7
Ramon Friedcf1e49f2018-07-02 02:57:55 +03008#include <dm.h>
9#include <smem.h>
10
11int smem_alloc(struct udevice *dev, unsigned int host,
12 unsigned int item, size_t size)
13{
14 struct smem_ops *ops = smem_get_ops(dev);
15
16 if (!ops->alloc)
17 return -ENOSYS;
18
19 return ops->alloc(host, item, size);
20}
21
22void *smem_get(struct udevice *dev, unsigned int host,
23 unsigned int item, size_t *size)
24{
25 struct smem_ops *ops = smem_get_ops(dev);
26
27 if (!ops->get)
28 return NULL;
29
30 return ops->get(host, item, size);
31}
32
33int smem_get_free_space(struct udevice *dev, unsigned int host)
34{
35 struct smem_ops *ops = smem_get_ops(dev);
36
37 if (!ops->get_free_space)
38 return -ENOSYS;
39
40 return ops->get_free_space(host);
41}
42
43UCLASS_DRIVER(smem) = {
44 .id = UCLASS_SMEM,
45 .name = "smem",
46};