From patchwork Fri Jul 31 15:14:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 6914021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E6936C05AC for ; Fri, 31 Jul 2015 15:17:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 105D020304 for ; Fri, 31 Jul 2015 15:17:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D401B202AE for ; Fri, 31 Jul 2015 15:17:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZLC2I-0008JS-Mo; Fri, 31 Jul 2015 15:15:50 +0000 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZLC1R-0006QO-Eb; Fri, 31 Jul 2015 15:14:59 +0000 Received: by wicmv11 with SMTP id mv11so62068826wic.0; Fri, 31 Jul 2015 08:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L9C1RsiJRkVbfpOlgGLBA2lubtE38WFMdcYgmzkiD2E=; b=IUQH0xDJ1I/MXEij7mwXfLTRvb9ECvFvqmUogJ2cbx6JRWQ0oD/Jor0vUNCRZgq7gL 4+piHVKHK6btL0wk6StH1BdE+Twpj2LcCTigHkQ5nQz92ZigqQ7Bgr0ELy5Kcb3Zf63E ohCk6Oac8xlGER+S9LL05v6EsxXJ63pyX2kkizla7cVglHvosbzspKOG75u1cuzHWTZ8 WRPm0du6B+WB13JW1YTbckBRChsweu6oDLfkdI1hkwcIgBdGeGSwjjXcYghxceClO2QD LPlr/OKNx4klxZQCglNatl5u9VZUN6FBrPNyZD4cgwy89NI3xng9S+fay7Ju/+CbagCW 497A== X-Received: by 10.180.231.40 with SMTP id td8mr7506020wic.9.1438355675943; Fri, 31 Jul 2015 08:14:35 -0700 (PDT) Received: from localhost.localdomain (225.91.135.37.dynamic.jazztel.es. [37.135.91.225]) by smtp.gmail.com with ESMTPSA id nb9sm4958844wic.10.2015.07.31.08.14.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Jul 2015 08:14:35 -0700 (PDT) From: Matthias Brugger To: mturquette@linaro.org, sboyd@codeaurora.org, matthias.bgg@gmail.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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150731_081457_785522_2F7A18DB X-CRM114-Status: GOOD ( 15.54 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jamesjj.liao@mediatek.com, p.zabel@pengutronix.com, manabian@gmail.com, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, henryc.chen@mediatek.com, linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);