Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754667AbbGaPOk (ORCPT ); Fri, 31 Jul 2015 11:14:40 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:36239 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754638AbbGaPOh (ORCPT ); Fri, 31 Jul 2015 11:14:37 -0400 From: Matthias Brugger To: mturquette@linaro.org, sboyd@codeaurora.org, matthias.bgg@gmail.com Cc: s.hauer@pengutronix.de, jamesjj.liao@mediatek.com, henryc.chen@mediatek.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, manabian@gmail.com, p.zabel@pengutronix.com Subject: [PATCH v4 RESEND 2/3] clk: mediatek: Add support for clk-mux using regmap Date: Fri, 31 Jul 2015 17:14:18 +0200 Message-Id: <1438355659-21558-3-git-send-email-matthias.bgg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438355659-21558-1-git-send-email-matthias.bgg@gmail.com> References: <1438355659-21558-1-git-send-email-matthias.bgg@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3049 Lines: 102 This patches adds support for the mediatek clocks to be able to register and use a clk-mux wich relies on regmap. Signed-off-by: Matthias Brugger --- drivers/clk/mediatek/clk-mtk.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 26 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 18444ae..cf953a8 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -111,6 +111,43 @@ int mtk_clk_register_gates(struct device_node *node, const struct mtk_gate *clks return 0; } +int mtk_clk_regm_register_mux(struct device_node *node, + const struct mtk_regm_mux *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + struct clk *clk; + struct regmap *regmap; + + if (!clk_data) + return -ENOMEM; + + regmap = syscon_node_to_regmap(node); + if (IS_ERR(regmap)) { + pr_err("Cannot find regmap for %s: %ld\n", node->full_name, + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } + + for (i = 0; i < num; i++) { + const struct mtk_regm_mux *mux = &clks[i]; + + clk = clk_regm_register_mux(NULL, mux->name, mux->parent_names, + mux->num_parents, 0, regmap, + mux->mux_offset, mux->mux_shift, + mux->mux_width, mux->flags, NULL); + if (IS_ERR(clk)) { + pr_err("Failed to register clk mux %s: %ld\n", + mux->name, PTR_ERR(clk)); + continue; + } + + clk_data->clks[mux->id] = clk; + } + + return 0; +} + struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 9dda9d8..6fe85ca 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -156,6 +156,32 @@ void __init mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data); +struct mtk_regm_mux { + int id; + const char *name; + const char * const *parent_names; + u8 num_parents; + unsigned flags; + uint32_t mux_offset; + uint32_t mux_shift; + uint32_t mux_width; +}; + +int __init mtk_clk_regm_register_mux(struct device_node *node, + const struct mtk_regm_mux *clks, int num, + struct clk_onecell_data *clk_data); + +#define MUX_REGMAP(_id, _name, _parents, _offset, _shift, _width) { \ + .id = _id, \ + .name = _name, \ + .parent_names = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = CLK_SET_RATE_PARENT, \ + .mux_offset = _offset, \ + .mux_shift = _shift, \ + .mux_width = _width, \ + } + #ifdef CONFIG_RESET_CONTROLLER void mtk_register_reset_controller(struct device_node *np, unsigned int num_regs, int regofs); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/