Received: by 10.223.185.116 with SMTP id b49csp4193222wrg; Mon, 26 Feb 2018 12:56:58 -0800 (PST) X-Google-Smtp-Source: AH8x226aReaA4k0rg85vMOG+SJ3vxhlYIo5KgvjzFjPEvw/qu4NjiOyA3V1a8FvyFSs7SKKN5QIl X-Received: by 2002:a17:902:7786:: with SMTP id o6-v6mr11583399pll.2.1519678618526; Mon, 26 Feb 2018 12:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519678618; cv=none; d=google.com; s=arc-20160816; b=P+fG6OUojl67WJqCbxvbuFQUe6TBuVZiu/cCjggqYVZ0hd7f2cssaN9vNx6xeCEdp5 0dSrYBWLq6DJjAwcSPoyDNEpkreJm6t0wVcKqtAg0kn5FKsw6Tivo7zf3oz7wM2toJJD QDjNUVS/zjVdfQQtmQLG8Ai+lULssXNJfeG754yec2i8dBXg0oxHH0ThCz3/dHpC+ru8 snREypWIE+FJIl6yILLoKdPMzMFqRirVA40fyvArquxxt2+1kQCatUWZXI8epQcy5M4w bJO2FEJo6of/OBT3kP0+jwSbjIDNBNKoxvEx+5nbnW0KPk3x1InOCV5KyYeAei7Haw2y wxBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e+f2tTjUdMXnxnXiJ73cHw9d6mh2AKnQzyxMuUho88k=; b=fztWgRQFDntETGMj630fUaXNCr+UdJ1ySqIMMGcJBfLUqFqSwXwblYmp31q6Z2FMSK 6EIWGb3j5iYZv9je+08gaZZDXB13FcU3+IvACM6C9tChzlQobBn+o/fkUidfsAQDQgqx ryEKxu5Nusu0QYxNzAOup++fbFFm7KzT7KuW+0YuU64t3/0ayVud4YWTFJd8id0eBGP/ exGTW7gAx3jyuhR5ICyCpUESbIVzrK1A9xYxKjhDciLdt0hXo4Hamgr9HgmjAKVyIyZx XJocX5hyx+mZF75sITQfbwOlEVrvneFZIQQM3CFNYlDa1XZhQ4XV/wN0rA5Y+e/CdSWP ZFyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b63-v6si2250926plb.12.2018.02.26.12.56.42; Mon, 26 Feb 2018 12:56:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752639AbeBZUXU (ORCPT + 99 others); Mon, 26 Feb 2018 15:23:20 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34724 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233AbeBZUXQ (ORCPT ); Mon, 26 Feb 2018 15:23:16 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AD6B2E83; Mon, 26 Feb 2018 20:23:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Anholt , Boris Brezillon , Wolfram Sang , stable@kernel.org Subject: [PATCH 4.14 10/54] i2c: bcm2835: Set up the rising/falling edge delays Date: Mon, 26 Feb 2018 21:21:47 +0100 Message-Id: <20180226202144.869715000@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Anholt commit fe32a815f05c8568669a062587435e15f9345764 upstream. We were leaving them in the power on state (or the state the firmware had set up for some client, if we were taking over from them). The boot state was 30 core clocks, when we actually want to sample some time after (to make sure that the new input bit has actually arrived). Signed-off-by: Eric Anholt Signed-off-by: Boris Brezillon Signed-off-by: Wolfram Sang Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -50,6 +50,9 @@ #define BCM2835_I2C_S_CLKT BIT(9) #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */ +#define BCM2835_I2C_FEDL_SHIFT 16 +#define BCM2835_I2C_REDL_SHIFT 0 + #define BCM2835_I2C_CDIV_MIN 0x0002 #define BCM2835_I2C_CDIV_MAX 0xFFFE @@ -81,7 +84,7 @@ static inline u32 bcm2835_i2c_readl(stru static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev) { - u32 divider; + u32 divider, redl, fedl; divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk), i2c_dev->bus_clk_rate); @@ -100,6 +103,22 @@ static int bcm2835_i2c_set_divider(struc bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider); + /* + * Number of core clocks to wait after falling edge before + * outputting the next data bit. Note that both FEDL and REDL + * can't be greater than CDIV/2. + */ + fedl = max(divider / 16, 1u); + + /* + * Number of core clocks to wait after rising edge before + * sampling the next incoming data bit. + */ + redl = max(divider / 4, 1u); + + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DEL, + (fedl << BCM2835_I2C_FEDL_SHIFT) | + (redl << BCM2835_I2C_REDL_SHIFT)); return 0; }