0001
0002
0003
0004
0005
0006
0007 #include <linux/clk-provider.h>
0008 #include <linux/err.h>
0009 #include <linux/of.h>
0010 #include <linux/of_address.h>
0011
0012 #include "icst.h"
0013 #include "clk-icst.h"
0014
0015 #define INTEGRATOR_HDR_LOCK_OFFSET 0x14
0016
0017 #define VERSATILE_SYS_OSCCLCD_OFFSET 0x1c
0018 #define VERSATILE_SYS_LOCK_OFFSET 0x20
0019
0020
0021 static void __iomem *cm_base;
0022
0023 static const struct icst_params cp_auxosc_params = {
0024 .vco_max = ICST525_VCO_MAX_5V,
0025 .vco_min = ICST525_VCO_MIN,
0026 .vd_min = 8,
0027 .vd_max = 263,
0028 .rd_min = 3,
0029 .rd_max = 65,
0030 .s2div = icst525_s2div,
0031 .idx2s = icst525_idx2s,
0032 };
0033
0034 static const struct clk_icst_desc cm_auxosc_desc __initconst = {
0035 .params = &cp_auxosc_params,
0036 .vco_offset = 0x1c,
0037 .lock_offset = INTEGRATOR_HDR_LOCK_OFFSET,
0038 };
0039
0040 static const struct icst_params versatile_auxosc_params = {
0041 .vco_max = ICST307_VCO_MAX,
0042 .vco_min = ICST307_VCO_MIN,
0043 .vd_min = 4 + 8,
0044 .vd_max = 511 + 8,
0045 .rd_min = 1 + 2,
0046 .rd_max = 127 + 2,
0047 .s2div = icst307_s2div,
0048 .idx2s = icst307_idx2s,
0049 };
0050
0051 static const struct clk_icst_desc versatile_auxosc_desc __initconst = {
0052 .params = &versatile_auxosc_params,
0053 .vco_offset = VERSATILE_SYS_OSCCLCD_OFFSET,
0054 .lock_offset = VERSATILE_SYS_LOCK_OFFSET,
0055 };
0056 static void __init cm_osc_setup(struct device_node *np,
0057 const struct clk_icst_desc *desc)
0058 {
0059 struct clk *clk;
0060 const char *clk_name = np->name;
0061 const char *parent_name;
0062
0063 if (!cm_base) {
0064
0065 struct device_node *parent;
0066
0067 parent = of_get_parent(np);
0068 if (!parent) {
0069 pr_err("no parent on core module clock\n");
0070 return;
0071 }
0072 cm_base = of_iomap(parent, 0);
0073 of_node_put(parent);
0074 if (!cm_base) {
0075 pr_err("could not remap core module base\n");
0076 return;
0077 }
0078 }
0079
0080 parent_name = of_clk_get_parent_name(np, 0);
0081 clk = icst_clk_register(NULL, desc, clk_name, parent_name, cm_base);
0082 if (!IS_ERR(clk))
0083 of_clk_add_provider(np, of_clk_src_simple_get, clk);
0084 }
0085
0086 static void __init of_integrator_cm_osc_setup(struct device_node *np)
0087 {
0088 cm_osc_setup(np, &cm_auxosc_desc);
0089 }
0090 CLK_OF_DECLARE(integrator_cm_auxosc_clk,
0091 "arm,integrator-cm-auxosc", of_integrator_cm_osc_setup);
0092
0093 static void __init of_versatile_cm_osc_setup(struct device_node *np)
0094 {
0095 cm_osc_setup(np, &versatile_auxosc_desc);
0096 }
0097 CLK_OF_DECLARE(versatile_cm_auxosc_clk,
0098 "arm,versatile-cm-auxosc", of_versatile_cm_osc_setup);