1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com>
4 */
5
6 #define LOG_CATEGORY UCLASS_SMEM
7
8 #include <dm.h>
9 #include <smem.h>
10
smem_alloc(struct udevice * dev,unsigned int host,unsigned int item,size_t size)11 int 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
smem_get(struct udevice * dev,unsigned int host,unsigned int item,size_t * size)22 void *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
smem_get_free_space(struct udevice * dev,unsigned int host)33 int 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
43 UCLASS_DRIVER(smem) = {
44 .id = UCLASS_SMEM,
45 .name = "smem",
46 };
47