This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3d7d7732c05f263e2a2d0a9347b59e28b593d364 Author: Saravanan Sekar <[email protected]> AuthorDate: Mon Nov 23 13:36:59 2026 +0530 arch/tricore: Add the port registers to configure any pin. The TC3xx and TC4xx port headers only have what the UART pins need. Add the base address of a port by its number, the output modification and input registers, the port control codes and pad fields of a pin, and on TC4xx the access protection of the pad configuration. Signed-off-by: Saravanan Sekar <[email protected]> --- arch/tricore/src/tc3x/hardware/tc3x_port.h | 21 +++++++++++++++++ arch/tricore/src/tc4x/hardware/tc4x_port.h | 36 +++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/arch/tricore/src/tc3x/hardware/tc3x_port.h b/arch/tricore/src/tc3x/hardware/tc3x_port.h index 28988a92cdf..045175fba3b 100644 --- a/arch/tricore/src/tc3x/hardware/tc3x_port.h +++ b/arch/tricore/src/tc3x/hardware/tc3x_port.h @@ -27,6 +27,15 @@ * Pre-processor Definitions ****************************************************************************/ +/* Registers of port n */ + +#define TC3X_PORT_BASE(n) (0xf003a000 + (n) * 0x100) +#define TC3X_PORT_OMR_OFFSET 0x04 /* Output modification */ +#define TC3X_PORT_IN_OFFSET 0x24 /* Input */ + +#define TC3X_PORT_OMR_SET(n) (1 << (n)) +#define TC3X_PORT_OMR_CLR(n) (1 << ((n) + 16)) + /* Port registers: one IOCR byte per pin, one PDR nibble per pin. PDR is * protected by the CPU ENDINIT. */ @@ -43,6 +52,18 @@ #define TC3X_PORT_PDR_SHIFT(n) (((n) & 7) * 4) #define TC3X_PORT_PDR_MASK 0xf +/* Port control code of a pin, bits 7:3 of its IOCR byte */ + +#define TC3X_PORT_PC_SHIFT 3 +#define TC3X_PORT_PC_PULL_MASK 0x03 /* Input: 1 pull-down, 2 up */ +#define TC3X_PORT_PC_OUTPUT 0x10 /* Output, alternate 0 to 7 */ +#define TC3X_PORT_PC_OPENDRAIN 0x08 +#define TC3X_PORT_PC_ALT_MAX 7 + +/* Pad nibble of a pin: pad level in bits 3:2, pad driver in bits 1:0 */ + +#define TC3X_PORT_PDR_PL_SHIFT 2 + #define TC3X_PORT_IN_PULLUP 0x10 /* Input with pull-up */ #define TC3X_PORT_OUT_ALT2 0x90 /* Push-pull, alternate 2 */ #define TC3X_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ diff --git a/arch/tricore/src/tc4x/hardware/tc4x_port.h b/arch/tricore/src/tc4x/hardware/tc4x_port.h index 6268b3df8fc..ef69c6e604d 100644 --- a/arch/tricore/src/tc4x/hardware/tc4x_port.h +++ b/arch/tricore/src/tc4x/hardware/tc4x_port.h @@ -27,14 +27,38 @@ * Pre-processor Definitions ****************************************************************************/ +/* Registers of port n */ + +#define TC4X_PORT_BASE(n) (0xf003a000 + (n) * 0x400) +#define TC4X_PORT_IN_OFFSET 0x24 /* Input */ +#define TC4X_PORT_OMR_OFFSET 0x3c /* Output modification */ +#define TC4X_PORT_PROTE_OFFSET 0xac /* PROTE of group 0 */ +#define TC4X_PORT_PROTE(p) ((p) + TC4X_PORT_PROTE_OFFSET) + +#define TC4X_PORT_OMR_SET(n) (1 << (n)) +#define TC4X_PORT_OMR_CLR(n) (1 << ((n) + 16)) + +/* PROTE: the pad configuration can be written in any state but RUN */ + +#define TC4X_PORT_PROT_STATE_MASK 0x7 +#define TC4X_PORT_PROT_CONFIG 1 +#define TC4X_PORT_PROT_RUN 4 +#define TC4X_PORT_PROT_SWEN (1 << 3) /* STATE write enable */ + /* Port pad configuration: one DRVCFG register per pin */ -#define TC4X_PORT_DRVCFG(p, n) ((p) + 0x304 + (n) * 0x10) -#define TC4X_PORT_DRVCFG_MODE_MASK 0xf3 /* MODE, OD and DIR */ -#define TC4X_PORT_DRVCFG_PAD_MASK 0x7700 /* PD and PL */ +#define TC4X_PORT_DRVCFG(p, n) ((p) + 0x304 + (n) * 0x10) +#define TC4X_PORT_DRVCFG_MODE_MASK 0xf3 /* MODE, OD and DIR */ +#define TC4X_PORT_DRVCFG_PAD_MASK 0x7700 /* PD and PL */ + +#define TC4X_PORT_DRVCFG_DIR (1 << 0) /* Output */ +#define TC4X_PORT_DRVCFG_OD (1 << 1) /* Open drain */ +#define TC4X_PORT_DRVCFG_MODE_SHIFT 4 /* Alternate or pull */ +#define TC4X_PORT_DRVCFG_PD_SHIFT 8 /* Pad driver */ +#define TC4X_PORT_DRVCFG_PL_SHIFT 12 /* Pad level */ -#define TC4X_PORT_IN_PULLUP 0x20 /* Input with pull-up */ -#define TC4X_PORT_OUT_ALT2 0x21 /* Push-pull, alternate 2 */ -#define TC4X_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ +#define TC4X_PORT_IN_PULLUP 0x20 /* Input with pull-up */ +#define TC4X_PORT_OUT_ALT2 0x21 /* Push-pull, alternate 2 */ +#define TC4X_PORT_PAD_SPEED1 0 /* CMOS automotive speed 1 */ #endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_PORT_H */
