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 cf18bc6d29d36b9bf5b1ded3582b65da00a3cd03
Author: Saravanan Sekar <[email protected]>
AuthorDate: Mon Nov 23 13:36:59 2026 +0530

    arch/tricore: Set up the UART pins with the GPIO interface.
    
    Describe the UART0 pins as pin sets in the chip header and configure
    them with tricore_gpio_config, and drop the pin code of the UART driver
    and the port definitions that only it used.  The port registers after
    boot are the same as before.
    
    Signed-off-by: Saravanan Sekar <[email protected]>
---
 arch/tricore/src/common/aurix/tricore_serial.c | 38 ++------------------------
 arch/tricore/src/tc3x/chip.h                   | 12 +++++---
 arch/tricore/src/tc3x/hardware/tc3x_port.h     |  4 ---
 arch/tricore/src/tc4x/chip.h                   | 12 +++++---
 arch/tricore/src/tc4x/hardware/tc4x_port.h     |  4 ---
 5 files changed, 19 insertions(+), 51 deletions(-)

diff --git a/arch/tricore/src/common/aurix/tricore_serial.c 
b/arch/tricore/src/common/aurix/tricore_serial.c
index e446c550982..f6ca821d0b4 100644
--- a/arch/tricore/src/common/aurix/tricore_serial.c
+++ b/arch/tricore/src/common/aurix/tricore_serial.c
@@ -43,6 +43,7 @@
 
 #include "tricore_internal.h"
 #include "tricore_asclin.h"
+#include "tricore_gpio.h"
 
 #if defined(CONFIG_ARCH_CHIP_TC3X)
 #  include "hardware/tc3x_port.h"
@@ -221,39 +222,6 @@ static void asclin_modify(uintptr_t reg, uint32_t clear, 
uint32_t set)
   putreg32((getreg32(reg) & ~clear) | set, reg);
 }
 
-/****************************************************************************
- * Name: asclin_pin_config
- *
- * Description:
- *   Set up a UART pin: RX as input with pull-up, TX as push-pull alternate
- *   output 2, both with the speed 1 pad driver.  On TC3xx the mode is in
- *   IOCR and the pad driver in PDR, under the CPU ENDINIT; on TC4xx both
- *   are in the PADCFG DRVCFG register of the pin.
- *
- ****************************************************************************/
-
-static void asclin_pin_config(uintptr_t port, int pin, bool tx)
-{
-#if defined(CONFIG_ARCH_CHIP_TC3X)
-  int shift = TC3X_PORT_IOCR_SHIFT(pin);
-
-  asclin_modify(TC3X_PORT_IOCR(port, pin), TC3X_PORT_IOCR_MASK << shift,
-                (tx ? TC3X_PORT_OUT_ALT2 : TC3X_PORT_IN_PULLUP) << shift);
-
-  shift = TC3X_PORT_PDR_SHIFT(pin);
-  tc3x_wdt_cpu_endinit(false);
-  asclin_modify(TC3X_PORT_PDR(port, pin), TC3X_PORT_PDR_MASK << shift,
-                TC3X_PORT_PAD_SPEED1 << shift);
-  tc3x_wdt_cpu_endinit(true);
-#elif defined(CONFIG_ARCH_CHIP_TC4X)
-  uintptr_t drvcfg = TC4X_PORT_DRVCFG(port, pin);
-
-  asclin_modify(drvcfg, TC4X_PORT_DRVCFG_MODE_MASK,
-                tx ? TC4X_PORT_OUT_ALT2 : TC4X_PORT_IN_PULLUP);
-  asclin_modify(drvcfg, TC4X_PORT_DRVCFG_PAD_MASK, TC4X_PORT_PAD_SPEED1);
-#endif
-}
-
 /****************************************************************************
  * Name: asclin_set_clock
  *
@@ -391,9 +359,9 @@ static void asclin_init(struct up_dev_s *priv)
 
   /* Pins, RX on input A */
 
