1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * PRU-ICSS sub-system specific definitions 4 * 5 * Copyright (C) 2014-2020 Texas Instruments Incorporated - http://www.ti.com/ 6 * Suman Anna <[email protected]> 7 */ 8 9 #ifndef _PRUSS_DRIVER_H_ 10 #define _PRUSS_DRIVER_H_ 11 12 #include <linux/mutex.h> 13 #include <linux/remoteproc/pruss.h> 14 #include <linux/types.h> 15 #include <linux/err.h> 16 17 /* 18 * enum pruss_mem - PRUSS memory range identifiers 19 */ 20 enum pruss_mem { 21 PRUSS_MEM_DRAM0 = 0, 22 PRUSS_MEM_DRAM1, 23 PRUSS_MEM_SHRD_RAM2, 24 PRUSS_MEM_MAX, 25 }; 26 27 /** 28 * struct pruss_mem_region - PRUSS memory region structure 29 * @va: kernel virtual address of the PRUSS memory region 30 * @pa: physical (bus) address of the PRUSS memory region 31 * @size: size of the PRUSS memory region 32 */ 33 struct pruss_mem_region { 34 void __iomem *va; 35 phys_addr_t pa; 36 size_t size; 37 }; 38 39 /** 40 * struct pruss - PRUSS parent structure 41 * @dev: pruss device pointer 42 * @cfg_base: base iomap for CFG region 43 * @cfg_regmap: regmap for config region 44 * @mem_regions: data for each of the PRUSS memory regions 45 * @mem_in_use: to indicate if memory resource is in use 46 * @lock: mutex to serialize access to resources 47 * @core_clk_mux: clk handle for PRUSS CORE_CLK_MUX 48 * @iep_clk_mux: clk handle for PRUSS IEP_CLK_MUX 49 */ 50 struct pruss { 51 struct device *dev; 52 void __iomem *cfg_base; 53 struct regmap *cfg_regmap; 54 struct pruss_mem_region mem_regions[PRUSS_MEM_MAX]; 55 struct pruss_mem_region *mem_in_use[PRUSS_MEM_MAX]; 56 struct mutex lock; /* PRU resource lock */ 57 struct clk *core_clk_mux; 58 struct clk *iep_clk_mux; 59 }; 60 61 #if IS_ENABLED(CONFIG_TI_PRUSS) 62 63 struct pruss *pruss_get(struct rproc *rproc); 64 void pruss_put(struct pruss *pruss); 65 int pruss_request_mem_region(struct pruss *pruss, enum pruss_mem mem_id, 66 struct pruss_mem_region *region); 67 int pruss_release_mem_region(struct pruss *pruss, 68 struct pruss_mem_region *region); 69 70 #else 71 72 static inline struct pruss *pruss_get(struct rproc *rproc) 73 { 74 return ERR_PTR(-EOPNOTSUPP); 75 } 76 77 static inline void pruss_put(struct pruss *pruss) { } 78 79 static inline int pruss_request_mem_region(struct pruss *pruss, 80 enum pruss_mem mem_id, 81 struct pruss_mem_region *region) 82 { 83 return -EOPNOTSUPP; 84 } 85 86 static inline int pruss_release_mem_region(struct pruss *pruss, 87 struct pruss_mem_region *region) 88 { 89 return -EOPNOTSUPP; 90 } 91 92 #endif /* CONFIG_TI_PRUSS */ 93 94 #endif /* _PRUSS_DRIVER_H_ */ 95