xref: /linux/drivers/soc/ti/pruss.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * PRU-ICSS Subsystem user interfaces
4  *
5  * Copyright (C) 2015-2023 Texas Instruments Incorporated - http://www.ti.com
6  *	MD Danish Anwar <danishanwar@ti.com>
7  */
8 
9 #ifndef _SOC_TI_PRUSS_H_
10 #define _SOC_TI_PRUSS_H_
11 
12 #include <linux/bits.h>
13 #include <linux/regmap.h>
14 
15 /*
16  * PRU_ICSS_CFG registers
17  * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only
18  */
19 #define PRUSS_CFG_REVID         0x00
20 #define PRUSS_CFG_SYSCFG        0x04
21 #define PRUSS_CFG_GPCFG(x)      (0x08 + (x) * 4)
22 #define PRUSS_CFG_CGR           0x10
23 #define PRUSS_CFG_ISRP          0x14
24 #define PRUSS_CFG_ISP           0x18
25 #define PRUSS_CFG_IESP          0x1C
26 #define PRUSS_CFG_IECP          0x20
27 #define PRUSS_CFG_SCRP          0x24
28 #define PRUSS_CFG_PMAO          0x28
29 #define PRUSS_CFG_MII_RT        0x2C
30 #define PRUSS_CFG_IEPCLK        0x30
31 #define PRUSS_CFG_SPP           0x34
32 #define PRUSS_CFG_PIN_MX        0x40
33 
34 /* PRUSS_GPCFG register bits */
35 #define PRUSS_GPCFG_PRU_GPI_MODE_MASK           GENMASK(1, 0)
36 #define PRUSS_GPCFG_PRU_GPI_MODE_SHIFT          0
37 
38 #define PRUSS_GPCFG_PRU_MUX_SEL_SHIFT           26
39 #define PRUSS_GPCFG_PRU_MUX_SEL_MASK            GENMASK(29, 26)
40 
41 /* PRUSS_MII_RT register bits */
42 #define PRUSS_MII_RT_EVENT_EN                   BIT(0)
43 
44 /* PRUSS_SPP register bits */
45 #define PRUSS_SPP_XFER_SHIFT_EN                 BIT(1)
46 #define PRUSS_SPP_PRU1_PAD_HP_EN                BIT(0)
47 #define PRUSS_SPP_RTU_XFR_SHIFT_EN              BIT(3)
48 
49 /**
50  * pruss_cfg_read() - read a PRUSS CFG sub-module register
51  * @pruss: the pruss instance handle
52  * @reg: register offset within the CFG sub-module
53  * @val: pointer to return the value in
54  *
55  * Reads a given register within the PRUSS CFG sub-module and
56  * returns it through the passed-in @val pointer
57  *
58  * Return: 0 on success, or an error code otherwise
59  */
pruss_cfg_read(struct pruss * pruss,unsigned int reg,unsigned int * val)60 static int pruss_cfg_read(struct pruss *pruss, unsigned int reg, unsigned int *val)
61 {
62 	if (IS_ERR_OR_NULL(pruss))
63 		return -EINVAL;
64 
65 	return regmap_read(pruss->cfg_regmap, reg, val);
66 }
67 
68 /**
69  * pruss_cfg_update() - configure a PRUSS CFG sub-module register
70  * @pruss: the pruss instance handle
71  * @reg: register offset within the CFG sub-module
72  * @mask: bit mask to use for programming the @val
73  * @val: value to write
74  *
75  * Programs a given register within the PRUSS CFG sub-module
76  *
77  * Return: 0 on success, or an error code otherwise
78  */
pruss_cfg_update(struct pruss * pruss,unsigned int reg,unsigned int mask,unsigned int val)79 static int pruss_cfg_update(struct pruss *pruss, unsigned int reg,
80 			    unsigned int mask, unsigned int val)
81 {
82 	if (IS_ERR_OR_NULL(pruss))
83 		return -EINVAL;
84 
85 	return regmap_update_bits(pruss->cfg_regmap, reg, mask, val);
86 }
87 
88 #endif  /* _SOC_TI_PRUSS_H_ */
89