blob: 201faf106b3f4e342337e2219213a72c670ef447 [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
Rafał Miłecki1fd41a62012-09-25 10:17:22 +020079 /*
80 * Add some delay; allow resources to come up and settle.
81 * Delay is required for SoC (early init).
82 */
Hauke Mehrtens4795f092012-06-30 01:44:45 +020083 mdelay(2);
Rafał Miłecki8369ae32011-05-09 18:56:46 +020084}
85
Rafał Miłecki984e5be2011-08-11 23:46:44 +020086/* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
87void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
88{
89 struct bcma_bus *bus = cc->core->bus;
90 u32 val;
91
92 val = bcma_cc_read32(cc, BCMA_CC_CHIPCTL);
93 if (enable) {
94 val |= BCMA_CHIPCTL_4331_EXTPA_EN;
95 if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
96 val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
Hauke Mehrtens00eeedc2012-06-30 01:44:37 +020097 else if (bus->chipinfo.rev > 0)
98 val |= BCMA_CHIPCTL_4331_EXTPA_EN2;
Rafał Miłecki984e5be2011-08-11 23:46:44 +020099 } else {
100 val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
Hauke Mehrtens00eeedc2012-06-30 01:44:37 +0200101 val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2;
Rafał Miłecki984e5be2011-08-11 23:46:44 +0200102 val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
103 }
104 bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
105}
106
Hauke Mehrtens94f34572012-08-05 16:54:41 +0200107static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200108{
109 struct bcma_bus *bus = cc->core->bus;
110
111 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200112 case BCMA_CHIP_ID_BCM4313:
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200113 /* enable 12 mA drive strenth for 4313 and set chipControl
114 register bit 1 */
115 bcma_chipco_chipctl_maskset(cc, 0,
Hauke Mehrtens1f03bf02012-07-25 23:08:54 +0200116 ~BCMA_CCTRL_4313_12MA_LED_DRIVE,
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200117 BCMA_CCTRL_4313_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200118 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200119 case BCMA_CHIP_ID_BCM4331:
120 case BCMA_CHIP_ID_BCM43431:
Seth Forshee69aaedd2012-06-01 09:13:17 -0500121 /* Ext PA lines must be enabled for tx on BCM4331 */
122 bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200123 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200124 case BCMA_CHIP_ID_BCM43224:
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200125 case BCMA_CHIP_ID_BCM43421:
126 /* enable 12 mA drive strenth for 43224 and set chipControl
127 register bit 15 */
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200128 if (bus->chipinfo.rev == 0) {
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200129 bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL,
Hauke Mehrtens1f03bf02012-07-25 23:08:54 +0200130 ~BCMA_CCTRL_43224_GPIO_TOGGLE,
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200131 BCMA_CCTRL_43224_GPIO_TOGGLE);
132 bcma_chipco_chipctl_maskset(cc, 0,
Hauke Mehrtens1f03bf02012-07-25 23:08:54 +0200133 ~BCMA_CCTRL_43224A0_12MA_LED_DRIVE,
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200134 BCMA_CCTRL_43224A0_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200135 } else {
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200136 bcma_chipco_chipctl_maskset(cc, 0,
Hauke Mehrtens1f03bf02012-07-25 23:08:54 +0200137 ~BCMA_CCTRL_43224B0_12MA_LED_DRIVE,
Hauke Mehrtensb9562542012-06-30 01:44:41 +0200138 BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200139 }
140 break;
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200141 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200142 bcma_debug(bus, "Workarounds unknown or not needed for device 0x%04X\n",
143 bus->chipinfo.id);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200144 }
145}
146
147void bcma_pmu_init(struct bcma_drv_cc *cc)
148{
149 u32 pmucap;
150
151 pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
152 cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
153
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200154 bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
155 cc->pmu.rev, pmucap);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200156
157 if (cc->pmu.rev == 1)
158 bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
159 ~BCMA_CC_PMU_CTL_NOILPONW);
160 else
161 bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
162 BCMA_CC_PMU_CTL_NOILPONW);
163
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200164 bcma_pmu_resources_init(cc);
Rafał Miłecki8369ae32011-05-09 18:56:46 +0200165 bcma_pmu_workarounds(cc);
166}
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200167
168u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
169{
170 struct bcma_bus *bus = cc->core->bus;
171
172 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200173 case BCMA_CHIP_ID_BCM4716:
174 case BCMA_CHIP_ID_BCM4748:
175 case BCMA_CHIP_ID_BCM47162:
176 case BCMA_CHIP_ID_BCM4313:
177 case BCMA_CHIP_ID_BCM5357:
178 case BCMA_CHIP_ID_BCM4749:
179 case BCMA_CHIP_ID_BCM53572:
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200180 /* always 20Mhz */
181 return 20000 * 1000;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200182 case BCMA_CHIP_ID_BCM5356:
183 case BCMA_CHIP_ID_BCM4706:
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200184 /* always 25Mhz */
185 return 25000 * 1000;
186 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200187 bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
188 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
Hauke Mehrtense3afe0e2011-07-23 01:20:10 +0200189 }
190 return BCMA_CC_PMU_ALP_CLOCK;
191}
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200192
193/* Find the output of the "m" pll divider given pll controls that start with
194 * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
195 */
196static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
197{
198 u32 tmp, div, ndiv, p1, p2, fc;
199 struct bcma_bus *bus = cc->core->bus;
200
201 BUG_ON((pll0 & 3) || (pll0 > BCMA_CC_PMU4716_MAINPLL_PLL0));
202
203 BUG_ON(!m || m > 4);
204
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200205 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
206 bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) {
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200207 /* Detect failure in clock setting */
208 tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
209 if (tmp & 0x40000)
210 return 133 * 1000000;
211 }
212
213 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_P1P2_OFF);
214 p1 = (tmp & BCMA_CC_PPL_P1_MASK) >> BCMA_CC_PPL_P1_SHIFT;
215 p2 = (tmp & BCMA_CC_PPL_P2_MASK) >> BCMA_CC_PPL_P2_SHIFT;
216
217 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_M14_OFF);
218 div = (tmp >> ((m - 1) * BCMA_CC_PPL_MDIV_WIDTH)) &
219 BCMA_CC_PPL_MDIV_MASK;
220
221 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_NM5_OFF);
222 ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
223
224 /* Do calculation in Mhz */
225 fc = bcma_pmu_alp_clock(cc) / 1000000;
226 fc = (p1 * ndiv * fc) / p2;
227
228 /* Return clock in Hertz */
229 return (fc / div) * 1000000;
230}
231
Hauke Mehrtens650cef382012-07-09 22:03:10 +0200232static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
233{
234 u32 tmp, ndiv, p1div, p2div;
235 u32 clock;
236
237 BUG_ON(!m || m > 4);
238
239 /* Get N, P1 and P2 dividers to determine CPU clock */
240 tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PMU6_4706_PROCPLL_OFF);
241 ndiv = (tmp & BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK)
242 >> BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT;
243 p1div = (tmp & BCMA_CC_PMU6_4706_PROC_P1DIV_MASK)
244 >> BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT;
245 p2div = (tmp & BCMA_CC_PMU6_4706_PROC_P2DIV_MASK)
246 >> BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT;
247
248 tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
249 if (tmp & BCMA_CC_CHIPST_4706_PKG_OPTION)
250 /* Low cost bonding: Fixed reference clock 25MHz and m = 4 */
251 clock = (25000000 / 4) * ndiv * p2div / p1div;
252 else
253 /* Fixed reference clock 25MHz and m = 2 */
254 clock = (25000000 / 2) * ndiv * p2div / p1div;
255
256 if (m == BCMA_CC_PMU5_MAINPLL_SSB)
257 clock = clock / 4;
258
259 return clock;
260}
261
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200262/* query bus clock frequency for PMU-enabled chipcommon */
Hauke Mehrtens94f34572012-08-05 16:54:41 +0200263static u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200264{
265 struct bcma_bus *bus = cc->core->bus;
266
267 switch (bus->chipinfo.id) {
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200268 case BCMA_CHIP_ID_BCM4716:
269 case BCMA_CHIP_ID_BCM4748:
270 case BCMA_CHIP_ID_BCM47162:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200271 return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
272 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200273 case BCMA_CHIP_ID_BCM5356:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200274 return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
275 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200276 case BCMA_CHIP_ID_BCM5357:
277 case BCMA_CHIP_ID_BCM4749:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200278 return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
279 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200280 case BCMA_CHIP_ID_BCM4706:
Hauke Mehrtens650cef382012-07-09 22:03:10 +0200281 return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
282 BCMA_CC_PMU5_MAINPLL_SSB);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200283 case BCMA_CHIP_ID_BCM53572:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200284 return 75000000;
285 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200286 bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
287 bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200288 }
289 return BCMA_CC_PMU_HT_CLOCK;
290}
291
292/* query cpu clock frequency for PMU-enabled chipcommon */
293u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
294{
295 struct bcma_bus *bus = cc->core->bus;
296
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200297 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200298 return 300000000;
299
300 if (cc->pmu.rev >= 5) {
301 u32 pll;
302 switch (bus->chipinfo.id) {
Hauke Mehrtens650cef382012-07-09 22:03:10 +0200303 case BCMA_CHIP_ID_BCM4706:
304 return bcma_pmu_clock_bcm4706(cc,
305 BCMA_CC_PMU4706_MAINPLL_PLL0,
306 BCMA_CC_PMU5_MAINPLL_CPU);
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200307 case BCMA_CHIP_ID_BCM5356:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200308 pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
309 break;
Hauke Mehrtens4b4f5be2012-06-30 01:44:38 +0200310 case BCMA_CHIP_ID_BCM5357:
311 case BCMA_CHIP_ID_BCM4749:
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200312 pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
313 break;
314 default:
315 pll = BCMA_CC_PMU4716_MAINPLL_PLL0;
316 break;
317 }
318
Hauke Mehrtens908debc2011-07-23 01:20:11 +0200319 return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
320 }
321
322 return bcma_pmu_get_clockcontrol(cc);
323}
Hauke Mehrtensc586e102012-06-30 01:44:44 +0200324
325static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
326 u32 value)
327{
328 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
329 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
330}
331
332void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
333{
334 u32 tmp = 0;
335 u8 phypll_offset = 0;
336 u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5};
337 u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc};
338 struct bcma_bus *bus = cc->core->bus;
339
340 switch (bus->chipinfo.id) {
341 case BCMA_CHIP_ID_BCM5357:
342 case BCMA_CHIP_ID_BCM4749:
343 case BCMA_CHIP_ID_BCM53572:
344 /* 5357[ab]0, 43236[ab]0, and 6362b0 */
345
346 /* BCM5357 needs to touch PLL1_PLLCTL[02],
347 so offset PLL0_PLLCTL[02] by 6 */
348 phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
349 bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 ||
350 bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
351
352 /* RMW only the P1 divider */
353 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
354 BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
355 tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
356 tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
357 tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
358 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
359
360 /* RMW only the int feedback divider */
361 bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
362 BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
363 tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
364 tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
365 tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
366 bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
367
368 tmp = 1 << 10;
369 break;
370
371 case BCMA_CHIP_ID_BCM4331:
372 case BCMA_CHIP_ID_BCM43431:
373 if (spuravoid == 2) {
374 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
375 0x11500014);
376 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
377 0x0FC00a08);
378 } else if (spuravoid == 1) {
379 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
380 0x11500014);
381 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
382 0x0F600a08);
383 } else {
384 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
385 0x11100014);
386 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
387 0x03000a08);
388 }
389 tmp = 1 << 10;
390 break;
391
392 case BCMA_CHIP_ID_BCM43224:
393 case BCMA_CHIP_ID_BCM43225:
394 case BCMA_CHIP_ID_BCM43421:
395 if (spuravoid == 1) {
396 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
397 0x11500010);
398 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
399 0x000C0C06);
400 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
401 0x0F600a08);
402 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
403 0x00000000);
404 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
405 0x2001E920);
406 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
407 0x88888815);
408 } else {
409 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
410 0x11100010);
411 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
412 0x000c0c06);
413 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
414 0x03000a08);
415 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
416 0x00000000);
417 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
418 0x200005c0);
419 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
420 0x88888815);
421 }
422 tmp = 1 << 10;
423 break;
424
425 case BCMA_CHIP_ID_BCM4716:
426 case BCMA_CHIP_ID_BCM4748:
427 case BCMA_CHIP_ID_BCM47162:
428 if (spuravoid == 1) {
429 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
430 0x11500060);
431 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
432 0x080C0C06);
433 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
434 0x0F600000);
435 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
436 0x00000000);
437 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
438 0x2001E924);
439 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
440 0x88888815);
441 } else {
442 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
443 0x11100060);
444 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
445 0x080c0c06);
446 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
447 0x03000000);
448 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
449 0x00000000);
450 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
451 0x200005c0);
452 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
453 0x88888815);
454 }
455
456 tmp = 3 << 9;
457 break;
458
459 case BCMA_CHIP_ID_BCM43227:
460 case BCMA_CHIP_ID_BCM43228:
461 case BCMA_CHIP_ID_BCM43428:
462 /* LCNXN */
463 /* PLL Settings for spur avoidance on/off mode,
464 no on2 support for 43228A0 */
465 if (spuravoid == 1) {
466 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
467 0x01100014);
468 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
469 0x040C0C06);
470 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
471 0x03140A08);
472 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
473 0x00333333);
474 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
475 0x202C2820);
476 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
477 0x88888815);
478 } else {
479 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
480 0x11100014);
481 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
482 0x040c0c06);
483 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
484 0x03000a08);
485 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
486 0x00000000);
487 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
488 0x200005c0);
489 bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
490 0x88888815);
491 }
492 tmp = 1 << 10;
493 break;
494 default:
Rafał Miłecki3d9d8af2012-07-05 22:07:32 +0200495 bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
496 bus->chipinfo.id);
Hauke Mehrtensc586e102012-06-30 01:44:44 +0200497 break;
498 }
499
500 tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
501 bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
502}
503EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);