Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1779443pxb; Fri, 5 Feb 2021 00:54:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJySJVgFBusNNyz+LVkiiP8rAqKAyOqrP99z8KGYluzC5lW9erZI2xci3O1mFMYZkcLblUDa X-Received: by 2002:a17:906:555:: with SMTP id k21mr3079571eja.148.1612515286612; Fri, 05 Feb 2021 00:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612515286; cv=none; d=google.com; s=arc-20160816; b=DeFyGyvYZ1HmE7VsVurXg3GzrsKqpmWTjhTtFeFfv9qx73X7K7Pcsfd94GRGMUfYqH cBwYpTF27OS1eKd5sapu0NIj5Cw2oibegVqTN5hraJgbj07qkHW8AmV3fqBIlw8txvJP C54mI116/NKzMNpuJLQZMPGW7wlZUwlmsfi9vrRT7RagdOqAt/5OTKI9SSExu9DrB06t jq+9CNnqtGgzaiztDiCBzllQsDKnP3jb/PDvuWkbuJCHkmFATfQwQ8uhnjLxYjyIFcTr PQx6SCOPonRInX9X2I6MXAm/8U8L9qLJEo14Ic8I6NmWDCstC2IGoi4nUkV6vNjmO+hM XX4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4sjVcBAIu91kgQQb9qupZQJrGYub/iUnq2yqTtTWMWQ=; b=Gyio6H9TgZNL3Qgvi0WgCtK8oHS1fBTwGDBHk0QPpWEA9DCC/6s/1C9e9ApHiz4CTq u/zggJFKZFvxOx1pJJgxfaFL5zpPy7SItof08d0OrCWJYioMyxgdbsI2Ekj8UBL83IjO PcxJ01VYQ891f4cHomCpEE/2AhRa6C79aqyZN14etcwJavvUsyOeC01MP7bIis4OfG93 DyroKmWmdhwKSKsozMlVcK9VlW7aGew/rHkWiGWbbRYU4xaxZhFHxF2NlijjqZNaLUU0 k+vQWJCMSNZkaS3q8tVD7SUWyDbdXy3ogzNBYofCfoPB5v4L4PElhnEApXYTu3EJjLGK pWsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=Q4TW0sco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si4842125edu.474.2021.02.05.00.54.21; Fri, 05 Feb 2021 00:54:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=Q4TW0sco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbhBEIxG (ORCPT + 99 others); Fri, 5 Feb 2021 03:53:06 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14304 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229508AbhBEIxD (ORCPT ); Fri, 5 Feb 2021 03:53:03 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1158l0lb007605; Fri, 5 Feb 2021 09:52:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=4sjVcBAIu91kgQQb9qupZQJrGYub/iUnq2yqTtTWMWQ=; b=Q4TW0scoETZOrOYSNw0uI0QK1tb5xie9JqPnEcwBDHtTcQkfXUyf7RYYLBDI8J9fUWTX DV3whN9VjVqwxFWJCvo/AjvJJQ5l/p8fZNV/mJkq5eSE/Ff3Rd9nyLmHGchCnzJ4yEvX oVfDQPnIqSvZo26TIhU0krhUzQxepI9xAxwgP77upiVNcNRVrpq5JrQZ8MmFt6T0LDwr qtTkkcMkqrkUtBIuihPJ3cFmuLIL5f/8yw0A45Rm/f3ni4Q4ZGmF5ndzXDE7q/N/zze7 SihvTaBA10wQsGJUAfl7Ddp8qXFLd8GRVTCtQap7Tvkkf4cbk1qEzOhp36gO5RfFGJnB Kw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36d0nse4kg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Feb 2021 09:52:07 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D4B09100038; Fri, 5 Feb 2021 09:52:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C794D221793; Fri, 5 Feb 2021 09:52:06 +0100 (CET) Received: from localhost (10.75.127.44) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 5 Feb 2021 09:52:06 +0100 From: Alain Volmat To: , CC: , , , , , , , , , , Subject: [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter Date: Fri, 5 Feb 2021 09:51:41 +0100 Message-ID: <1612515104-838-3-git-send-email-alain.volmat@foss.st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612515104-838-1-git-send-email-alain.volmat@foss.st.com> References: <1612515104-838-1-git-send-email-alain.volmat@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-05_06:2021-02-05,2021-02-05 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace driver internally coded enabling/disabling of the analog-filter with the DT binding "i2c-analog-filter". Signed-off-by: Alain Volmat --- drivers/i2c/busses/i2c-stm32f7.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index 473fbe144b7e..0c539fea2754 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -164,7 +164,6 @@ enum { #define STM32F7_I2C_DNF_DEFAULT 0 #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_MAX 260 /* ns */ @@ -224,7 +223,6 @@ struct stm32f7_i2c_spec { * @rise_time: Rise time (ns) * @fall_time: Fall time (ns) * @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 */ struct stm32f7_i2c_setup { @@ -233,7 +231,6 @@ struct stm32f7_i2c_setup { u32 rise_time; u32 fall_time; u8 dnf; - bool analog_filter; u32 fmp_clr_offset; }; @@ -312,6 +309,7 @@ struct stm32f7_i2c_msg { * @wakeup_src: boolean to know if the device is a wakeup source * @smbus_mode: states that the controller is configured in SMBus mode * @host_notify_client: SMBus host-notify client + * @analog_filter: boolean to indicate enabling of the analog filter */ struct stm32f7_i2c_dev { struct i2c_adapter adap; @@ -340,6 +338,7 @@ struct stm32f7_i2c_dev { bool wakeup_src; bool smbus_mode; struct i2c_client *host_notify_client; + bool analog_filter; }; /* @@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = { .rise_time = STM32F7_I2C_RISE_TIME_DEFAULT, .fall_time = STM32F7_I2C_FALL_TIME_DEFAULT, .dnf = STM32F7_I2C_DNF_DEFAULT, - .analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE, }; static const struct stm32f7_i2c_setup stm32mp15_setup = { .rise_time = STM32F7_I2C_RISE_TIME_DEFAULT, .fall_time = STM32F7_I2C_FALL_TIME_DEFAULT, .dnf = STM32F7_I2C_DNF_DEFAULT, - .analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE, .fmp_clr_offset = 0x40, }; @@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev, /* Analog and Digital Filters */ af_delay_min = - (setup->analog_filter ? + (i2c_dev->analog_filter ? STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0); af_delay_max = - (setup->analog_filter ? + (i2c_dev->analog_filter ? STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0); dnf_delay = setup->dnf * i2cclk; @@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, 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", setup->speed_freq, setup->clock_src); dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n", setup->rise_time, setup->fall_time); 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; @@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev) timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll); writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR); - /* Enable I2C */ - if (i2c_dev->setup.analog_filter) + /* Configure the Analog Filter */ + if (i2c_dev->analog_filter) stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, STM32F7_I2C_CR1_ANFOFF); else -- 2.17.1