From patchwork Thu May 16 22:10:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1100763 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 454m0Z22nhz9s7h for ; Fri, 17 May 2019 08:13:50 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BAFA9C21DA1; Thu, 16 May 2019 22:12:10 +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 B4E8FC21DF9; Thu, 16 May 2019 22:11:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F0A36C21DD4; Thu, 16 May 2019 22:11:16 +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 EFE47C21E0D for ; Thu, 16 May 2019 22:11:12 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 454lxX4ntjz1rbLm; Fri, 17 May 2019 00:11:12 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 454lxX477Xz1qqkh; Fri, 17 May 2019 00:11:12 +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 LI30XH1-EoyK; Fri, 17 May 2019 00:11:10 +0200 (CEST) X-Auth-Info: /c5kSEznAJWOeolba+OjJ8QKbBoQePBtLau4zBy0HYQ= 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:10 +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:36 +0200 Message-Id: <20190516221042.3583-8-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 07/13] dm: clk: Define clk_get_parent() for clk operations 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 adds the clk_get_parent() function, which is responsible for getting the parent's struct clock pointer. U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the pdev->driver_data field is read. Signed-off-by: Lukasz Majewski Reviewed-by: Peng Fan Reviewed-by: Peng Fan Reviewed-by: Stefano Babic --- Changes in v4: None Changes in v3: - New patch drivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 79b3b0494c..1a726dafaa 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk) return ops->get_rate(clk); } +struct clk *clk_get_parent(struct clk *clk) +{ + struct udevice *pdev; + struct clk *pclk; + + debug("%s(clk=%p)\n", __func__, clk); + + pdev = dev_get_parent(clk->dev); + pclk = (struct clk *)dev_get_driver_data(pdev); + if (!pclk) + return ERR_PTR(-ENODEV); + + return pclk; +} + ulong clk_set_rate(struct clk *clk, ulong rate) { const struct clk_ops *ops = clk_dev_ops(clk->dev); diff --git a/include/clk.h b/include/clk.h index 89dc64bfaf..0873b1e507 100644 --- a/include/clk.h +++ b/include/clk.h @@ -259,6 +259,15 @@ int clk_free(struct clk *clk); ulong clk_get_rate(struct clk *clk); /** + * clk_get_parent() - Get current clock's parent. + * + * @clk: A clock struct that was previously successfully requested by + * clk_request/get_by_*(). + * @return pointer to parent's struct clk, or error code passed as pointer + */ +struct clk *clk_get_parent(struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by