blob: 74a87d530424cc3523f782edc92ca88cd576073a [file] [log] [blame]
Rafał Miłecki8369ae32011-05-09 18:56:46 +02001/*
2 * Broadcom specific AMBA
3 * ChipCommon Power Management Unit driver
4 *
Michael Büscheb032b92011-07-04 20:50:05 +02005 * Copyright 2009, Michael Buesch <m@bues.ch>
Hauke Mehrtensc586e102012-06-30 01:44:44 +02006 * Copyright 2007, 2011, Broadcom Corporation
7 * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
Rafał Miłecki8369ae32011-05-09 18:56:46 +02008 *
9 * Licensed under the GNU/GPL. See COPYING for details.
10 */
11
12#include "bcma_private.h"
Paul Gortmaker44a8e372011-07-27 21:21:04 -040013#include <linux/export.h>
Rafał Miłecki8369ae32011-05-09 18:56:46 +020014#include <linux/bcma/bcma.h>
15
Hauke Mehrtens908debc2011-07-23 01:20:11 +020016static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
17{
18 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
19 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
20 return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
21}
22
Rafał Miłecki3861b2c2011-09-16 12:33:58 +020023void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
Rafał Miłecki8369ae32011-05-09 18:56:46 +020024{
Rafał Miłecki3861b2c2011-09-16 12:33:58 +020025 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
26 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
27 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
28}
29EXPORT_SYMBOL_GPL(bcma_chipco_pll_write);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020030
Rafał Miłecki3861b2c2011-09-16 12:33:58 +020031void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
32 u32 set)
33{
34 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
35 bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
36 bcma_cc_maskset32(cc, BCMA_CC_PLLCTL_DATA, mask, set);
37}
38EXPORT_SYMBOL_GPL(bcma_chipco_pll_maskset);
39
40void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
41 u32 offset, u32 mask, u32 set)
42{
Rafał Miłecki8369ae32011-05-09 18:56:46 +020043 bcma_cc_write32(cc, BCMA_CC_CHIPCTL_ADDR, offset);
44 bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
Rafał Miłecki3861b2c2011-09-16 12:33:58 +020045 bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL_DATA, mask, set);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020046}
Rafał Miłecki3861b2c2011-09-16 12:33:58 +020047EXPORT_SYMBOL_GPL(bcma_chipco_chipctl_maskset);
48
49void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
50 u32 set)
51{
52 bcma_cc_write32(cc, BCMA_CC_REGCTL_ADDR, offset);
53 bcma_cc_read32(cc, BCMA_CC_REGCTL_ADDR);
54 bcma_cc_maskset32(cc, BCMA_CC_REGCTL_DATA, mask, set);
55}
56EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020057
Rafał Miłecki8369ae32011-05-09 18:56:46 +020058static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
59{
60 struct bcma_bus *bus = cc->core->bus;
61 u32 min_msk = 0, max_msk = 0;
62
63 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +020064 case BCMA_CHIP_ID_BCM4313:
Rafał Miłecki8369ae32011-05-09 18:56:46 +020065 min_msk = 0x200D;
66 max_msk = 0xFFFF;
67 break;
Rafał Miłecki8369ae32011-05-09 18:56:46 +020068 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +020069 bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
70 bus->chipinfo.id);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020071 }
72
73 /* Set the resource masks. */
74 if (min_msk)
75 bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
76 if (max_msk)
77 bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
Hauke Mehrtens4795f092012-06-30 01:44:45 +020078
79 /* Add some delay; allow resources to come up and settle. */
80 mdelay(2);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020081}
82
Rafał Miłecki984e5be2011-08-11 23:46:44 +020083/* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
84void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
85{
86 struct bcma_bus *bus = cc->core->bus;
87 u32 val;
88
89 val = bcma_cc_read32(cc, BCMA_CC_CHIPCTL);
90 if (enable) {
91 val |= BCMA_CHIPCTL_4331_EXTPA_EN;
92 if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
93 val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
Hauke Mehrtens00eeedc2012-06-30 01:44:37 +020094 else if (bus->chipinfo.rev > 0)
95 val |= BCMA_CHIPCTL_4331_EXTPA_EN2;
Rafał Miłecki984e5be2011-08-11 23:46:44 +020096 } else {
97 val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
Hauke Mehrtens00eeedc2012-06-30 01:44:37 +020098 val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2;
Rafał Miłecki984e5be2011-08-11 23:46:44 +020099 val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
100 }
101 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
102}
103
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200104void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
105{
106 struct bcma_bus *bus = cc->core->bus;
107
108 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200109 case BCMA_CHIP_ID_BCM4313:
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200110 /* enable 12 mA drive strenth for 4313 and set chipControl
111 register bit 1 */
112 bcma_chipco_chipctl_maskset(cc, 0,
113 BCMA_CCTRL_4313_12MA_LED_DRIVE,
114 BCMA_CCTRL_4313_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200115 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200116 case BCMA_CHIP_ID_BCM4331:
117 case BCMA_CHIP_ID_BCM43431:
Seth Forshee69aaedd2012-06-01 09:13:17 -0500118 /* Ext PA lines must be enabled for tx on BCM4331 */
119 bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200120 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200121 case BCMA_CHIP_ID_BCM43224:
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200122 case BCMA_CHIP_ID_BCM43421:
123 /* enable 12 mA drive strenth for 43224 and set chipControl
124 register bit 15 */
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200125 if (bus->chipinfo.rev == 0) {
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200126 bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL,
127 BCMA_CCTRL_43224_GPIO_TOGGLE,
128 BCMA_CCTRL_43224_GPIO_TOGGLE);
129 bcma_chipco_chipctl_maskset(cc, 0,
130 BCMA_CCTRL_43224A0_12MA_LED_DRIVE,
131 BCMA_CCTRL_43224A0_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200132 } else {
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200133 bcma_chipco_chipctl_maskset(cc, 0,
134 BCMA_CCTRL_43224B0_12MA_LED_DRIVE,
135 BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200136 }
137 break;
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200138 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200139 bcma_debug(bus, "Workarounds unknown or not needed for device 0x%04X\n",
140 bus->chipinfo.id);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200141 }
142}
143
144void bcma_pmu_init(struct bcma_drv_cc *cc)
145{
146 u32 pmucap;
147
148 pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
149 cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
150
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200151 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
152 cc->pmu.rev, pmucap);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200153
154 if (cc->pmu.rev == 1)
155 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
156 ~BCMA_CC_PMU_CTL_NOILPONW);
157 else
158 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
159 BCMA_CC_PMU_CTL_NOILPONW);
160
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200161 bcma_pmu_resources_init(cc);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200162 bcma_pmu_workarounds(cc);
163}
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200164
165u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
166{
167 struct bcma_bus *bus = cc->core->bus;
168
169 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200170 case BCMA_CHIP_ID_BCM4716:
171 case BCMA_CHIP_ID_BCM4748:
172 case BCMA_CHIP_ID_BCM47162:
173 case BCMA_CHIP_ID_BCM4313:
174 case BCMA_CHIP_ID_BCM5357:
175 case BCMA_CHIP_ID_BCM4749:
176 case BCMA_CHIP_ID_BCM53572:
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200177 /* always 20Mhz */
178 return 20000 * 1000;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200179 case BCMA_CHIP_ID_BCM5356:
180 case BCMA_CHIP_ID_BCM4706:
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200181 /* always 25Mhz */
182 return 25000 * 1000;
183 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200184 bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
185 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200186 }
187 return BCMA_CC_PMU_ALP_CLOCK;
188}
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200189
190/* Find the output of the "m" pll divider given pll controls that start with
191 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
192 */
193static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
194{
195 u32 tmp, div, ndiv, p1, p2, fc;
196 struct bcma_bus *bus = cc->core->bus;
197
198 BUG_ON((pll0 & 3) || (pll0 > BCMA_CC_PMU4716_MAINPLL_PLL0));
199
200 BUG_ON(!m || m > 4);
201
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200202 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
203 bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) {
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200204 /* Detect failure in clock setting */
205 tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
206 if (tmp & 0x40000)
207 return 133 * 1000000;
208 }
209
210 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_P1P2_OFF);
211 p1 = (tmp & BCMA_CC_PPL_P1_MASK) >> BCMA_CC_PPL_P1_SHIFT;
212 p2 = (tmp & BCMA_CC_PPL_P2_MASK) >> BCMA_CC_PPL_P2_SHIFT;
213
214 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_M14_OFF);
215 div = (tmp >> ((m - 1) * BCMA_CC_PPL_MDIV_WIDTH)) &
216 BCMA_CC_PPL_MDIV_MASK;
217
218 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_NM5_OFF);
219 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
220
221 /* Do calculation in Mhz */
222 fc = bcma_pmu_alp_clock(cc) / 1000000;
223 fc = (p1 * ndiv * fc) / p2;
224
225 /* Return clock in Hertz */
226 return (fc / div) * 1000000;
227}
228
229/* query bus clock frequency for PMU-enabled chipcommon */
230u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
231{
232 struct bcma_bus *bus = cc->core->bus;
233
234 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200235 case BCMA_CHIP_ID_BCM4716:
236 case BCMA_CHIP_ID_BCM4748:
237 case BCMA_CHIP_ID_BCM47162:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200238 return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
239 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200240 case BCMA_CHIP_ID_BCM5356:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200241 return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
242 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200243 case BCMA_CHIP_ID_BCM5357:
244 case BCMA_CHIP_ID_BCM4749:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200245 return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
246 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200247 case BCMA_CHIP_ID_BCM4706:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200248 return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
249 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200250 case BCMA_CHIP_ID_BCM53572:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200251 return 75000000;
252 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200253 bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
254 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200255 }
256 return BCMA_CC_PMU_HT_CLOCK;
257}
258
259/* query cpu clock frequency for PMU-enabled chipcommon */
260u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
261{
262 struct bcma_bus *bus = cc->core->bus;
263
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200264 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200265 return 300000000;
266
267 if (cc->pmu.rev >= 5) {
268 u32 pll;
269 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200270 case BCMA_CHIP_ID_BCM5356:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200271 pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
272 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200273 case BCMA_CHIP_ID_BCM5357:
274 case BCMA_CHIP_ID_BCM4749:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200275 pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
276 break;
277 default:
278 pll = BCMA_CC_PMU4716_MAINPLL_PLL0;
279 break;
280 }
281
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200282 /* TODO: if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200283 return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
284 return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
285 }
286
287 return bcma_pmu_get_clockcontrol(cc);
288}
Hauke Mehrtensc586e102012-06-30 01:44:44 +0200289
290static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
291 u32 value)
292{
293 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
294 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
295}
296
297void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
298{
299 u32 tmp = 0;
300 u8 phypll_offset = 0;
301 u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5};
302 u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc};
303 struct bcma_bus *bus = cc->core->bus;
304
305 switch (bus->chipinfo.id) {
306 case BCMA_CHIP_ID_BCM5357:
307 case BCMA_CHIP_ID_BCM4749:
308 case BCMA_CHIP_ID_BCM53572:
309 /* 5357[ab]0, 43236[ab]0, and 6362b0 */
310
311 /* BCM5357 needs to touch PLL1_PLLCTL[02],
312 so offset PLL0_PLLCTL[02] by 6 */
313 phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
314 bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 ||
315 bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
316
317 /* RMW only the P1 divider */
318 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
319 BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
320 tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
321 tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
322 tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
323 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
324
325 /* RMW only the int feedback divider */
326 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
327 BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
328 tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
329 tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
330 tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
331 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
332
333 tmp = 1 << 10;
334 break;
335
336 case BCMA_CHIP_ID_BCM4331:
337 case BCMA_CHIP_ID_BCM43431:
338 if (spuravoid == 2) {
339 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
340 0x11500014);
341 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
342 0x0FC00a08);
343 } else if (spuravoid == 1) {
344 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
345 0x11500014);
346 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
347 0x0F600a08);
348 } else {
349 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
350 0x11100014);
351 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
352 0x03000a08);
353 }
354 tmp = 1 << 10;
355 break;
356
357 case BCMA_CHIP_ID_BCM43224:
358 case BCMA_CHIP_ID_BCM43225:
359 case BCMA_CHIP_ID_BCM43421:
360 if (spuravoid == 1) {
361 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
362 0x11500010);
363 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
364 0x000C0C06);
365 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
366 0x0F600a08);
367 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
368 0x00000000);
369 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
370 0x2001E920);
371 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
372 0x88888815);
373 } else {
374 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
375 0x11100010);
376 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
377 0x000c0c06);
378 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
379 0x03000a08);
380 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
381 0x00000000);
382 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
383 0x200005c0);
384 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
385 0x88888815);
386 }
387 tmp = 1 << 10;
388 break;
389
390 case BCMA_CHIP_ID_BCM4716:
391 case BCMA_CHIP_ID_BCM4748:
392 case BCMA_CHIP_ID_BCM47162:
393 if (spuravoid == 1) {
394 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
395 0x11500060);
396 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
397 0x080C0C06);
398 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
399 0x0F600000);
400 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
401 0x00000000);
402 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
403 0x2001E924);
404 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
405 0x88888815);
406 } else {
407 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
408 0x11100060);
409 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
410 0x080c0c06);
411 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
412 0x03000000);
413 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
414 0x00000000);
415 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
416 0x200005c0);
417 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
418 0x88888815);
419 }
420
421 tmp = 3 << 9;
422 break;
423
424 case BCMA_CHIP_ID_BCM43227:
425 case BCMA_CHIP_ID_BCM43228:
426 case BCMA_CHIP_ID_BCM43428:
427 /* LCNXN */
428 /* PLL Settings for spur avoidance on/off mode,
429 no on2 support for 43228A0 */
430 if (spuravoid == 1) {
431 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
432 0x01100014);
433 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
434 0x040C0C06);
435 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
436 0x03140A08);
437 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
438 0x00333333);
439 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
440 0x202C2820);
441 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
442 0x88888815);
443 } else {
444 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
445 0x11100014);
446 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
447 0x040c0c06);
448 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
449 0x03000a08);
450 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
451 0x00000000);
452 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
453 0x200005c0);
454 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
455 0x88888815);
456 }
457 tmp = 1 << 10;
458 break;
459 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200460 bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
461 bus->chipinfo.id);
Hauke Mehrtensc586e102012-06-30 01:44:44 +0200462 break;
463 }
464
465 tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
466 bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
467}
468EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);