Skip to content

Commit 98d750f

Browse files
John Allenjallen-amd
authored andcommitted
i2c: designware: add a new bit check for IC_CON control
JIRA: https://issues.redhat.com/browse/RHEL-78660 commit 60a1f9f Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jan 24 16:41:27 2023 +0530 i2c: designware: add a new bit check for IC_CON control On some AMD platforms, based on the new designware datasheet, BIOS sets the BIT(11) within the IC_CON register to advertise the "bus clear feature capability". AMD/Designware datasheet says: Bit(11) BUS_CLEAR_FEATURE_CTRL. Read-write,Volatile. Reset: 0. Description: In Master mode: - 1'b1: Bus Clear Feature is enabled. - 1'b0: Bus Clear Feature is Disabled. In Slave mode, this register bit is not applicable. On AMD platform designs: 1. BIOS programs the BUS_CLEAR_FEATURE_CTRL and enables the detection of SCL/SDA stuck low. 2. Whenever the stuck low is detected, the SMU FW shall do the bus recovery procedure. Currently, the way in which the "master_cfg" is built in the driver, it overrides the BUS_CLEAR_FEATURE_CTRL advertised by BIOS and the SMU FW cannot initiate the bus recovery if the stuck low is detected. Hence add a check in i2c_dw_probe_master() that if the BIOS advertises the bus clear feature, let driver not ignore it and adapt accordingly. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: John Allen <johnalle@redhat.com>
1 parent bad5fea commit 98d750f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define DW_IC_CON_STOP_DET_IFADDRESSED BIT(7)
3838
#define DW_IC_CON_TX_EMPTY_CTRL BIT(8)
3939
#define DW_IC_CON_RX_FIFO_FULL_HLD_CTRL BIT(9)
40+
#define DW_IC_CON_BUS_CLEAR_CTRL BIT(11)
4041

4142
#define DW_IC_DATA_CMD_DAT GENMASK(7, 0)
4243

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
874874
{
875875
struct i2c_adapter *adap = &dev->adapter;
876876
unsigned long irq_flags;
877+
unsigned int ic_con;
877878
int ret;
878879

879880
init_completion(&dev->cmd_complete);
@@ -894,6 +895,25 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
894895
if (ret)
895896
return ret;
896897

898+
/* Lock the bus for accessing DW_IC_CON */
899+
ret = i2c_dw_acquire_lock(dev);
900+
if (ret)
901+
return ret;
902+
903+
/*
904+
* On AMD platforms BIOS advertises the bus clear feature
905+
* and enables the SCL/SDA stuck low. SMU FW does the
906+
* bus recovery process. Driver should not ignore this BIOS
907+
* advertisement of bus clear feature.
908+
*/
909+
ret = regmap_read(dev->map, DW_IC_CON, &ic_con);
910+
i2c_dw_release_lock(dev);
911+
if (ret)
912+
return ret;
913+
914+
if (ic_con & DW_IC_CON_BUS_CLEAR_CTRL)
915+
dev->master_cfg |= DW_IC_CON_BUS_CLEAR_CTRL;
916+
897917
ret = dev->init(dev);
898918
if (ret)
899919
return ret;

0 commit comments

Comments
 (0)