Commit 83c3408f authored by Alain Volmat's avatar Alain Volmat Committed by Wolfram Sang

i2c: stm32f7: support DT binding i2c-analog-filter

Replace driver internally coded enabling/disabling of the
analog-filter with the DT binding "i2c-analog-filter".
Signed-off-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
Reviewed-by: default avatarPierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 1e28eed1
...@@ -164,7 +164,6 @@ enum { ...@@ -164,7 +164,6 @@ enum {
#define STM32F7_I2C_DNF_DEFAULT 0 #define STM32F7_I2C_DNF_DEFAULT 0
#define STM32F7_I2C_DNF_MAX 15 #define STM32F7_I2C_DNF_MAX 15
#define STM32F7_I2C_ANALOG_FILTER_ENABLE 1
#define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */ #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */
#define STM32F7_I2C_ANALOG_FILTER_DELAY_MAX 260 /* ns */ #define STM32F7_I2C_ANALOG_FILTER_DELAY_MAX 260 /* ns */
...@@ -224,7 +223,6 @@ struct stm32f7_i2c_spec { ...@@ -224,7 +223,6 @@ struct stm32f7_i2c_spec {
* @rise_time: Rise time (ns) * @rise_time: Rise time (ns)
* @fall_time: Fall time (ns) * @fall_time: Fall time (ns)
* @dnf: Digital filter coefficient (0-16) * @dnf: Digital filter coefficient (0-16)
* @analog_filter: Analog filter delay (On/Off)
* @fmp_clr_offset: Fast Mode Plus clear register offset from set register * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
*/ */
struct stm32f7_i2c_setup { struct stm32f7_i2c_setup {
...@@ -233,7 +231,6 @@ struct stm32f7_i2c_setup { ...@@ -233,7 +231,6 @@ struct stm32f7_i2c_setup {
u32 rise_time; u32 rise_time;
u32 fall_time; u32 fall_time;
u8 dnf; u8 dnf;
bool analog_filter;
u32 fmp_clr_offset; u32 fmp_clr_offset;
}; };
...@@ -312,6 +309,7 @@ struct stm32f7_i2c_msg { ...@@ -312,6 +309,7 @@ struct stm32f7_i2c_msg {
* @wakeup_src: boolean to know if the device is a wakeup source * @wakeup_src: boolean to know if the device is a wakeup source
* @smbus_mode: states that the controller is configured in SMBus mode * @smbus_mode: states that the controller is configured in SMBus mode
* @host_notify_client: SMBus host-notify client * @host_notify_client: SMBus host-notify client
* @analog_filter: boolean to indicate enabling of the analog filter
*/ */
struct stm32f7_i2c_dev { struct stm32f7_i2c_dev {
struct i2c_adapter adap; struct i2c_adapter adap;
...@@ -340,6 +338,7 @@ struct stm32f7_i2c_dev { ...@@ -340,6 +338,7 @@ struct stm32f7_i2c_dev {
bool wakeup_src; bool wakeup_src;
bool smbus_mode; bool smbus_mode;
struct i2c_client *host_notify_client; struct i2c_client *host_notify_client;
bool analog_filter;
}; };
/* /*
...@@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = { ...@@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = {
.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT, .rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT, .fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
.dnf = STM32F7_I2C_DNF_DEFAULT, .dnf = STM32F7_I2C_DNF_DEFAULT,
.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
}; };
static const struct stm32f7_i2c_setup stm32mp15_setup = { static const struct stm32f7_i2c_setup stm32mp15_setup = {
.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT, .rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT, .fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
.dnf = STM32F7_I2C_DNF_DEFAULT, .dnf = STM32F7_I2C_DNF_DEFAULT,
.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
.fmp_clr_offset = 0x40, .fmp_clr_offset = 0x40,
}; };
...@@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev, ...@@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
/* Analog and Digital Filters */ /* Analog and Digital Filters */
af_delay_min = af_delay_min =
(setup->analog_filter ? (i2c_dev->analog_filter ?
STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0); STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0);
af_delay_max = af_delay_max =
(setup->analog_filter ? (i2c_dev->analog_filter ?
STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0); STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
dnf_delay = setup->dnf * i2cclk; dnf_delay = setup->dnf * i2cclk;
...@@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, ...@@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
return ret; return ret;
} }
i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
"i2c-analog-filter");
dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n", dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
setup->speed_freq, setup->clock_src); setup->speed_freq, setup->clock_src);
dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n", dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
setup->rise_time, setup->fall_time); setup->rise_time, setup->fall_time);
dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n", dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
(setup->analog_filter ? "On" : "Off"), setup->dnf); (i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
i2c_dev->bus_rate = setup->speed_freq; i2c_dev->bus_rate = setup->speed_freq;
...@@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev) ...@@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll); timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll);
writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR); writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR);
/* Enable I2C */ /* Configure the Analog Filter */
if (i2c_dev->setup.analog_filter) if (i2c_dev->analog_filter)
stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
STM32F7_I2C_CR1_ANFOFF); STM32F7_I2C_CR1_ANFOFF);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment