From patchwork Tue Apr 24 21:21:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christ, Austin" X-Patchwork-Id: 903881 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="aR9+FuGF"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="aR9+FuGF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Vx8t5rkpz9ry1 for ; Wed, 25 Apr 2018 07:21:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751216AbeDXVVd (ORCPT ); Tue, 24 Apr 2018 17:21:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50930 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbeDXVVd (ORCPT ); Tue, 24 Apr 2018 17:21:33 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A99A360310; Tue, 24 Apr 2018 21:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524604892; bh=BYA8z/WJ4OsIxGyefJ+4uFrNpD1DdfN2TJx51riSzUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aR9+FuGFt/KF2GMuugui/TIy3PXe7R71umogHD1B8Z17Y6bHX1nZAF/j8hPSZUsxZ TRsdazZPf9ixgrMHgJ8pbS8pzFhMNiITXZbjCnDV5ljAwHXhY6x74l+CwzOcoTEpad r6Du4aAM/ue61odtdjsv6UsHAW8N5g7kdR/qaI/I= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from austinwc-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: austinwc@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 602D760F5F; Tue, 24 Apr 2018 21:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524604892; bh=BYA8z/WJ4OsIxGyefJ+4uFrNpD1DdfN2TJx51riSzUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aR9+FuGFt/KF2GMuugui/TIy3PXe7R71umogHD1B8Z17Y6bHX1nZAF/j8hPSZUsxZ TRsdazZPf9ixgrMHgJ8pbS8pzFhMNiITXZbjCnDV5ljAwHXhY6x74l+CwzOcoTEpad r6Du4aAM/ue61odtdjsv6UsHAW8N5g7kdR/qaI/I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 602D760F5F Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=austinwc@codeaurora.org From: Austin Christ To: wsa@the-dreams.de, linux-i2c@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, rruigrok@codeaurora.org, timur@codeaurora.org, sricharan@codeaurora.org, Austin Christ Subject: [PATCH 3/4] i2c: qup: Correct duty cycle for FM and FM+ Date: Tue, 24 Apr 2018 15:21:21 -0600 Message-Id: <1524604882-25377-4-git-send-email-austinwc@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524604882-25377-1-git-send-email-austinwc@codeaurora.org> References: <1524604882-25377-1-git-send-email-austinwc@codeaurora.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The I2C spec UM10204 Rev. 6 specifies the following timings. Standard Fast Mode Fast Mode Plus SCL low 4.7us 1.3us 0.5us SCL high 4.0us 0.6us 0.26us This results in a 33%/66% duty cycle as opposed to the 50%/50% duty cycle used for Standard-mode. Add High Time Divider settings to correct duty cycle for FM(400kHz) and FM+(1MHz). Signed-off-by: Austin Christ --- drivers/i2c/busses/i2c-qup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index ce5f215..f87f29f 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -1855,9 +1855,15 @@ static int qup_i2c_probe(struct platform_device *pdev) size = QUP_INPUT_FIFO_SIZE(io_mode); qup->in_fifo_sz = qup->in_blk_sz * (2 << size); - fs_div = ((src_clk_freq / clk_freq) / 2) - 3; hs_div = 3; - qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff); + if (clk_freq <= I2C_STANDARD_FREQ) { + fs_div = ((src_clk_freq / clk_freq) / 2) - 3; + qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff); + } else { + /* 33%/66% duty cycle */ + fs_div = ((src_clk_freq / clk_freq) - 6) * 2 / 3; + qup->clk_ctl = ((fs_div / 2) << 16) | (hs_div << 8) | (fs_div & 0xff); + } /* * Time it takes for a byte to be clocked out on the bus.