aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-01-16 15:16:10 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-05-02 04:35:33 -0400
commitc5a0adb51002e51a4254cb7f0ab7190d41d8b930 (patch)
treeb6ae6bd13b1aa722e7d96876da28cd5ac3722188 /arch/arm/common
parent232eaf7f268f765b52170bec42bfa0c5825aa239 (diff)
ARM: ICST: kill duplicate icst code
The only difference between ICST307 and ICST525 are the two arrays for calculating the S parameter; the code is now identical. Merge the two files and kill the duplicated code. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/common')
-rw-r--r--arch/arm/common/Kconfig5
-rw-r--r--arch/arm/common/Makefile3
-rw-r--r--arch/arm/common/icst.c (renamed from arch/arm/common/icst307.c)19
-rw-r--r--arch/arm/common/icst525.c99
4 files changed, 11 insertions, 115 deletions
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 4efbb9df0444..323d2d289523 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -12,10 +12,7 @@ config ARM_VIC_NR
12 The maximum number of VICs available in the system, for 12 The maximum number of VICs available in the system, for
13 power management. 13 power management.
14 14
15config ICST525 15config ICST
16 bool
17
18config ICST307
19 bool 16 bool
20 17
21config SA1111 18config SA1111
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 76be7ff2a7ca..5e8ad0d6c917 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -4,8 +4,7 @@
4 4
5obj-$(CONFIG_ARM_GIC) += gic.o 5obj-$(CONFIG_ARM_GIC) += gic.o
6obj-$(CONFIG_ARM_VIC) += vic.o 6obj-$(CONFIG_ARM_VIC) += vic.o
7obj-$(CONFIG_ICST525) += icst525.o 7obj-$(CONFIG_ICST) += icst.o
8obj-$(CONFIG_ICST307) += icst307.o
9obj-$(CONFIG_SA1111) += sa1111.o 8obj-$(CONFIG_SA1111) += sa1111.o
10obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o 9obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o
11obj-$(CONFIG_DMABOUNCE) += dmabounce.o 10obj-$(CONFIG_DMABOUNCE) += dmabounce.o
diff --git a/arch/arm/common/icst307.c b/arch/arm/common/icst.c
index 8332c0726e73..9a7f09cff300 100644
--- a/arch/arm/common/icst307.c
+++ b/arch/arm/common/icst.c
@@ -17,31 +17,33 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19 19
20#include <asm/hardware/icst307.h> 20#include <asm/hardware/icst.h>
21 21
22/* 22/*
23 * Divisors for each OD setting. 23 * Divisors for each OD setting.
24 */ 24 */
25const unsigned char icst307_s2div[8] = { 10, 2, 8, 4, 5, 7, 3, 6 }; 25const unsigned char icst307_s2div[8] = { 10, 2, 8, 4, 5, 7, 3, 6 };
26 26const unsigned char icst525_s2div[8] = { 10, 2, 8, 4, 5, 7, 9, 6 };
27EXPORT_SYMBOL(icst307_s2div); 27EXPORT_SYMBOL(icst307_s2div);
28EXPORT_SYMBOL(icst525_s2div);
28 29
29unsigned long icst307_hz(const struct icst_params *p, struct icst_vco vco) 30unsigned long icst_hz(const struct icst_params *p, struct icst_vco vco)
30{ 31{
31 return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]); 32 return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]);
32} 33}
33 34
34EXPORT_SYMBOL(icst307_hz); 35EXPORT_SYMBOL(icst_hz);
35 36
36/* 37/*
37 * Ascending divisor S values. 38 * Ascending divisor S values.
38 */ 39 */
39const unsigned char icst307_idx2s[8] = { 1, 6, 3, 4, 7, 5, 2, 0 }; 40const unsigned char icst307_idx2s[8] = { 1, 6, 3, 4, 7, 5, 2, 0 };
40 41const unsigned char icst525_idx2s[8] = { 1, 3, 4, 7, 5, 2, 6, 0 };
41EXPORT_SYMBOL(icst307_idx2s); 42EXPORT_SYMBOL(icst307_idx2s);
43EXPORT_SYMBOL(icst525_idx2s);
42 44
43struct icst_vco 45struct icst_vco
44icst307_hz_to_vco(const struct icst_params *p, unsigned long freq) 46icst_hz_to_vco(const struct icst_params *p, unsigned long freq)
45{ 47{
46 struct icst_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max }; 48 struct icst_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max };
47 unsigned long f; 49 unsigned long f;
@@ -54,9 +56,6 @@ icst307_hz_to_vco(const struct icst_params *p, unsigned long freq)
54 do { 56 do {
55 f = freq * p->s2div[p->idx2s[i]]; 57 f = freq * p->s2div[p->idx2s[i]];
56 58
57 /*
58 * f must be between 6MHz and 200MHz (3.3 or 5V)
59 */
60 if (f > p->vco_min && f <= p->vco_max) 59 if (f > p->vco_min && f <= p->vco_max)
61 break; 60 break;
62 } while (i < 8); 61 } while (i < 8);
@@ -98,4 +97,4 @@ icst307_hz_to_vco(const struct icst_params *p, unsigned long freq)
98 return vco; 97 return vco;
99} 98}
100 99
101EXPORT_SYMBOL(icst307_hz_to_vco); 100EXPORT_SYMBOL(icst_hz_to_vco);
diff --git a/arch/arm/common/icst525.c b/arch/arm/common/icst525.c
deleted file mode 100644
index 4180255eb078..000000000000
--- a/arch/arm/common/icst525.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * linux/arch/arm/common/icst525.c
3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Support functions for calculating clocks/divisors for the ICST525
11 * clock generators. See http://www.icst.com/ for more information
12 * on these devices.
13 */
14#include <linux/module.h>
15#include <linux/kernel.h>
16
17#include <asm/hardware/icst525.h>
18
19/*
20 * Divisors for each OD setting.
21 */
22const unsigned char icst525_s2div[8] = { 10, 2, 8, 4, 5, 7, 9, 6 };
23
24EXPORT_SYMBOL(icst525_s2div);
25
26unsigned long icst525_hz(const struct icst_params *p, struct icst_vco vco)
27{
28 return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]);
29}
30
31EXPORT_SYMBOL(icst525_hz);
32
33/*
34 * Ascending divisor S values.
35 */
36const unsigned char icst525_idx2s[8] = { 1, 3, 4, 7, 5, 2, 6, 0 };
37
38EXPORT_SYMBOL(icst525_idx2s);
39
40struct icst_vco
41icst525_hz_to_vco(const struct icst_params *p, unsigned long freq)
42{
43 struct icst_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max };
44 unsigned long f;
45 unsigned int i = 0, rd, best = (unsigned int)-1;
46
47 /*
48 * First, find the PLL output divisor such
49 * that the PLL output is within spec.
50 */
51 do {
52 f = freq * p->s2div[p->idx2s[i]];
53
54 /*
55 * f must be between 10MHz and
56 * 320MHz (5V) or 200MHz (3V)
57 */
58 if (f > p->vco_min && f <= p->vco_max)
59 break;
60 } while (i < 8);
61
62 if (i >= 8)
63 return vco;
64
65 vco.s = p->idx2s[i];
66
67 /*
68 * Now find the closest divisor combination
69 * which gives a PLL output of 'f'.
70 */
71 for (rd = p->rd_min; rd <= p->rd_max; rd++) {
72 unsigned long fref_div, f_pll;
73 unsigned int vd;
74 int f_diff;
75
76 fref_div = (2 * p->ref) / rd;
77
78 vd = (f + fref_div / 2) / fref_div;
79 if (vd < p->vd_min || vd > p->vd_max)
80 continue;
81
82 f_pll = fref_div * vd;
83 f_diff = f_pll - f;
84 if (f_diff < 0)
85 f_diff = -f_diff;
86
87 if ((unsigned)f_diff < best) {
88 vco.v = vd - 8;
89 vco.r = rd - 2;
90 if (f_diff == 0)
91 break;
92 best = f_diff;
93 }
94 }
95
96 return vco;
97}
98
99EXPORT_SYMBOL(icst525_hz_to_vco);