From 0da69efd079f50bf504de8ef1801c0ca25df782c Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 21 Jan 2026 23:49:59 +0200 Subject: [PATCH] bdk: pinmux: always detach I2C4 pins from I2C3 pm Generally I2C3 communication can work via I2C3 or I2C4 pins. Defaults are fine as long as one of the pin groups are floating or grounded or both share I2C traces. In NX boards I2C4 SDA is used for GC and connected to 1V8. So if a GC is slotted, I2C3 works, if not, no communication is possible. This config was done previously inside I2C3 consumer driver (touchscreen). Now it's moved inside pinmux_config_i2c. --- bdk/input/touch.c | 8 ++------ bdk/soc/pinmux.c | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bdk/input/touch.c b/bdk/input/touch.c index 2d6ef034..205089a2 100644 --- a/bdk/input/touch.c +++ b/bdk/input/touch.c @@ -2,7 +2,7 @@ * Touch driver for Nintendo Switch's STM FingerTip S (FTM4CD60DA1BE/FTM4CD50TA1BE) touch controller * * Copyright (c) 2018 langerhans - * Copyright (c) 2018-2023 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -367,6 +367,7 @@ int touch_execute_autotune() // Trim low power oscillator. if (touch_command(STMFTS_LP_TIMER_CALIB, NULL, 0)) return 0; + msleep(200); // Apply Mutual Sense Compensation tuning. @@ -401,11 +402,6 @@ static int touch_init() int touch_power_on() { - // Configure Touscreen and GCAsic shared GPIO. - PINMUX_AUX(PINMUX_AUX_CAM_I2C_SDA) = PINMUX_LPDR | PINMUX_INPUT_ENABLE | PINMUX_TRISTATE | PINMUX_PULL_UP | 2; - PINMUX_AUX(PINMUX_AUX_CAM_I2C_SCL) = PINMUX_IO_HV | PINMUX_LPDR | PINMUX_TRISTATE | PINMUX_PULL_DOWN | 2; // Unused. - gpio_config(GPIO_PORT_S, GPIO_PIN_3, GPIO_MODE_GPIO); // GC detect. - // Configure touchscreen Touch Reset pin. PINMUX_AUX(PINMUX_AUX_DAP4_SCLK) = PINMUX_PULL_DOWN | 1; gpio_direction_output(GPIO_PORT_J, GPIO_PIN_7, GPIO_LOW); diff --git a/bdk/soc/pinmux.c b/bdk/soc/pinmux.c index 84969c67..e11be09b 100644 --- a/bdk/soc/pinmux.c +++ b/bdk/soc/pinmux.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2024 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -30,6 +31,13 @@ void pinmux_config_i2c(u32 idx) { PINMUX_AUX(PINMUX_AUX_X_I2C_SCL(idx)) = PINMUX_INPUT_ENABLE; PINMUX_AUX(PINMUX_AUX_X_I2C_SDA(idx)) = PINMUX_INPUT_ENABLE; + + // Detach I2C4 pins from I2C3 function. + if (idx == I2C_3 || idx == I2C_4) + { + PINMUX_AUX(PINMUX_AUX_X_I2C_SCL(I2C_4)) |= 1; + PINMUX_AUX(PINMUX_AUX_X_I2C_SDA(I2C_4)) |= 1; + } } void pinmux_config_i2s(u32 idx)