From patchwork Fri May 29 16:01:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 6508781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E575B9F1C1 for ; Fri, 29 May 2015 16:04:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1392320814 for ; Fri, 29 May 2015 16:04:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A39D207FE for ; Fri, 29 May 2015 16:04:42 +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 1YyMkF-00021L-Kl; Fri, 29 May 2015 16:02:51 +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 1YyMjS-0001Nq-Bl; Fri, 29 May 2015 16:02:03 +0000 Received: by wizo1 with SMTP id o1so29556150wiz.1; Fri, 29 May 2015 09:01:40 -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=DOk/y3scUIaAV/1f30IhNmMg9aqlj6L9izYa7+NmSOg=; b=dLipPCoNoYXs7pFYHVXgX3bBdS8PGQPRFiDWiRRl1Vj9UaZ/FATWUnnnXGZwoiiYEG RtiSEwWKYdgTGYo/Jpe3wcGK7w6rFwKHSNqMG0r+n58wOMqaifZMiPASflSRqKKNkxJ3 V2mRRQ27LIVpSTW/IBHvKpQDLcu7O4eagqjPt/tB0O39ppKzXg67ggD0u2/6H3778bv5 chCIHh1b4gx96Aj7gUPaZzJN1yD3bluZ2Rc0Bqlhe/1CnXYl+dVtXk1i20TnfUFc0uze sgmu/S/hra6EaG+18J0rXZqA4ik3H2K/pHbrFJLxTiKQ8Sj07qFpNyO1OpmWR6+2IVdj 1NtA== X-Received: by 10.194.79.225 with SMTP id m1mr16818275wjx.8.1432915300170; Fri, 29 May 2015 09:01:40 -0700 (PDT) Received: from localhost.localdomain (225.91.135.37.dynamic.jazztel.es. [37.135.91.225]) by mx.google.com with ESMTPSA id y19sm1153682wia.15.2015.05.29.09.01.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 09:01:39 -0700 (PDT) From: Matthias Brugger To: mturquette@linaro.org, sboyd@codeaurora.org, matthias.bgg@gmail.com Subject: [PATCH v2 2/3] clk: mediatek: Add support for clk-mux using regmap Date: Fri, 29 May 2015 18:01:27 +0200 Message-Id: <1432915288-14034-3-git-send-email-matthias.bgg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432915288-14034-1-git-send-email-matthias.bgg@gmail.com> References: <1432915288-14034-1-git-send-email-matthias.bgg@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150529_090202_542199_754F18A5 X-CRM114-Status: GOOD ( 13.56 ) X-Spam-Score: -0.8 (/) Cc: jamesjj.liao@mediatek.com, manabian@gmail.com, linux-kernel@vger.kernel.org, henryc.chen@mediatek.com, linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org, p.zabel@pengutronix.de, s.hauer@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 61035b9..3f41725 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);