Skip to content

Commit 3d6a3d3

Browse files
Alain Volmatwsakernel
authored andcommitted
i2c: stm32f7: fix configuration of the digital filter
The digital filter related computation are present in the driver however the programming of the filter within the IP is missing. The maximum value for the DNF is wrong and should be 15 instead of 16. Fixes: aeb068c ("i2c: i2c-stm32f7: add driver") Signed-off-by: Alain Volmat <[email protected]> Signed-off-by: Pierre-Yves MORDRET <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 92bf226 commit 3d6a3d3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/i2c/busses/i2c-stm32f7.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
#define STM32F7_I2C_CR1_RXDMAEN BIT(15)
5858
#define STM32F7_I2C_CR1_TXDMAEN BIT(14)
5959
#define STM32F7_I2C_CR1_ANFOFF BIT(12)
60+
#define STM32F7_I2C_CR1_DNF_MASK GENMASK(11, 8)
61+
#define STM32F7_I2C_CR1_DNF(n) (((n) & 0xf) << 8)
6062
#define STM32F7_I2C_CR1_ERRIE BIT(7)
6163
#define STM32F7_I2C_CR1_TCIE BIT(6)
6264
#define STM32F7_I2C_CR1_STOPIE BIT(5)
@@ -160,7 +162,7 @@ enum {
160162
};
161163

162164
#define STM32F7_I2C_DNF_DEFAULT 0
163-
#define STM32F7_I2C_DNF_MAX 16
165+
#define STM32F7_I2C_DNF_MAX 15
164166

165167
#define STM32F7_I2C_ANALOG_FILTER_ENABLE 1
166168
#define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */
@@ -725,6 +727,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
725727
else
726728
stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
727729
STM32F7_I2C_CR1_ANFOFF);
730+
731+
/* Program the Digital Filter */
732+
stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
733+
STM32F7_I2C_CR1_DNF_MASK);
734+
stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
735+
STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
736+
728737
stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
729738
STM32F7_I2C_CR1_PE);
730739
}

0 commit comments

Comments
 (0)