diff options
Diffstat (limited to 'arch/arm/common/icst307.c')
-rw-r--r-- | arch/arm/common/icst307.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/arch/arm/common/icst307.c b/arch/arm/common/icst307.c index 2eebd960c01b..f78f5b5880c2 100644 --- a/arch/arm/common/icst307.c +++ b/arch/arm/common/icst307.c | |||
@@ -95,67 +95,3 @@ icst307_khz_to_vco(const struct icst_params *p, unsigned long freq) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | EXPORT_SYMBOL(icst307_khz_to_vco); | 97 | EXPORT_SYMBOL(icst307_khz_to_vco); |
98 | |||
99 | struct icst_vco | ||
100 | icst307_ps_to_vco(const struct icst_params *p, unsigned long period) | ||
101 | { | ||
102 | struct icst_vco vco = { .s = 1, .v = p->vd_max, .r = p->rd_max }; | ||
103 | unsigned long f, ps; | ||
104 | unsigned int i = 0, rd, best = (unsigned int)-1; | ||
105 | |||
106 | ps = 1000000000UL / p->vco_max; | ||
107 | |||
108 | /* | ||
109 | * First, find the PLL output divisor such | ||
110 | * that the PLL output is within spec. | ||
111 | */ | ||
112 | do { | ||
113 | f = period / s2div[idx2s[i]]; | ||
114 | |||
115 | /* | ||
116 | * f must be between 6MHz and 200MHz (3.3 or 5V) | ||
117 | */ | ||
118 | if (f >= ps && f < 1000000000UL / 6000 + 1) | ||
119 | break; | ||
120 | } while (i < ARRAY_SIZE(idx2s)); | ||
121 | |||
122 | if (i >= ARRAY_SIZE(idx2s)) | ||
123 | return vco; | ||
124 | |||
125 | vco.s = idx2s[i]; | ||
126 | |||
127 | ps = 500000000UL / p->ref; | ||
128 | |||
129 | /* | ||
130 | * Now find the closest divisor combination | ||
131 | * which gives a PLL output of 'f'. | ||
132 | */ | ||
133 | for (rd = p->rd_min; rd <= p->rd_max; rd++) { | ||
134 | unsigned long f_in_div, f_pll; | ||
135 | unsigned int vd; | ||
136 | int f_diff; | ||
137 | |||
138 | f_in_div = ps * rd; | ||
139 | |||
140 | vd = (f_in_div + f / 2) / f; | ||
141 | if (vd < p->vd_min || vd > p->vd_max) | ||
142 | continue; | ||
143 | |||
144 | f_pll = (f_in_div + vd / 2) / vd; | ||
145 | f_diff = f_pll - f; | ||
146 | if (f_diff < 0) | ||
147 | f_diff = -f_diff; | ||
148 | |||
149 | if ((unsigned)f_diff < best) { | ||
150 | vco.v = vd - 8; | ||
151 | vco.r = rd - 2; | ||
152 | if (f_diff == 0) | ||
153 | break; | ||
154 | best = f_diff; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | return vco; | ||
159 | } | ||
160 | |||
161 | EXPORT_SYMBOL(icst307_ps_to_vco); | ||