From a54c959d8be9d057b1a192e34a378b74dd81c5f6 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 1 Mar 2014 22:05:44 -0600 Subject: clk: versatile: add versatile OSC support Versatile platforms share the same OSC programming model as Integrator platforms. Add the necessary parameters and init functions for Versatile. Renaming the file to clk-versatile.c as versatile is used as the family name for ARM, Ltd. boards. Signed-off-by: Rob Herring Acked-by: Mike Turquette Acked-by: Arnd Bergmann Reviewed-by: Linus Walleij --- drivers/clk/versatile/Makefile | 3 +- drivers/clk/versatile/clk-integrator.c | 69 ---------------------- drivers/clk/versatile/clk-versatile.c | 101 +++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 71 deletions(-) delete mode 100644 drivers/clk/versatile/clk-integrator.c create mode 100644 drivers/clk/versatile/clk-versatile.c diff --git a/drivers/clk/versatile/Makefile b/drivers/clk/versatile/Makefile index fd449f9b006d..162e519cb0f9 100644 --- a/drivers/clk/versatile/Makefile +++ b/drivers/clk/versatile/Makefile @@ -1,6 +1,5 @@ # Makefile for Versatile-specific clocks -obj-$(CONFIG_ICST) += clk-icst.o -obj-$(CONFIG_ARCH_INTEGRATOR) += clk-integrator.o +obj-$(CONFIG_ICST) += clk-icst.o clk-versatile.o obj-$(CONFIG_INTEGRATOR_IMPD1) += clk-impd1.o obj-$(CONFIG_ARCH_REALVIEW) += clk-realview.o obj-$(CONFIG_ARCH_VEXPRESS) += clk-vexpress.o diff --git a/drivers/clk/versatile/clk-integrator.c b/drivers/clk/versatile/clk-integrator.c deleted file mode 100644 index 734c4b8fe6ab..000000000000 --- a/drivers/clk/versatile/clk-integrator.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Clock driver for the ARM Integrator/AP and Integrator/CP boards - * Copyright (C) 2012 Linus Walleij - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include - -#include "clk-icst.h" - -#define INTEGRATOR_HDR_LOCK_OFFSET 0x14 - -/* Base offset for the core module */ -static void __iomem *cm_base; - -static const struct icst_params cp_auxosc_params = { - .vco_max = ICST525_VCO_MAX_5V, - .vco_min = ICST525_VCO_MIN, - .vd_min = 8, - .vd_max = 263, - .rd_min = 3, - .rd_max = 65, - .s2div = icst525_s2div, - .idx2s = icst525_idx2s, -}; - -static const struct clk_icst_desc __initdata cm_auxosc_desc = { - .params = &cp_auxosc_params, - .vco_offset = 0x1c, - .lock_offset = INTEGRATOR_HDR_LOCK_OFFSET, -}; - -static void __init of_integrator_cm_osc_setup(struct device_node *np) -{ - struct clk *clk = ERR_PTR(-EINVAL); - const char *clk_name = np->name; - const struct clk_icst_desc *desc = &cm_auxosc_desc; - const char *parent_name; - - if (!cm_base) { - /* Remap the core module base if not done yet */ - struct device_node *parent; - - parent = of_get_parent(np); - if (!np) { - pr_err("no parent on core module clock\n"); - return; - } - cm_base = of_iomap(parent, 0); - if (!cm_base) { - pr_err("could not remap core module base\n"); - return; - } - } - - parent_name = of_clk_get_parent_name(np, 0); - clk = icst_clk_register(NULL, desc, clk_name, parent_name, cm_base); - if (!IS_ERR(clk)) - of_clk_add_provider(np, of_clk_src_simple_get, clk); -} -CLK_OF_DECLARE(integrator_cm_auxosc_clk, - "arm,integrator-cm-auxosc", of_integrator_cm_osc_setup); diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c new file mode 100644 index 000000000000..a76981e88cb6 --- /dev/null +++ b/drivers/clk/versatile/clk-versatile.c @@ -0,0 +1,101 @@ +/* + * Clock driver for the ARM Integrator/AP, Integrator/CP, Versatile AB and + * Versatile PB boards. + * Copyright (C) 2012 Linus Walleij + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include + +#include "clk-icst.h" + +#define INTEGRATOR_HDR_LOCK_OFFSET 0x14 + +#define VERSATILE_SYS_OSCCLCD_OFFSET 0x1c +#define VERSATILE_SYS_LOCK_OFFSET 0x20 + +/* Base offset for the core module */ +static void __iomem *cm_base; + +static const struct icst_params cp_auxosc_params = { + .vco_max = ICST525_VCO_MAX_5V, + .vco_min = ICST525_VCO_MIN, + .vd_min = 8, + .vd_max = 263, + .rd_min = 3, + .rd_max = 65, + .s2div = icst525_s2div, + .idx2s = icst525_idx2s, +}; + +static const struct clk_icst_desc __initdata cm_auxosc_desc = { + .params = &cp_auxosc_params, + .vco_offset = 0x1c, + .lock_offset = INTEGRATOR_HDR_LOCK_OFFSET, +}; + +static const struct icst_params versatile_auxosc_params = { + .vco_max = ICST307_VCO_MAX, + .vco_min = ICST307_VCO_MIN, + .vd_min = 4 + 8, + .vd_max = 511 + 8, + .rd_min = 1 + 2, + .rd_max = 127 + 2, + .s2div = icst307_s2div, + .idx2s = icst307_idx2s, +}; + +static const struct clk_icst_desc versatile_auxosc_desc __initconst = { + .params = &versatile_auxosc_params, + .vco_offset = VERSATILE_SYS_OSCCLCD_OFFSET, + .lock_offset = VERSATILE_SYS_LOCK_OFFSET, +}; +static void __init cm_osc_setup(struct device_node *np, + const struct clk_icst_desc *desc) +{ + struct clk *clk = ERR_PTR(-EINVAL); + const char *clk_name = np->name; + const char *parent_name; + + if (!cm_base) { + /* Remap the core module base if not done yet */ + struct device_node *parent; + + parent = of_get_parent(np); + if (!np) { + pr_err("no parent on core module clock\n"); + return; + } + cm_base = of_iomap(parent, 0); + if (!cm_base) { + pr_err("could not remap core module base\n"); + return; + } + } + + parent_name = of_clk_get_parent_name(np, 0); + clk = icst_clk_register(NULL, desc, clk_name, parent_name, cm_base); + if (!IS_ERR(clk)) + of_clk_add_provider(np, of_clk_src_simple_get, clk); +} + +static void __init of_integrator_cm_osc_setup(struct device_node *np) +{ + cm_osc_setup(np, &cm_auxosc_desc); +} +CLK_OF_DECLARE(integrator_cm_auxosc_clk, + "arm,integrator-cm-auxosc", of_integrator_cm_osc_setup); + +static void __init of_versatile_cm_osc_setup(struct device_node *np) +{ + cm_osc_setup(np, &versatile_auxosc_desc); +} +CLK_OF_DECLARE(versatile_cm_auxosc_clk, + "arm,versatile-cm-auxosc", of_versatile_cm_osc_setup); -- cgit v1.2.3