From: Peng Fan Date: Tue, 30 Apr 2019 10:17:40 +0000 Subject: [U-Boot] [i.MX8MM+CCF 03/41] clk: introduce clk_dev_binded In-Reply-To: <20190430103056.32537-1-peng.fan@nxp.com> References: <20190430103056.32537-1-peng.fan@nxp.com> Message-ID: <20190430103056.32537-4-peng.fan@nxp.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de When support Clock Common Framework, U-Boot use dev for clk tree information, there is no clk->parent. When support composite clk, it contains mux/gate/divider, but the mux/gate/divider is not binded with device. So we could not use dev_get_driver_data to get the correct clk_mux/gate/divider. So add clk_dev_binded to let choose the correct method. Signed-off-by: Peng Fan --- drivers/clk/clk.c | 8 ++++++++ include/clk.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0a0fffb50b..025bb99ecc 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -54,3 +54,11 @@ const char *clk_hw_get_name(const struct clk *hw) { return hw->dev->name; } + +bool clk_dev_binded(struct clk *clk) +{ + if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND)) + return true; + + return false; +} diff --git a/include/clk.h b/include/clk.h index a4ecca9fbc..8199119d01 100644 --- a/include/clk.h +++ b/include/clk.h @@ -337,4 +337,13 @@ static inline bool clk_valid(struct clk *clk) * @return zero on success, or -ENOENT on error */ int clk_get_by_id(ulong id, struct clk **clkp); + +/** + * clk_dev_binded() - Check whether the clk has a device binded + * + * @clk A pointer to the clk + * + * @return true on binded, or false on no + */ +bool clk_dev_binded(struct clk *clk); #endif -- 2.16.4