blob: 397205b8bf6ff61145272ae8857d8c2d1339c249 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Dave Gerlachcdd17372017-01-12 14:52:18 -06002/*
3 * Defines for the SRAM driver
Dave Gerlachcdd17372017-01-12 14:52:18 -06004 */
5#ifndef __SRAM_H
6#define __SRAM_H
7
Mikko Perttunenfec29bf2021-07-15 13:34:23 +03008struct sram_config {
9 int (*init)(void);
10 bool map_only_reserved;
11};
12
Dave Gerlachcdd17372017-01-12 14:52:18 -060013struct sram_partition {
14 void __iomem *base;
15
16 struct gen_pool *pool;
17 struct bin_attribute battr;
18 struct mutex lock;
19 struct list_head list;
20};
21
22struct sram_dev {
Mikko Perttunenfec29bf2021-07-15 13:34:23 +030023 const struct sram_config *config;
24
Dave Gerlachcdd17372017-01-12 14:52:18 -060025 struct device *dev;
26 void __iomem *virt_base;
Mikko Perttunenfec29bf2021-07-15 13:34:23 +030027 bool no_memory_wc;
Dave Gerlachcdd17372017-01-12 14:52:18 -060028
29 struct gen_pool *pool;
Dave Gerlachcdd17372017-01-12 14:52:18 -060030
31 struct sram_partition *partition;
32 u32 partitions;
33};
34
35struct sram_reserve {
36 struct list_head list;
37 u32 start;
38 u32 size;
Mikko Perttunenfec29bf2021-07-15 13:34:23 +030039 struct resource res;
Dave Gerlachcdd17372017-01-12 14:52:18 -060040 bool export;
41 bool pool;
Dave Gerlach37afff02017-01-12 14:52:20 -060042 bool protect_exec;
Dave Gerlachcdd17372017-01-12 14:52:18 -060043 const char *label;
44};
Dave Gerlach728bbe72017-01-12 14:52:19 -060045
46#ifdef CONFIG_SRAM_EXEC
47int sram_check_protect_exec(struct sram_dev *sram, struct sram_reserve *block,
48 struct sram_partition *part);
49int sram_add_protect_exec(struct sram_partition *part);
50#else
51static inline int sram_check_protect_exec(struct sram_dev *sram,
52 struct sram_reserve *block,
53 struct sram_partition *part)
54{
55 return -ENODEV;
56}
57
58static inline int sram_add_protect_exec(struct sram_partition *part)
59{
60 return -ENODEV;
61}
62#endif /* CONFIG_SRAM_EXEC */
Dave Gerlachcdd17372017-01-12 14:52:18 -060063#endif /* __SRAM_H */