summaryrefslogtreecommitdiff
path: root/drivers/clk/clk_pic32.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2016-06-17 15:44:00 (GMT)
committerSimon Glass <sjg@chromium.org>2016-06-19 23:05:55 (GMT)
commit135aa95002646c46e89de93fa36adad1b010548f (patch)
treeb601e08f7d91c7e2cda127d59f8f81128d0cb1ac /drivers/clk/clk_pic32.c
parent4581b717b1bf0fb04e7d9fcaf3d4c23d357154ac (diff)
downloadu-boot-fsl-qoriq-135aa95002646c46e89de93fa36adad1b010548f.tar.xz
clk: convert API to match reset/mailbox style
The following changes are made to the clock API: * The concept of "clocks" and "peripheral clocks" are unified; each clock provider now implements a single set of clocks. This provides a simpler conceptual interface to clients, and better aligns with device tree clock bindings. * Clocks are now identified with a single "struct clk", rather than requiring clients to store the clock provider device and clock identity values separately. For simple clock consumers, this isolates clients from internal details of the clock API. * clk.h is split so it only contains the client/consumer API, whereas clk-uclass.h contains the provider API. This aligns with the recently added reset and mailbox APIs. * clk_ops .of_xlate(), .request(), and .free() are added so providers can customize these operations if needed. This also aligns with the recently added reset and mailbox APIs. * clk_disable() is added. * All users of the current clock APIs are updated. * Sandbox clock tests are updated to exercise clock lookup via DT, and clock enable/disable. * rkclk_get_clk() is removed and replaced with standard APIs. Buildman shows no clock-related errors for any board for which buildman can download a toolchain. test/py passes for sandbox (which invokes the dm clk test amongst others). Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/clk/clk_pic32.c')
-rw-r--r--drivers/clk/clk_pic32.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c
index 5d88354..70ec354 100644
--- a/drivers/clk/clk_pic32.c
+++ b/drivers/clk/clk_pic32.c
@@ -6,7 +6,7 @@
*/
#include <common.h>
-#include <clk.h>
+#include <clk-uclass.h>
#include <dm.h>
#include <div64.h>
#include <wait_bit.h>
@@ -339,24 +339,17 @@ static void pic32_clk_init(struct udevice *dev)
pic32_mpll_init(priv);
}
-static ulong pic32_clk_get_rate(struct udevice *dev)
+static ulong pic32_get_rate(struct clk *clk)
{
- struct pic32_clk_priv *priv = dev_get_priv(dev);
-
- return pic32_get_cpuclk(priv);
-}
-
-static ulong pic32_get_periph_rate(struct udevice *dev, int periph)
-{
- struct pic32_clk_priv *priv = dev_get_priv(dev);
+ struct pic32_clk_priv *priv = dev_get_priv(clk->dev);
ulong rate;
- switch (periph) {
+ switch (clk->id) {
case PB1CLK ... PB7CLK:
- rate = pic32_get_pbclk(priv, periph);
+ rate = pic32_get_pbclk(priv, clk->id);
break;
case REF1CLK ... REF5CLK:
- rate = pic32_get_refclk(priv, periph);
+ rate = pic32_get_refclk(priv, clk->id);
break;
case PLLCLK:
rate = pic32_get_pll_rate(priv);
@@ -372,15 +365,15 @@ static ulong pic32_get_periph_rate(struct udevice *dev, int periph)
return rate;
}
-static ulong pic32_set_periph_rate(struct udevice *dev, int periph, ulong rate)
+static ulong pic32_set_rate(struct clk *clk, ulong rate)
{
- struct pic32_clk_priv *priv = dev_get_priv(dev);
+ struct pic32_clk_priv *priv = dev_get_priv(clk->dev);
ulong pll_hz;
- switch (periph) {
+ switch (clk->id) {
case REF1CLK ... REF5CLK:
pll_hz = pic32_get_pll_rate(priv);
- pic32_set_refclk(priv, periph, pll_hz, rate, ROCLK_SRC_SPLL);
+ pic32_set_refclk(priv, clk->id, pll_hz, rate, ROCLK_SRC_SPLL);
break;
default:
break;
@@ -390,9 +383,8 @@ static ulong pic32_set_periph_rate(struct udevice *dev, int periph, ulong rate)
}
static struct clk_ops pic32_pic32_clk_ops = {
- .get_rate = pic32_clk_get_rate,
- .set_periph_rate = pic32_set_periph_rate,
- .get_periph_rate = pic32_get_periph_rate,
+ .set_rate = pic32_set_rate,
+ .get_rate = pic32_get_rate,
};
static int pic32_clk_probe(struct udevice *dev)