From patchwork Thu May 10 16:13:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christ, Austin" X-Patchwork-Id: 911423 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="aOqIqEdQ"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="KlJ+B3D4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40hdZp2CjSz9s0y for ; Fri, 11 May 2018 02:14:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966026AbeEJQOJ (ORCPT ); Thu, 10 May 2018 12:14:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55966 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966299AbeEJQOH (ORCPT ); Thu, 10 May 2018 12:14:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 195AA60A00; Thu, 10 May 2018 16:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525968847; bh=Sbka2yW3XqpwwpFJ+UpunR1Q3/HZjFjT1ny6No12G1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aOqIqEdQ0Hqp7BwZasNwXSQ+0l4JM3w9U8sLBEK/XaGftGUs7KXvVCM7mEoZAIWCu XOrRJXqkKkJQJgqvMq6oAkLBhwVRUa6Xu/FuvURX7LSTgQ4MMEjWGTTmNc1R7IF1ih RDTTKx1hNVZJZC6Rj+BWKSAhfqCGmhcacQ12O+AY= 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 1BED260881; Thu, 10 May 2018 16:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525968846; bh=Sbka2yW3XqpwwpFJ+UpunR1Q3/HZjFjT1ny6No12G1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KlJ+B3D4/pSMOCrdb0tmQ8lXYQBUWtlrbn4CEJlJEUtTk7+YMuU1NzOq1hdo4yC7F ExvAQWlx5qDUzoMtD6T+CJACR7n6hiU+rxw/xCBombIgzmWnpA1mdWjEfNYKdLhvqt 9soVSNJKupxP0ZYloK4jCmV0K1sCWtnBa0q+xk9g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1BED260881 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, sricharan@codeaurora.org, timur@codeaurora.org, rruigrok@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, Austin Christ Subject: [PATCH v3 3/4] i2c: qup: Correct duty cycle for FM and FM+ Date: Thu, 10 May 2018 10:13:56 -0600 Message-Id: <1525968837-13381-4-git-send-email-austinwc@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525968837-13381-1-git-send-email-austinwc@codeaurora.org> References: <1525968837-13381-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 Reviewed-by: Sricharan R Reviewed-by: Andy Gross --- v1: - Initial v2: - No changes v3: - No changes --- 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.