From patchwork Thu May 5 15:53:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 9025701 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 7E8FC9F372 for ; Thu, 5 May 2016 15:57:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 801C1203AE for ; Thu, 5 May 2016 15:57:08 +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 9608B203A4 for ; Thu, 5 May 2016 15:57:07 +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 1ayLbv-0007li-5v; Thu, 05 May 2016 15:54:43 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ayLbT-0007WQ-Kn; Thu, 05 May 2016 15:54:17 +0000 Received: from rasp3a.intern.sperl.org (account martin@sperl.org [10.10.10.43] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6448387; Thu, 05 May 2016 15:53:31 +0000 From: kernel@martin.sperl.org To: Rob Herring , Mark Rutland , Stephen Warren , Lee Jones , Eric Anholt , Michael Turquette , Stephen Boyd , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH 4/5] clk: bcm2835: allow setting clocks flags via the dt Date: Thu, 5 May 2016 15:53:27 +0000 Message-Id: <1462463608-22940-5-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462463608-22940-1-git-send-email-kernel@martin.sperl.org> References: <1462463608-22940-1-git-send-email-kernel@martin.sperl.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160505_085416_066843_B7F5B1F9 X-CRM114-Status: GOOD ( 11.04 ) X-Spam-Score: -0.9 (/) 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: Martin Sperl 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=-6.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 From: Martin Sperl Allow setting flags for each clock via the device tree. Signed-off-by: Martin Sperl --- drivers/clk/bcm/clk-bcm2835.c | 57 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 8a44ebf..c80487e 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1125,7 +1125,8 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = { }; static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman, - const struct bcm2835_pll_data *data) + const struct bcm2835_pll_data *data, + u32 flags) { struct bcm2835_pll *pll; struct clk_init_data init; @@ -1152,7 +1153,8 @@ static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman, static struct clk * bcm2835_register_pll_divider(struct bcm2835_cprman *cprman, - const struct bcm2835_pll_divider_data *data) + const struct bcm2835_pll_divider_data *data, + u32 flags) { struct bcm2835_pll_divider *divider; struct clk_init_data init; @@ -1223,8 +1225,10 @@ static u32 bcm2835_register_clock_default_parents( struct device *dev, const struct bcm2835_clock_data *data); -static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman, - const struct bcm2835_clock_data *data) +static struct clk * +bcm2835_register_clock(struct bcm2835_cprman *cprman, + const struct bcm2835_clock_data *data, + u32 flags) { struct bcm2835_clock *clock; struct clk_init_data init; @@ -1270,14 +1274,19 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman, clock->cprman = cprman; clock->data = data; clock->hw.init = &init; - clock->flags = bcm2835_register_clock_default_parents( - cprman->dev, data); + + clock->flags = flags; + if ((clock->flags & (BIT(data->num_mux_parents) - 1)) == 0) + clock->flags |= bcm2835_register_clock_default_parents( + cprman->dev, data); return devm_clk_register(cprman->dev, &clock->hw); } -static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman, - const struct bcm2835_gate_data *data) +static struct clk * +bcm2835_register_gate(struct bcm2835_cprman *cprman, + const struct bcm2835_gate_data *data, + u32 flags) { return clk_register_gate(cprman->dev, data->name, data->parent, CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, @@ -1286,7 +1295,7 @@ static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman, } typedef struct clk *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman, - const void *data); + const void *data, int flags); struct bcm2835_clk_desc { bcm2835_clk_register clk_register; const void *data; @@ -1861,6 +1870,10 @@ static int bcm2835_clk_probe(struct platform_device *pdev) struct resource *res; const struct bcm2835_clk_desc *desc; const size_t asize = ARRAY_SIZE(clk_desc_array); + u32 flags[asize], index; + struct property *prop; + const __be32 *cur; + int ret; size_t i; cprman = devm_kzalloc(dev, @@ -1869,6 +1882,29 @@ static int bcm2835_clk_probe(struct platform_device *pdev) if (!cprman) return -ENOMEM; + /* fill in flags from dt */ + memset(flags, 0, sizeof(flags)); + i = 0; + of_property_for_each_u32(dev->of_node, "brcm,clock-index", + prop, cur, index) { + if (index >= asize) { + dev_err(dev, + "clock-index %d in \"brcm,clock-index\" is out of bounds at position %d\n", + index, i); + } else { + ret = of_property_read_u32_index(dev->of_node, + "brcm,clock-flags", + i, &flags[index]); + if (ret) { + dev_err(dev, + "no value at position %d in \"brcm,clock-flags\" - %d\n", + i, ret); + } + } + /* increment index */ + i++; + } + spin_lock_init(&cprman->regs_lock); cprman->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1889,7 +1925,8 @@ static int bcm2835_clk_probe(struct platform_device *pdev) for (i = 0; i < asize; i++) { desc = &clk_desc_array[i]; if (desc->clk_register && desc->data) - clks[i] = desc->clk_register(cprman, desc->data); + clks[i] = desc->clk_register(cprman, desc->data, + flags[i]); } return of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,