aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2012-12-07 06:56:56 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-12-10 15:47:30 -0500
commit5b5ac41447de30cb5ed5e72d3d4e1a9e6e12f640 (patch)
tree9c5ea531adfad60c873281bea03a9d40e76d406a /drivers/bcma
parent576d28a7c73013717311cfcb514dbcae27c82eeb (diff)
bcma: unify naming schema for clock functions
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/bcma')
-rw-r--r--drivers/bcma/bcma_private.h4
-rw-r--r--drivers/bcma/driver_chipcommon.c10
-rw-r--r--drivers/bcma/driver_chipcommon_pmu.c39
-rw-r--r--drivers/bcma/driver_mips.c2
4 files changed, 29 insertions, 26 deletions
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index bcb830ec4bb4..537ae53231cd 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -48,8 +48,8 @@ void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
48#endif /* CONFIG_BCMA_DRIVER_MIPS */ 48#endif /* CONFIG_BCMA_DRIVER_MIPS */
49 49
50/* driver_chipcommon_pmu.c */ 50/* driver_chipcommon_pmu.c */
51u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc); 51u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
52u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc); 52u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
53 53
54#ifdef CONFIG_BCMA_SFLASH 54#ifdef CONFIG_BCMA_SFLASH
55/* driver_chipcommon_sflash.c */ 55/* driver_chipcommon_sflash.c */
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c
index d017f2512275..dc96dd8ebff2 100644
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -25,10 +25,10 @@ static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
25 return value; 25 return value;
26} 26}
27 27
28static u32 bcma_chipco_alp_clock(struct bcma_drv_cc *cc) 28static u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
29{ 29{
30 if (cc->capabilities & BCMA_CC_CAP_PMU) 30 if (cc->capabilities & BCMA_CC_CAP_PMU)
31 return bcma_pmu_alp_clock(cc); 31 return bcma_pmu_get_alp_clock(cc);
32 32
33 return 20000000; 33 return 20000000;
34} 34}
@@ -79,12 +79,12 @@ static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
79 if (cc->capabilities & BCMA_CC_CAP_PMU) { 79 if (cc->capabilities & BCMA_CC_CAP_PMU) {
80 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) 80 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
81 /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */ 81 /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
82 return bcma_chipco_alp_clock(cc) / 4000; 82 return bcma_chipco_get_alp_clock(cc) / 4000;
83 else 83 else
84 /* based on 32KHz ILP clock */ 84 /* based on 32KHz ILP clock */
85 return 32; 85 return 32;
86 } else { 86 } else {
87 return bcma_chipco_alp_clock(cc) / 1000; 87 return bcma_chipco_get_alp_clock(cc) / 1000;
88 } 88 }
89} 89}
90 90
@@ -236,7 +236,7 @@ void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
236 struct bcma_serial_port *ports = cc->serial_ports; 236 struct bcma_serial_port *ports = cc->serial_ports;
237 237
238 if (ccrev >= 11 && ccrev != 15) { 238 if (ccrev >= 11 && ccrev != 15) {
239 baud_base = bcma_chipco_alp_clock(cc); 239 baud_base = bcma_chipco_get_alp_clock(cc);
240 if (ccrev >= 21) { 240 if (ccrev >= 21) {
241 /* Turn off UART clock before switching clocksource. */ 241 /* Turn off UART clock before switching clocksource. */
242 bcma_cc_write32(cc, BCMA_CC_CORECTL, 242 bcma_cc_write32(cc, BCMA_CC_CORECTL,
diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index a63ddd9c70eb..e162999bf916 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -168,7 +168,7 @@ void bcma_pmu_init(struct bcma_drv_cc *cc)
168 bcma_pmu_workarounds(cc); 168 bcma_pmu_workarounds(cc);
169} 169}
170 170
171u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc) 171u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
172{ 172{
173 struct bcma_bus *bus = cc->core->bus; 173 struct bcma_bus *bus = cc->core->bus;
174 174
@@ -196,7 +196,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
196/* Find the output of the "m" pll divider given pll controls that start with 196/* Find the output of the "m" pll divider given pll controls that start with
197 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc. 197 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
198 */ 198 */
199static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m) 199static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
200{ 200{
201 u32 tmp, div, ndiv, p1, p2, fc; 201 u32 tmp, div, ndiv, p1, p2, fc;
202 struct bcma_bus *bus = cc->core->bus; 202 struct bcma_bus *bus = cc->core->bus;
@@ -225,14 +225,14 @@ static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
225 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT; 225 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
226 226
227 /* Do calculation in Mhz */ 227 /* Do calculation in Mhz */
228 fc = bcma_pmu_alp_clock(cc) / 1000000; 228 fc = bcma_pmu_get_alp_clock(cc) / 1000000;
229 fc = (p1 * ndiv * fc) / p2; 229 fc = (p1 * ndiv * fc) / p2;
230 230
231 /* Return clock in Hertz */ 231 /* Return clock in Hertz */
232 return (fc / div) * 1000000; 232 return (fc / div) * 1000000;
233} 233}
234 234
235static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m) 235static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
236{ 236{
237 u32 tmp, ndiv, p1div, p2div; 237 u32 tmp, ndiv, p1div, p2div;
238 u32 clock; 238 u32 clock;
@@ -263,7 +263,7 @@ static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
263} 263}
264 264
265/* query bus clock frequency for PMU-enabled chipcommon */ 265/* query bus clock frequency for PMU-enabled chipcommon */
266static u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc) 266static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
267{ 267{
268 struct bcma_bus *bus = cc->core->bus; 268 struct bcma_bus *bus = cc->core->bus;
269 269
@@ -271,40 +271,42 @@ static u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
271 case BCMA_CHIP_ID_BCM4716: 271 case BCMA_CHIP_ID_BCM4716:
272 case BCMA_CHIP_ID_BCM4748: 272 case BCMA_CHIP_ID_BCM4748:
273 case BCMA_CHIP_ID_BCM47162: 273 case BCMA_CHIP_ID_BCM47162:
274 return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0, 274 return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
275 BCMA_CC_PMU5_MAINPLL_SSB); 275 BCMA_CC_PMU5_MAINPLL_SSB);
276 case BCMA_CHIP_ID_BCM5356: 276 case BCMA_CHIP_ID_BCM5356:
277 return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0, 277 return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
278 BCMA_CC_PMU5_MAINPLL_SSB); 278 BCMA_CC_PMU5_MAINPLL_SSB);
279 case BCMA_CHIP_ID_BCM5357: 279 case BCMA_CHIP_ID_BCM5357:
280 case BCMA_CHIP_ID_BCM4749: 280 case BCMA_CHIP_ID_BCM4749:
281 return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0, 281 return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
282 BCMA_CC_PMU5_MAINPLL_SSB); 282 BCMA_CC_PMU5_MAINPLL_SSB);
283 case BCMA_CHIP_ID_BCM4706: 283 case BCMA_CHIP_ID_BCM4706:
284 return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0, 284 return bcma_pmu_pll_clock_bcm4706(cc,
285 BCMA_CC_PMU5_MAINPLL_SSB); 285 BCMA_CC_PMU4706_MAINPLL_PLL0,
286 BCMA_CC_PMU5_MAINPLL_SSB);
286 case BCMA_CHIP_ID_BCM53572: 287 case BCMA_CHIP_ID_BCM53572:
287 return 75000000; 288 return 75000000;
288 default: 289 default:
289 bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n", 290 bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
290 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK); 291 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
291 } 292 }
292 return BCMA_CC_PMU_HT_CLOCK; 293 return BCMA_CC_PMU_HT_CLOCK;
293} 294}
294 295
295/* query cpu clock frequency for PMU-enabled chipcommon */ 296/* query cpu clock frequency for PMU-enabled chipcommon */
296u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc) 297u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
297{ 298{
298 struct bcma_bus *bus = cc->core->bus; 299 struct bcma_bus *bus = cc->core->bus;
299 300
300 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) 301 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
301 return 300000000; 302 return 300000000;
302 303
304 /* New PMUs can have different clock for bus and CPU */
303 if (cc->pmu.rev >= 5) { 305 if (cc->pmu.rev >= 5) {
304 u32 pll; 306 u32 pll;
305 switch (bus->chipinfo.id) { 307 switch (bus->chipinfo.id) {
306 case BCMA_CHIP_ID_BCM4706: 308 case BCMA_CHIP_ID_BCM4706:
307 return bcma_pmu_clock_bcm4706(cc, 309 return bcma_pmu_pll_clock_bcm4706(cc,
308 BCMA_CC_PMU4706_MAINPLL_PLL0, 310 BCMA_CC_PMU4706_MAINPLL_PLL0,
309 BCMA_CC_PMU5_MAINPLL_CPU); 311 BCMA_CC_PMU5_MAINPLL_CPU);
310 case BCMA_CHIP_ID_BCM5356: 312 case BCMA_CHIP_ID_BCM5356:
@@ -319,10 +321,11 @@ u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
319 break; 321 break;
320 } 322 }
321 323
322 return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU); 324 return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
323 } 325 }
324 326
325 return bcma_pmu_get_clockcontrol(cc); 327 /* On old PMUs CPU has the same clock as the bus */
328 return bcma_pmu_get_bus_clock(cc);
326} 329}
327 330
328static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset, 331static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
index 170822ea51c7..c45ded8a6963 100644
--- a/drivers/bcma/driver_mips.c
+++ b/drivers/bcma/driver_mips.c
@@ -171,7 +171,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips *mcore)
171 struct bcma_bus *bus = mcore->core->bus; 171 struct bcma_bus *bus = mcore->core->bus;
172 172
173 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU) 173 if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
174 return bcma_pmu_get_clockcpu(&bus->drv_cc); 174 return bcma_pmu_get_cpu_clock(&bus->drv_cc);
175 175
176 bcma_err(bus, "No PMU available, need this to get the cpu clock\n"); 176 bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
177 return 0; 177 return 0;