From: Stephen Boyd <stephen.boyd@linaro.org>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Eric Anholt <eric@anholt.net>,
Martin Sperl <kernel@martin.sperl.org>
Subject: [PATCH 04/34] clk: bcm2835: Migrate to clk_hw based registration and OF APIs
Date: Wed, 1 Jun 2016 16:15:03 -0700 [thread overview]
Message-ID: <20160601231533.9354-5-stephen.boyd@linaro.org> (raw)
In-Reply-To: <20160601231533.9354-1-stephen.boyd@linaro.org>
Now that we have clk_hw based provider APIs to register clks, we
can get rid of struct clk pointers while registering clks in
these drivers, allowing us to move closer to a clear split of
consumer and provider clk APIs.
Cc: Eric Anholt <eric@anholt.net>
Cc: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
See commit 58657d189a2f and it's children for details on this
new registration API.
drivers/clk/bcm/clk-bcm2835-aux.c | 28 ++++++-------
drivers/clk/bcm/clk-bcm2835.c | 83 +++++++++++++++++++++------------------
2 files changed, 57 insertions(+), 54 deletions(-)
diff --git a/drivers/clk/bcm/clk-bcm2835-aux.c b/drivers/clk/bcm/clk-bcm2835-aux.c
index 3a177ade6e6c..bd750cf2238d 100644
--- a/drivers/clk/bcm/clk-bcm2835-aux.c
+++ b/drivers/clk/bcm/clk-bcm2835-aux.c
@@ -25,7 +25,7 @@
static int bcm2835_aux_clk_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct clk_onecell_data *onecell;
+ struct clk_hw_onecell_data *onecell;
const char *parent;
struct clk *parent_clk;
struct resource *res;
@@ -41,28 +41,24 @@ static int bcm2835_aux_clk_probe(struct platform_device *pdev)
if (IS_ERR(reg))
return PTR_ERR(reg);
- onecell = devm_kmalloc(dev, sizeof(*onecell), GFP_KERNEL);
+ onecell = devm_kmalloc(dev, sizeof(*onecell) + sizeof(*onecell->hws) *
+ BCM2835_AUX_CLOCK_COUNT, GFP_KERNEL);
if (!onecell)
return -ENOMEM;
- onecell->clk_num = BCM2835_AUX_CLOCK_COUNT;
- onecell->clks = devm_kcalloc(dev, BCM2835_AUX_CLOCK_COUNT,
- sizeof(*onecell->clks), GFP_KERNEL);
- if (!onecell->clks)
- return -ENOMEM;
+ onecell->num = BCM2835_AUX_CLOCK_COUNT;
gate = reg + BCM2835_AUXENB;
- onecell->clks[BCM2835_AUX_CLOCK_UART] =
- clk_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);
-
- onecell->clks[BCM2835_AUX_CLOCK_SPI1] =
- clk_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);
+ onecell->hws[BCM2835_AUX_CLOCK_UART] =
+ clk_hw_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);
- onecell->clks[BCM2835_AUX_CLOCK_SPI2] =
- clk_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);
+ onecell->hws[BCM2835_AUX_CLOCK_SPI1] =
+ clk_hw_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);
- of_clk_add_provider(pdev->dev.of_node, of_clk_src_onecell_get, onecell);
+ onecell->hws[BCM2835_AUX_CLOCK_SPI2] =
+ clk_hw_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);
- return 0;
+ return of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get,
+ onecell);
}
static const struct of_device_id bcm2835_aux_clk_of_match[] = {
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 7a7970865c2d..0131b922d3c5 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -302,8 +302,8 @@ struct bcm2835_cprman {
spinlock_t regs_lock; /* spinlock for all clocks */
const char *osc_name;
- struct clk_onecell_data onecell;
- struct clk *clks[];
+ /* Must be last */
+ struct clk_hw_onecell_data onecell;
};
static inline void cprman_write(struct bcm2835_cprman *cprman, u32 reg, u32 val)
@@ -344,24 +344,24 @@ static int bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base,
*/
void __init bcm2835_init_clocks(void)
{
- struct clk *clk;
+ struct clk_hw *hw;
int ret;
- clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, 0, 126000000);
- if (IS_ERR(clk))
+ hw = clk_hw_register_fixed_rate(NULL, "apb_pclk", NULL, 0, 126000000);
+ if (IS_ERR(hw))
pr_err("apb_pclk not registered\n");
- clk = clk_register_fixed_rate(NULL, "uart0_pclk", NULL, 0, 3000000);
- if (IS_ERR(clk))
+ hw = clk_hw_register_fixed_rate(NULL, "uart0_pclk", NULL, 0, 3000000);
+ if (IS_ERR(hw))
pr_err("uart0_pclk not registered\n");
- ret = clk_register_clkdev(clk, NULL, "20201000.uart");
+ ret = clk_hw_register_clkdev(hw, NULL, "20201000.uart");
if (ret)
pr_err("uart0_pclk alias not registered\n");
- clk = clk_register_fixed_rate(NULL, "uart1_pclk", NULL, 0, 125000000);
- if (IS_ERR(clk))
+ hw = clk_hw_register_fixed_rate(NULL, "uart1_pclk", NULL, 0, 125000000);
+ if (IS_ERR(hw))
pr_err("uart1_pclk not registered\n");
- ret = clk_register_clkdev(clk, NULL, "20215000.uart");
+ ret = clk_hw_register_clkdev(hw, NULL, "20215000.uart");
if (ret)
pr_err("uart1_pclk alias not registered\n");
}
@@ -1121,11 +1121,12 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
.debug_init = bcm2835_clock_debug_init,
};
-static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
- const struct bcm2835_pll_data *data)
+static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
+ const struct bcm2835_pll_data *data)
{
struct bcm2835_pll *pll;
struct clk_init_data init;
+ int ret;
memset(&init, 0, sizeof(init));
@@ -1144,17 +1145,20 @@ static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
pll->data = data;
pll->hw.init = &init;
- return devm_clk_register(cprman->dev, &pll->hw);
+ ret = devm_clk_hw_register(cprman->dev, &pll->hw);
+ if (ret)
+ return NULL;
+ return &pll->hw;
}
-static struct clk *
+static struct clk_hw *
bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
const struct bcm2835_pll_divider_data *data)
{
struct bcm2835_pll_divider *divider;
struct clk_init_data init;
- struct clk *clk;
const char *divider_name;
+ int ret;
if (data->fixed_divider != 1) {
divider_name = devm_kasprintf(cprman->dev, GFP_KERNEL,
@@ -1188,32 +1192,33 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
divider->cprman = cprman;
divider->data = data;
- clk = devm_clk_register(cprman->dev, ÷r->div.hw);
- if (IS_ERR(clk))
- return clk;
+ ret = devm_clk_hw_register(cprman->dev, ÷r->div.hw);
+ if (ret)
+ return ERR_PTR(ret);
/*
* PLLH's channels have a fixed divide by 10 afterwards, which
* is what our consumers are actually using.
*/
if (data->fixed_divider != 1) {
- return clk_register_fixed_factor(cprman->dev, data->name,
- divider_name,
- CLK_SET_RATE_PARENT,
- 1,
- data->fixed_divider);
+ return clk_hw_register_fixed_factor(cprman->dev, data->name,
+ divider_name,
+ CLK_SET_RATE_PARENT,
+ 1,
+ data->fixed_divider);
}
- return clk;
+ return ÷r->div.hw;
}
-static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman,
+static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
const struct bcm2835_clock_data *data)
{
struct bcm2835_clock *clock;
struct clk_init_data init;
const char *parents[1 << CM_SRC_BITS];
size_t i;
+ int ret;
/*
* Replace our "xosc" references with the oscillator's
@@ -1247,7 +1252,10 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman,
clock->data = data;
clock->hw.init = &init;
- return devm_clk_register(cprman->dev, &clock->hw);
+ ret = devm_clk_hw_register(cprman->dev, &clock->hw);
+ if (ret)
+ return ERR_PTR(ret);
+ return &clock->hw;
}
static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
@@ -1259,8 +1267,8 @@ static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
CM_GATE_BIT, 0, &cprman->regs_lock);
}
-typedef struct clk *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
- const void *data);
+typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
+ const void *data);
struct bcm2835_clk_desc {
bcm2835_clk_register clk_register;
const void *data;
@@ -1793,15 +1801,15 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
static int bcm2835_clk_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct clk **clks;
+ struct clk_hw **hws;
struct bcm2835_cprman *cprman;
struct resource *res;
const struct bcm2835_clk_desc *desc;
const size_t asize = ARRAY_SIZE(clk_desc_array);
size_t i;
- cprman = devm_kzalloc(dev,
- sizeof(*cprman) + asize * sizeof(*clks),
+ cprman = devm_kzalloc(dev, sizeof(*cprman) +
+ sizeof(*cprman->onecell.hws) * asize,
GFP_KERNEL);
if (!cprman)
return -ENOMEM;
@@ -1819,18 +1827,17 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, cprman);
- cprman->onecell.clk_num = asize;
- cprman->onecell.clks = cprman->clks;
- clks = cprman->clks;
+ cprman->onecell.num = asize;
+ hws = cprman->onecell.hws;
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);
+ hws[i] = desc->clk_register(cprman, desc->data);
}
- return of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,
- &cprman->onecell);
+ return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
+ &cprman->onecell);
}
static const struct of_device_id bcm2835_clk_of_match[] = {
--
2.7.4
next prev parent reply other threads:[~2016-06-01 23:15 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 23:14 [PATCH 00/34] Convert clk providers to clk_hw based APIs (part 1) Stephen Boyd
2016-06-01 23:15 ` [PATCH 01/34] clk: qcom: Migrate to clk_hw based registration and OF APIs Stephen Boyd
2016-06-01 23:15 ` [PATCH 02/34] clk: at91: " Stephen Boyd
2016-06-07 16:36 ` Alexandre Belloni
2016-06-07 16:40 ` Boris Brezillon
2016-09-15 0:39 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 03/34] clk: highbank: " Stephen Boyd
2016-06-02 1:02 ` Rob Herring
2016-06-30 19:25 ` Stephen Boyd
2016-06-01 23:15 ` Stephen Boyd [this message]
2016-06-02 18:25 ` [PATCH 04/34] clk: bcm2835: " Eric Anholt
2016-09-15 0:36 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 05/34] clk: bcm: iproc: " Stephen Boyd
2016-06-02 17:22 ` Ray Jui
2016-06-30 19:27 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 06/34] clk: bcm: kona: " Stephen Boyd
2016-08-24 23:08 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 07/34] clk: berlin: " Stephen Boyd
2016-06-05 17:41 ` Alexandre Belloni
[not found] ` <146528884761.28742.8093002152658120585@sboyd-linaro>
2016-06-07 16:33 ` Alexandre Belloni
2016-06-01 23:15 ` [PATCH 08/34] clk: asm9260: " Stephen Boyd
2016-08-24 23:09 ` Stephen Boyd
2016-08-24 23:10 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 09/34] clk: axi-clkgen: Migrate to clk_hw based OF and registration APIs Stephen Boyd
2016-08-24 23:11 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 10/34] clk: axm5516: " Stephen Boyd
2016-08-24 23:12 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 11/34] clk: cdce: " Stephen Boyd
2016-08-24 23:13 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 12/34] clk: cdce925: Migrate to clk_hw based OF and provider APIs Stephen Boyd
2016-08-25 0:19 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 13/34] clk: clps711x: Migrate to clk_hw based OF and registration APIs Stephen Boyd
2016-08-25 0:20 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 14/34] clk: cs2000: " Stephen Boyd
2016-08-25 0:21 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 15/34] clk: efm32gg: " Stephen Boyd
2016-08-25 0:22 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 16/34] clk: ls1x: " Stephen Boyd
2016-08-19 0:09 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 17/34] clk: maxgen: " Stephen Boyd
2016-06-07 18:50 ` Javier Martinez Canillas
2016-06-07 18:55 ` Javier Martinez Canillas
2016-08-16 20:06 ` Stephen Boyd
2016-08-17 3:00 ` Javier Martinez Canillas
2016-06-01 23:15 ` [PATCH 18/34] clk: mb86s7x: " Stephen Boyd
2016-08-25 0:27 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 19/34] clk: moxart: " Stephen Boyd
2016-08-25 0:25 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 20/34] clk: nomadik: " Stephen Boyd
2016-06-02 12:06 ` Linus Walleij
2016-06-30 19:26 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 21/34] clk: nspire: " Stephen Boyd
2016-08-25 0:25 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 22/34] clk: palmas: " Stephen Boyd
2016-08-25 0:25 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 23/34] clk: pwm: " Stephen Boyd
2016-08-25 0:25 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 24/34] clk: rk808: " Stephen Boyd
2016-08-25 0:30 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 25/34] clk: s2mps11: " Stephen Boyd
2016-06-03 7:18 ` Krzysztof Kozlowski
2016-06-08 7:22 ` Andi Shyti
2016-06-30 19:29 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 26/34] clk: scpi: " Stephen Boyd
2016-08-25 0:30 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 27/34] clk: si514: " Stephen Boyd
2016-08-25 0:30 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 28/34] clk: si5351: " Stephen Boyd
2016-08-25 0:30 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 29/34] clk: si570: " Stephen Boyd
2016-08-25 0:30 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 30/34] clk: stm32f3: " Stephen Boyd
2016-06-06 13:48 ` Daniel Thompson
2016-06-07 8:37 ` Stephen Boyd
2016-06-30 19:28 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 31/34] clk: twl6040: Migrate to clk_hw based " Stephen Boyd
2016-08-25 0:34 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 32/34] clk: u300: " Stephen Boyd
2016-06-02 12:06 ` Linus Walleij
2016-06-30 19:26 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 33/34] clk: vt8500: " Stephen Boyd
2016-08-25 0:36 ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 34/34] clk: wm831x: " Stephen Boyd
2016-08-25 0:36 ` Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160601231533.9354-5-stephen.boyd@linaro.org \
--to=stephen.boyd@linaro.org \
--cc=eric@anholt.net \
--cc=kernel@martin.sperl.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).