From patchwork Wed Apr 4 19:44:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christ, Austin" X-Patchwork-Id: 895128 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="dBiZb5Lo"; dkim=pass (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="R+JcLMc3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Gbz22fSvz9s0x for ; Thu, 5 Apr 2018 05:45:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751787AbeDDTpQ (ORCPT ); Wed, 4 Apr 2018 15:45:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55794 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbeDDTpN (ORCPT ); Wed, 4 Apr 2018 15:45:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0DE0160F5C; Wed, 4 Apr 2018 19:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522871113; bh=papTRwlJsS7uSLSNsN2wYb56X1tS8AzlBPKCn+fPpUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBiZb5Locvmi7uPaW2gvbfqr27DJYlsFKLBfBHb6PrkVvpPYpCQlI2CC9w0BU6E3a VTweDNYyP/dTslOqxASVtEnzLCurNM9J7nf0WR+E+6iIMoe+0zj8ohdsQukW27aUew qo/VkR1huqrxU576FTzW88iMO3yqltQawCc/leMY= 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 2586F607A2; Wed, 4 Apr 2018 19:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522871112; bh=papTRwlJsS7uSLSNsN2wYb56X1tS8AzlBPKCn+fPpUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+JcLMc3NBYbUGeSM6s68+grBrlYOF0sAPIWU+VFjWeM5iqAb0jP7VlH/97Lh7Rzb d8iFM2A2/zaInBQd9ZULhla9lacPbWMunceVMaRji43iLbxYZ7FLb4MiAgaZ4euIyH yONmrsmtafFA8ihSVqpm9Wf+fz3T4S7qwomAZAH4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2586F607A2 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, linux-arm-msm@vger.kernel.org Cc: rruigrok@codeaurora.org, timur@codeaurora.org, Austin Christ Subject: [PATCH 3/4] i2c: qup: Correct duty cycle for FM and FM+ Date: Wed, 4 Apr 2018 13:44:59 -0600 Message-Id: <1522871100-3621-4-git-send-email-austinwc@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522871100-3621-1-git-send-email-austinwc@codeaurora.org> References: <1522871100-3621-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 cb14687..2a88611 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -1858,9 +1858,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.