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: Austin Christ X-Patchwork-Id: 10392049 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0768F6054D for ; Thu, 10 May 2018 16:15:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7F9C286F6 for ; Thu, 10 May 2018 16:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44C828A50; Thu, 10 May 2018 16:15:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4725E286F6 for ; Thu, 10 May 2018 16:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966444AbeEJQOJ (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= 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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.