From patchwork Mon Feb 24 15:15:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1243239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48R5H254Mbz9sRf for ; Tue, 25 Feb 2020 02:15:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbgBXPPk (ORCPT ); Mon, 24 Feb 2020 10:15:40 -0500 Received: from mga18.intel.com ([134.134.136.126]:50814 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbgBXPPj (ORCPT ); Mon, 24 Feb 2020 10:15:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 07:15:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,480,1574150400"; d="scan'208";a="226007452" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 07:15:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 09F369E7; Mon, 24 Feb 2020 17:15:33 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Andy Shevchenko , Shawn Guo , Sascha Hauer Subject: [PATCH v1 22/40] i2c: mxs: Use generic definitions for bus frequencies Date: Mon, 24 Feb 2020 17:15:12 +0200 Message-Id: <20200224151530.31713-22-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224151530.31713-1-andriy.shevchenko@linux.intel.com> References: <20200224151530.31713-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Since we have generic definitions for bus frequencies, let's use them. Cc: Shawn Guo Cc: Sascha Hauer Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-mxs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 89224913f578..215aa18cc4f5 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c @@ -731,18 +731,18 @@ static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, uint32_t speed) * This is compensated for by subtracting the respective constants * from the values written to the timing registers. */ - if (speed > 100000) { + if (speed > I2C_STANDARD_MODE_FREQ) { /* fast mode */ low_count = DIV_ROUND_CLOSEST(divider * 13, (13 + 6)); high_count = DIV_ROUND_CLOSEST(divider * 6, (13 + 6)); - leadin = DIV_ROUND_UP(600 * (clk / 1000000), 1000); - bus_free = DIV_ROUND_UP(1300 * (clk / 1000000), 1000); + leadin = DIV_ROUND_UP(600 * (clk / HZ_PER_MHZ), 1000); + bus_free = DIV_ROUND_UP(1300 * (clk / HZ_PER_MHZ), 1000); } else { /* normal mode */ low_count = DIV_ROUND_CLOSEST(divider * 47, (47 + 40)); high_count = DIV_ROUND_CLOSEST(divider * 40, (47 + 40)); - leadin = DIV_ROUND_UP(4700 * (clk / 1000000), 1000); - bus_free = DIV_ROUND_UP(4700 * (clk / 1000000), 1000); + leadin = DIV_ROUND_UP(4700 * (clk / HZ_PER_MHZ), 1000); + bus_free = DIV_ROUND_UP(4700 * (clk / HZ_PER_MHZ), 1000); } rcv_count = high_count * 3 / 8; xmit_count = low_count * 3 / 8; @@ -769,7 +769,7 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c) ret = of_property_read_u32(node, "clock-frequency", &speed); if (ret) { dev_warn(dev, "No I2C speed selected, using 100kHz\n"); - speed = 100000; + speed = I2C_STANDARD_MODE_FREQ; } mxs_i2c_derive_timing(i2c, speed);