From patchwork Tue Mar 12 11:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 10849077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24B556C2 for ; Tue, 12 Mar 2019 11:00:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1229D2950D for ; Tue, 12 Mar 2019 11:00:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 067BA293EC; Tue, 12 Mar 2019 11:00:25 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 7D56829531 for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726487AbfCLLAX (ORCPT ); Tue, 12 Mar 2019 07:00:23 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:59197 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfCLLAU (ORCPT ); Tue, 12 Mar 2019 07:00:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3f8s-0005nU-Bx; Tue, 12 Mar 2019 12:00:18 +0100 Received: from mtr by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3f8r-0007bP-Hs; Tue, 12 Mar 2019 12:00:17 +0100 From: Michael Tretter To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel@pengutronix.de, Michael Turquette , Stephen Boyd , Michal Simek , Jolly Shah , Michael Tretter Subject: [PATCH 1/5] clk: zynqmp: fix check for fractional clock Date: Tue, 12 Mar 2019 12:00:12 +0100 Message-Id: <20190312110016.29174-2-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312110016.29174-1-m.tretter@pengutronix.de> References: <20190312110016.29174-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CLK_FRAC is not set in the divider->flags, but in the hw->flags. The firmware sets CLK_FRAC for fractional clocks in the clkflag field. When registering the devider, these clkflags are copied to hw->flags. Moreover, divider->flags field is a u8 type, but CLK_FRAG is BIT(13). So this check would never work. Signed-off-by: Michael Tretter --- drivers/clk/zynqmp/divider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c index a371c66e72ef..fc70950c1e24 100644 --- a/drivers/clk/zynqmp/divider.c +++ b/drivers/clk/zynqmp/divider.c @@ -117,7 +117,7 @@ static long zynqmp_clk_divider_round_rate(struct clk_hw *hw, bestdiv = zynqmp_divider_get_val(*prate, rate); if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && - (divider->flags & CLK_FRAC)) + (clk_hw_get_flags(hw) & CLK_FRAC)) bestdiv = rate % *prate ? 1 : bestdiv; *prate = rate * bestdiv; From patchwork Tue Mar 12 11:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 10849071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B09617DF for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06AE829528 for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF2BB2952E; Tue, 12 Mar 2019 11:00:23 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 6273429541 for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbfCLLAW (ORCPT ); Tue, 12 Mar 2019 07:00:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:51445 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbfCLLAU (ORCPT ); Tue, 12 Mar 2019 07:00:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3f8s-0005ng-C0; Tue, 12 Mar 2019 12:00:18 +0100 Received: from mtr by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3f8r-0007bS-IT; Tue, 12 Mar 2019 12:00:17 +0100 From: Michael Tretter To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel@pengutronix.de, Michael Turquette , Stephen Boyd , Michal Simek , Jolly Shah , Michael Tretter Subject: [PATCH 2/5] clk: zynqmp: fix doc of __zynqmp_clock_get_parents Date: Tue, 12 Mar 2019 12:00:13 +0100 Message-Id: <20190312110016.29174-3-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312110016.29174-1-m.tretter@pengutronix.de> References: <20190312110016.29174-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The kernel-doc refers to __zynqmp_clock_get_topology(), while it actually documents __zynqmp_clock_get_parents(). Fix the documentation to refer to the correct function name. Signed-off-by: Michael Tretter --- I think most of the function documentation in this file is pretty useless and sometimes misleading. Maybe we should drop the documentation entirely, because all functions are static anyway? --- drivers/clk/zynqmp/clkc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c index b0908ec62f73..d3d4ce305e71 100644 --- a/drivers/clk/zynqmp/clkc.c +++ b/drivers/clk/zynqmp/clkc.c @@ -408,7 +408,7 @@ static int zynqmp_clock_get_topology(u32 clk_id, } /** - * __zynqmp_clock_get_topology() - Get parents info of clock from firmware + * __zynqmp_clock_get_parents() - Get parents info of clock from firmware * response data * @parents: Clock parents * @data: Clock parents data received from firmware From patchwork Tue Mar 12 11:00:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 10849069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD0CE6C2 for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B959D2953D for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD84D29538; Tue, 12 Mar 2019 11:00:23 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 416C22952E for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725811AbfCLLAW (ORCPT ); Tue, 12 Mar 2019 07:00:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56293 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbfCLLAU (ORCPT ); Tue, 12 Mar 2019 07:00:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3f8s-0005nq-C0; Tue, 12 Mar 2019 12:00:18 +0100 Received: from mtr by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3f8r-0007bV-J3; Tue, 12 Mar 2019 12:00:17 +0100 From: Michael Tretter To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel@pengutronix.de, Michael Turquette , Stephen Boyd , Michal Simek , Jolly Shah , Michael Tretter Subject: [PATCH 3/5] clk: zynqmp: do not export zynqmp_clk_register_mux Date: Tue, 12 Mar 2019 12:00:14 +0100 Message-Id: <20190312110016.29174-4-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312110016.29174-1-m.tretter@pengutronix.de> References: <20190312110016.29174-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP zynqmp_clk_register_mux is an internal function of the driver that only should be used from clkc.c. Therefore, there is no need to export that function. Follow the suit of the other files of the driver and do not export the register function. Signed-off-by: Michael Tretter --- drivers/clk/zynqmp/clk-mux-zynqmp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/clk/zynqmp/clk-mux-zynqmp.c b/drivers/clk/zynqmp/clk-mux-zynqmp.c index 4143f560c28d..0af8f74c5fa5 100644 --- a/drivers/clk/zynqmp/clk-mux-zynqmp.c +++ b/drivers/clk/zynqmp/clk-mux-zynqmp.c @@ -138,4 +138,3 @@ struct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id, return hw; } -EXPORT_SYMBOL_GPL(zynqmp_clk_register_mux); From patchwork Tue Mar 12 11:00:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 10849075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A8F718A6 for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3415C29412 for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 325AC292BF; Tue, 12 Mar 2019 11:00:24 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 B1EF429412 for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbfCLLAX (ORCPT ); Tue, 12 Mar 2019 07:00:23 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:41793 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726487AbfCLLAU (ORCPT ); Tue, 12 Mar 2019 07:00:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3f8s-0005o0-Bx; Tue, 12 Mar 2019 12:00:18 +0100 Received: from mtr by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3f8r-0007bY-JW; Tue, 12 Mar 2019 12:00:17 +0100 From: Michael Tretter To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel@pengutronix.de, Michael Turquette , Stephen Boyd , Michal Simek , Jolly Shah , Michael Tretter Subject: [PATCH 4/5] clk: zynqmp: cleanup sizes of firmware responses Date: Tue, 12 Mar 2019 12:00:15 +0100 Message-Id: <20190312110016.29174-5-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312110016.29174-1-m.tretter@pengutronix.de> References: <20190312110016.29174-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The queries for the clock name, clock topology, clock parents, and clock attributes return a specified count of values, whose type and number depends on the query. Properly separate the number of values per query, make it dependent on the returned type values and get rid of leftover hard coded sizes. Signed-off-by: Michael Tretter --- drivers/clk/zynqmp/clk-zynqmp.h | 6 ------ drivers/clk/zynqmp/clkc.c | 32 +++++++++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/clk/zynqmp/clk-zynqmp.h b/drivers/clk/zynqmp/clk-zynqmp.h index 7ab163b67249..fec9a15c8786 100644 --- a/drivers/clk/zynqmp/clk-zynqmp.h +++ b/drivers/clk/zynqmp/clk-zynqmp.h @@ -10,12 +10,6 @@ #include -/* Clock APIs payload parameters */ -#define CLK_GET_NAME_RESP_LEN 16 -#define CLK_GET_TOPOLOGY_RESP_WORDS 3 -#define CLK_GET_PARENTS_RESP_WORDS 3 -#define CLK_GET_ATTR_RESP_WORDS 1 - enum topology_type { TYPE_INVALID, TYPE_MUX, diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c index d3d4ce305e71..573c3c58dbbc 100644 --- a/drivers/clk/zynqmp/clkc.c +++ b/drivers/clk/zynqmp/clkc.c @@ -23,14 +23,11 @@ #define CLK_TYPE_SHIFT 2 -#define PM_API_PAYLOAD_LEN 3 - #define NA_PARENT 0xFFFFFFFF #define DUMMY_PARENT 0xFFFFFFFE #define CLK_TYPE_FIELD_LEN 4 #define CLK_TOPOLOGY_NODE_OFFSET 16 -#define NODES_PER_RESP 3 #define CLK_TYPE_FIELD_MASK 0xF #define CLK_FLAG_FIELD_MASK GENMASK(21, 8) @@ -54,6 +51,11 @@ #define CLK_VALID_MASK 0x1 +#define CLK_GET_NAME_RESP_LEN 16 +#define CLK_GET_TOPOLOGY_RESP_WORDS 3 +#define CLK_GET_PARENTS_RESP_WORDS 3 +#define CLK_GET_ATTR_RESP_WORDS 1 + enum clk_type { CLK_TYPE_OUTPUT, CLK_TYPE_EXTERNAL, @@ -215,7 +217,8 @@ static int zynqmp_pm_clock_get_name(u32 clock_id, char *name) qdata.arg1 = clock_id; eemi_ops->query_data(qdata, ret_payload); - memcpy(name, ret_payload, CLK_GET_NAME_RESP_LEN); + memcpy(name, ret_payload, + CLK_GET_NAME_RESP_LEN * sizeof(*name)); return 0; } @@ -248,7 +251,8 @@ static int zynqmp_pm_clock_get_topology(u32 clock_id, u32 index, u32 *topology) qdata.arg2 = index; ret = eemi_ops->query_data(qdata, ret_payload); - memcpy(topology, &ret_payload[1], CLK_GET_TOPOLOGY_RESP_WORDS * 4); + memcpy(topology, &ret_payload[1], + CLK_GET_TOPOLOGY_RESP_WORDS * sizeof(*topology)); return ret; } @@ -321,7 +325,8 @@ static int zynqmp_pm_clock_get_parents(u32 clock_id, u32 index, u32 *parents) qdata.arg2 = index; ret = eemi_ops->query_data(qdata, ret_payload); - memcpy(parents, &ret_payload[1], CLK_GET_PARENTS_RESP_WORDS * 4); + memcpy(parents, &ret_payload[1], + CLK_GET_PARENTS_RESP_WORDS * sizeof(*parents)); return ret; } @@ -345,7 +350,8 @@ static int zynqmp_pm_clock_get_attributes(u32 clock_id, u32 *attr) qdata.arg1 = clock_id; ret = eemi_ops->query_data(qdata, ret_payload); - memcpy(attr, &ret_payload[1], CLK_GET_ATTR_RESP_WORDS * 4); + memcpy(attr, &ret_payload[1], + CLK_GET_ATTR_RESP_WORDS * sizeof(*attr)); return ret; } @@ -364,7 +370,7 @@ static int __zynqmp_clock_get_topology(struct clock_topology *topology, { int i; - for (i = 0; i < PM_API_PAYLOAD_LEN; i++) { + for (i = 0; i < CLK_GET_TOPOLOGY_RESP_WORDS; i++) { if (!(data[i] & CLK_TYPE_FIELD_MASK)) return END_OF_TOPOLOGY_NODE; topology[*nnodes].type = data[i] & CLK_TYPE_FIELD_MASK; @@ -392,10 +398,10 @@ static int zynqmp_clock_get_topology(u32 clk_id, u32 *num_nodes) { int j, ret; - u32 pm_resp[PM_API_PAYLOAD_LEN] = {0}; + u32 pm_resp[CLK_GET_TOPOLOGY_RESP_WORDS] = {0}; *num_nodes = 0; - for (j = 0; j <= MAX_NODES; j += 3) { + for (j = 0; j <= MAX_NODES; j += CLK_GET_TOPOLOGY_RESP_WORDS) { ret = zynqmp_pm_clock_get_topology(clk_id, j, pm_resp); if (ret) return ret; @@ -422,7 +428,7 @@ static int __zynqmp_clock_get_parents(struct clock_parent *parents, u32 *data, int i; struct clock_parent *parent; - for (i = 0; i < PM_API_PAYLOAD_LEN; i++) { + for (i = 0; i < CLK_GET_PARENTS_RESP_WORDS; i++) { if (data[i] == NA_PARENT) return END_OF_PARENTS; @@ -454,7 +460,7 @@ static int zynqmp_clock_get_parents(u32 clk_id, struct clock_parent *parents, u32 *num_parents) { int j = 0, ret; - u32 pm_resp[PM_API_PAYLOAD_LEN] = {0}; + u32 pm_resp[CLK_GET_PARENTS_RESP_WORDS] = {0}; *num_parents = 0; do { @@ -467,7 +473,7 @@ static int zynqmp_clock_get_parents(u32 clk_id, struct clock_parent *parents, num_parents); if (ret == END_OF_PARENTS) return 0; - j += PM_API_PAYLOAD_LEN; + j += CLK_GET_PARENTS_RESP_WORDS; } while (*num_parents <= MAX_PARENT); return 0; From patchwork Tue Mar 12 11:00:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 10849073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DE931390 for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A004292BF for ; Tue, 12 Mar 2019 11:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17DD62954C; Tue, 12 Mar 2019 11:00:24 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 8F90C29534 for ; Tue, 12 Mar 2019 11:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbfCLLAW (ORCPT ); Tue, 12 Mar 2019 07:00:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56791 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfCLLAU (ORCPT ); Tue, 12 Mar 2019 07:00:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h3f8s-0005o2-Bw; Tue, 12 Mar 2019 12:00:18 +0100 Received: from mtr by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3f8r-0007bb-KB; Tue, 12 Mar 2019 12:00:17 +0100 From: Michael Tretter To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel@pengutronix.de, Michael Turquette , Stephen Boyd , Michal Simek , Jolly Shah , Michael Tretter Subject: [PATCH 5/5] clk: zynqmp: make field definitions of query responses consistent Date: Tue, 12 Mar 2019 12:00:16 +0100 Message-Id: <20190312110016.29174-6-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312110016.29174-1-m.tretter@pengutronix.de> References: <20190312110016.29174-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-clk@vger.kernel.org Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The definition of the fields in the firmware responses to the queries is inconsistent. Some are specified as a mask, some as a shift, and some by the length of the previous field. Specify all of them as bit masks and access the fields using the FIELD_GET macro. Signed-off-by: Michael Tretter --- drivers/clk/zynqmp/clkc.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c index 573c3c58dbbc..b4e13b8618b2 100644 --- a/drivers/clk/zynqmp/clkc.c +++ b/drivers/clk/zynqmp/clkc.c @@ -21,20 +21,18 @@ #define MAX_NODES 6 #define MAX_NAME_LEN 50 -#define CLK_TYPE_SHIFT 2 - #define NA_PARENT 0xFFFFFFFF #define DUMMY_PARENT 0xFFFFFFFE -#define CLK_TYPE_FIELD_LEN 4 -#define CLK_TOPOLOGY_NODE_OFFSET 16 +#define CLK_TOPOLOGY_TYPE GENMASK(3, 0) +#define CLK_TOPOLOGY_FLAGS GENMASK(21, 8) +#define CLK_TOPOLOGY_TYPE_FLAGS GENMASK(31, 24) -#define CLK_TYPE_FIELD_MASK 0xF -#define CLK_FLAG_FIELD_MASK GENMASK(21, 8) -#define CLK_TYPE_FLAG_FIELD_MASK GENMASK(31, 24) +#define CLK_PARENTS_ID GENMASK(15, 0) +#define CLK_PARENTS_FLAGS GENMASK(31, 16) -#define CLK_PARENTS_ID_LEN 16 -#define CLK_PARENTS_ID_MASK 0xFFFF +#define CLK_ATTR_VALID BIT(0) +#define CLK_ATTR_TYPE BIT(2) /* Flags for parents */ #define PARENT_CLK_SELF 0 @@ -49,8 +47,6 @@ #define END_OF_PARENTS 1 #define RESERVED_CLK_NAME "" -#define CLK_VALID_MASK 0x1 - #define CLK_GET_NAME_RESP_LEN 16 #define CLK_GET_TOPOLOGY_RESP_WORDS 3 #define CLK_GET_PARENTS_RESP_WORDS 3 @@ -369,15 +365,16 @@ static int __zynqmp_clock_get_topology(struct clock_topology *topology, u32 *data, u32 *nnodes) { int i; + u32 type; for (i = 0; i < CLK_GET_TOPOLOGY_RESP_WORDS; i++) { - if (!(data[i] & CLK_TYPE_FIELD_MASK)) + type = FIELD_GET(CLK_TOPOLOGY_TYPE, data[i]); + if (type == TYPE_INVALID) return END_OF_TOPOLOGY_NODE; - topology[*nnodes].type = data[i] & CLK_TYPE_FIELD_MASK; - topology[*nnodes].flag = FIELD_GET(CLK_FLAG_FIELD_MASK, - data[i]); + topology[*nnodes].type = type + topology[*nnodes].flag = FIELD_GET(CLK_TOPOLOGY_FLAGS, data[i]); topology[*nnodes].type_flag = - FIELD_GET(CLK_TYPE_FLAG_FIELD_MASK, data[i]); + FIELD_GET(CLK_TOPOLOGY_TYPE_FLAGS, data[i]); (*nnodes)++; } @@ -433,12 +430,12 @@ static int __zynqmp_clock_get_parents(struct clock_parent *parents, u32 *data, return END_OF_PARENTS; parent = &parents[i]; - parent->id = data[i] & CLK_PARENTS_ID_MASK; + parent->id = FIELD_GET(CLK_PARENTS_ID, data[i]); if (data[i] == DUMMY_PARENT) { strcpy(parent->name, "dummy_name"); parent->flag = 0; } else { - parent->flag = data[i] >> CLK_PARENTS_ID_LEN; + parent->flag = FIELD_GET(CLK_PARENTS_FLAGS, data[i]); if (zynqmp_get_clock_name(parent->id, parent->name)) continue; } @@ -638,9 +635,9 @@ static void zynqmp_get_clock_info(void) if (ret) continue; - clock[i].valid = attr & CLK_VALID_MASK; - clock[i].type = attr >> CLK_TYPE_SHIFT ? CLK_TYPE_EXTERNAL : - CLK_TYPE_OUTPUT; + clock[i].valid = FIELD_GET(CLK_ATTR_VALID, attr); + clock[i].type = FIELD_GET(CLK_ATTR_TYPE) ? + CLK_TYPE_EXTERNAL : CLK_TYPE_OUTPUT; } /* Get topology of all clock */