From patchwork Tue May 29 04:45:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 921809 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tkos.co.il Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40w1QD5fcZz9s0q for ; Tue, 29 May 2018 14:46:12 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4CB77C21DB3; Tue, 29 May 2018 04:46:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 13881C21C27; Tue, 29 May 2018 04:46:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EBB92C21BE5; Tue, 29 May 2018 04:46:00 +0000 (UTC) Received: from mx.tkos.co.il (guitar.tcltek.co.il [192.115.133.116]) by lists.denx.de (Postfix) with ESMTPS id 7BA65C21BE5 for ; Tue, 29 May 2018 04:46:00 +0000 (UTC) Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPSA id 98B6E4405F1; Tue, 29 May 2018 07:45:59 +0300 (IDT) From: Baruch Siach To: Heiko Schocher , =?utf-8?q?Marek_Beh=C3=BAn?= Date: Tue, 29 May 2018 07:45:32 +0300 Message-Id: <8795abbec31a71ce30ae3b149c22e0e6b7d66414.1527569133.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.17.0 Cc: u-boot@lists.denx.de, Baruch Siach , Stefan Roese , Chris Packham , Rabeeh Khoury Subject: [U-Boot] [PATCH 1/2] i2c: mvtwsi: disable i2c slave on Armada 38x X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Equivalent code that disables the hidden i2c0 slave already exists in the Turris Omnia platform specific code. But this hidden i2c0 slave that interferes the i2c bus is not board specific. Armada 38x SoCs and at least some Kirkwood variants are affected as well. Add code to disable this slave to the i2c bus driver to make it work on all affected hardware. Use the bind callback because we want this to always run at boot, regardless of whether U-Boot uses the i2c bus. Cc: Rabeeh Khoury Cc: Chris Packham Reviewed-by: Stefan Roese Reviewed-by: Heiko Schocher Signed-off-by: Baruch Siach Tested-by: Chris Packham --- v2: * Use clrbits_le32 (Stefan Roese) * Apply to Kirkwood (Chris Packham) * Add review tags from Stefan and Heiko --- drivers/i2c/mvtwsi.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index f9822e56b894..c0d9a71627db 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #ifdef CONFIG_DM_I2C #include @@ -70,8 +71,10 @@ struct mvtwsi_registers { u32 baudrate; /* When writing */ }; u32 xtnd_slave_addr; - u32 reserved[2]; + u32 reserved0[2]; u32 soft_reset; + u32 reserved1[27]; + u32 debug; }; #endif @@ -795,6 +798,23 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus) return 0; } +static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi) +{ + clrbits_le32(&twsi->debug, BIT(18)); +} + +static int mvtwsi_i2c_bind(struct udevice *bus) +{ + struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus); + + /* Disable the hidden slave in i2c0 of these platforms */ + if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_KIRKWOOD)) + && bus->req_seq == 0) + twsi_disable_i2c_slave(twsi); + + return 0; +} + static int mvtwsi_i2c_probe(struct udevice *bus) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); @@ -850,6 +870,7 @@ U_BOOT_DRIVER(i2c_mvtwsi) = { .name = "i2c_mvtwsi", .id = UCLASS_I2C, .of_match = mvtwsi_i2c_ids, + .bind = mvtwsi_i2c_bind, .probe = mvtwsi_i2c_probe, .ofdata_to_platdata = mvtwsi_i2c_ofdata_to_platdata, .priv_auto_alloc_size = sizeof(struct mvtwsi_i2c_dev),