Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * The On Chip Memory (OCMEM) allocator allows various clients to allocate
0004  * memory from OCMEM based on performance, latency and power requirements.
0005  * This is typically used by the GPU, camera/video, and audio components on
0006  * some Snapdragon SoCs.
0007  *
0008  * Copyright (C) 2019 Brian Masney <masneyb@onstation.org>
0009  * Copyright (C) 2015 Red Hat. Author: Rob Clark <robdclark@gmail.com>
0010  */
0011 
0012 #include <linux/device.h>
0013 #include <linux/err.h>
0014 
0015 #ifndef __OCMEM_H__
0016 #define __OCMEM_H__
0017 
0018 enum ocmem_client {
0019     /* GMEM clients */
0020     OCMEM_GRAPHICS = 0x0,
0021     /*
0022      * TODO add more once ocmem_allocate() is clever enough to
0023      * deal with multiple clients.
0024      */
0025     OCMEM_CLIENT_MAX,
0026 };
0027 
0028 struct ocmem;
0029 
0030 struct ocmem_buf {
0031     unsigned long offset;
0032     unsigned long addr;
0033     unsigned long len;
0034 };
0035 
0036 #if IS_ENABLED(CONFIG_QCOM_OCMEM)
0037 
0038 struct ocmem *of_get_ocmem(struct device *dev);
0039 struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client,
0040                  unsigned long size);
0041 void ocmem_free(struct ocmem *ocmem, enum ocmem_client client,
0042         struct ocmem_buf *buf);
0043 
0044 #else /* IS_ENABLED(CONFIG_QCOM_OCMEM) */
0045 
0046 static inline struct ocmem *of_get_ocmem(struct device *dev)
0047 {
0048     return ERR_PTR(-ENODEV);
0049 }
0050 
0051 static inline struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem,
0052                            enum ocmem_client client,
0053                            unsigned long size)
0054 {
0055     return ERR_PTR(-ENODEV);
0056 }
0057 
0058 static inline void ocmem_free(struct ocmem *ocmem, enum ocmem_client client,
0059                   struct ocmem_buf *buf)
0060 {
0061 }
0062 
0063 #endif /* IS_ENABLED(CONFIG_QCOM_OCMEM) */
0064 
0065 #endif /* __OCMEM_H__ */