From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4436C76188 for ; Tue, 4 Apr 2023 23:00:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E18485D77; Wed, 5 Apr 2023 00:59:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=kernel-space.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel-space.org header.i=@kernel-space.org header.b="WChZKhl0"; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=kernel-space.org header.i=@kernel-space.org header.b="AfSlCiOI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 28E6D85CA9; Wed, 5 Apr 2023 00:59:49 +0200 (CEST) Received: from mail.kernel-space.org (unknown [IPv6:2a01:4f8:c2c:5a84::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BD06585D77 for ; Wed, 5 Apr 2023 00:59:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=kernel-space.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angelo@kernel-space.org Received: from ziongate (localhost [127.0.0.1]) by ziongate (OpenSMTPD) with ESMTP id 37bd476c; Tue, 4 Apr 2023 22:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=kernel-space.org; h=from:to :cc:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=default; bh=Mmumx5/fFCqHCySwomE6xS Q0vFE=; b=WChZKhl0ZdhLkv6jTIRtRdZopXNH6qvdBLVrUETtbblZrOx5PMH4Kb mfcSL7zgNUsVmGpMbvwMHu/b7xlFIZ4PZuNriRGimzu+63BFdiQ9VYXswnzkYx0x hUyVVGbG9mlCD/MjeSkgttYfi0PlHPMaMsj4USMg6+1oYfHixDbM4= DomainKey-Signature: a=rsa-sha1; c=simple; d=kernel-space.org; h=from:to :cc:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=default; b=GWDKnz+2EaaDZyzp bdqWWNmbidRHdbxKHm/F2MuYU9beGK8lqJBVmHNDH6CNUbchbMI80+dI/bL8iivu o88JOqZtHfw+hJ4dQIM1jtaJM1cJ8zomiOirehYfNiipRZFSqp1B7BG4c40fFqPO o3UK+0hrTqF5V6xoeJtHGFKDHQg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-space.org; s=20190913; t=1680649178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YAYaV+gO6OJ8Nb3j93CmEo9VNtV/8rOt1mAbRFPV39s=; b=AfSlCiOIxkd4eYrA7FbSlggaMpTKKHoqeCnmFN4ENIZ8OtZTfplUDIriU2zdzMY2dCxTn8 qLQVzCDAjaps5mfS6bzgR8aAmEd5/boYNTUwH77VYeK1W0oonwdvA+om2BAFrbehq3H3dq L534eMub7sg1UPhF88HdHfCe1uBSKcw= Received: from localhost.localdomain (host-79-50-12-19.retail.telecomitalia.it [79.50.12.19]) by ziongate (OpenSMTPD) with ESMTPSA id a33fa785 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 4 Apr 2023 22:59:38 +0000 (UTC) From: Angelo Dureghello To: trini@konsulko.com, hs@denx.de Cc: u-boot@lists.denx.de, mario.six@gdsys.cc, Angelo Dureghello Subject: [PATCH 4/6] i2c: fsl_i2c: fix m68k transferts Date: Wed, 5 Apr 2023 00:59:26 +0200 Message-Id: <20230404225928.3032456-4-angelo@kernel-space.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404225928.3032456-1-angelo@kernel-space.org> References: <20230404225928.3032456-1-angelo@kernel-space.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This driver is actually used for powerpc and m68k/ColdFire. On ColdFire SoC's, interrupt flag get not set if IIEN flag (mbcr bit6, interrupt enabled) is not set appropriately before each transfert. As a result, the transfert hangs forever waiting for IIEN. This patch set IIEN before each transfert, while considering this fix as not harming powerpc arch. Signed-off-by: Angelo Dureghello --- arch/m68k/include/asm/fsl_i2c.h | 10 ++++++++++ drivers/i2c/fsl_i2c.c | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/m68k/include/asm/fsl_i2c.h b/arch/m68k/include/asm/fsl_i2c.h index 9c54fdea77..dc6b37a575 100644 --- a/arch/m68k/include/asm/fsl_i2c.h +++ b/arch/m68k/include/asm/fsl_i2c.h @@ -57,4 +57,14 @@ typedef struct fsl_i2c_base { #define I2C_DR_RES ~(I2C_DR) } fsl_i2c_t; +#if CONFIG_IS_ENABLED(DM_I2C) +struct fsl_i2c_dev { + struct fsl_i2c_base __iomem *base; /* register base */ + u32 i2c_clk; + u32 index; + u8 slaveadd; + uint speed; +}; +#endif + #endif /* _ASM_I2C_H_ */ diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index d312f35f04..d9d8ee81d2 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -278,7 +278,8 @@ static void __i2c_init(const struct fsl_i2c_base *base, int speed, int set_i2c_bus_speed(base, i2c_clk, speed); writeb(slaveadd << 1, &base->adr);/* write slave address */ writeb(0x0, &base->sr); /* clear status register */ - writeb(I2C_CR_MEN, &base->cr); /* start I2C controller */ + /* start I2C controller */ + writeb(I2C_CR_MEN | I2C_CR_MIEN, &base->cr); timeval = get_ticks(); while (readb(&base->sr) & I2C_SR_MBB) { @@ -346,7 +347,7 @@ static int i2c_wait(const struct fsl_i2c_base *base, int write) static int i2c_write_addr(const struct fsl_i2c_base *base, u8 dev, u8 dir, int rsta) { - writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX + writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA | I2C_CR_MTX | (rsta ? I2C_CR_RSTA : 0), &base->cr); @@ -378,7 +379,8 @@ static int __i2c_read_data(const struct fsl_i2c_base *base, u8 *data, { int i; - writeb(I2C_CR_MEN | I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0), + writeb(I2C_CR_MEN | I2C_CR_MIEN | + I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0), &base->cr); /* dummy read */ @@ -390,13 +392,13 @@ static int __i2c_read_data(const struct fsl_i2c_base *base, u8 *data, /* Generate ack on last next to last byte */ if (i == length - 2) - writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_TXAK, - &base->cr); + writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA | + I2C_CR_TXAK, &base->cr); /* Do not generate stop on last byte */ if (i == length - 1) - writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX, - &base->cr); + writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA | + I2C_CR_MTX, &base->cr); data[i] = readb(&base->dr); } -- 2.40.0