Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4341280pxu; Mon, 12 Oct 2020 16:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDTBZ+9Qq6A555Xa5wHBG/46crcgLHjDOSm7DRoCdj9dKrpJWyfrwsQTx0smOOTbGm2k6J X-Received: by 2002:aa7:cd42:: with SMTP id v2mr11744422edw.151.1602546686266; Mon, 12 Oct 2020 16:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546686; cv=none; d=google.com; s=arc-20160816; b=h2uVJD00zdvyXMuhpg/bu9ThZK9xa8sdeQ7SE3ooCq/vz7bceVkuZ+Vntrugw0tVl2 ZHreRDYmRcgucQbvFXF+Dn7FTnAVNhLr7nOmQxngFUoL3qJ7XZsawoWLe3kUXGDCEGBD yqyDAE/toWoOZS0oIaJycu1A2R/ckcCuLIe1H/1g+GzyiectnS4RPFgin4rY5UsObeWh 5byxsH4IugNQeqPt+ngqKhZeI6/7XJDY5vb8yLyMmEqzkifuUpM4zX2G/cllOZ3NrSGV TAc0d1zx3nqvoplm1zDBfbIZBfTliTlGYkkqg+aUqOkHl2HQXKOA/ssymdVGmsT7DJna S36w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=peyx7vD+QAJiW41r6BzPMvh874oFzDi5nZXIBiwmF9U=; b=j7xzf7AniSalYKDYKuMQETR00oGszixPMGqfdI/zR4uUvyY0RqnbPTXVn9qAlD8ino N/IdqvL0ThSac8qAlGe8YpoxDDHH/Gws9IXTspYXS4/ymOEXjyedhQ0tQSXTc9C+RWdF 8Sib31ChemtGI21sOhcsZgtnFvCeSBBIJNirtsCj2M8vPjPXoJFeRy0hcTOxjUjaT9ch gvRfcfr2eMykKeqcXAY7ao/+VkQBRnOASMv8LuetiXnJ4VcF9Is7ecFibwcZoQXbzatW r8CybCkk62MgHyiiD94ivadDwXYRhYgDbjdgy15YR9PUSAnlF5JbzlqCdi/dkT/L42hJ rSBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KKk6d7NJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si4609933edw.9.2020.10.12.16.51.03; Mon, 12 Oct 2020 16:51:26 -0700 (PDT) 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=@kernel.org header.s=default header.b=KKk6d7NJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389619AbgJLNpN (ORCPT + 99 others); Mon, 12 Oct 2020 09:45:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:46224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731502AbgJLNmD (ORCPT ); Mon, 12 Oct 2020 09:42:03 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6586C2076E; Mon, 12 Oct 2020 13:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510103; bh=wWPstj76VCjHe5UD4+nvWxKDxs8CX7HojEx61usBlKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KKk6d7NJXmsqF8TXA/y5QXP9hE12q9bE9+lBfbLPzyK06rglwfFuNs26ibH5fBBe+ JHWE2/7UVGBtjs3IMRWUdy0DQ5L0N41Ly+0E0sdpdH7MrGTpnafjRvgCj8LgbLXiew KahmUpFrdCi+1/7E69EcF7TP8QQa4MzEWQ5ss8YU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jerome Brunet , Wolfram Sang Subject: [PATCH 5.4 40/85] i2c: meson: fix clock setting overwrite Date: Mon, 12 Oct 2020 15:27:03 +0200 Message-Id: <20201012132634.785589451@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet commit 28683e847e2f20eed22cdd24f185d7783db396d3 upstream. When the slave address is written in do_start(), SLAVE_ADDR is written completely. This may overwrite some setting related to the clock rate or signal filtering. Fix this by writing only the bits related to slave address. To avoid causing unexpected changed, explicitly disable filtering or high/low clock mode which may have been left over by the bootloader. Fixes: 30021e3707a7 ("i2c: add support for Amlogic Meson I2C controller") Signed-off-by: Jerome Brunet Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-meson.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/drivers/i2c/busses/i2c-meson.c +++ b/drivers/i2c/busses/i2c-meson.c @@ -5,6 +5,7 @@ * Copyright (C) 2014 Beniamino Galvani */ +#include #include #include #include @@ -37,6 +38,12 @@ #define REG_CTRL_CLKDIVEXT_SHIFT 28 #define REG_CTRL_CLKDIVEXT_MASK GENMASK(29, 28) +#define REG_SLV_ADDR GENMASK(7, 0) +#define REG_SLV_SDA_FILTER GENMASK(10, 8) +#define REG_SLV_SCL_FILTER GENMASK(13, 11) +#define REG_SLV_SCL_LOW GENMASK(27, 16) +#define REG_SLV_SCL_LOW_EN BIT(28) + #define I2C_TIMEOUT_MS 500 enum { @@ -146,6 +153,9 @@ static void meson_i2c_set_clk_div(struct meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIVEXT_MASK, (div >> 10) << REG_CTRL_CLKDIVEXT_SHIFT); + /* Disable HIGH/LOW mode */ + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_SCL_LOW_EN, 0); + dev_dbg(i2c->dev, "%s: clk %lu, freq %u, div %u\n", __func__, clk_rate, freq, div); } @@ -273,7 +283,10 @@ static void meson_i2c_do_start(struct me token = (msg->flags & I2C_M_RD) ? TOKEN_SLAVE_ADDR_READ : TOKEN_SLAVE_ADDR_WRITE; - writel(msg->addr << 1, i2c->regs + REG_SLAVE_ADDR); + + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_ADDR, + FIELD_PREP(REG_SLV_ADDR, msg->addr << 1)); + meson_i2c_add_token(i2c, TOKEN_START); meson_i2c_add_token(i2c, token); } @@ -432,6 +445,10 @@ static int meson_i2c_probe(struct platfo return ret; } + /* Disable filtering */ + meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, + REG_SLV_SDA_FILTER | REG_SLV_SCL_FILTER, 0); + meson_i2c_set_clk_div(i2c, timings.bus_freq_hz); return 0;