From patchwork Thu May 16 22:10:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1100767 X-Patchwork-Delegate: sbabic@denx.de 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=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 454m2X54TCz9s7h for ; Fri, 17 May 2019 08:15:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 64A74C21DF3; Thu, 16 May 2019 22:13:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CE127C21E15; Thu, 16 May 2019 22:12:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 87BA2C21DD7; Thu, 16 May 2019 22:11:23 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id 20CFDC21DF9 for ; Thu, 16 May 2019 22:11:20 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 454lxg6HlGz1rbLq; Fri, 17 May 2019 00:11:19 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 454lxg61Ndz1qqkh; Fri, 17 May 2019 00:11:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id cy3QiE3WJqHw; Fri, 17 May 2019 00:11:18 +0200 (CEST) X-Auth-Info: rZJiSy7qxoh6deHljYMq2t6U7uzUClEZq47skmbElXo= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 17 May 2019 00:11:18 +0200 (CEST) From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Marek Vasut , Simon Glass , Tom Rini , u-boot@lists.denx.de, Jagan Teki , Peng Fan , Marcel Ziswiler , Adam Ford Date: Fri, 17 May 2019 00:10:40 +0200 Message-Id: <20190516221042.3583-12-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190516221042.3583-1-lukma@denx.de> References: <20190516221042.3583-1-lukma@denx.de> Subject: [U-Boot] [PATCH v4 11/13] clk: test: Provide unit test for clk_get_parent_rate() method X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This commit provides sandbox unit test for clk_get_parent_rate() method. For testing the default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices). The clk_get_parent_rate() relies on dev->driver_data having the pointer to proper struct clk. It uses internally clk_get_parent() method also tested by this test. Signed-off-by: Lukasz Majewski --- Changes in v4: None Changes in v3: - New patch arch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 26 ++++++++++++++++++++++++++ test/dm/clk.c | 1 + 3 files changed, 35 insertions(+) diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h index 90f925109f..1df9534236 100644 --- a/arch/sandbox/include/asm/clk.h +++ b/arch/sandbox/include/asm/clk.h @@ -79,6 +79,14 @@ int sandbox_clk_test_get_by_id(struct udevice *dev); */ int sandbox_clk_test_get_bulk(struct udevice *dev); /** + * sandbox_clk_test_get_parent_rate - Ask the sandbox clock test device to + * query a passed clock's parent rate. + * + * @dev: The sandbox clock test (client) devivce. + * @return: The rate of the clock + */ +ulong sandbox_clk_test_get_parent_rate(struct udevice *dev); +/** * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a * clock's rate. * diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c index 4d276f55b9..8ea15614c1 100644 --- a/drivers/clk/clk_sandbox_test.c +++ b/drivers/clk/clk_sandbox_test.c @@ -64,6 +64,32 @@ int sandbox_clk_test_get_bulk(struct udevice *dev) return clk_get_bulk(dev, &sbct->bulk); } +ulong sandbox_clk_test_get_parent_rate(struct udevice *dev) +{ + struct sandbox_clk_test *sbct = dev_get_priv(dev); + struct clk *i2c_clk, *parent_clk; + struct udevice *parent_bkp; + ulong rate; + + parent_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_FIXED]; + i2c_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_I2C]; + + parent_clk->dev->driver_data = (ulong)parent_clk; + parent_bkp = i2c_clk->dev->parent; + i2c_clk->dev->parent = parent_clk->dev; + + rate = clk_get_parent_rate(i2c_clk); + + i2c_clk->dev->parent = parent_bkp; + parent_clk->dev->driver_data = 0; + + /* Check if cache'd value is correct */ + if (parent_clk->rate != 1234) + return 0; + + return rate; +} + ulong sandbox_clk_test_get_rate(struct udevice *dev, int id) { struct sandbox_clk_test *sbct = dev_get_priv(dev); diff --git a/test/dm/clk.c b/test/dm/clk.c index 1685532259..438e4277f0 100644 --- a/test/dm/clk.c +++ b/test/dm/clk.c @@ -121,6 +121,7 @@ static int dm_test_clk(struct unit_test_state *uts) ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C)); ut_asserteq(0, sandbox_clk_test_get_by_id(dev_test)); + ut_asserteq(1234, sandbox_clk_test_get_parent_rate(dev_test)); ut_assertok(sandbox_clk_test_free(dev_test)); return 0;