From b7cdc545105d113ea13ab860167b44d38a3ced16 Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Thu, 8 May 2025 15:42:21 +0800 Subject: [PATCH 1/4] downstream: Add gpio-hisi softdepend Add gpio-hisi for module soft depend to ensure gpio driver is loaded fist and I2C driver can obtain bus recovery gpio pin resources. Fixes: bdc031294c4d ("i2c: hisi: Add gpio bus recovery support") Signed-off-by: Devyn Liu Signed-off-by: lujunhua Signed-off-by: Yanze Liu --- drivers/i2c/busses/i2c-hisi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-hisi.c b/drivers/i2c/busses/i2c-hisi.c index e13e4b3f59f91..2d5892066a704 100644 --- a/drivers/i2c/busses/i2c-hisi.c +++ b/drivers/i2c/busses/i2c-hisi.c @@ -613,3 +613,4 @@ module_platform_driver(hisi_i2c_driver); MODULE_AUTHOR("Yicong Yang "); MODULE_DESCRIPTION("HiSilicon I2C Controller Driver"); MODULE_LICENSE("GPL"); +MODULE_SOFTDEP("pre: gpio-hisi"); From 4ccf65c8fd6768dc8b10b4d1d9b2166c82afe7b6 Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Thu, 28 Mar 2024 18:55:52 +0800 Subject: [PATCH 2/4] downstream: i2c: hisi: Add I2C controller reset and initialization proccess in bus recovery action The I2C controller hardware manual specifies the bus recovery operation for I2C. It is recommended to reset the I2C controller and reinitialize the I2C bus configuration in bus recovery operation, which can more effectively ensure the recovery of the I2C bus. So we add I2C controller reset and initialization proccess in bus recovery action. Signed-off-by: Devyn Liu Signed-off-by: Junhua Lu Signed-off-by: Yanze Liu --- drivers/i2c/busses/i2c-hisi.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-hisi.c b/drivers/i2c/busses/i2c-hisi.c index 2d5892066a704..24672f425e13c 100644 --- a/drivers/i2c/busses/i2c-hisi.c +++ b/drivers/i2c/busses/i2c-hisi.c @@ -461,6 +461,26 @@ static void hisi_i2c_configure_bus(struct hisi_i2c_controller *ctlr) #ifdef CONFIG_ACPI #define HISI_I2C_PIN_MUX_METHOD "PMUX" +#define HISI_I2C_SOFT_RESET_METHOD "SRST" + +/** + * i2c_hisi_soft_reset - Do I2C master soft reset method through ACPI + * @dev: device need to be reset + * + * The function invokes the specific ACPI method "SRST" for trigger a soft + * reset of I2C controller in order to help on I2C controller recover from + * the abnormal state after bus recovery process. + */ +static void i2c_hisi_soft_reset(struct device *dev) +{ + acpi_handle handle = ACPI_HANDLE(dev); + acpi_status status; + unsigned long long data; + + status = acpi_evaluate_integer(handle, HISI_I2C_SOFT_RESET_METHOD, NULL, &data); + dev_info(dev, "I2C controller reset %s", ACPI_FAILURE(status) ? "failed" : + "succeed"); +} /** * i2c_dw_acpi_pin_mux_change - Change the I2C controller's pin mux through ACPI @@ -498,6 +518,13 @@ static void i2c_hisi_unprepare_recovery(struct i2c_adapter *adap) struct hisi_i2c_controller *ctlr = i2c_get_adapdata(adap); i2c_hisi_pin_mux_change(ctlr->dev, false); + i2c_hisi_soft_reset(ctlr->dev); + + /* + * After a soft reset, the device configuration return to default + * values and require reinitialization. + */ + hisi_i2c_configure_bus(ctlr); } static void hisi_i2c_init_recovery_info(struct hisi_i2c_controller *ctlr) @@ -509,7 +536,8 @@ static void hisi_i2c_init_recovery_info(struct hisi_i2c_controller *ctlr) if (acpi_disabled) return; - if (!adev || !acpi_has_method(adev->handle, HISI_I2C_PIN_MUX_METHOD)) + if (!adev || !acpi_has_method(adev->handle, HISI_I2C_PIN_MUX_METHOD) || + !acpi_has_method(adev->handle, HISI_I2C_SOFT_RESET_METHOD)) return; gpio = devm_gpiod_get_optional(ctlr->dev, "scl", GPIOD_OUT_HIGH); From c15bfb9684c93174295085de61ad3602d0602a21 Mon Sep 17 00:00:00 2001 From: Devyn Liu Date: Sun, 28 Apr 2024 18:35:06 +0800 Subject: [PATCH 3/4] downstream: i2c: hisi: Correct the description comment for PIN_MUX METHOD Correct the description comment for PIN_MUX METHOD and rename it to hisi instead of dw. Signed-off-by: Devyn Liu Signed-off-by: Junhua Lu Signed-off-by: Yanze Liu --- drivers/i2c/busses/i2c-hisi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-hisi.c b/drivers/i2c/busses/i2c-hisi.c index 24672f425e13c..b5a659b8b0a12 100644 --- a/drivers/i2c/busses/i2c-hisi.c +++ b/drivers/i2c/busses/i2c-hisi.c @@ -483,7 +483,7 @@ static void i2c_hisi_soft_reset(struct device *dev) } /** - * i2c_dw_acpi_pin_mux_change - Change the I2C controller's pin mux through ACPI + * i2c_hisi_pin_mux_change - Change the I2C controller's pin mux through ACPI * @dev: device owns the SCL/SDA pin * @to_gpio: true to switch to GPIO, false to switch to SCL/SDA * From 7b8f41856ac2afe27eba00f935fa394ad2d0a143 Mon Sep 17 00:00:00 2001 From: hbmm Date: Fri, 11 Jul 2025 17:07:22 +0800 Subject: [PATCH 4/4] I2C: fix the CONFIG_I2C_HISI configuration not work config.aarch64 and config.aarch64-64k, these two files previously had incorrect parameters configured, and this modification is intended to resolve the issue. Signed-off-by: Yanze Liu --- config.aarch64 | 1 - config.aarch64-64k | 1 - 2 files changed, 2 deletions(-) diff --git a/config.aarch64 b/config.aarch64 index 3bb003a14a964..c055a230a51ae 100644 --- a/config.aarch64 +++ b/config.aarch64 @@ -4179,7 +4179,6 @@ CONFIG_I2C_DESIGNWARE_PLATFORM=m CONFIG_I2C_GPIO=m # CONFIG_I2C_GPIO_FAULT_INJECTOR is not set CONFIG_I2C_HISI=m -# CONFIG_I2C_HISI is not set CONFIG_I2C_MESON=m CONFIG_I2C_MV64XXX=m # CONFIG_I2C_NOMADIK is not set diff --git a/config.aarch64-64k b/config.aarch64-64k index 5cce0103e23f9..ae0503084d9a6 100644 --- a/config.aarch64-64k +++ b/config.aarch64-64k @@ -4177,7 +4177,6 @@ CONFIG_I2C_DESIGNWARE_PLATFORM=m CONFIG_I2C_GPIO=m # CONFIG_I2C_GPIO_FAULT_INJECTOR is not set CONFIG_I2C_HISI=m -# CONFIG_I2C_HISI is not set CONFIG_I2C_MESON=m CONFIG_I2C_MV64XXX=m # CONFIG_I2C_NOMADIK is not set