Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Defines for the SRAM driver |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 4 | */ |
| 5 | #ifndef __SRAM_H |
| 6 | #define __SRAM_H |
| 7 | |
Mikko Perttunen | fec29bf | 2021-07-15 13:34:23 +0300 | [diff] [blame] | 8 | struct sram_config { |
| 9 | int (*init)(void); |
| 10 | bool map_only_reserved; |
| 11 | }; |
| 12 | |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 13 | struct 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 | |
| 22 | struct sram_dev { |
Mikko Perttunen | fec29bf | 2021-07-15 13:34:23 +0300 | [diff] [blame] | 23 | const struct sram_config *config; |
| 24 | |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 25 | struct device *dev; |
| 26 | void __iomem *virt_base; |
Mikko Perttunen | fec29bf | 2021-07-15 13:34:23 +0300 | [diff] [blame] | 27 | bool no_memory_wc; |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 28 | |
| 29 | struct gen_pool *pool; |
| 30 | struct clk *clk; |
| 31 | |
| 32 | struct sram_partition *partition; |
| 33 | u32 partitions; |
| 34 | }; |
| 35 | |
| 36 | struct sram_reserve { |
| 37 | struct list_head list; |
| 38 | u32 start; |
| 39 | u32 size; |
Mikko Perttunen | fec29bf | 2021-07-15 13:34:23 +0300 | [diff] [blame] | 40 | struct resource res; |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 41 | bool export; |
| 42 | bool pool; |
Dave Gerlach | 37afff0 | 2017-01-12 14:52:20 -0600 | [diff] [blame] | 43 | bool protect_exec; |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 44 | const char *label; |
| 45 | }; |
Dave Gerlach | 728bbe7 | 2017-01-12 14:52:19 -0600 | [diff] [blame] | 46 | |
| 47 | #ifdef CONFIG_SRAM_EXEC |
| 48 | int sram_check_protect_exec(struct sram_dev *sram, struct sram_reserve *block, |
| 49 | struct sram_partition *part); |
| 50 | int sram_add_protect_exec(struct sram_partition *part); |
| 51 | #else |
| 52 | static inline int sram_check_protect_exec(struct sram_dev *sram, |
| 53 | struct sram_reserve *block, |
| 54 | struct sram_partition *part) |
| 55 | { |
| 56 | return -ENODEV; |
| 57 | } |
| 58 | |
| 59 | static inline int sram_add_protect_exec(struct sram_partition *part) |
| 60 | { |
| 61 | return -ENODEV; |
| 62 | } |
| 63 | #endif /* CONFIG_SRAM_EXEC */ |
Dave Gerlach | cdd1737 | 2017-01-12 14:52:18 -0600 | [diff] [blame] | 64 | #endif /* __SRAM_H */ |