aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/versatile/clk-integrator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/versatile/clk-integrator.c')
-rw-r--r--drivers/clk/versatile/clk-integrator.c55
1 files changed, 14 insertions, 41 deletions
diff --git a/drivers/clk/versatile/clk-integrator.c b/drivers/clk/versatile/clk-integrator.c
index a5053921bf7f..08593b4ee2c9 100644
--- a/drivers/clk/versatile/clk-integrator.c
+++ b/drivers/clk/versatile/clk-integrator.c
@@ -1,8 +1,16 @@
1/*
2 * Clock driver for the ARM Integrator/AP and Integrator/CP boards
3 * Copyright (C) 2012 Linus Walleij
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#include <linux/clk-provider.h>
1#include <linux/clk.h> 10#include <linux/clk.h>
2#include <linux/clkdev.h> 11#include <linux/clkdev.h>
3#include <linux/err.h> 12#include <linux/err.h>
4#include <linux/io.h> 13#include <linux/platform_data/clk-integrator.h>
5#include <linux/clk-provider.h>
6 14
7#include <mach/hardware.h> 15#include <mach/hardware.h>
8#include <mach/platform.h> 16#include <mach/platform.h>
@@ -14,42 +22,6 @@
14 * Inspired by portions of: 22 * Inspired by portions of:
15 * plat-versatile/clock.c and plat-versatile/include/plat/clock.h 23 * plat-versatile/clock.c and plat-versatile/include/plat/clock.h
16 */ 24 */
17#define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET)
18#define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c)
19
20/**
21 * cp_auxvco_get() - get ICST VCO settings for the Integrator/CP
22 * @vco: ICST VCO parameters to update with hardware status
23 */
24static struct icst_vco cp_auxvco_get(void)
25{
26 u32 val;
27 struct icst_vco vco;
28
29 val = readl(CM_AUXOSC);
30 vco.v = val & 0x1ff;
31 vco.r = (val >> 9) & 0x7f;
32 vco.s = (val >> 16) & 03;
33 return vco;
34}
35
36/**
37 * cp_auxvco_set() - commit changes to Integrator/CP ICST VCO
38 * @vco: ICST VCO parameters to commit
39 */
40static void cp_auxvco_set(struct icst_vco vco)
41{
42 u32 val;
43
44 val = readl(CM_AUXOSC) & ~0x7ffff;
45 val |= vco.v | (vco.r << 9) | (vco.s << 16);
46
47 /* This magic unlocks the CM VCO so it can be controlled */
48 writel(0xa05f, CM_LOCK);
49 writel(val, CM_AUXOSC);
50 /* This locks the CM again */
51 writel(0, CM_LOCK);
52}
53 25
54static const struct icst_params cp_auxvco_params = { 26static const struct icst_params cp_auxvco_params = {
55 .ref = 24000000, 27 .ref = 24000000,
@@ -65,8 +37,8 @@ static const struct icst_params cp_auxvco_params = {
65 37
66static const struct clk_icst_desc __initdata cp_icst_desc = { 38static const struct clk_icst_desc __initdata cp_icst_desc = {
67 .params = &cp_auxvco_params, 39 .params = &cp_auxvco_params,
68 .getvco = cp_auxvco_get, 40 .vco_offset = 0x1c,
69 .setvco = cp_auxvco_set, 41 .lock_offset = INTEGRATOR_HDR_LOCK_OFFSET,
70}; 42};
71 43
72/* 44/*
@@ -106,6 +78,7 @@ void __init integrator_clk_init(bool is_cp)
106 clk_register_clkdev(clk, NULL, "sp804"); 78 clk_register_clkdev(clk, NULL, "sp804");
107 79
108 /* ICST VCO clock used on the Integrator/CP CLCD */ 80 /* ICST VCO clock used on the Integrator/CP CLCD */
109 clk = icst_clk_register(NULL, &cp_icst_desc); 81 clk = icst_clk_register(NULL, &cp_icst_desc,
82 __io_address(INTEGRATOR_HDR_BASE));
110 clk_register_clkdev(clk, NULL, "clcd"); 83 clk_register_clkdev(clk, NULL, "clcd");
111} 84}