From 620edc1ba3e18c900580f642f5d26f62f729812c Mon Sep 17 00:00:00 2001 From: diijkstra <16804536+diijkstra@users.noreply.github.com> Date: Sun, 1 Feb 2026 13:34:29 +0100 Subject: [PATCH] Initialize GPIOs with PIN defines + Support in MUX setup (not used thou) --- machine.c | 7 +++++-- rtl837x_pins.c | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/machine.c b/machine.c index 8660bda..84f1d2c 100644 --- a/machine.c +++ b/machine.c @@ -21,7 +21,7 @@ __code const struct machine machine = { .sfp_port[1].pin_tx_disable = GPIO_NA, .sfp_port[1].sds = 0, .sfp_port[1].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 }, - .reset_pin = 46, + .reset_pin = GPIO46_I2C_SCL0, }; #elif defined MACHINE_KP_9000_6XH_X __code const struct machine machine = { @@ -38,6 +38,7 @@ __code const struct machine machine = { .sfp_port[0].pin_tx_disable = GPIO_NA, .sfp_port[0].sds = 1, .sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 }, + .reset_pin = GPIO_NA, }; #elif defined MACHINE_KP_9000_9XH_X_EU __code const struct machine machine = { @@ -54,6 +55,7 @@ __code const struct machine machine = { .sfp_port[0].pin_tx_disable = GPIO_NA, .sfp_port[0].sds = 1, .sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 }, + .reset_pin = GPIO_NA, }; #elif defined MACHINE_SWGT024_V2_0 @@ -78,7 +80,7 @@ __code const struct machine machine = { .sfp_port[1].pin_tx_disable = GPIO_NA, .sfp_port[1].sds = 0, .sfp_port[1].i2c = { .sda = GPIO41_I2C_SDA3_MDIO1, .scl = GPIO40_I2C_SCL3_MDC1 }, /* GPIO 40 */ - .reset_pin = 36, + .reset_pin = GPIO36_PWM_OUT, }; #elif defined DEFAULT_8C_1SFP @@ -96,5 +98,6 @@ __code const struct machine machine = { .sfp_port[0].pin_tx_disable = GPIO_NA, .sfp_port[0].sds = 1, .sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 }, + .reset_pin = GPIO_NA, }; #endif diff --git a/rtl837x_pins.c b/rtl837x_pins.c index 83a9adb..a6cbe06 100644 --- a/rtl837x_pins.c +++ b/rtl837x_pins.c @@ -60,8 +60,16 @@ static void gpio_mux_setup(uint8_t pin) reg_bit_set(RTL837X_PIN_MUX_1, 30); break; case GPIO37: + case GPIO38: // Intentionally empty, always GPIO break; + case GPIO46_I2C_SCL0: + // Bit 7-8 0b00 -> GPIO + reg_read_m(RTL837X_PIN_MUX_1); + sfr_mask_data(0, 0x80, 0x00); + sfr_mask_data(1, 0x01, 0x00); + reg_write_m(RTL837X_PIN_MUX_1); + break; case GPIO50_I2C_SCL2_UART1_TX: // Bit 15-16 0b00 -> GPIO reg_read_m(RTL837X_PIN_MUX_1);