blob: 8469076915e005928a60abf33906cb56873f6c32 [file] [log] [blame]
Ramon Fried7b384ec2018-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 Delaunayb953ec22021-04-27 11:02:19 +02006#define LOG_CATEGORY UCLASS_SMEM
7
Ramon Fried7b384ec2018-07-02 02:57:55 +03008#include <common.h>
9#include <dm.h>
10#include <smem.h>
11
12int smem_alloc(struct udevice *dev, unsigned int host,
13 unsigned int item, size_t size)
14{
15 struct smem_ops *ops = smem_get_ops(dev);
16
17 if (!ops->alloc)
18 return -ENOSYS;
19
20 return ops->alloc(host, item, size);
21}
22
23void *smem_get(struct udevice *dev, unsigned int host,
24 unsigned int item, size_t *size)
25{
26 struct smem_ops *ops = smem_get_ops(dev);
27
28 if (!ops->get)
29 return NULL;
30
31 return ops->get(host, item, size);
32}
33
34int smem_get_free_space(struct udevice *dev, unsigned int host)
35{
36 struct smem_ops *ops = smem_get_ops(dev);
37
38 if (!ops->get_free_space)
39 return -ENOSYS;
40
41 return ops->get_free_space(host);
42}
43
44UCLASS_DRIVER(smem) = {
45 .id = UCLASS_SMEM,
46 .name = "smem",
47};