-  asclin_pin_config(UART_PIN_PORT, UART_PIN_RX, false);
+  tricore_gpio_config(UART0_PIN_RX);
   asclin_modify(ASCLIN_REG(priv, IOCR), ASCLIN_IOCR_ALTI_MASK, 0);
-  asclin_pin_config(UART_PIN_PORT, UART_PIN_TX, true);
+  tricore_gpio_config(UART0_PIN_TX);
 
   /* Clock on, error flags enabled, FIFOs enabled and flushed */
 
diff --git a/arch/tricore/src/tc3x/chip.h b/arch/tricore/src/tc3x/chip.h
index 45c75ba6378..7b54c90e5a2 100644
--- a/arch/tricore/src/tc3x/chip.h
+++ b/arch/tricore/src/tc3x/chip.h
@@ -28,12 +28,16 @@
  ****************************************************************************/
 
 #include "hardware/tc3x_cpu.h"
+#include "aurix/tricore_gpio.h"
 
-/* UART0 pins: ASCLIN0 RXA on P14.1, TX on P14.0 (alternate output 2) */
+/* UART0 pins: ASCLIN0 RXA on P14.1 with pull-up, TX on P14.0 as alternate
+ * output 2
+ */
 
-#define UART_PIN_PORT              0xf003ae00  /* P14 */
-#define UART_PIN_RX                1
-#define UART_PIN_TX                0
+#define UART0_PIN_RX               (GPIO_PORT(14) | GPIO_PIN(1) | \
+                                    GPIO_INPUT | GPIO_PULLUP)
+#define UART0_PIN_TX               (GPIO_PORT(14) | GPIO_PIN(0) | \
+                                    GPIO_OUTPUT | GPIO_ALT(2))
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/arch/tricore/src/tc3x/hardware/tc3x_port.h 
b/arch/tricore/src/tc3x/hardware/tc3x_port.h
index 045175fba3b..3455f7641d0 100644
--- a/arch/tricore/src/tc3x/hardware/tc3x_port.h
+++ b/arch/tricore/src/tc3x/hardware/tc3x_port.h
@@ -64,8 +64,4 @@
 
 #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 */
-
 #endif /* __ARCH_TRICORE_SRC_TC3X_HARDWARE_TC3X_PORT_H */
diff --git a/arch/tricore/src/tc4x/chip.h b/arch/tricore/src/tc4x/chip.h
index 9335eac4d1b..9ff02275872 100644
--- a/arch/tricore/src/tc4x/chip.h
+++ b/arch/tricore/src/tc4x/chip.h
@@ -28,12 +28,16 @@
  ****************************************************************************/
 
 #include "hardware/tc4x_cpu.h"
+#include "aurix/tricore_gpio.h"
 
-/* UART0 pins: ASCLIN0 RXA on P14.1, TX on P14.0 (alternate output 2) */
+/* UART0 pins: ASCLIN0 RXA on P14.1 with pull-up, TX on P14.0 as alternate
+ * output 2
+ */
 
-#define UART_PIN_PORT              0xf003d800  /* P14 */
-#define UART_PIN_RX                1
-#define UART_PIN_TX                0
+#define UART0_PIN_RX               (GPIO_PORT(14) | GPIO_PIN(1) | \
+                                    GPIO_INPUT | GPIO_PULLUP)
+#define UART0_PIN_TX               (GPIO_PORT(14) | GPIO_PIN(0) | \
+                                    GPIO_OUTPUT | GPIO_ALT(2))
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/arch/tricore/src/tc4x/hardware/tc4x_port.h 
b/arch/tricore/src/tc4x/hardware/tc4x_port.h
index ef69c6e604d..796305beb35 100644
--- a/arch/tricore/src/tc4x/hardware/tc4x_port.h
+++ b/arch/tricore/src/tc4x/hardware/tc4x_port.h
@@ -57,8 +57,4 @@
 #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 */
-
 #endif /* __ARCH_TRICORE_SRC_TC4X_HARDWARE_TC4X_PORT_H */

Reply via email to