Received: by 10.223.164.202 with SMTP id h10csp1212289wrb; Thu, 9 Nov 2017 23:59:29 -0800 (PST) X-Google-Smtp-Source: ABhQp+Tp4vdeS6dq66NR3WzV8IY7KyoVLG70rGUp8Hl750pTlgta1vizWTlfW/kqnJPTJXHEtPVV X-Received: by 10.98.75.71 with SMTP id y68mr3457461pfa.45.1510300769421; Thu, 09 Nov 2017 23:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510300769; cv=none; d=google.com; s=arc-20160816; b=XFBWIVmnNWTN3AQ0oUa7TFJ5hOQqGNK/RLcekVavhdGHSVMfXfFNT0cQly/xmsjAlU 0PHvHIOTEOxPc9w4QoukXGzR9Sj4PmiwLVCE3MqzQxAC7f4u7Xa02fw5Gz9Xjx0HL1T3 Oiy27kTmz5cDP6YYuou8Lk2hmsc2IsLfJMGFBR1w8rSgiuqrJIqoQCNkErnpepOB3sO0 8UXNu6t5nxI1wWK+lTBCRNlbExdYaI/ZjpG1CTkof+vlzIG+pO5xc7rXZqqvQJWDWy/y QFeuLZWe8olX/b/D5vYB1EU3DRgiufQrUWc83sSDGPWnbRzWbCGeLSnCQc37OzUHeKUX ivBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=N2Atn8aQmhEkZVwATuHEE7Mr4o9uhdUdtFn2qOZQ9G8=; b=cC99fGHpdtUh9/1qbrEzUpfAA3fEzOOf8cgXBUcMA3wfyQrPOBcywcXaSXDjmlI0D+ 7Est8yvSgMbYVooxkseP3aUkSAx2IStygVXQF5Dd5t2zXmndVMCokp5AsX/lz1tJZZGR QMoslaEDYpCen6dZlYyEXzmOh3PqYFVRhyFOL+138/UxScGDQng3pdTfkpMsX4S8D5zx gEEKTJnyaMador42gKSJIhvbuQsDT1ez/RLcNvf3JqfezMMqSe8XIMmeJiiO4Sa8l8tO HumpO52lxFHdf/xO7dFYnrPep0Cj0rJdm2z1rUIzOkSBSVN+mKwiFE+rkZKJoyDyW5vk aOdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si3063327pll.378.2017.11.09.23.59.17; Thu, 09 Nov 2017 23:59:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756013AbdKJH6a (ORCPT + 83 others); Fri, 10 Nov 2017 02:58:30 -0500 Received: from ispman.iskranet.ru ([62.213.33.10]:41411 "EHLO ispman.iskranet.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755695AbdKJH6W (ORCPT ); Fri, 10 Nov 2017 02:58:22 -0500 Received: by ispman.iskranet.ru (Postfix, from userid 8) id DA7B7821EEA; Fri, 10 Nov 2017 14:50:31 +0700 (KRAT) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on ispman.iskranet.ru X-Spam-Level: X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.3.2 Received: from KB00016249.iskra.kb (unknown [62.213.40.60]) (Authenticated sender: asolokha@kb.kras.ru) by ispman.iskranet.ru (Postfix) with ESMTPA id AA8EF821EE7; Fri, 10 Nov 2017 14:50:31 +0700 (KRAT) From: Arseny Solokha To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Valentin Longchamp , Arseny Solokha Subject: [PATCH 4/4] i2c: mpc: always determine I2C clock prescaler at runtime Date: Fri, 10 Nov 2017 14:50:15 +0700 Message-Id: <20171110075015.23906-5-asolokha@kb.kras.ru> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171110075015.23906-1-asolokha@kb.kras.ru> References: <20171110075015.23906-1-asolokha@kb.kras.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the facility for setting the prescaler value at compile time entirely. It was only used for two SoCs, duplicating the actual value for one of them and setting sometimes bogus value for another. Make all MPC8xxx SoCs obtain their actual I2C clock prescaler from a single place in the code. Signed-off-by: Arseny Solokha --- drivers/i2c/busses/i2c-mpc.c | 52 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 8d60db0080f6..e0f059687c2d 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -78,9 +78,7 @@ struct mpc_i2c_divider { }; struct mpc_i2c_data { - void (*setup)(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler); - u32 prescaler; + void (*setup)(struct device_node *node, struct mpc_i2c *i2c, u32 clock); }; static inline void writeccr(struct mpc_i2c *i2c, u32 x) @@ -201,7 +199,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { }; static int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, - int prescaler, u32 *real_clk) + u32 *real_clk) { const struct mpc_i2c_divider *div = NULL; unsigned int pvr = mfspr(SPRN_PVR); @@ -236,7 +234,7 @@ static int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, static void mpc_i2c_setup_52xx(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { int ret, fdr; @@ -246,7 +244,7 @@ static void mpc_i2c_setup_52xx(struct device_node *node, return; } - ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler, &i2c->real_clk); + ret = mpc_i2c_get_fdr_52xx(node, clock, &i2c->real_clk); fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */ writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); @@ -258,7 +256,7 @@ static void mpc_i2c_setup_52xx(struct device_node *node, #else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */ static void mpc_i2c_setup_52xx(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { } #endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */ @@ -266,7 +264,7 @@ static void mpc_i2c_setup_52xx(struct device_node *node, #ifdef CONFIG_PPC_MPC512x static void mpc_i2c_setup_512x(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { struct device_node *node_ctrl; void __iomem *ctrl; @@ -289,12 +287,12 @@ static void mpc_i2c_setup_512x(struct device_node *node, } /* The clock setup for the 52xx works also fine for the 512x */ - mpc_i2c_setup_52xx(node, i2c, clock, prescaler); + mpc_i2c_setup_52xx(node, i2c, clock); } #else /* CONFIG_PPC_MPC512x */ static void mpc_i2c_setup_512x(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { } #endif /* CONFIG_PPC_MPC512x */ @@ -388,16 +386,13 @@ static u32 mpc_i2c_get_prescaler_8xxx(void) } static int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, - u32 prescaler, u32 *real_clk) + u32 *real_clk) { const struct mpc_i2c_divider *div = NULL; + u32 prescaler = mpc_i2c_get_prescaler_8xxx(); u32 divider; int i; - /* Determine proper divider value */ - if (!prescaler) - prescaler = mpc_i2c_get_prescaler_8xxx(); - if (clock == MPC_I2C_CLOCK_LEGACY) { /* see below - default fdr = 0x1031 -> div = 16 * 3072 */ *real_clk = fsl_get_sys_freq() / prescaler / (16 * 3072); @@ -425,7 +420,7 @@ static int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, static void mpc_i2c_setup_8xxx(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { int ret, fdr; @@ -436,7 +431,7 @@ static void mpc_i2c_setup_8xxx(struct device_node *node, return; } - ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler, &i2c->real_clk); + ret = mpc_i2c_get_fdr_8xxx(node, clock, &i2c->real_clk); fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */ writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); @@ -450,7 +445,7 @@ static void mpc_i2c_setup_8xxx(struct device_node *node, #else /* !CONFIG_FSL_SOC */ static void mpc_i2c_setup_8xxx(struct device_node *node, struct mpc_i2c *i2c, - u32 clock, u32 prescaler) + u32 clock) { } #endif /* CONFIG_FSL_SOC */ @@ -721,11 +716,11 @@ static int fsl_i2c_probe(struct platform_device *op) if (match->data) { const struct mpc_i2c_data *data = match->data; - data->setup(op->dev.of_node, i2c, clock, data->prescaler); + data->setup(op->dev.of_node, i2c, clock); } else { /* Backwards compatibility */ if (of_get_property(op->dev.of_node, "dfsrr", NULL)) - mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock, 0); + mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); } prop = of_get_property(op->dev.of_node, "fsl,timeout", &plen); @@ -817,28 +812,11 @@ static const struct mpc_i2c_data mpc_i2c_data_52xx = { .setup = mpc_i2c_setup_52xx, }; -static const struct mpc_i2c_data mpc_i2c_data_8313 = { - .setup = mpc_i2c_setup_8xxx, -}; - -static const struct mpc_i2c_data mpc_i2c_data_8543 = { - .setup = mpc_i2c_setup_8xxx, - .prescaler = 2, -}; - -static const struct mpc_i2c_data mpc_i2c_data_8544 = { - .setup = mpc_i2c_setup_8xxx, - .prescaler = 3, -}; - static const struct of_device_id mpc_i2c_of_match[] = { {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, }, {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, }, {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, }, {.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, }, - {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, }, - {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, }, - {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, }, /* Backward compatibility */ {.compatible = "fsl-i2c", }, {}, -- 2.15.0 From 1586666301888840116@xxx Wed Dec 13 11:01:40 +0000 2017 X-GM-THRID: 1586436956579732680 X-Gmail-Labels: Inbox,Category Forums