From patchwork Sun Jun 21 13:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 242731 List-Id: U-Boot discussion From: sagar.kadam at sifive.com (Sagar Shrikant Kadam) Date: Sun, 21 Jun 2020 06:10:05 -0700 Subject: [PATCH v4 1/4] fu540: prci: add request and free clock handlers In-Reply-To: <1592745008-17196-1-git-send-email-sagar.kadam@sifive.com> References: <1592745008-17196-1-git-send-email-sagar.kadam@sifive.com> Message-ID: <1592745008-17196-2-git-send-email-sagar.kadam@sifive.com> Add clk_request handler to check if a valid clock is requested. Here clk_free handler is added for debug purpose which will display details of clock passed to clk_free. Signed-off-by: Sagar Shrikant Kadam Reviewed-by: Pragnesh Patel --- drivers/clk/sifive/fu540-prci.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c index fe6e0d4..9a9ff6b 100644 --- a/drivers/clk/sifive/fu540-prci.c +++ b/drivers/clk/sifive/fu540-prci.c @@ -686,6 +686,25 @@ static ulong sifive_fu540_prci_set_rate(struct clk *clk, ulong rate) return rate; } +static int sifive_fu540_prci_clk_request(struct clk *clk) +{ + debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev, + clk->id); + + if (clk->id >= ARRAY_SIZE(__prci_init_clocks)) + return -EINVAL; + + return 0; +} + +static int sifive_fu540_prci_clk_free(struct clk *clk) +{ + debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev, + clk->id); + + return 0; +} + static int sifive_fu540_prci_enable(struct clk *clk) { struct __prci_clock *pc; @@ -755,6 +774,8 @@ static struct clk_ops sifive_fu540_prci_ops = { .get_rate = sifive_fu540_prci_get_rate, .enable = sifive_fu540_prci_enable, .disable = sifive_fu540_prci_disable, + .request = sifive_fu540_prci_clk_request, + .rfree = sifive_fu540_prci_clk_free, }; static const struct udevice_id sifive_fu540_prci_ids[] = {