^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Defines for the SRAM driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __SRAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define __SRAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct sram_partition {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct gen_pool *pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct bin_attribute battr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct sram_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void __iomem *virt_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct gen_pool *pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct clk *clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct sram_partition *partition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) u32 partitions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct sram_reserve {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u32 start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) bool export;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bool pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) bool protect_exec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) const char *label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #ifdef CONFIG_SRAM_EXEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int sram_check_protect_exec(struct sram_dev *sram, struct sram_reserve *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct sram_partition *part);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int sram_add_protect_exec(struct sram_partition *part);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static inline int sram_check_protect_exec(struct sram_dev *sram,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct sram_reserve *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct sram_partition *part)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline int sram_add_protect_exec(struct sram_partition *part)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif /* CONFIG_SRAM_EXEC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #endif /* __SRAM_H */