From patchwork Fri Jun 10 00:27:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 9168627 X-Patchwork-Delegate: mturquette@baylibre.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C8A3604DB for ; Fri, 10 Jun 2016 00:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EE8C27248 for ; Fri, 10 Jun 2016 00:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7396428364; Fri, 10 Jun 2016 00:27:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D156A2835A for ; Fri, 10 Jun 2016 00:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751118AbcFJA1x (ORCPT ); Thu, 9 Jun 2016 20:27:53 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34698 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbcFJA1w (ORCPT ); Thu, 9 Jun 2016 20:27:52 -0400 Received: by mail-pf0-f171.google.com with SMTP id 62so17773637pfd.1 for ; Thu, 09 Jun 2016 17:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i5nAAR2Vhmed5Ax6Kg7R8R1M0NsagmD/RPK0VKQrD1A=; b=VlnEdnHewSRIxfnO6CIG2sasfEMugqxqUbbHcgFZXKOhiYplat6BWNTykREIagogwK TocIkiXXg+jEHV17IDMglsx68yWoUofxzO9PcLbQE0tEq+RbL1qNYhke/iDFdAew1JxO w/UiIcB0KYnmcv2BChHp1rt1fDP78LCjF0gFUdq+EU456xJMMdfsvMUbrVBkNjXsfAS9 lTuyxzGU2paO3viDirAbxs5bNcBuM816gYCURtOv/HDcyFB/u/+HxcVZIMHpziv6xFUh xP5Uaqs6QNn7aqzGtoKnzJOi8FmbP9vkgMP9dvuSAIfAI0+BOi3IqYG8FtfnQ6Fc1/Af gLlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i5nAAR2Vhmed5Ax6Kg7R8R1M0NsagmD/RPK0VKQrD1A=; b=hi/7Yo5htL3txj0uvDlJrVDwhQy9eZYEhbXnXkuyyx/PR5gLgQ9z+Z1MeMvgGB1PoH BGAw0jDTZ/wWN8Cf9xVSV+Qqwq/Fs8bXClff5nvNSAdFG6wyFWmkO0ZNrACZxngtDc1i DFebxGuJWFV+XEKit37kCvAkbwhi9sNAA1/PzeKKsQuU+VXeZeP7Mnp2/iGdcXZ10Jb9 nFSJSLmpqzg5L63YsBX6ywrStJVkn1/QnfEJogWVNURp9fqvB+Dr6srY6ShFcEYgDNd+ wsCctcDcaeQgCNebmXjg2gK/4gK0yESsNiwvuLZ79TSx3IA5tUguNu0bR8wPCYj6LVix FBXA== X-Gm-Message-State: ALyK8tLWaHuGGI1+jnHVOvYPKei9lv8QC4DB/cYE3pw8uXHkuecIxhheD/iMkLfUDEcbslSm X-Received: by 10.98.30.133 with SMTP id e127mr7441104pfe.112.1465518471720; Thu, 09 Jun 2016 17:27:51 -0700 (PDT) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id lg17sm12670529pab.36.2016.06.09.17.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 17:27:51 -0700 (PDT) From: Michael Turquette To: linux-clk@vger.kernel.org Cc: linux-amlogic@lists.infradead.org, khilman@baylibre.com, carlo@endlessm.com, victor.wan@amlogic.com, jerry.cao@amlogic.com, xing.xu@amlogic.com Subject: [PATCH 02/10] clk: meson8b: clean up fixed rate clocks Date: Thu, 9 Jun 2016 17:27:39 -0700 Message-Id: <1465518467-23939-3-git-send-email-mturquette@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465518467-23939-1-git-send-email-mturquette@baylibre.com> References: <1465518467-23939-1-git-send-email-mturquette@baylibre.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the fixed_rate registration function and helpers from clkc.[ch]. Replace unnecessary configuration struct with static initialization of the desired clock type. While we're here, begin the transition to a proper platform_driver and call of_clk_add_hw_provider with a shiny new struct clk_hw_onecell_data. Signed-off-by: Michael Turquette --- drivers/clk/meson/clkc.c | 34 -------------------- drivers/clk/meson/clkc.h | 26 --------------- drivers/clk/meson/meson8b-clkc.c | 69 +++++++++++++++++++++++++++++++--------- 3 files changed, 54 insertions(+), 75 deletions(-) diff --git a/drivers/clk/meson/clkc.c b/drivers/clk/meson/clkc.c index d920d41..c6802fd 100644 --- a/drivers/clk/meson/clkc.c +++ b/drivers/clk/meson/clkc.c @@ -167,36 +167,6 @@ meson_clk_register_fixed_factor(const struct clk_conf *clk_conf, return clk; } -static struct clk * __init -meson_clk_register_fixed_rate(const struct clk_conf *clk_conf, - void __iomem *clk_base) -{ - struct clk *clk; - const struct fixed_rate_conf *fixed_rate_conf; - const struct parm *r; - unsigned long rate; - u32 reg; - - fixed_rate_conf = &clk_conf->conf.fixed_rate; - rate = fixed_rate_conf->rate; - - if (!rate) { - r = &fixed_rate_conf->rate_parm; - reg = readl(clk_base + clk_conf->reg_off + r->reg_off); - rate = PARM_GET(r->width, r->shift, reg); - } - - rate *= 1000000; - - clk = clk_register_fixed_rate(NULL, - clk_conf->clk_name, - clk_conf->num_parents - ? clk_conf->clks_parent[0] : NULL, - clk_conf->flags, rate); - - return clk; -} - void __init meson_clk_register_clks(const struct clk_conf *clk_confs, unsigned int nr_confs, void __iomem *clk_base) @@ -208,10 +178,6 @@ void __init meson_clk_register_clks(const struct clk_conf *clk_confs, const struct clk_conf *clk_conf = &clk_confs[i]; switch (clk_conf->clk_type) { - case CLK_FIXED_RATE: - clk = meson_clk_register_fixed_rate(clk_conf, - clk_base); - break; case CLK_FIXED_FACTOR: clk = meson_clk_register_fixed_factor(clk_conf, clk_base); diff --git a/drivers/clk/meson/clkc.h b/drivers/clk/meson/clkc.h index 609ae92..b23b057 100644 --- a/drivers/clk/meson/clkc.h +++ b/drivers/clk/meson/clkc.h @@ -69,11 +69,6 @@ struct fixed_fact_conf { struct parm mult_parm; }; -struct fixed_rate_conf { - unsigned long rate; - struct parm rate_parm; -}; - struct composite_conf { struct parm mux_parm; struct parm div_parm; @@ -89,7 +84,6 @@ struct composite_conf { enum clk_type { CLK_FIXED_FACTOR, - CLK_FIXED_RATE, CLK_COMPOSITE, CLK_CPU, CLK_PLL, @@ -105,32 +99,12 @@ struct clk_conf { unsigned long flags; union { struct fixed_fact_conf fixed_fact; - struct fixed_rate_conf fixed_rate; const struct composite_conf *composite; struct pll_conf *pll; const struct clk_div_table *div_table; } conf; }; -#define FIXED_RATE_P(_ro, _ci, _cn, _f, _c) \ - { \ - .reg_off = (_ro), \ - .clk_type = CLK_FIXED_RATE, \ - .clk_id = (_ci), \ - .clk_name = (_cn), \ - .flags = (_f), \ - .conf.fixed_rate.rate_parm = _c, \ - } \ - -#define FIXED_RATE(_ci, _cn, _f, _r) \ - { \ - .clk_type = CLK_FIXED_RATE, \ - .clk_id = (_ci), \ - .clk_name = (_cn), \ - .flags = (_f), \ - .conf.fixed_rate.rate = (_r), \ - } \ - #define PLL(_ro, _ci, _cn, _cp, _f, _c) \ { \ .reg_off = (_ro), \ diff --git a/drivers/clk/meson/meson8b-clkc.c b/drivers/clk/meson/meson8b-clkc.c index 444ef94..9afd480 100644 --- a/drivers/clk/meson/meson8b-clkc.c +++ b/drivers/clk/meson/meson8b-clkc.c @@ -33,7 +33,6 @@ * * [0] http://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf */ -#define MESON8B_REG_CTL0_ADDR 0x0000 #define MESON8B_REG_SYS_CPU_CNTL1 0x015c /* 0x57 offset in data sheet */ #define MESON8B_REG_HHI_MPEG 0x0174 /* 0x5d offset in data sheet */ #define MESON8B_REG_MALI 0x01b0 /* 0x6c offset in data sheet */ @@ -149,12 +148,25 @@ static const struct composite_conf mali_conf __initconst = { .gate_parm = PARM(0x00, 8, 1), }; -static const struct clk_conf meson8b_xtal_conf __initconst = - FIXED_RATE_P(MESON8B_REG_CTL0_ADDR, CLKID_XTAL, "xtal", 0, - PARM(0x00, 4, 7)); +static struct clk_fixed_rate meson8b_xtal = { + .fixed_rate = 24000000, + .hw.init = &(struct clk_init_data){ + .name = "xtal", + .num_parents = 0, + .ops = &clk_fixed_rate_ops, + }, +}; + +static struct clk_fixed_rate meson8b_zero = { + .fixed_rate = 0, + .hw.init = &(struct clk_init_data){ + .name = "zero", + .num_parents = 0, + .ops = &clk_fixed_rate_ops, + }, +}; static const struct clk_conf meson8b_clk_confs[] __initconst = { - FIXED_RATE(CLKID_ZERO, "zero", 0, 0), PLL(MESON8B_REG_PLL_FIXED, CLKID_PLL_FIXED, "fixed_pll", p_xtal, 0, &pll_confs), PLL(MESON8B_REG_PLL_VID, CLKID_PLL_VID, "vid_pll", @@ -174,23 +186,29 @@ static const struct clk_conf meson8b_clk_confs[] __initconst = { CLK_IGNORE_UNUSED, &mali_conf), }; +/* + * FIXME we cannot register two providers w/o breaking things. Luckily only + * clk81 is actually used by any drivers. Convert clk81 to use + * clk_hw_onecell_data last and flip the switch to call of_clk_add_hw_provider + * instead of of_clk_add_provider in the clk81 conversion patch to keep from + * breaking bisect. Then delete this comment ;-) + */ +static struct clk_hw_onecell_data meson8b_hw_onecell_data = { + .hws = { + [CLKID_XTAL] = &meson8b_xtal.hw, + [CLKID_ZERO] = &meson8b_zero.hw, + }, + .num = CLK_NR_CLKS, +}; + static void __init meson8b_clkc_init(struct device_node *np) { void __iomem *clk_base; + int ret, clkid; if (!meson_clk_init(np, CLK_NR_CLKS)) return; - /* XTAL */ - clk_base = of_iomap(np, 0); - if (!clk_base) { - pr_err("%s: Unable to map xtal base\n", __func__); - return; - } - - meson_clk_register_clks(&meson8b_xtal_conf, 1, clk_base); - iounmap(clk_base); - /* Generic clocks and PLLs */ clk_base = of_iomap(np, 1); if (!clk_base) { @@ -198,8 +216,29 @@ static void __init meson8b_clkc_init(struct device_node *np) return; } + /* + * register all clks + * CLKID_UNUSED = 0, so skip it and start with CLKID_XTAL = 1 + */ + for (clkid = CLKID_XTAL; clkid < CLK_NR_CLKS; clkid++) { + /* array might be sparse */ + if (!meson8b_hw_onecell_data.hws[clkid]) + continue; + + /* FIXME convert to devm_clk_register */ + ret = clk_hw_register(NULL, meson8b_hw_onecell_data.hws[clkid]); + if (ret) + goto unregister; + } + meson_clk_register_clks(meson8b_clk_confs, ARRAY_SIZE(meson8b_clk_confs), clk_base); + return; + +/* FIXME remove after converting to platform_driver/devm_clk_register */ +unregister: + for (clkid = CLK_NR_CLKS - 1; clkid >= 0; clkid--) + clk_hw_unregister(meson8b_hw_onecell_data.hws[clkid]); } CLK_OF_DECLARE(meson8b_clock, "amlogic,meson8b-clkc", meson8b_clkc_init);