forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/siutils.c
....@@ -1,16 +1,17 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Misc utility routines for accessing chip-specific features
43 * of the SiliconBackplane-based Broadcom chips.
54 *
6
- * Copyright (C) 1999-2019, Broadcom Corporation
7
- *
5
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
6
+ *
7
+ * Copyright (C) 1999-2017, Broadcom Corporation
8
+ *
89 * Unless you and Broadcom execute a separate written software license
910 * agreement governing use of this software, this software is licensed to you
1011 * under the terms of the GNU General Public License version 2 (the "GPL"),
1112 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1213 * following added to such license:
13
- *
14
+ *
1415 * As a special exception, the copyright holders of this software give you
1516 * permission to link this software with independent modules, and to copy and
1617 * distribute the resulting executable under terms of your choice, provided that
....@@ -18,7 +19,7 @@
1819 * the license of that module. An independent module is a module which is not
1920 * derived from this software. The special exception does not apply to any
2021 * modifications of the software.
21
- *
22
+ *
2223 * Notwithstanding the above, under no circumstances may you combine this
2324 * software in any way with any other Broadcom software provided under a license
2425 * other than the GPL, without Broadcom's express prior written consent.
....@@ -26,7 +27,7 @@
2627 *
2728 * <<Broadcom-WL-IPTag/Open:>>
2829 *
29
- * $Id: siutils.c 722050 2019-08-21 02:24:57Z $
30
+ * $Id: siutils.c 701025 2017-05-23 10:23:52Z $
3031 */
3132
3233 #include <bcm_cfg.h>
....@@ -38,8 +39,12 @@
3839 #include <bcmdevs.h>
3940 #include <hndsoc.h>
4041 #include <sbchipc.h>
42
+#include <sbgci.h>
43
+#ifndef BCMSDIO
44
+#include <pcie_core.h>
45
+#endif // endif
4146 #ifdef BCMPCIEDEV
42
-#include <pciedev.h>
47
+/
4348 #endif /* BCMPCIEDEV */
4449 #include <pcicfg.h>
4550 #include <sbpcmcia.h>
....@@ -54,10 +59,9 @@
5459 #include <bcmsdpcm.h>
5560 #endif /* BCMSDIO */
5661 #include <hndpmu.h>
57
-
58
-#ifdef LOAD_DHD_WITH_FW_ALIVE
59
-#include <dhd_chip_info.h>
60
-#endif
62
+#ifdef BCMSPI
63
+#include <spid.h>
64
+#endif /* BCMSPI */
6165
6266 #ifdef BCM_SDRBL
6367 #include <hndcpu.h>
....@@ -65,8 +69,28 @@
6569 #ifdef HNDGCI
6670 #include <hndgci.h>
6771 #endif /* HNDGCI */
72
+#ifdef WLGCIMBHLR
73
+#include <hnd_gci.h>
74
+#endif /* WLGCIMBHLR */
75
+#ifdef BCMULP
76
+#include <ulp.h>
77
+#endif /* BCMULP */
78
+#include <hndlhl.h>
79
+
80
+#include <lpflags.h>
6881
6982 #include "siutils_priv.h"
83
+#ifdef SECI_UART
84
+/* Defines the set of GPIOs to be used for SECI UART if not specified in NVRAM */
85
+/* For further details on each ppin functionality please refer to PINMUX table in
86
+ * Top level architecture of BCMXXXX Chip
87
+ */
88
+#define DEFAULT_SECI_UART_PINMUX 0x08090a0b
89
+#define DEFAULT_SECI_UART_PINMUX_43430 0x0102
90
+static bool force_seci_clk = 0;
91
+#endif /* SECI_UART */
92
+
93
+#define XTAL_FREQ_26000KHZ 26000
7094
7195 /**
7296 * A set of PMU registers is clocked in the ILP domain, which has an implication on register write
....@@ -83,26 +107,35 @@
83107 (regoff) == OFFSETOF(chipcregs_t, pmuwatchdog) || \
84108 (regoff) == OFFSETOF(chipcregs_t, res_req_timer))
85109
110
+#define GCI_FEM_CTRL_WAR 0x11111111
111
+
112
+#ifndef AXI_TO_VAL
113
+#define AXI_TO_VAL 19
114
+#endif /* AXI_TO_VAL */
115
+
116
+#ifndef AXI_TO_VAL_4347
117
+/*
118
+ * Increase BP timeout for fast clock and short PCIe timeouts
119
+ * New timeout: 2 ** 25 cycles
120
+ */
121
+#define AXI_TO_VAL_4347 25
122
+#endif /* AXI_TO_VAL_4347 */
123
+
86124 /* local prototypes */
87
-static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, void *regs,
125
+static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, volatile void *regs,
88126 uint bustype, void *sdh, char **vars, uint *varsz);
89127 static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid, void *sdh);
90128 static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, uint32 savewin,
91
- uint *origidx, void *regs);
92
-
129
+ uint *origidx, volatile void *regs);
93130
94131 static bool si_pmu_is_ilp_sensitive(uint32 idx, uint regoff);
95
-
96
-#ifdef BCMLTECOEX
97
-static void si_config_gcigpio(si_t *sih, uint32 gci_pos, uint8 gcigpio,
98
- uint8 gpioctl_mask, uint8 gpioctl_val);
99
-#endif /* BCMLTECOEX */
100
-
101132
102133 /* global variable to indicate reservation/release of gpio's */
103134 static uint32 si_gpioreservation = 0;
104135
105136 /* global flag to prevent shared resources from being initialized multiple times in si_attach() */
137
+static bool si_onetimeinit = FALSE;
138
+
106139 #ifdef SR_DEBUG
107140 static const uint32 si_power_island_test_array[] = {
108141 0x0000, 0x0001, 0x0010, 0x0011,
....@@ -113,6 +146,11 @@
113146 #endif /* SR_DEBUG */
114147
115148 int do_4360_pcie2_war = 0;
149
+
150
+#ifdef BCMULP
151
+/* Variable to store boot_type: warm_boot/cold_boot/etc. */
152
+static int boot_type = 0;
153
+#endif // endif
116154
117155 /* global kernel resource */
118156 static si_info_t ksii;
....@@ -130,19 +168,21 @@
130168 * varsz - pointer to int to return the size of the vars
131169 */
132170 si_t *
133
-si_attach(uint devid, osl_t *osh, void *regs,
171
+si_attach(uint devid, osl_t *osh, volatile void *regs,
134172 uint bustype, void *sdh, char **vars, uint *varsz)
135173 {
136174 si_info_t *sii;
137175 si_cores_info_t *cores_info;
138176 /* alloc si_info_t */
139
- if ((sii = MALLOCZ(osh, sizeof (si_info_t))) == NULL) {
177
+ /* freed after ucode download for firmware builds */
178
+ if ((sii = MALLOCZ_NOPERSIST(osh, sizeof(si_info_t))) == NULL) {
140179 SI_ERROR(("si_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
141180 return (NULL);
142181 }
143182
144183 /* alloc si_cores_info_t */
145
- if ((cores_info = (si_cores_info_t *)MALLOCZ(osh, sizeof (si_cores_info_t))) == NULL) {
184
+ if ((cores_info = (si_cores_info_t *)MALLOCZ(osh,
185
+ sizeof(si_cores_info_t))) == NULL) {
146186 SI_ERROR(("si_attach: malloc failed! malloced %d bytes\n", MALLOCED(osh)));
147187 MFREE(osh, sii, sizeof(si_info_t));
148188 return (NULL);
....@@ -160,10 +200,39 @@
160200 return (si_t *)sii;
161201 }
162202
203
+static uint32 wd_msticks; /**< watchdog timer ticks normalized to ms */
163204
164
-static uint32 wd_msticks; /* watchdog timer ticks normalized to ms */
205
+/** Returns the backplane address of the chipcommon core for a particular chip */
206
+uint32
207
+si_enum_base(uint devid)
208
+{
209
+ // NIC/DHD build
210
+ switch (devid) {
211
+ case BCM7271_CHIP_ID:
212
+ case BCM7271_D11AC_ID:
213
+ case BCM7271_D11AC2G_ID:
214
+ case BCM7271_D11AC5G_ID:
215
+ return 0xF1800000;
216
+ }
165217
166
-/** generic kernel variant of si_attach() */
218
+ return SI_ENUM_BASE_DEFAULT;
219
+}
220
+
221
+/** Returns the backplane address of the PCIE core for a particular chip */
222
+uint32
223
+si_pcie_enum_base(uint devid)
224
+{
225
+ switch (devid) {
226
+ case CYW55560_WLAN_ID:
227
+ case CYW89570_WLAN_ID:
228
+ return SI_ENUM_PCIE2_BASE;
229
+ }
230
+
231
+ /* Default - In future chips if devid is not matched */
232
+ return SI_ENUM_PCIE2_BASE;
233
+}
234
+
235
+/** generic kernel variant of si_attach(). Is not called for Linux WLAN NIC builds. */
167236 si_t *
168237 si_kattach(osl_t *osh)
169238 {
....@@ -172,12 +241,14 @@
172241
173242 if (!ksii_attached) {
174243 void *regs = NULL;
175
- regs = REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE);
244
+ const uint device_id = BCM4710_DEVICE_ID; // pick an arbitrary default device_id
245
+
246
+ regs = REG_MAP(si_enum_base(device_id), SI_CORE_SIZE); // map physical to virtual
176247 cores_info = (si_cores_info_t *)&ksii_cores_info;
177248 ksii.cores_info = cores_info;
178249
179250 ASSERT(osh);
180
- if (si_doattach(&ksii, BCM4710_DEVICE_ID, osh, regs,
251
+ if (si_doattach(&ksii, device_id, osh, regs,
181252 SI_BUS, NULL,
182253 osh != SI_OSH ? &(ksii.vars) : NULL,
183254 osh != SI_OSH ? &(ksii.varsz) : NULL) == NULL) {
....@@ -189,30 +260,30 @@
189260
190261 /* save ticks normalized to ms for si_watchdog_ms() */
191262 if (PMUCTL_ENAB(&ksii.pub)) {
192
- /* based on 32KHz ILP clock */
193
- wd_msticks = 32;
263
+ /* based on 32KHz ILP clock */
264
+ wd_msticks = 32;
194265 } else {
195266 wd_msticks = ALP_CLOCK / 1000;
196267 }
197268
198269 ksii_attached = TRUE;
199270 SI_MSG(("si_kattach done. ccrev = %d, wd_msticks = %d\n",
200
- ksii.pub.ccrev, wd_msticks));
271
+ CCREV(ksii.pub.ccrev), wd_msticks));
201272 }
202273
203274 return &ksii.pub;
204275 }
205276
206
-
207277 static bool
208278 si_buscore_prep(si_info_t *sii, uint bustype, uint devid, void *sdh)
209279 {
280
+ BCM_REFERENCE(sdh);
281
+ BCM_REFERENCE(devid);
210282 /* need to set memseg flag for CF card first before any sb registers access */
211283 if (BUSTYPE(bustype) == PCMCIA_BUS)
212284 sii->memseg = TRUE;
213285
214
-
215
-#if defined(BCMSDIO)
286
+#if defined(BCMSDIO) && !defined(BCMSDIOLITE)
216287 if (BUSTYPE(bustype) == SDIO_BUS) {
217288 int err;
218289 uint8 clkset;
....@@ -245,7 +316,25 @@
245316 bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, 0, NULL);
246317 }
247318
248
-#endif /* BCMSDIO && BCMDONGLEHOST */
319
+#ifdef BCMSPI
320
+ /* Avoid backplane accesses before wake-wlan (i.e. htavail) for spi.
321
+ * F1 read accesses may return correct data but with data-not-available dstatus bit set.
322
+ */
323
+ if (BUSTYPE(bustype) == SPI_BUS) {
324
+
325
+ int err;
326
+ uint32 regdata;
327
+ /* wake up wlan function :WAKE_UP goes as HT_AVAIL request in hardware */
328
+ regdata = bcmsdh_cfg_read_word(sdh, SDIO_FUNC_0, SPID_CONFIG, NULL);
329
+ SI_MSG(("F0 REG0 rd = 0x%x\n", regdata));
330
+ regdata |= WAKE_UP;
331
+
332
+ bcmsdh_cfg_write_word(sdh, SDIO_FUNC_0, SPID_CONFIG, regdata, &err);
333
+
334
+ OSL_DELAY(100000);
335
+ }
336
+#endif /* BCMSPI */
337
+#endif /* BCMSDIO && BCMDONGLEHOST && !BCMSDIOLITE */
249338
250339 return TRUE;
251340 }
....@@ -268,46 +357,31 @@
268357 origidx = sii->curidx;
269358 pmucoreidx = si_findcoreidx(&sii->pub, PMU_CORE_ID, 0);
270359 pmu = si_setcoreidx(&sii->pub, pmucoreidx);
271
- pmuaddr = (uint32)(unsigned long)((uint8*)pmu + offset);
360
+ pmuaddr = (uint32)(uintptr)((volatile uint8*)pmu + offset);
272361 si_setcoreidx(sih, origidx);
273362 } else
274
- pmuaddr = SI_ENUM_BASE + offset;
363
+ pmuaddr = SI_ENUM_BASE(sih) + offset;
275364
276365 done:
277
- SI_MSG(("%s: addrRET: %x\n", __FUNCTION__, pmuaddr));
366
+ printf("%s: addrRET: %x\n", __FUNCTION__, pmuaddr);
278367 return pmuaddr;
279368 }
280369
281370 static bool
282371 si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, uint32 savewin,
283
- uint *origidx, void *regs)
372
+ uint *origidx, volatile void *regs)
284373 {
285374 si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
286375 bool pci, pcie, pcie_gen2 = FALSE;
287376 uint i;
288377 uint pciidx, pcieidx, pcirev, pcierev;
378
+ struct si_pub *sih = &sii->pub;
289379
290
-#ifdef LOAD_DHD_WITH_FW_ALIVE
291
- if(alive == FW_ALIVE_MAGIC) {
292
- switch(card_dev) {
293
- case BCM43430_CHIP_ID:
294
- if(card_rev == 2)
295
- memcpy(&sii->pub, &sii_pub_43436, sizeof(sii->pub));
296
- else
297
- memcpy(&sii->pub, &sii_pub_43430, sizeof(sii->pub));
298
- break;
299
-
300
- case BCM43012_CHIP_ID:
301
- memcpy(&sii->pub, &sii_pub_43012, sizeof(sii->pub));
302
- break;
303
- }
304
- return true;
305
- }
306
-#endif
307
-
380
+#if defined(BCM_BACKPLANE_TIMEOUT) || defined(AXI_TIMEOUTS)
308381 /* first, enable backplane timeouts */
309
- if (CHIPTYPE(sii->pub.socitype) == SOCI_AI)
310
- ai_enable_backplane_timeouts(&sii->pub);
382
+ si_slave_wrapper_add(&sii->pub);
383
+#endif // endif
384
+ sii->curidx = 0;
311385
312386 cc = si_setcoreidx(&sii->pub, SI_CC_IDX);
313387 ASSERT((uintptr)cc);
....@@ -316,33 +390,50 @@
316390 sii->pub.ccrev = (int)si_corerev(&sii->pub);
317391
318392 /* get chipcommon chipstatus */
319
- if (sii->pub.ccrev >= 11)
320
- sii->pub.chipst = R_REG(sii->osh, &cc->chipstatus);
393
+ if (CCREV(sii->pub.ccrev) >= 11) {
394
+ /* TODO : We need a better approach to avoid this access in secure mode chips */
395
+ if (sii->pub.chip != CYW55500_CHIP_ID &&
396
+ sii->pub.chip != CYW55560_CHIP_ID) {
397
+ sii->pub.chipst = R_REG(sii->osh, &cc->chipstatus);
398
+ }
399
+ }
321400
322
- /* get chipcommon capabilites */
323
- sii->pub.cccaps = R_REG(sii->osh, &cc->capabilities);
324
- /* get chipcommon extended capabilities */
401
+ if (!sih->chipidpresent) {
402
+ /* get chipcommon capabilites */
403
+ sii->pub.cccaps = R_REG(sii->osh, &cc->capabilities);
404
+ /* get chipcommon extended capabilities */
405
+ if (CCREV(sii->pub.ccrev) >= 35)
406
+ sii->pub.cccaps_ext = R_REG(sii->osh, &cc->capabilities_ext);
325407
326
- if (sii->pub.ccrev >= 35)
327
- sii->pub.cccaps_ext = R_REG(sii->osh, &cc->capabilities_ext);
408
+ /* get pmu rev and caps */
409
+ if (sii->pub.cccaps & CC_CAP_PMU) {
410
+ if (AOB_ENAB(&sii->pub)) {
411
+ uint pmucoreidx;
412
+ pmuregs_t *pmu;
413
+ struct si_pub *sih = &sii->pub;
328414
329
- /* get pmu rev and caps */
330
- if (sii->pub.cccaps & CC_CAP_PMU) {
331
- if (AOB_ENAB(&sii->pub)) {
332
- uint pmucoreidx;
333
- pmuregs_t *pmu;
334
- pmucoreidx = si_findcoreidx(&sii->pub, PMU_CORE_ID, 0);
335
- pmu = si_setcoreidx(&sii->pub, pmucoreidx);
336
- sii->pub.pmucaps = R_REG(sii->osh, &pmu->pmucapabilities);
337
- si_setcoreidx(&sii->pub, SI_CC_IDX);
338
- } else
339
- sii->pub.pmucaps = R_REG(sii->osh, &cc->pmucapabilities);
415
+ pmucoreidx = si_findcoreidx(&sii->pub, PMU_CORE_ID, 0);
416
+ if (!GOODIDX(pmucoreidx)) {
417
+ SI_ERROR(("si_buscore_setup: si_findcoreidx failed\n"));
418
+ return FALSE;
419
+ }
340420
341
- sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
421
+ pmu = si_setcoreidx(&sii->pub, pmucoreidx);
422
+ sii->pub.pmucaps = R_REG(sii->osh, &pmu->pmucapabilities);
423
+ si_setcoreidx(&sii->pub, SI_CC_IDX);
424
+
425
+ sii->pub.gcirev = si_corereg(sih, GCI_CORE_IDX(sih),
426
+ GCI_OFFSETOF(sih, gci_corecaps0), 0, 0) &
427
+ GCI_CAP0_REV_MASK;
428
+ } else
429
+ sii->pub.pmucaps = R_REG(sii->osh, &cc->pmucapabilities);
430
+
431
+ sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
432
+ }
342433 }
343434
344435 SI_MSG(("Chipc: rev %d, caps 0x%x, chipst 0x%x pmurev %d, pmucaps 0x%x\n",
345
- sii->pub.ccrev, sii->pub.cccaps, sii->pub.chipst, sii->pub.pmurev,
436
+ CCREV(sii->pub.ccrev), sii->pub.cccaps, sii->pub.chipst, sii->pub.pmurev,
346437 sii->pub.pmucaps));
347438
348439 /* figure out bus/orignal core idx */
....@@ -362,28 +453,23 @@
362453 crev = si_corerev(&sii->pub);
363454
364455 /* Display cores found */
365
- SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x regs 0x%p\n",
366
- i, cid, crev, cores_info->coresba[i], cores_info->regs[i]));
456
+ SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x size:%x regs 0x%p\n",
457
+ i, cid, crev, sii->coresba[i], sii->coresba_size[i],
458
+ OSL_OBFUSCATE_BUF(sii->regs[i])));
367459
368460 if (BUSTYPE(bustype) == SI_BUS) {
369461 /* now look at the chipstatus register to figure the pacakge */
370462 /* for SDIO but downloaded on PCIE dev */
463
+#ifdef BCMPCIEDEV_ENABLED
371464 if (cid == PCIE2_CORE_ID) {
372
- if (BCM43602_CHIP(sii->pub.chip) ||
373
- (CHIPID(sii->pub.chip) == BCM4365_CHIP_ID) ||
374
- (CHIPID(sii->pub.chip) == BCM4366_CHIP_ID) ||
375
- ((CHIPID(sii->pub.chip) == BCM4345_CHIP_ID ||
376
- CHIPID(sii->pub.chip) == BCM43454_CHIP_ID) &&
377
- CST4345_CHIPMODE_PCIE(sii->pub.chipst))) {
378465 pcieidx = i;
379466 pcierev = crev;
380467 pcie = TRUE;
381468 pcie_gen2 = TRUE;
382
- }
383469 }
470
+#endif // endif
384471
385
- }
386
- else if (BUSTYPE(bustype) == PCI_BUS) {
472
+ } else if (BUSTYPE(bustype) == PCI_BUS) {
387473 if (cid == PCI_CORE_ID) {
388474 pciidx = i;
389475 pcirev = crev;
....@@ -418,7 +504,6 @@
418504 *origidx = i;
419505 }
420506
421
-
422507 #if defined(PCIE_FULL_DONGLE)
423508 if (pcie) {
424509 if (pcie_gen2)
....@@ -449,11 +534,6 @@
449534 SI_VMSG(("Buscore id/type/rev %d/0x%x/%d\n", sii->pub.buscoreidx, sii->pub.buscoretype,
450535 sii->pub.buscorerev));
451536
452
- if (BUSTYPE(sii->pub.bustype) == SI_BUS && (CHIPID(sii->pub.chip) == BCM4712_CHIP_ID) &&
453
- (sii->pub.chippkg != BCM4712LARGE_PKG_ID) && (CHIPREV(sii->pub.chiprev) <= 3))
454
- OR_REG(sii->osh, &cc->slow_clk_ctl, SCC_SS_XTAL);
455
-
456
-
457537 #if defined(BCMSDIO)
458538 /* Make sure any on-chip ARM is off (in case strapping is wrong), or downloaded code was
459539 * already running.
....@@ -471,9 +551,6 @@
471551 return TRUE;
472552 }
473553
474
-
475
-
476
-
477554 uint16
478555 si_chipid(si_t *sih)
479556 {
....@@ -482,6 +559,7 @@
482559 return (sii->chipnew) ? sii->chipnew : sih->chip;
483560 }
484561
562
+/* CHIP_ID's being mapped here should not be used anywhere else in the code */
485563 static void
486564 si_chipid_fixup(si_t *sih)
487565 {
....@@ -493,49 +571,162 @@
493571 sii->chipnew = sih->chip; /* save it */
494572 sii->pub.chip = BCM43570_CHIP_ID; /* chip class */
495573 break;
574
+ case BCM43562_CHIP_ID:
496575 case BCM4358_CHIP_ID:
497576 case BCM43566_CHIP_ID:
498577 sii->chipnew = sih->chip; /* save it */
499578 sii->pub.chip = BCM43569_CHIP_ID; /* chip class */
500579 break;
501580 case BCM4356_CHIP_ID:
581
+ case BCM4371_CHIP_ID:
502582 sii->chipnew = sih->chip; /* save it */
503583 sii->pub.chip = BCM4354_CHIP_ID; /* chip class */
504584 break;
585
+ case BCM4357_CHIP_ID:
586
+ case BCM4361_CHIP_ID:
587
+ sii->chipnew = sih->chip; /* save it */
588
+ sii->pub.chip = BCM4347_CHIP_ID; /* chip class */
589
+ break;
590
+#ifdef CHIPS_CUSTOMER_HW6
591
+ case BCM4377_CHIP_ID:
592
+ sii->chipnew = sih->chip; /* save it */
593
+ sii->pub.chip = BCM4369_CHIP_ID; /* chip class */
594
+ break;
595
+#endif /* CHIPS_CUSTOMER_HW6 */
505596 default:
506597 break;
507598 }
508599 }
509600
601
+#ifdef BCMULP
602
+static void
603
+si_check_boot_type(si_t *sih, osl_t *osh)
604
+{
605
+ if (sih->pmurev >= 30) {
606
+ boot_type = PMU_REG_NEW(sih, swscratch, 0, 0);
607
+ } else {
608
+ boot_type = CHIPC_REG(sih, flashdata, 0, 0);
609
+ }
610
+
611
+ SI_ERROR(("%s: boot_type: 0x%08x\n", __func__, boot_type));
612
+}
613
+#endif /* BCMULP */
614
+
615
+#ifdef BCM_BACKPLANE_TIMEOUT
616
+uint32
617
+si_clear_backplane_to_fast(void *sih, void *addr)
618
+{
619
+ si_t *_sih = DISCARD_QUAL(sih, si_t);
620
+
621
+ if (CHIPTYPE(_sih->socitype) == SOCI_AI) {
622
+ return ai_clear_backplane_to_fast(_sih, addr);
623
+ }
624
+
625
+ return 0;
626
+}
627
+
628
+const si_axi_error_info_t *
629
+si_get_axi_errlog_info(si_t *sih)
630
+{
631
+ if (CHIPTYPE(sih->socitype) == SOCI_AI) {
632
+ return (const si_axi_error_info_t *)sih->err_info;
633
+ }
634
+
635
+ return NULL;
636
+}
637
+
638
+void
639
+si_reset_axi_errlog_info(si_t *sih)
640
+{
641
+ if (sih->err_info) {
642
+ sih->err_info->count = 0;
643
+ }
644
+}
645
+#endif /* BCM_BACKPLANE_TIMEOUT */
646
+
647
+#ifdef BCMSDIO
648
+void *
649
+si_get_sdio_addrbase(void *sdh)
650
+{
651
+ uint8 devctl;
652
+ int err = 0;
653
+ uint32 addr = 0;
654
+
655
+ devctl = bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err);
656
+ if (err)
657
+ return NULL;
658
+
659
+ bcmsdh_cfg_write(sdh, SDIO_FUNC_1,
660
+ SBSDIO_DEVICE_CTL, devctl | SBSDIO_DEVCTL_ADDR_RESET, &err);
661
+ if (err)
662
+ goto exit;
663
+
664
+ addr |= (bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, NULL) << 8) |
665
+ (bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, NULL) << 16) |
666
+ (bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, NULL) << 24);
667
+
668
+ SI_MSG(("%s: sdiod core address is 0x%x\n", __FUNCTION__, addr));
669
+exit:
670
+ if (err) {
671
+ SI_ERROR(("%s: Get SDIO core base address failed, err=%d", __FUNCTION__, err));
672
+ addr = 0;
673
+ }
674
+ bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err);
675
+
676
+ return (void *)((uintptr)addr);
677
+}
678
+#endif /* BCMSDIO */
679
+
510680 /**
511
- * Allocate an si handle. This function may be called multiple times.
681
+ * Allocate an si handle. This function may be called multiple times. This function is called by
682
+ * both si_attach() and si_kattach().
512683 *
513684 * vars - pointer to a to-be created pointer area for "environment" variables. Some callers of this
514685 * function set 'vars' to NULL.
515686 */
516687 static si_info_t *
517
-si_doattach(si_info_t *sii, uint devid, osl_t *osh, void *regs,
688
+si_doattach(si_info_t *sii, uint devid, osl_t *osh, volatile void *regs,
518689 uint bustype, void *sdh, char **vars, uint *varsz)
519690 {
520691 struct si_pub *sih = &sii->pub;
521
- uint32 w, savewin;
692
+ uint32 w = 0;
693
+ uint32 savewin;
522694 chipcregs_t *cc;
523695 char *pvars = NULL;
524696 uint origidx;
525
-#if !defined(_CFEZ_) || defined(CFG_WL)
526
-#endif
697
+#ifdef NVSRCX
698
+ char *sromvars;
699
+#endif // endif
700
+ uint32 erombase;
701
+#ifdef BCMSDIO
702
+ uint8 cardcap;
703
+ sdpcmd_regs_t *sdioc;
704
+#endif // endif
527705
528706 ASSERT(GOODREGS(regs));
529707
530708 savewin = 0;
531709
532710 sih->buscoreidx = BADIDX;
711
+ sii->device_removed = FALSE;
533712
534713 sii->curmap = regs;
535714 sii->sdh = sdh;
536715 sii->osh = osh;
537716 sii->second_bar0win = ~0x0;
717
+ sih->enum_base = si_enum_base(devid);
538718
719
+#if defined(BCM_BACKPLANE_TIMEOUT)
720
+ sih->err_info = MALLOCZ(osh, sizeof(si_axi_error_info_t));
721
+ if (sih->err_info == NULL) {
722
+ SI_ERROR(("%s: %zu bytes MALLOC FAILED",
723
+ __FUNCTION__, sizeof(si_axi_error_info_t)));
724
+ }
725
+#endif /* BCM_BACKPLANE_TIMEOUT */
726
+
727
+#if defined(BCM_BACKPLANE_TIMEOUT)
728
+ osl_set_bpt_cb(osh, (void *)si_clear_backplane_to_fast, (void *)sih);
729
+#endif // endif
539730
540731 /* check to see if we are a si core mimic'ing a pci core */
541732 if ((bustype == PCI_BUS) &&
....@@ -548,29 +739,42 @@
548739 /* find Chipcommon address */
549740 if (bustype == PCI_BUS) {
550741 savewin = OSL_PCI_READ_CONFIG(sii->osh, PCI_BAR0_WIN, sizeof(uint32));
551
- if (!GOODCOREADDR(savewin, SI_ENUM_BASE))
552
- savewin = SI_ENUM_BASE;
553
- OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, 4, SI_ENUM_BASE);
742
+ if (!GOODCOREADDR(savewin, SI_ENUM_BASE(sih)))
743
+ savewin = SI_ENUM_BASE(sih);
744
+ OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, 4, SI_ENUM_BASE(sih));
554745 if (!regs)
555746 return NULL;
556747 cc = (chipcregs_t *)regs;
748
+ erombase = R_REG(osh, &cc->eromptr);
557749 #ifdef BCMSDIO
558750 } else if ((bustype == SDIO_BUS) || (bustype == SPI_BUS)) {
559751 cc = (chipcregs_t *)sii->curmap;
560
-#endif
752
+ cardcap = bcmsdh_cfg_read(sdh, SDIO_FUNC_0, SDIOD_CCCR_BRCM_CARDCAP, NULL);
753
+ if (cardcap & SDIOD_CCCR_BRCM_CARDCAP_CHIPID_PRESENT) {
754
+ sih->chipidpresent = TRUE;
755
+ sdioc = si_get_sdio_addrbase(sdh);
756
+ w = R_REG(osh, &sdioc->chipid);
757
+ erombase = R_REG(osh, &sdioc->eromptr);
758
+ } else {
759
+ erombase = R_REG(osh, &cc->eromptr);
760
+ }
761
+ if (cardcap & SDIOD_CCCR_BRCM_CARDCAP_SECURE_MODE) {
762
+ sih->secureboot = TRUE;
763
+ }
764
+#endif // endif
561765 } else {
562
- cc = (chipcregs_t *)REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE);
766
+ cc = (chipcregs_t *)REG_MAP(SI_ENUM_BASE(sih), SI_CORE_SIZE);
767
+ erombase = R_REG(osh, &cc->eromptr);
563768 }
564769
565770 sih->bustype = bustype;
566771 #ifdef BCMBUSTYPE
567
- /* Fix the -Werror=tautological-compare compiling error */
568772 if (bustype != BUSTYPE(bustype)) {
569773 SI_ERROR(("si_doattach: bus type %d does not match configured bus type %d\n",
570774 bustype, BUSTYPE(bustype)));
571775 return NULL;
572776 }
573
-#endif
777
+#endif // endif
574778
575779 /* bus/core/clk setup for register access */
576780 if (!si_buscore_prep(sii, bustype, devid, sdh)) {
....@@ -587,7 +791,8 @@
587791 SI_ERROR(("%s: chipcommon register space is null \n", __FUNCTION__));
588792 return NULL;
589793 }
590
- w = R_REG(osh, &cc->chipid);
794
+ if (!w)
795
+ w = R_REG(osh, &cc->chipid);
591796 if ((w & 0xfffff) == 148277) w -= 65532;
592797 sih->socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
593798 /* Might as wll fill in chip id rev & pkg */
....@@ -597,24 +802,50 @@
597802
598803 si_chipid_fixup(sih);
599804
600
- if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) && CHIPREV(sih->chiprev == 0) &&
601
- (sih->chippkg != BCM4329_289PIN_PKG_ID)) {
602
- sih->chippkg = BCM4329_182PIN_PKG_ID;
805
+ if (CHIPID(sih->chip) == BCM43465_CHIP_ID) {
806
+ sih->chip = BCM4366_CHIP_ID;
807
+ } else if (CHIPID(sih->chip) == BCM43525_CHIP_ID) {
808
+ sih->chip = BCM4365_CHIP_ID;
603809 }
810
+
604811 sih->issim = IS_SIM(sih->chippkg);
812
+
813
+#ifdef CHIPS_CUSTOMER_HW6
814
+ if (MULTIBP_CAP(sih))
815
+ {
816
+ sih->_multibp_enable = TRUE;
817
+ }
818
+#endif // endif
605819
606820 /* scan for cores */
607821 if (CHIPTYPE(sii->pub.socitype) == SOCI_SB) {
608822 SI_MSG(("Found chip type SB (0x%08x)\n", w));
609823 sb_scan(&sii->pub, regs, devid);
610824 } else if ((CHIPTYPE(sii->pub.socitype) == SOCI_AI) ||
611
- (CHIPTYPE(sii->pub.socitype) == SOCI_NAI)) {
825
+ (CHIPTYPE(sii->pub.socitype) == SOCI_NAI) ||
826
+ (CHIPTYPE(sii->pub.socitype) == SOCI_DVTBUS)) {
827
+
612828 if (CHIPTYPE(sii->pub.socitype) == SOCI_AI)
613829 SI_MSG(("Found chip type AI (0x%08x)\n", w));
614
- else
830
+ else if (CHIPTYPE(sii->pub.socitype) == SOCI_NAI)
615831 SI_MSG(("Found chip type NAI (0x%08x)\n", w));
832
+ else
833
+ SI_MSG(("Found chip type DVT (0x%08x)\n", w));
616834 /* pass chipc address instead of original core base */
617
- ai_scan(&sii->pub, (void *)(uintptr)cc, devid);
835
+
836
+ if (sii->osh) {
837
+ sii->axi_wrapper = (axi_wrapper_t *)MALLOCZ(sii->osh,
838
+ (sizeof(axi_wrapper_t) * SI_MAX_AXI_WRAPPERS));
839
+
840
+ if (sii->axi_wrapper == NULL) {
841
+ SI_ERROR(("%s: %zu bytes MALLOC Failed", __FUNCTION__,
842
+ (sizeof(axi_wrapper_t) * SI_MAX_AXI_WRAPPERS)));
843
+ }
844
+ } else {
845
+ sii->axi_wrapper = NULL;
846
+ }
847
+
848
+ ai_scan(&sii->pub, (void *)(uintptr)cc, erombase, devid);
618849 } else if (CHIPTYPE(sii->pub.socitype) == SOCI_UBUS) {
619850 SI_MSG(("Found chip type UBUS (0x%08x), chip id = 0x%4x\n", w, sih->chip));
620851 /* pass chipc address instead of original core base */
....@@ -634,17 +865,19 @@
634865 SI_ERROR(("si_doattach: si_buscore_setup failed\n"));
635866 goto exit;
636867 }
868
+#ifdef BCMULP
869
+ if (BCMULP_ENAB()) {
870
+ si_check_boot_type(sih, osh);
871
+ if (ulp_module_init(osh, sih) != BCME_OK) {
872
+ ULP_ERR(("%s: err in ulp_module_init\n", __FUNCTION__));
873
+ goto exit;
874
+ }
875
+ }
876
+#endif /* BCMULP */
637877
638878 #if !defined(_CFEZ_) || defined(CFG_WL)
639
- if (CHIPID(sih->chip) == BCM4322_CHIP_ID && (((sih->chipst & CST4322_SPROM_OTP_SEL_MASK)
640
- >> CST4322_SPROM_OTP_SEL_SHIFT) == (CST4322_OTP_PRESENT |
641
- CST4322_SPROM_PRESENT))) {
642
- SI_ERROR(("%s: Invalid setting: both SPROM and OTP strapped.\n", __FUNCTION__));
643
- return NULL;
644
- }
645
-
646879 /* assume current core is CC */
647
- if ((sii->pub.ccrev == 0x25) && ((CHIPID(sih->chip) == BCM43236_CHIP_ID ||
880
+ if ((CCREV(sii->pub.ccrev) == 0x25) && ((CHIPID(sih->chip) == BCM43236_CHIP_ID ||
648881 CHIPID(sih->chip) == BCM43235_CHIP_ID ||
649882 CHIPID(sih->chip) == BCM43234_CHIP_ID ||
650883 CHIPID(sih->chip) == BCM43238_CHIP_ID) &&
....@@ -661,10 +894,54 @@
661894 OSL_DELAY(10);
662895 }
663896
897
+ /* Set the clkdiv2 divisor bits (2:0) to 0x4 if srom is present */
898
+ if (bustype == SI_BUS) {
899
+ uint32 clkdiv2, sromprsnt, capabilities, srom_supported;
900
+ capabilities = R_REG(osh, &cc->capabilities);
901
+ srom_supported = capabilities & SROM_SUPPORTED;
902
+ if (srom_supported)
903
+ {
904
+ sromprsnt = R_REG(osh, &cc->sromcontrol);
905
+ sromprsnt = sromprsnt & SROM_PRSNT_MASK;
906
+ if (sromprsnt) {
907
+ /* SROM clock come from backplane clock/div2. Must <= 1Mhz */
908
+ clkdiv2 = (R_REG(osh, &cc->clkdiv2) & ~CLKD2_SROM);
909
+ clkdiv2 |= CLKD2_SROMDIV_192;
910
+ W_REG(osh, &cc->clkdiv2, clkdiv2);
911
+ }
912
+ }
913
+ }
914
+
664915 if (bustype == PCI_BUS) {
665916
917
+#ifdef BCMQT
918
+ /* Set OTPClkDiv to smaller value otherwise OTP always reads 0xFFFF.
919
+ * For real-chip we shouldn't set OTPClkDiv to 2 because 20/2 = 10 > 9Mhz
920
+ */
921
+ {
922
+ uint otpclkdiv = 0;
923
+
924
+ if ((CHIPID(sih->chip) == BCM43131_CHIP_ID) ||
925
+ (CHIPID(sih->chip) == BCM43217_CHIP_ID)) {
926
+ otpclkdiv = 4;
927
+ }
928
+
929
+ if (otpclkdiv != 0) {
930
+ uint clkdiv, savecore;
931
+ savecore = si_coreidx(sih);
932
+ si_setcore(sih, CC_CORE_ID, 0);
933
+
934
+ clkdiv = R_REG(osh, &cc->clkdiv);
935
+ clkdiv = (clkdiv & ~CLKD_OTP) | (otpclkdiv << CLKD_OTP_SHIFT);
936
+ W_REG(osh, &cc->clkdiv, clkdiv);
937
+
938
+ SI_ERROR(("%s: set clkdiv to 0x%x for QT\n", __FUNCTION__, clkdiv));
939
+ si_setcoreidx(sih, savecore);
940
+ }
941
+ }
942
+#endif /* BCMQT */
666943 }
667
-#endif
944
+#endif // endif
668945 #ifdef BCM_SDRBL
669946 /* 4360 rom bootloader in PCIE case, if the SDR is enabled, But preotection is
670947 * not turned on, then we want to hold arm in reset.
....@@ -689,35 +966,34 @@
689966 pvars = NULL;
690967 BCM_REFERENCE(pvars);
691968
969
+ {
970
+ sii->lhl_ps_mode = LHL_PS_MODE_0;
971
+ }
692972
973
+ if (!si_onetimeinit) {
693974
694
- if (sii->pub.ccrev >= 20) {
975
+ if (CCREV(sii->pub.ccrev) >= 20) {
695976 uint32 gpiopullup = 0, gpiopulldown = 0;
696977 cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0);
697978 ASSERT(cc != NULL);
698
-
699
- /* 4314/43142 has pin muxing, don't clear gpio bits */
700
- if ((CHIPID(sih->chip) == BCM4314_CHIP_ID) ||
701
- (CHIPID(sih->chip) == BCM43142_CHIP_ID)) {
702
- gpiopullup |= 0x402e0;
703
- gpiopulldown |= 0x20500;
704
- }
705
-
706
-
707
- W_REG(osh, &cc->gpiopullup, gpiopullup);
708
- W_REG(osh, &cc->gpiopulldown, gpiopulldown);
979
+ BCM_REFERENCE(gpiopullup);
980
+ BCM_REFERENCE(gpiopulldown);
709981 si_setcoreidx(sih, origidx);
710982 }
711983
984
+ }
712985
713986 /* clear any previous epidiag-induced target abort */
714987 ASSERT(!si_taclear(sih, FALSE));
715988
989
+#if defined(BCMPMU_STATS) && !defined(BCMPMU_STATS_DISABLED)
990
+ si_pmustatstimer_init(sih);
991
+#endif /* BCMPMU_STATS */
716992
717993 #ifdef BOOTLOADER_CONSOLE_OUTPUT
718994 /* Enable console prints */
719995 si_muxenab(sii, 3);
720
-#endif
996
+#endif // endif
721997
722998 return (sii);
723999
....@@ -734,7 +1010,6 @@
7341010 si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
7351011 uint idx;
7361012
737
-
7381013 if (BUSTYPE(sih->bustype) == SI_BUS)
7391014 for (idx = 0; idx < SI_MAXCORES; idx++)
7401015 if (cores_info->regs[idx]) {
....@@ -742,11 +1017,23 @@
7421017 cores_info->regs[idx] = NULL;
7431018 }
7441019
745
-
7461020 #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
7471021 if (cores_info != &ksii_cores_info)
7481022 #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
7491023 MFREE(sii->osh, cores_info, sizeof(si_cores_info_t));
1024
+
1025
+#if defined(BCM_BACKPLANE_TIMEOUT)
1026
+ if (sih->err_info) {
1027
+ MFREE(sii->osh, sih->err_info, sizeof(si_axi_error_info_t));
1028
+ sii->pub.err_info = NULL;
1029
+ }
1030
+#endif /* BCM_BACKPLANE_TIMEOUT */
1031
+
1032
+ if (sii->axi_wrapper) {
1033
+ MFREE(sii->osh, sii->axi_wrapper,
1034
+ (sizeof(axi_wrapper_t) * SI_MAX_AXI_WRAPPERS));
1035
+ sii->axi_wrapper = NULL;
1036
+ }
7501037
7511038 #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
7521039 if (sii != &ksii)
....@@ -811,7 +1098,9 @@
8111098
8121099 if (CHIPTYPE(sih->socitype) == SOCI_SB)
8131100 return sb_intflag(sih);
814
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1101
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1102
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1103
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
8151104 return R_REG(sii->osh, ((uint32 *)(uintptr)
8161105 (sii->oob_router + OOB_STATUSA)));
8171106 else {
....@@ -825,7 +1114,9 @@
8251114 {
8261115 if (CHIPTYPE(sih->socitype) == SOCI_SB)
8271116 return sb_flag(sih);
828
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1117
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1118
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1119
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
8291120 return ai_flag(sih);
8301121 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
8311122 return ub_flag(sih);
....@@ -838,7 +1129,9 @@
8381129 uint
8391130 si_flag_alt(si_t *sih)
8401131 {
841
- if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1132
+ if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1133
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1134
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
8421135 return ai_flag_alt(sih);
8431136 else {
8441137 ASSERT(0);
....@@ -851,12 +1144,31 @@
8511144 {
8521145 if (CHIPTYPE(sih->socitype) == SOCI_SB)
8531146 sb_setint(sih, siflag);
854
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1147
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1148
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1149
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
8551150 ai_setint(sih, siflag);
8561151 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
8571152 ub_setint(sih, siflag);
8581153 else
8591154 ASSERT(0);
1155
+}
1156
+
1157
+uint32
1158
+si_oobr_baseaddr(si_t *sih, bool second)
1159
+{
1160
+ si_info_t *sii = SI_INFO(sih);
1161
+
1162
+ if (CHIPTYPE(sih->socitype) == SOCI_SB)
1163
+ return 0;
1164
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1165
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1166
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
1167
+ return (second ? sii->oob_router1 : sii->oob_router);
1168
+ else {
1169
+ ASSERT(0);
1170
+ return 0;
1171
+ }
8601172 }
8611173
8621174 uint
....@@ -877,7 +1189,7 @@
8771189 return sii->curidx;
8781190 }
8791191
880
-void *
1192
+volatile void *
8811193 si_d11_switch_addrbase(si_t *sih, uint coreunit)
8821194 {
8831195 return si_setcore(sih, D11_CORE_ID, coreunit);
....@@ -914,7 +1226,9 @@
9141226 {
9151227 if (CHIPTYPE(sih->socitype) == SOCI_SB)
9161228 return sb_corevendor(sih);
917
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1229
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1230
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1231
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
9181232 return ai_corevendor(sih);
9191233 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
9201234 return ub_corevendor(sih);
....@@ -935,7 +1249,9 @@
9351249 {
9361250 if (CHIPTYPE(sih->socitype) == SOCI_SB)
9371251 return sb_corerev(sih);
938
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1252
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1253
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1254
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
9391255 return ai_corerev(sih);
9401256 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
9411257 return ub_corerev(sih);
....@@ -945,6 +1261,15 @@
9451261 }
9461262 }
9471263
1264
+uint
1265
+si_corerev_minor(si_t *sih)
1266
+{
1267
+ if (CHIPTYPE(sih->socitype) == SOCI_AI) {
1268
+ return ai_corerev_minor(sih);
1269
+ } else {
1270
+ return 0;
1271
+ }
1272
+}
9481273
9491274 /* return index of coreid or BADIDX if not found */
9501275 uint
....@@ -954,7 +1279,6 @@
9541279 si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
9551280 uint found;
9561281 uint i;
957
-
9581282
9591283 found = 0;
9601284
....@@ -1029,7 +1353,7 @@
10291353 }
10301354
10311355 /** return current register mapping */
1032
-void *
1356
+volatile void *
10331357 si_coreregs(si_t *sih)
10341358 {
10351359 si_info_t *sii;
....@@ -1045,7 +1369,7 @@
10451369 * must be called with interrupts off.
10461370 * Moreover, callers should keep interrupts off during switching out of and back to d11 core
10471371 */
1048
-void *
1372
+volatile void *
10491373 si_setcore(si_t *sih, uint coreid, uint coreunit)
10501374 {
10511375 uint idx;
....@@ -1056,7 +1380,9 @@
10561380
10571381 if (CHIPTYPE(sih->socitype) == SOCI_SB)
10581382 return sb_setcoreidx(sih, idx);
1059
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1383
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1384
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1385
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
10601386 return ai_setcoreidx(sih, idx);
10611387 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
10621388 return ub_setcoreidx(sih, idx);
....@@ -1066,12 +1392,14 @@
10661392 }
10671393 }
10681394
1069
-void *
1395
+volatile void *
10701396 si_setcoreidx(si_t *sih, uint coreidx)
10711397 {
10721398 if (CHIPTYPE(sih->socitype) == SOCI_SB)
10731399 return sb_setcoreidx(sih, coreidx);
1074
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1400
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1401
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1402
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
10751403 return ai_setcoreidx(sih, coreidx);
10761404 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
10771405 return ub_setcoreidx(sih, coreidx);
....@@ -1082,12 +1410,11 @@
10821410 }
10831411
10841412 /** Turn off interrupt as required by sb_setcore, before switch core */
1085
-void *
1413
+volatile void *
10861414 si_switch_core(si_t *sih, uint coreid, uint *origidx, uint *intr_val)
10871415 {
1088
- void *cc;
1416
+ volatile void *cc;
10891417 si_info_t *sii = SI_INFO(sih);
1090
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
10911418
10921419 if (SI_FAST(sii)) {
10931420 /* Overloading the origidx variable to remember the coreid,
....@@ -1096,9 +1423,9 @@
10961423 */
10971424 *origidx = coreid;
10981425 if (coreid == CC_CORE_ID)
1099
- return (void *)CCREGS_FAST(sii);
1100
- else if (coreid == sih->buscoretype)
1101
- return (void *)PCIEREGS(sii);
1426
+ return (volatile void *)CCREGS_FAST(sii);
1427
+ else if (coreid == BUSCORETYPE(sih->buscoretype))
1428
+ return (volatile void *)PCIEREGS(sii);
11021429 }
11031430 INTR_OFF(sii, *intr_val);
11041431 *origidx = sii->curidx;
....@@ -1113,9 +1440,8 @@
11131440 si_restore_core(si_t *sih, uint coreid, uint intr_val)
11141441 {
11151442 si_info_t *sii = SI_INFO(sih);
1116
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
11171443
1118
- if (SI_FAST(sii) && ((coreid == CC_CORE_ID) || (coreid == sih->buscoretype)))
1444
+ if (SI_FAST(sii) && ((coreid == CC_CORE_ID) || (coreid == BUSCORETYPE(sih->buscoretype))))
11191445 return;
11201446
11211447 si_setcoreidx(sih, coreid);
....@@ -1127,7 +1453,9 @@
11271453 {
11281454 if (CHIPTYPE(sih->socitype) == SOCI_SB)
11291455 return sb_numaddrspaces(sih);
1130
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1456
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1457
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1458
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
11311459 return ai_numaddrspaces(sih);
11321460 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
11331461 return ub_numaddrspaces(sih);
....@@ -1137,30 +1465,47 @@
11371465 }
11381466 }
11391467
1468
+/* Return the address of the nth address space in the current core
1469
+ * Arguments:
1470
+ * sih : Pointer to struct si_t
1471
+ * spidx : slave port index
1472
+ * baidx : base address index
1473
+ */
1474
+
11401475 uint32
1141
-si_addrspace(si_t *sih, uint asidx)
1476
+si_addrspace(si_t *sih, uint spidx, uint baidx)
11421477 {
11431478 if (CHIPTYPE(sih->socitype) == SOCI_SB)
1144
- return sb_addrspace(sih, asidx);
1145
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1146
- return ai_addrspace(sih, asidx);
1479
+ return sb_addrspace(sih, baidx);
1480
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1481
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1482
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
1483
+ return ai_addrspace(sih, spidx, baidx);
11471484 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
1148
- return ub_addrspace(sih, asidx);
1485
+ return ub_addrspace(sih, baidx);
11491486 else {
11501487 ASSERT(0);
11511488 return 0;
11521489 }
11531490 }
11541491
1492
+/* Return the size of the nth address space in the current core
1493
+ * Arguments:
1494
+ * sih : Pointer to struct si_t
1495
+ * spidx : slave port index
1496
+ * baidx : base address index
1497
+ */
11551498 uint32
1156
-si_addrspacesize(si_t *sih, uint asidx)
1499
+si_addrspacesize(si_t *sih, uint spidx, uint baidx)
11571500 {
11581501 if (CHIPTYPE(sih->socitype) == SOCI_SB)
1159
- return sb_addrspacesize(sih, asidx);
1160
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1161
- return ai_addrspacesize(sih, asidx);
1502
+ return sb_addrspacesize(sih, baidx);
1503
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1504
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1505
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
1506
+ return ai_addrspacesize(sih, spidx, baidx);
11621507 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
1163
- return ub_addrspacesize(sih, asidx);
1508
+ return ub_addrspacesize(sih, baidx);
11641509 else {
11651510 ASSERT(0);
11661511 return 0;
....@@ -1171,7 +1516,9 @@
11711516 si_coreaddrspaceX(si_t *sih, uint asidx, uint32 *addr, uint32 *size)
11721517 {
11731518 /* Only supported for SOCI_AI */
1174
- if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1519
+ if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1520
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1521
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
11751522 ai_coreaddrspaceX(sih, asidx, addr, size);
11761523 else
11771524 *size = 0;
....@@ -1182,7 +1529,9 @@
11821529 {
11831530 if (CHIPTYPE(sih->socitype) == SOCI_SB)
11841531 return sb_core_cflags(sih, mask, val);
1185
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1532
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1533
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1534
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
11861535 return ai_core_cflags(sih, mask, val);
11871536 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
11881537 return ub_core_cflags(sih, mask, val);
....@@ -1197,7 +1546,9 @@
11971546 {
11981547 if (CHIPTYPE(sih->socitype) == SOCI_SB)
11991548 sb_core_cflags_wo(sih, mask, val);
1200
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1549
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1550
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1551
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
12011552 ai_core_cflags_wo(sih, mask, val);
12021553 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
12031554 ub_core_cflags_wo(sih, mask, val);
....@@ -1210,7 +1561,9 @@
12101561 {
12111562 if (CHIPTYPE(sih->socitype) == SOCI_SB)
12121563 return sb_core_sflags(sih, mask, val);
1213
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1564
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1565
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1566
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
12141567 return ai_core_sflags(sih, mask, val);
12151568 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
12161569 return ub_core_sflags(sih, mask, val);
....@@ -1220,12 +1573,30 @@
12201573 }
12211574 }
12221575
1576
+void
1577
+si_commit(si_t *sih)
1578
+{
1579
+ if (CHIPTYPE(sih->socitype) == SOCI_SB)
1580
+ sb_commit(sih);
1581
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1582
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1583
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
1584
+ ;
1585
+ else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
1586
+ ;
1587
+ else {
1588
+ ASSERT(0);
1589
+ }
1590
+}
1591
+
12231592 bool
12241593 si_iscoreup(si_t *sih)
12251594 {
12261595 if (CHIPTYPE(sih->socitype) == SOCI_SB)
12271596 return sb_iscoreup(sih);
1228
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1597
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1598
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1599
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
12291600 return ai_iscoreup(sih);
12301601 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
12311602 return ub_iscoreup(sih);
....@@ -1239,7 +1610,9 @@
12391610 si_wrapperreg(si_t *sih, uint32 offset, uint32 mask, uint32 val)
12401611 {
12411612 /* only for AI back plane chips */
1242
- if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1613
+ if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1614
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1615
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
12431616 return (ai_wrap_reg(sih, offset, mask, val));
12441617 return 0;
12451618 }
....@@ -1272,13 +1645,20 @@
12721645 bcmerror = BCME_ERROR;
12731646 }
12741647 }
1275
-
12761648 return bcmerror;
12771649 }
1278
-uint
1650
+
1651
+void
1652
+si_invalidate_second_bar0win(si_t *sih)
1653
+{
1654
+ si_info_t *sii = SI_INFO(sih);
1655
+ sii->second_bar0win = ~0x0;
1656
+}
1657
+
1658
+int
12791659 si_backplane_access(si_t *sih, uint addr, uint size, uint *val, bool read)
12801660 {
1281
- uint32 *r = NULL;
1661
+ volatile uint32 *r = NULL;
12821662 uint32 region = 0;
12831663 si_info_t *sii = SI_INFO(sih);
12841664
....@@ -1307,31 +1687,30 @@
13071687 * PCI_SECOND_BAR0_OFFSET : secondar bar-0 offset
13081688 * regoff : actual reg offset
13091689 */
1310
- r = (uint32 *)((char *)sii->curmap + PCI_SECOND_BAR0_OFFSET + addr);
1690
+ r = (volatile uint32 *)((volatile char *)sii->curmap + PCI_SECOND_BAR0_OFFSET + addr);
13111691
13121692 SI_VMSG(("si curmap %p region %x regaddr %x effective addr %p READ %d\n",
1313
- (char*)sii->curmap, region, addr, r, read));
1693
+ (volatile char*)sii->curmap, region, addr, r, read));
13141694
13151695 switch (size) {
13161696 case sizeof(uint8) :
13171697 if (read)
1318
- *val = R_REG(sii->osh, (uint8*)r);
1698
+ *val = R_REG(sii->osh, (volatile uint8*)r);
13191699 else
1320
- W_REG(sii->osh, (uint8*)r, *val);
1700
+ W_REG(sii->osh, (volatile uint8*)r, *val);
13211701 break;
13221702 case sizeof(uint16) :
13231703 if (read)
1324
- *val = R_REG(sii->osh, (uint16*)r);
1704
+ *val = R_REG(sii->osh, (volatile uint16*)r);
13251705 else
1326
- W_REG(sii->osh, (uint16*)r, *val);
1706
+ W_REG(sii->osh, (volatile uint16*)r, *val);
13271707 break;
13281708 case sizeof(uint32) :
13291709 if (read)
1330
- *val = R_REG(sii->osh, (uint32*)r);
1710
+ *val = R_REG(sii->osh, (volatile uint32*)r);
13311711 else
1332
- W_REG(sii->osh, (uint32*)r, *val);
1712
+ W_REG(sii->osh, (volatile uint32*)r, *val);
13331713 break;
1334
-
13351714 default :
13361715 SI_ERROR(("Invalid size %d \n", size));
13371716 return (BCME_ERROR);
....@@ -1345,7 +1724,9 @@
13451724 {
13461725 if (CHIPTYPE(sih->socitype) == SOCI_SB)
13471726 return sb_corereg(sih, coreidx, regoff, mask, val);
1348
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1727
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1728
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1729
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
13491730 return ai_corereg(sih, coreidx, regoff, mask, val);
13501731 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
13511732 return ub_corereg(sih, coreidx, regoff, mask, val);
....@@ -1353,6 +1734,12 @@
13531734 ASSERT(0);
13541735 return 0;
13551736 }
1737
+}
1738
+
1739
+uint
1740
+si_corereg_writeonly(si_t *sih, uint coreidx, uint regoff, uint mask, uint val)
1741
+{
1742
+ return ai_corereg_writeonly(sih, coreidx, regoff, mask, val);
13561743 }
13571744
13581745 /** ILP sensitive register access needs special treatment to avoid backplane stalls */
....@@ -1375,7 +1762,7 @@
13751762 int pmustatus_offset;
13761763
13771764 /* prevent backplane stall on double write to 'ILP domain' registers in the PMU */
1378
- if (mask != 0 && sih->pmurev >= 22 &&
1765
+ if (mask != 0 && PMUREV(sih->pmurev) >= 22 &&
13791766 si_pmu_is_ilp_sensitive(idx, regoff)) {
13801767 pmustatus_offset = AOB_ENAB(sih) ? OFFSETOF(pmuregs_t, pmustatus) :
13811768 OFFSETOF(chipcregs_t, pmustatus);
....@@ -1396,12 +1783,14 @@
13961783 * For accessing registers that would need a core switch, this function will return
13971784 * NULL.
13981785 */
1399
-uint32 *
1786
+volatile uint32 *
14001787 si_corereg_addr(si_t *sih, uint coreidx, uint regoff)
14011788 {
14021789 if (CHIPTYPE(sih->socitype) == SOCI_SB)
14031790 return sb_corereg_addr(sih, coreidx, regoff);
1404
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1791
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1792
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1793
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
14051794 return ai_corereg_addr(sih, coreidx, regoff);
14061795 else {
14071796 return 0;
....@@ -1413,7 +1802,9 @@
14131802 {
14141803 if (CHIPTYPE(sih->socitype) == SOCI_SB)
14151804 sb_core_disable(sih, bits);
1416
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1805
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1806
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1807
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
14171808 ai_core_disable(sih, bits);
14181809 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
14191810 ub_core_disable(sih, bits);
....@@ -1424,7 +1815,9 @@
14241815 {
14251816 if (CHIPTYPE(sih->socitype) == SOCI_SB)
14261817 sb_core_reset(sih, bits, resetbits);
1427
- else if ((CHIPTYPE(sih->socitype) == SOCI_AI) || (CHIPTYPE(sih->socitype) == SOCI_NAI))
1818
+ else if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1819
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1820
+ (CHIPTYPE(sih->socitype) == SOCI_NAI))
14281821 ai_core_reset(sih, bits, resetbits);
14291822 else if (CHIPTYPE(sih->socitype) == SOCI_UBUS)
14301823 ub_core_reset(sih, bits, resetbits);
....@@ -1455,6 +1848,64 @@
14551848 return result;
14561849 }
14571850
1851
+uint
1852
+si_num_slaveports(si_t *sih, uint coreid)
1853
+{
1854
+ uint idx = si_findcoreidx(sih, coreid, 0);
1855
+ uint num = 0;
1856
+
1857
+ if (idx != BADIDX) {
1858
+ if (CHIPTYPE(sih->socitype) == SOCI_AI) {
1859
+ num = ai_num_slaveports(sih, idx);
1860
+ }
1861
+ }
1862
+ return num;
1863
+}
1864
+
1865
+uint32
1866
+si_get_slaveport_addr(si_t *sih, uint spidx, uint baidx, uint core_id, uint coreunit)
1867
+{
1868
+ si_info_t *sii = SI_INFO(sih);
1869
+ uint origidx = sii->curidx;
1870
+ uint32 addr = 0x0;
1871
+
1872
+ if (!((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1873
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1874
+ (CHIPTYPE(sih->socitype) == SOCI_NAI)))
1875
+ goto done;
1876
+
1877
+ si_setcore(sih, core_id, coreunit);
1878
+
1879
+ addr = ai_addrspace(sih, spidx, baidx);
1880
+
1881
+ si_setcoreidx(sih, origidx);
1882
+
1883
+done:
1884
+ return addr;
1885
+}
1886
+
1887
+uint32
1888
+si_get_d11_slaveport_addr(si_t *sih, uint spidx, uint baidx, uint coreunit)
1889
+{
1890
+ si_info_t *sii = SI_INFO(sih);
1891
+ uint origidx = sii->curidx;
1892
+ uint32 addr = 0x0;
1893
+
1894
+ if (!((CHIPTYPE(sih->socitype) == SOCI_AI) ||
1895
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS) ||
1896
+ (CHIPTYPE(sih->socitype) == SOCI_NAI)))
1897
+ goto done;
1898
+
1899
+ si_setcore(sih, D11_CORE_ID, coreunit);
1900
+
1901
+ addr = ai_addrspace(sih, spidx, baidx);
1902
+
1903
+ si_setcoreidx(sih, origidx);
1904
+
1905
+done:
1906
+ return addr;
1907
+}
1908
+
14581909 static uint32
14591910 factor6(uint32 x)
14601911 {
....@@ -1478,7 +1929,6 @@
14781929 {
14791930 return div ? clock / div : 0;
14801931 }
1481
-
14821932
14831933 /** calculate the speed the SI would run at given a set of clockcontrol values */
14841934 uint32
....@@ -1562,7 +2012,6 @@
15622012
15632013 return (clock);
15642014 }
1565
- return 0;
15662015 }
15672016
15682017 /**
....@@ -1575,7 +2024,13 @@
15752024 uint hosti = 0;
15762025
15772026 switch (CHIPID(sih->chip)) {
1578
-
2027
+ case BCM43018_CHIP_ID:
2028
+ case BCM43430_CHIP_ID:
2029
+ hosti = CHIP_HOSTIF_SDIOMODE;
2030
+ break;
2031
+ case BCM43012_CHIP_ID:
2032
+ hosti = CHIP_HOSTIF_SDIOMODE;
2033
+ break;
15792034 CASE_BCM43602_CHIP:
15802035 hosti = CHIP_HOSTIF_PCIEMODE;
15812036 break;
....@@ -1601,8 +2056,7 @@
16012056 hosti = CHIP_HOSTIF_PCIEMODE;
16022057 break;
16032058
1604
- case BCM4345_CHIP_ID:
1605
- case BCM43454_CHIP_ID:
2059
+ CASE_BCM4345_CHIP:
16062060 if (CST4345_CHIPMODE_USB20D(sih->chipst) || CST4345_CHIPMODE_HSIC(sih->chipst))
16072061 hosti = CHIP_HOSTIF_USBMODE;
16082062 else if (CST4345_CHIPMODE_SDIOD(sih->chipst))
....@@ -1612,22 +2066,47 @@
16122066 break;
16132067
16142068 case BCM4349_CHIP_GRPID:
2069
+ case BCM53573_CHIP_GRPID:
16152070 if (CST4349_CHIPMODE_SDIOD(sih->chipst))
16162071 hosti = CHIP_HOSTIF_SDIOMODE;
16172072 else if (CST4349_CHIPMODE_PCIE(sih->chipst))
16182073 hosti = CHIP_HOSTIF_PCIEMODE;
16192074 break;
2075
+ case BCM4364_CHIP_ID:
2076
+ if (CST4364_CHIPMODE_SDIOD(sih->chipst))
2077
+ hosti = CHIP_HOSTIF_SDIOMODE;
2078
+ else if (CST4364_CHIPMODE_PCIE(sih->chipst))
2079
+ hosti = CHIP_HOSTIF_PCIEMODE;
2080
+ break;
16202081 case BCM4373_CHIP_ID:
1621
- if (CST4373_CHIPMODE_USB20D(sih->chipst))
1622
- hosti = CHIP_HOSTIF_USBMODE;
1623
- else if (CST4373_CHIPMODE_SDIOD(sih->chipst))
1624
- hosti = CHIP_HOSTIF_SDIOMODE;
1625
- else if (CST4373_CHIPMODE_PCIE(sih->chipst))
1626
- hosti = CHIP_HOSTIF_PCIEMODE;
1627
- break;
2082
+ if (CST4373_CHIPMODE_USB20D(sih->chipst))
2083
+ hosti = CHIP_HOSTIF_USBMODE;
2084
+ else if (CST4373_CHIPMODE_SDIOD(sih->chipst))
2085
+ hosti = CHIP_HOSTIF_SDIOMODE;
2086
+ else if (CST4373_CHIPMODE_PCIE(sih->chipst))
2087
+ hosti = CHIP_HOSTIF_PCIEMODE;
2088
+ break;
2089
+
2090
+ case BCM4347_CHIP_GRPID:
2091
+ if (CST4347_CHIPMODE_SDIOD(sih->chipst))
2092
+ hosti = CHIP_HOSTIF_SDIOMODE;
2093
+ else if (CST4347_CHIPMODE_PCIE(sih->chipst))
2094
+ hosti = CHIP_HOSTIF_PCIEMODE;
2095
+ break;
2096
+ case BCM4369_CHIP_GRPID:
2097
+ if (CST4369_CHIPMODE_SDIOD(sih->chipst))
2098
+ hosti = CHIP_HOSTIF_SDIOMODE;
2099
+ else if (CST4369_CHIPMODE_PCIE(sih->chipst))
2100
+ hosti = CHIP_HOSTIF_PCIEMODE;
2101
+ break;
2102
+#ifdef CHIPS_CUSTOMER_HW6
2103
+ case BCM4368_CHIP_GRPID:
2104
+ hosti = CHIP_HOSTIF_PCIEMODE;
2105
+ break;
2106
+#endif /* CHIPS_CUSTOMER_HW6 */
2107
+
16282108 case BCM4350_CHIP_ID:
16292109 case BCM4354_CHIP_ID:
1630
- case BCM4356_CHIP_ID:
16312110 case BCM43556_CHIP_ID:
16322111 case BCM43558_CHIP_ID:
16332112 case BCM43566_CHIP_ID:
....@@ -1654,26 +2133,15 @@
16542133 return hosti;
16552134 }
16562135
1657
-
16582136 /** set chip watchdog reset timer to fire in 'ticks' */
16592137 void
16602138 si_watchdog(si_t *sih, uint ticks)
16612139 {
16622140 uint nb, maxt;
2141
+ uint pmu_wdt = 1;
16632142
1664
- if (PMUCTL_ENAB(sih)) {
1665
-
1666
-#if !defined(_CFEZ_) || defined(CFG_WL)
1667
- if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) &&
1668
- (CHIPREV(sih->chiprev) == 0) && (ticks != 0)) {
1669
- si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, clk_ctl_st), ~0, 0x2);
1670
- si_setcore(sih, USB20D_CORE_ID, 0);
1671
- si_core_disable(sih, 1);
1672
- si_setcore(sih, CC_CORE_ID, 0);
1673
- }
1674
-#endif
1675
-
1676
- nb = (sih->ccrev < 26) ? 16 : ((sih->ccrev >= 37) ? 32 : 24);
2143
+ if (PMUCTL_ENAB(sih) && pmu_wdt) {
2144
+ nb = (CCREV(sih->ccrev) < 26) ? 16 : ((CCREV(sih->ccrev) >= 37) ? 32 : 24);
16772145 /* The mips compiler uses the sllv instruction,
16782146 * so we specially handle the 32-bit case.
16792147 */
....@@ -1694,8 +2162,13 @@
16942162 SPINWAIT((PMU_REG(sih, pmustatus, 0, 0) & PST_ILPFASTLPO),
16952163 PMU_MAX_TRANSITION_DLY);
16962164 }
1697
-
1698
- pmu_corereg(sih, SI_CC_IDX, pmuwatchdog, ~0, ticks);
2165
+ if (sih->chip == CYW55500_CHIP_ID ||
2166
+ sih->chip == CYW55560_CHIP_ID) {
2167
+ si_corereg(sih, si_findcoreidx(sih, PMU_CORE_ID, 0),
2168
+ OFFSETOF(pmuregs_t, pmuwatchdog), ~0, ticks);
2169
+ } else {
2170
+ pmu_corereg(sih, SI_CC_IDX, pmuwatchdog, ~0, ticks);
2171
+ }
16992172 } else {
17002173 maxt = (1 << 28) - 1;
17012174 if (ticks > maxt)
....@@ -1723,8 +2196,6 @@
17232196 return FALSE;
17242197 }
17252198
1726
-
1727
-
17282199 /** return the slow clock source - LPO, XTAL, or PCI */
17292200 static uint
17302201 si_slowclk_src(si_info_t *sii)
....@@ -1733,14 +2204,14 @@
17332204
17342205 ASSERT(SI_FAST(sii) || si_coreid(&sii->pub) == CC_CORE_ID);
17352206
1736
- if (sii->pub.ccrev < 6) {
2207
+ if (CCREV(sii->pub.ccrev) < 6) {
17372208 if ((BUSTYPE(sii->pub.bustype) == PCI_BUS) &&
17382209 (OSL_PCI_READ_CONFIG(sii->osh, PCI_GPIO_OUT, sizeof(uint32)) &
17392210 PCI_CFG_GPIO_SCS))
17402211 return (SCC_SS_PCI);
17412212 else
17422213 return (SCC_SS_XTAL);
1743
- } else if (sii->pub.ccrev < 10) {
2214
+ } else if (CCREV(sii->pub.ccrev) < 10) {
17442215 cc = (chipcregs_t *)si_setcoreidx(&sii->pub, sii->curidx);
17452216 ASSERT(cc);
17462217 return (R_REG(sii->osh, &cc->slow_clk_ctl) & SCC_SS_MASK);
....@@ -1761,12 +2232,12 @@
17612232 ASSERT(R_REG(sii->osh, &cc->capabilities) & CC_CAP_PWR_CTL);
17622233
17632234 slowclk = si_slowclk_src(sii);
1764
- if (sii->pub.ccrev < 6) {
2235
+ if (CCREV(sii->pub.ccrev) < 6) {
17652236 if (slowclk == SCC_SS_PCI)
17662237 return (max_freq ? (PCIMAXFREQ / 64) : (PCIMINFREQ / 64));
17672238 else
17682239 return (max_freq ? (XTALMAXFREQ / 32) : (XTALMINFREQ / 32));
1769
- } else if (sii->pub.ccrev < 10) {
2240
+ } else if (CCREV(sii->pub.ccrev) < 10) {
17702241 div = 4 *
17712242 (((R_REG(sii->osh, &cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
17722243 if (slowclk == SCC_SS_LPO)
....@@ -1804,7 +2275,7 @@
18042275 pll_delay += XTAL_ON_DELAY;
18052276
18062277 /* Starting with 4318 it is ILP that is used for the delays */
1807
- slowmaxfreq = si_slowclk_freq(sii, (sii->pub.ccrev >= 10) ? FALSE : TRUE, cc);
2278
+ slowmaxfreq = si_slowclk_freq(sii, (CCREV(sii->pub.ccrev) >= 10) ? FALSE : TRUE, cc);
18082279
18092280 pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
18102281 fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
....@@ -1836,7 +2307,7 @@
18362307 ASSERT(cc != NULL);
18372308
18382309 /* set all Instaclk chip ILP to 1 MHz */
1839
- if (sih->ccrev >= 10)
2310
+ if (CCREV(sih->ccrev) >= 10)
18402311 SET_REG(sii->osh, &cc->system_clk_ctl, SYCC_CD_MASK,
18412312 (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
18422313
....@@ -1848,9 +2319,8 @@
18482319 si_setcoreidx(sih, origidx);
18492320 }
18502321
1851
-
18522322 /** change logical "focus" to the gpio core for optimized access */
1853
-void *
2323
+volatile void *
18542324 si_gpiosetcore(si_t *sih)
18552325 {
18562326 return (si_setcoreidx(sih, SI_CC_IDX));
....@@ -2029,11 +2499,25 @@
20292499 return (si_corereg(sih, SI_CC_IDX, regoff, mask, val));
20302500 }
20312501
2502
+uint32
2503
+si_gpioeventintmask(si_t *sih, uint32 mask, uint32 val, uint8 priority)
2504
+{
2505
+ uint regoff;
2506
+ /* gpios could be shared on router platforms */
2507
+ if ((BUSTYPE(sih->bustype) == SI_BUS) && (val || mask)) {
2508
+ mask = priority ? (si_gpioreservation & mask) :
2509
+ ((si_gpioreservation | mask) & ~(si_gpioreservation));
2510
+ val &= mask;
2511
+ }
2512
+ regoff = OFFSETOF(chipcregs_t, gpioeventintmask);
2513
+ return (si_corereg(sih, SI_CC_IDX, regoff, mask, val));
2514
+}
2515
+
20322516 /* assign the gpio to an led */
20332517 uint32
20342518 si_gpioled(si_t *sih, uint32 mask, uint32 val)
20352519 {
2036
- if (sih->ccrev < 16)
2520
+ if (CCREV(sih->ccrev) < 16)
20372521 return 0xffffffff;
20382522
20392523 /* gpio led powersave reg */
....@@ -2044,7 +2528,7 @@
20442528 uint32
20452529 si_gpiotimerval(si_t *sih, uint32 mask, uint32 gpiotimerval)
20462530 {
2047
- if (sih->ccrev < 16)
2531
+ if (CCREV(sih->ccrev) < 16)
20482532 return 0xffffffff;
20492533
20502534 return (si_corereg(sih, SI_CC_IDX,
....@@ -2056,7 +2540,7 @@
20562540 {
20572541 uint offs;
20582542
2059
- if (sih->ccrev < 20)
2543
+ if (CCREV(sih->ccrev) < 20)
20602544 return 0xffffffff;
20612545
20622546 offs = (updown ? OFFSETOF(chipcregs_t, gpiopulldown) : OFFSETOF(chipcregs_t, gpiopullup));
....@@ -2068,7 +2552,7 @@
20682552 {
20692553 uint offs;
20702554
2071
- if (sih->ccrev < 11)
2555
+ if (CCREV(sih->ccrev) < 11)
20722556 return 0xffffffff;
20732557
20742558 if (regtype == GPIO_REGEVT)
....@@ -2088,7 +2572,7 @@
20882572 {
20892573 uint offs;
20902574
2091
- if (sih->ccrev < 11)
2575
+ if (CCREV(sih->ccrev) < 11)
20922576 return 0xffffffff;
20932577
20942578 offs = OFFSETOF(chipcregs_t, intmask);
....@@ -2113,7 +2597,6 @@
21132597 si_sysmem_size(si_t *sih)
21142598 {
21152599 si_info_t *sii = SI_INFO(sih);
2116
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
21172600 uint origidx;
21182601 uint intr_val = 0;
21192602
....@@ -2170,7 +2653,6 @@
21702653 void si_socram_set_bankpda(si_t *sih, uint32 bankidx, uint32 bankpda)
21712654 {
21722655 si_info_t *sii = SI_INFO(sih);
2173
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
21742656 uint origidx;
21752657 uint intr_val = 0;
21762658 sbsocramregs_t *regs;
....@@ -2207,7 +2689,6 @@
22072689 si_socdevram(si_t *sih, bool set, uint8 *enable, uint8 *protect, uint8 *remap)
22082690 {
22092691 si_info_t *sii = SI_INFO(sih);
2210
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
22112692 uint origidx;
22122693 uint intr_val = 0;
22132694 sbsocramregs_t *regs;
....@@ -2255,8 +2736,7 @@
22552736 (1 << SOCRAM_BANKINFO_DEVRAMREMAP_SHIFT);
22562737 }
22572738 W_REG(sii->osh, &regs->bankinfo, bankinfo);
2258
- }
2259
- else if (i == 0) {
2739
+ } else if (i == 0) {
22602740 if (bankinfo & SOCRAM_BANKINFO_DEVRAMSEL_MASK) {
22612741 *enable = 1;
22622742 if (bankinfo & SOCRAM_BANKINFO_DEVRAMPRO_MASK)
....@@ -2281,7 +2761,6 @@
22812761 si_socdevram_remap_isenb(si_t *sih)
22822762 {
22832763 si_info_t *sii = SI_INFO(sih);
2284
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
22852764 uint origidx;
22862765 uint intr_val = 0;
22872766 sbsocramregs_t *regs;
....@@ -2342,7 +2821,6 @@
23422821 si_socdevram_size(si_t *sih)
23432822 {
23442823 si_info_t *sii = SI_INFO(sih);
2345
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
23462824 uint origidx;
23472825 uint intr_val = 0;
23482826 uint32 memsize = 0;
....@@ -2389,7 +2867,6 @@
23892867 si_socdevram_remap_size(si_t *sih)
23902868 {
23912869 si_info_t *sii = SI_INFO(sih);
2392
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
23932870 uint origidx;
23942871 uint intr_val = 0;
23952872 uint32 memsize = 0, banksz;
....@@ -2455,7 +2932,6 @@
24552932 si_socram_size(si_t *sih)
24562933 {
24572934 si_info_t *sii = SI_INFO(sih);
2458
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
24592935 uint origidx;
24602936 uint intr_val = 0;
24612937
....@@ -2518,27 +2994,26 @@
25182994 return memsize;
25192995 }
25202996
2521
-
25222997 /** Return the TCM-RAM size of the ARMCR4 core. */
25232998 uint32
25242999 si_tcm_size(si_t *sih)
25253000 {
25263001 si_info_t *sii = SI_INFO(sih);
2527
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
25283002 uint origidx;
25293003 uint intr_val = 0;
2530
- uint8 *regs;
2531
- bool wasup;
3004
+ volatile uint8 *regs;
3005
+ bool wasup = FALSE;
25323006 uint32 corecap;
25333007 uint memsize = 0;
3008
+ uint banku_size = 0;
25343009 uint32 nab = 0;
25353010 uint32 nbb = 0;
25363011 uint32 totb = 0;
25373012 uint32 bxinfo = 0;
25383013 uint32 idx = 0;
2539
- uint32 *arm_cap_reg;
2540
- uint32 *arm_bidx;
2541
- uint32 *arm_binfo;
3014
+ volatile uint32 *arm_cap_reg;
3015
+ volatile uint32 *arm_bidx;
3016
+ volatile uint32 *arm_binfo;
25423017
25433018 /* Block ints and save current core */
25443019 INTR_OFF(sii, intr_val);
....@@ -2551,28 +3026,37 @@
25513026 /* Get info for determining size. If in reset, come out of reset,
25523027 * but remain in halt
25533028 */
2554
- if (!(wasup = si_iscoreup(sih)))
2555
- si_core_reset(sih, SICF_CPUHALT, SICF_CPUHALT);
3029
+ if (!sih->secureboot) {
3030
+ if (!(wasup = si_iscoreup(sih)))
3031
+ si_core_reset(sih, SICF_CPUHALT, SICF_CPUHALT);
3032
+ }
25563033
2557
- arm_cap_reg = (uint32 *)(regs + SI_CR4_CAP);
3034
+ arm_cap_reg = (volatile uint32 *)(regs + SI_CR4_CAP);
25583035 corecap = R_REG(sii->osh, arm_cap_reg);
25593036
25603037 nab = (corecap & ARMCR4_TCBANB_MASK) >> ARMCR4_TCBANB_SHIFT;
25613038 nbb = (corecap & ARMCR4_TCBBNB_MASK) >> ARMCR4_TCBBNB_SHIFT;
25623039 totb = nab + nbb;
25633040
2564
- arm_bidx = (uint32 *)(regs + SI_CR4_BANKIDX);
2565
- arm_binfo = (uint32 *)(regs + SI_CR4_BANKINFO);
3041
+ arm_bidx = (volatile uint32 *)(regs + SI_CR4_BANKIDX);
3042
+ arm_binfo = (volatile uint32 *)(regs + SI_CR4_BANKINFO);
25663043 for (idx = 0; idx < totb; idx++) {
25673044 W_REG(sii->osh, arm_bidx, idx);
25683045
25693046 bxinfo = R_REG(sii->osh, arm_binfo);
2570
- memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * ARMCR4_BSZ_MULT;
3047
+ if (bxinfo & ARMCR4_BUNITSZ_MASK) {
3048
+ banku_size = ARMCR4_BSZ_1K;
3049
+ } else {
3050
+ banku_size = ARMCR4_BSZ_8K;
3051
+ }
3052
+ memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * banku_size;
25713053 }
25723054
25733055 /* Return to previous state and core */
2574
- if (!wasup)
2575
- si_core_disable(sih, 0);
3056
+ if (!sih->secureboot) {
3057
+ if (!wasup)
3058
+ si_core_disable(sih, 0);
3059
+ }
25763060 si_setcoreidx(sih, origidx);
25773061
25783062 done:
....@@ -2602,7 +3086,6 @@
26023086 si_socram_srmem_size(si_t *sih)
26033087 {
26043088 si_info_t *sii = SI_INFO(sih);
2605
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
26063089 uint origidx;
26073090 uint intr_val = 0;
26083091
....@@ -2611,10 +3094,6 @@
26113094 uint corerev;
26123095 uint32 coreinfo;
26133096 uint memsize = 0;
2614
-
2615
- if ((CHIPID(sih->chip) == BCM4334_CHIP_ID) && (CHIPREV(sih->chiprev) < 2)) {
2616
- return (32 * 1024);
2617
- }
26183097
26193098 if (CHIPID(sih->chip) == BCM43430_CHIP_ID ||
26203099 CHIPID(sih->chip) == BCM43018_CHIP_ID) {
....@@ -2657,13 +3136,11 @@
26573136 return memsize;
26583137 }
26593138
2660
-
26613139 #if !defined(_CFEZ_) || defined(CFG_WL)
26623140 void
26633141 si_btcgpiowar(si_t *sih)
26643142 {
26653143 si_info_t *sii = SI_INFO(sih);
2666
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
26673144 uint origidx;
26683145 uint intr_val = 0;
26693146 chipcregs_t *cc;
....@@ -2683,43 +3160,6 @@
26833160 ASSERT(cc != NULL);
26843161
26853162 W_REG(sii->osh, &cc->uart0mcr, R_REG(sii->osh, &cc->uart0mcr) | 0x04);
2686
-
2687
- /* restore the original index */
2688
- si_setcoreidx(sih, origidx);
2689
-
2690
- INTR_RESTORE(sii, intr_val);
2691
-}
2692
-
2693
-void
2694
-si_chipcontrl_btshd0_4331(si_t *sih, bool on)
2695
-{
2696
- si_info_t *sii = SI_INFO(sih);
2697
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
2698
- chipcregs_t *cc;
2699
- uint origidx;
2700
- uint32 val;
2701
- uint intr_val = 0;
2702
-
2703
- INTR_OFF(sii, intr_val);
2704
-
2705
- origidx = si_coreidx(sih);
2706
-
2707
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2708
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2709
- return;
2710
- }
2711
-
2712
- val = R_REG(sii->osh, &cc->chipcontrol);
2713
-
2714
- /* bt_shd0 controls are same for 4331 chiprevs 0 and 1, packages 12x9 and 12x12 */
2715
- if (on) {
2716
- /* Enable bt_shd0 on gpio4: */
2717
- val |= (CCTRL4331_BT_SHD0_ON_GPIO4);
2718
- W_REG(sii->osh, &cc->chipcontrol, val);
2719
- } else {
2720
- val &= ~(CCTRL4331_BT_SHD0_ON_GPIO4);
2721
- W_REG(sii->osh, &cc->chipcontrol, val);
2722
- }
27233163
27243164 /* restore the original index */
27253165 si_setcoreidx(sih, origidx);
....@@ -2759,42 +3199,6 @@
27593199 return val;
27603200 }
27613201
2762
-void
2763
-si_chipcontrl_epa4331(si_t *sih, bool on)
2764
-{
2765
- si_info_t *sii = SI_INFO(sih);
2766
- chipcregs_t *cc;
2767
- uint origidx = si_coreidx(sih);
2768
- uint32 val;
2769
-
2770
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2771
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2772
- return;
2773
- }
2774
- val = R_REG(sii->osh, &cc->chipcontrol);
2775
-
2776
- if (on) {
2777
- if (sih->chippkg == 9 || sih->chippkg == 0xb) {
2778
- val |= (CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5);
2779
- /* Ext PA Controls for 4331 12x9 Package */
2780
- W_REG(sii->osh, &cc->chipcontrol, val);
2781
- } else {
2782
- /* Ext PA Controls for 4331 12x12 Package */
2783
- if (CHIPREV(sih->chiprev) > 0) {
2784
- W_REG(sii->osh, &cc->chipcontrol, val |
2785
- (CCTRL4331_EXTPA_EN) | (CCTRL4331_EXTPA_EN2));
2786
- } else {
2787
- W_REG(sii->osh, &cc->chipcontrol, val | (CCTRL4331_EXTPA_EN));
2788
- }
2789
- }
2790
- } else {
2791
- val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_EN2 | CCTRL4331_EXTPA_ON_GPIO2_5);
2792
- W_REG(sii->osh, &cc->chipcontrol, val);
2793
- }
2794
-
2795
- si_setcoreidx(sih, origidx);
2796
-}
2797
-
27983202 /** switch muxed pins, on: SROM, off: FEMCTRL. Called for a family of ac chips, not just 4360. */
27993203 void
28003204 si_chipcontrl_srom4360(si_t *sih, bool on)
....@@ -2824,141 +3228,41 @@
28243228 si_setcoreidx(sih, origidx);
28253229 }
28263230
3231
+/**
3232
+ * The SROM clock is derived from the backplane clock. 4365 (200Mhz) and 43684 (240Mhz) have a fast
3233
+ * backplane clock that requires a higher-than-POR-default clock divisor ratio for the SROM clock.
3234
+ */
28273235 void
2828
-si_clk_srom4365(si_t *sih)
3236
+si_srom_clk_set(si_t *sih)
28293237 {
28303238 si_info_t *sii = SI_INFO(sih);
28313239 chipcregs_t *cc;
28323240 uint origidx = si_coreidx(sih);
28333241 uint32 val;
3242
+ uint32 divisor = 1;
28343243
28353244 if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
28363245 SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
28373246 return;
28383247 }
3248
+
28393249 val = R_REG(sii->osh, &cc->clkdiv2);
2840
- W_REG(sii->osh, &cc->clkdiv2, ((val&~0xf) | 0x4));
2841
-
2842
- si_setcoreidx(sih, origidx);
2843
-}
2844
-
2845
-void
2846
-si_d11rsdb_core1_alt_reg_clk_dis(si_t *sih)
2847
-{
2848
-#if defined(WLRSDB) && !defined(WLRSDB_DISABLED)
2849
- ai_d11rsdb_core1_alt_reg_clk_dis(sih);
2850
-#endif /* defined(WLRSDB) && !defined(WLRSDB_DISABLED) */
2851
-}
2852
-
2853
-void
2854
-si_d11rsdb_core1_alt_reg_clk_en(si_t *sih)
2855
-{
2856
-#if defined(WLRSDB) && !defined(WLRSDB_DISABLED)
2857
- ai_d11rsdb_core1_alt_reg_clk_en(sih);
2858
-#endif /* defined(WLRSDB) && !defined(WLRSDB_DISABLED) */
2859
-}
2860
-
2861
-void
2862
-si_chipcontrl_epa4331_wowl(si_t *sih, bool enter_wowl)
2863
-{
2864
- si_info_t *sii;
2865
- chipcregs_t *cc;
2866
- uint origidx;
2867
- uint32 val;
2868
- bool sel_chip;
2869
-
2870
- sel_chip = (CHIPID(sih->chip) == BCM4331_CHIP_ID) ||
2871
- (CHIPID(sih->chip) == BCM43431_CHIP_ID);
2872
- sel_chip &= ((sih->chippkg == 9 || sih->chippkg == 0xb));
2873
-
2874
- if (!sel_chip)
2875
- return;
2876
-
2877
- sii = SI_INFO(sih);
2878
- origidx = si_coreidx(sih);
2879
-
2880
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2881
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2882
- return;
2883
- }
2884
-
2885
- val = R_REG(sii->osh, &cc->chipcontrol);
2886
-
2887
- if (enter_wowl) {
2888
- val |= CCTRL4331_EXTPA_EN;
2889
- W_REG(sii->osh, &cc->chipcontrol, val);
3250
+ if (BCM4365_CHIP(sih->chip)) {
3251
+ divisor = CLKD2_SROMDIV_192; /* divide 200 by 192 -> SPROM clock ~ 1.04Mhz */
28903252 } else {
2891
- val |= (CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5);
2892
- W_REG(sii->osh, &cc->chipcontrol, val);
2893
- }
2894
- si_setcoreidx(sih, origidx);
2895
-}
2896
-#endif
2897
-
2898
-uint
2899
-si_pll_reset(si_t *sih)
2900
-{
2901
- uint err = 0;
2902
-
2903
- return (err);
2904
-}
2905
-
2906
-/** Enable BT-COEX & Ex-PA for 4313 */
2907
-void
2908
-si_epa_4313war(si_t *sih)
2909
-{
2910
- si_info_t *sii = SI_INFO(sih);
2911
- chipcregs_t *cc;
2912
- uint origidx = si_coreidx(sih);
2913
-
2914
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2915
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2916
- return;
3253
+ ASSERT(0);
29173254 }
29183255
2919
- /* EPA Fix */
2920
- W_REG(sii->osh, &cc->gpiocontrol,
2921
- R_REG(sii->osh, &cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK);
2922
-
3256
+ W_REG(sii->osh, &cc->clkdiv2, ((val & ~CLKD2_SROM) | divisor));
29233257 si_setcoreidx(sih, origidx);
29243258 }
2925
-
2926
-void
2927
-si_clk_pmu_htavail_set(si_t *sih, bool set_clear)
2928
-{
2929
-}
3259
+#endif // endif
29303260
29313261 void
29323262 si_pmu_avb_clk_set(si_t *sih, osl_t *osh, bool set_flag)
29333263 {
29343264 }
29353265
2936
-/** Re-enable synth_pwrsw resource in min_res_mask for 4313 */
2937
-void
2938
-si_pmu_synth_pwrsw_4313_war(si_t *sih)
2939
-{
2940
-}
2941
-
2942
-/** WL/BT control for 4313 btcombo boards >= P250 */
2943
-void
2944
-si_btcombo_p250_4313_war(si_t *sih)
2945
-{
2946
- si_info_t *sii = SI_INFO(sih);
2947
- chipcregs_t *cc;
2948
- uint origidx = si_coreidx(sih);
2949
-
2950
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2951
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2952
- return;
2953
- }
2954
- W_REG(sii->osh, &cc->gpiocontrol,
2955
- R_REG(sii->osh, &cc->gpiocontrol) | GPIO_CTRL_5_6_EN_MASK);
2956
-
2957
- W_REG(sii->osh, &cc->gpioouten,
2958
- R_REG(sii->osh, &cc->gpioouten) | GPIO_CTRL_5_6_EN_MASK);
2959
-
2960
- si_setcoreidx(sih, origidx);
2961
-}
29623266 void
29633267 si_btc_enable_chipcontrol(si_t *sih)
29643268 {
....@@ -2977,22 +3281,13 @@
29773281
29783282 si_setcoreidx(sih, origidx);
29793283 }
2980
-void
2981
-si_btcombo_43228_war(si_t *sih)
3284
+
3285
+/** cache device removed state */
3286
+void si_set_device_removed(si_t *sih, bool status)
29823287 {
29833288 si_info_t *sii = SI_INFO(sih);
2984
- chipcregs_t *cc;
2985
- uint origidx = si_coreidx(sih);
29863289
2987
- if ((cc = (chipcregs_t *)si_setcore(sih, CC_CORE_ID, 0)) == NULL) {
2988
- SI_ERROR(("%s: Failed to find CORE ID!\n", __FUNCTION__));
2989
- return;
2990
- }
2991
-
2992
- W_REG(sii->osh, &cc->gpioouten, GPIO_CTRL_7_6_EN_MASK);
2993
- W_REG(sii->osh, &cc->gpioout, GPIO_OUT_7_EN_MASK);
2994
-
2995
- si_setcoreidx(sih, origidx);
3290
+ sii->device_removed = status;
29963291 }
29973292
29983293 /** check if the device is removed */
....@@ -3000,6 +3295,11 @@
30003295 si_deviceremoved(si_t *sih)
30013296 {
30023297 uint32 w;
3298
+ si_info_t *sii = SI_INFO(sih);
3299
+
3300
+ if (sii->device_removed) {
3301
+ return TRUE;
3302
+ }
30033303
30043304 switch (BUSTYPE(sih->bustype)) {
30053305 case PCI_BUS:
....@@ -3013,9 +3313,20 @@
30133313 }
30143314
30153315 bool
3316
+si_is_warmboot(void)
3317
+{
3318
+
3319
+#ifdef BCMULP
3320
+ return (boot_type == WARM_BOOT);
3321
+#else
3322
+ return FALSE;
3323
+#endif // endif
3324
+}
3325
+
3326
+bool
30163327 si_is_sprom_available(si_t *sih)
30173328 {
3018
- if (sih->ccrev >= 31) {
3329
+ if (CCREV(sih->ccrev) >= 31) {
30193330 si_info_t *sii;
30203331 uint origidx;
30213332 chipcregs_t *cc;
....@@ -3034,52 +3345,35 @@
30343345 }
30353346
30363347 switch (CHIPID(sih->chip)) {
3037
- case BCM4312_CHIP_ID:
3038
- return ((sih->chipst & CST4312_SPROM_OTP_SEL_MASK) != CST4312_OTP_SEL);
3039
- case BCM4325_CHIP_ID:
3040
- return (sih->chipst & CST4325_SPROM_SEL) != 0;
3041
- case BCM4322_CHIP_ID: case BCM43221_CHIP_ID: case BCM43231_CHIP_ID:
3042
- case BCM43222_CHIP_ID: case BCM43111_CHIP_ID: case BCM43112_CHIP_ID:
3043
- case BCM4342_CHIP_ID: {
3044
- uint32 spromotp;
3045
- spromotp = (sih->chipst & CST4322_SPROM_OTP_SEL_MASK) >>
3046
- CST4322_SPROM_OTP_SEL_SHIFT;
3047
- return (spromotp & CST4322_SPROM_PRESENT) != 0;
3048
- }
3049
- case BCM4329_CHIP_ID:
3050
- return (sih->chipst & CST4329_SPROM_SEL) != 0;
3051
- case BCM4315_CHIP_ID:
3052
- return (sih->chipst & CST4315_SPROM_SEL) != 0;
3053
- case BCM4319_CHIP_ID:
3054
- return (sih->chipst & CST4319_SPROM_SEL) != 0;
3055
- case BCM4336_CHIP_ID:
3056
- case BCM43362_CHIP_ID:
3057
- return (sih->chipst & CST4336_SPROM_PRESENT) != 0;
3058
- case BCM4330_CHIP_ID:
3059
- return (sih->chipst & CST4330_SPROM_PRESENT) != 0;
3060
- case BCM4313_CHIP_ID:
3061
- return (sih->chipst & CST4313_SPROM_PRESENT) != 0;
3062
- case BCM4331_CHIP_ID:
3063
- case BCM43431_CHIP_ID:
3064
- return (sih->chipst & CST4331_SPROM_PRESENT) != 0;
3065
- case BCM43239_CHIP_ID:
3066
- return ((sih->chipst & CST43239_SPROM_MASK) &&
3067
- !(sih->chipst & CST43239_SFLASH_MASK));
3068
- case BCM4324_CHIP_ID:
3069
- case BCM43242_CHIP_ID:
3070
- return ((sih->chipst & CST4324_SPROM_MASK) &&
3071
- !(sih->chipst & CST4324_SFLASH_MASK));
3348
+ case BCM43018_CHIP_ID:
3349
+ case BCM43430_CHIP_ID:
3350
+ return FALSE;
30723351 case BCM4335_CHIP_ID:
3073
- case BCM4345_CHIP_ID:
3074
- case BCM43454_CHIP_ID:
3352
+ CASE_BCM4345_CHIP:
30753353 return ((sih->chipst & CST4335_SPROM_MASK) &&
30763354 !(sih->chipst & CST4335_SFLASH_MASK));
30773355 case BCM4349_CHIP_GRPID:
30783356 return (sih->chipst & CST4349_SPROM_PRESENT) != 0;
3357
+ case BCM53573_CHIP_GRPID:
3358
+ return FALSE; /* SPROM PRESENT is not defined for 53573 as of now */
3359
+ case BCM4364_CHIP_ID:
3360
+ return (sih->chipst & CST4364_SPROM_PRESENT) != 0;
3361
+ case BCM4369_CHIP_GRPID:
3362
+ if (CHIPREV(sih->chiprev) == 0) {
3363
+ /* WAR for 4369a0: HW4369-1729. no sprom, default to otp always. */
3364
+ return 0;
3365
+ } else {
3366
+ return (sih->chipst & CST4369_SPROM_PRESENT) != 0;
3367
+ }
3368
+#ifdef CHIPS_CUSTOMER_HW6
3369
+ case BCM4368_CHIP_ID:
3370
+ return FALSE;
3371
+#endif /* CHIPS_CUSTOMER_HW6 */
3372
+ case BCM4347_CHIP_GRPID:
3373
+ return (sih->chipst & CST4347_SPROM_PRESENT) != 0;
30793374 break;
30803375 case BCM4350_CHIP_ID:
30813376 case BCM4354_CHIP_ID:
3082
- case BCM4356_CHIP_ID:
30833377 case BCM43556_CHIP_ID:
30843378 case BCM43558_CHIP_ID:
30853379 case BCM43566_CHIP_ID:
....@@ -3092,15 +3386,15 @@
30923386 return (sih->chipst & CST43602_SPROM_PRESENT) != 0;
30933387 case BCM43131_CHIP_ID:
30943388 case BCM43217_CHIP_ID:
3095
- case BCM43227_CHIP_ID:
3096
- case BCM43228_CHIP_ID:
30973389 case BCM43428_CHIP_ID:
30983390 return (sih->chipst & CST43228_OTP_PRESENT) != CST43228_OTP_PRESENT;
3391
+ case BCM4373_CHIP_ID:
3392
+ case BCM43012_CHIP_ID:
3393
+ return FALSE;
30993394 default:
31003395 return TRUE;
31013396 }
31023397 }
3103
-
31043398
31053399 uint32 si_get_sromctl(si_t *sih)
31063400 {
....@@ -3156,7 +3450,6 @@
31563450 uint origidx, intr_val = 0;
31573451 uint ret_val;
31583452 si_info_t *sii = SI_INFO(sih);
3159
- si_cores_info_t *cores_info = (si_cores_info_t *)sii->cores_info;
31603453
31613454 origidx = si_coreidx(sih);
31623455
....@@ -3171,7 +3464,6 @@
31713464 return ret_val;
31723465 }
31733466
3174
-
31753467 /* cleanup the timer from the host when ARM is been halted
31763468 * without a chance for ARM cleanup its resources
31773469 * If left not cleanup, Intr from a software timer can still
....@@ -3183,8 +3475,7 @@
31833475 uint32 mask;
31843476
31853477 mask = PRRT_REQ_ACTIVE | PRRT_INTEN | PRRT_HT_REQ;
3186
- if (CHIPID(sih->chip) != BCM4328_CHIP_ID)
3187
- mask <<= 14;
3478
+ mask <<= 14;
31883479 /* clear mask bits */
31893480 pmu_corereg(sih, SI_CC_IDX, res_req_timer, mask, 0);
31903481 /* readback to ensure write completes */
....@@ -3197,67 +3488,17 @@
31973488 {
31983489 }
31993490
3200
-
3201
-#ifdef SURVIVE_PERST_ENAB
3202
-static uint32
3203
-si_pcie_survive_perst(si_t *sih, uint32 mask, uint32 val)
3204
-{
3205
- si_info_t *sii;
3206
-
3207
- sii = SI_INFO(sih);
3208
-
3209
- if (!PCIE(sii))
3210
- return (0);
3211
-
3212
- return pcie_survive_perst(sii->pch, mask, val);
3213
-}
3214
-
3215
-static void
3216
-si_watchdog_reset(si_t *sih)
3217
-{
3218
- uint32 i;
3219
-
3220
- /* issue a watchdog reset */
3221
- pmu_corereg(sih, SI_CC_IDX, pmuwatchdog, 2, 2);
3222
- /* do busy wait for 20ms */
3223
- for (i = 0; i < 2000; i++) {
3224
- OSL_DELAY(10);
3225
- }
3226
-}
3227
-#endif /* SURVIVE_PERST_ENAB */
3228
-
3491
+/* Caller of this function should make sure is on PCIE core
3492
+ * Used in pciedev.c.
3493
+ */
32293494 void
3230
-si_survive_perst_war(si_t *sih, bool reset, uint32 sperst_mask, uint32 sperst_val)
3495
+si_pcie_disable_oobselltr(si_t *sih)
32313496 {
3232
-#ifdef SURVIVE_PERST_ENAB
3233
- if (BUSTYPE(sih->bustype) != PCI_BUS)
3234
- return;
3235
-
3236
- if ((CHIPID(sih->chip) != BCM4360_CHIP_ID && CHIPID(sih->chip) != BCM4352_CHIP_ID) ||
3237
- (CHIPREV(sih->chiprev) >= 4))
3238
- return;
3239
-
3240
- if (reset) {
3241
- si_info_t *sii = SI_INFO(sih);
3242
- uint32 bar0win, bar0win_after;
3243
-
3244
- /* save the bar0win */
3245
- bar0win = OSL_PCI_READ_CONFIG(sii->osh, PCI_BAR0_WIN, sizeof(uint32));
3246
-
3247
- si_watchdog_reset(sih);
3248
-
3249
- bar0win_after = OSL_PCI_READ_CONFIG(sii->osh, PCI_BAR0_WIN, sizeof(uint32));
3250
- if (bar0win_after != bar0win) {
3251
- SI_ERROR(("%s: bar0win before %08x, bar0win after %08x\n",
3252
- __FUNCTION__, bar0win, bar0win_after));
3253
- OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, sizeof(uint32), bar0win);
3254
- }
3255
- }
3256
- if (sperst_mask) {
3257
- /* enable survive perst */
3258
- si_pcie_survive_perst(sih, sperst_mask, sperst_val);
3259
- }
3260
-#endif /* SURVIVE_PERST_ENAB */
3497
+ ASSERT(si_coreid(sih) == PCIE2_CORE_ID);
3498
+ if (PCIECOREREV(sih->buscorerev) >= 23)
3499
+ si_wrapperreg(sih, AI_OOBSELIND74, ~0, 0);
3500
+ else
3501
+ si_wrapperreg(sih, AI_OOBSELIND30, ~0, 0);
32613502 }
32623503
32633504 void
....@@ -3285,11 +3526,117 @@
32853526 {
32863527 }
32873528
3529
+#if defined(AXI_TIMEOUTS) || defined(BCM_BACKPLANE_TIMEOUT)
3530
+uint32
3531
+si_clear_backplane_to_per_core(si_t *sih, uint coreid, uint coreunit, void * wrap)
3532
+{
3533
+ if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
3534
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS)) {
3535
+ return ai_clear_backplane_to_per_core(sih, coreid, coreunit, wrap);
3536
+ }
32883537
3538
+ return AXI_WRAP_STS_NONE;
3539
+}
3540
+#endif /* AXI_TIMEOUTS || BCM_BACKPLANE_TIMEOUT */
3541
+
3542
+uint32
3543
+si_clear_backplane_to(si_t *sih)
3544
+{
3545
+ if ((CHIPTYPE(sih->socitype) == SOCI_AI) ||
3546
+ (CHIPTYPE(sih->socitype) == SOCI_DVTBUS)) {
3547
+ return ai_clear_backplane_to(sih);
3548
+ }
3549
+
3550
+ return 0;
3551
+}
3552
+
3553
+void
3554
+si_update_backplane_timeouts(si_t *sih, bool enable, uint32 timeout_exp, uint32 cid)
3555
+{
3556
+#if defined(AXI_TIMEOUTS) || defined(BCM_BACKPLANE_TIMEOUT)
3557
+ /* Enable only for AXI */
3558
+ if (CHIPTYPE(sih->socitype) != SOCI_AI) {
3559
+ return;
3560
+ }
3561
+
3562
+ ai_update_backplane_timeouts(sih, enable, timeout_exp, cid);
3563
+#endif /* AXI_TIMEOUTS || BCM_BACKPLANE_TIMEOUT */
3564
+}
3565
+
3566
+/*
3567
+ * This routine adds the AXI timeouts for
3568
+ * chipcommon, pcie and ARM slave wrappers
3569
+ */
3570
+void
3571
+si_slave_wrapper_add(si_t *sih)
3572
+{
3573
+#if defined(AXI_TIMEOUTS) || defined(BCM_BACKPLANE_TIMEOUT)
3574
+ uint32 axi_to = 0;
3575
+
3576
+ /* Enable only for AXI */
3577
+ if ((CHIPTYPE(sih->socitype) != SOCI_AI) &&
3578
+ (CHIPTYPE(sih->socitype) != SOCI_DVTBUS)) {
3579
+ return;
3580
+ }
3581
+
3582
+ if (CHIPID(sih->chip) == BCM4345_CHIP_ID && CHIPREV(sih->chiprev) >= 6) {
3583
+ si_info_t *sii = SI_INFO(sih);
3584
+
3585
+ int wrapper_idx = (int)sii->axi_num_wrappers - 1;
3586
+
3587
+ ASSERT(wrapper_idx >= 0); /* axi_wrapper[] not initialised */
3588
+ do {
3589
+ if (sii->axi_wrapper[wrapper_idx].wrapper_type == AI_SLAVE_WRAPPER &&
3590
+ sii->axi_wrapper[wrapper_idx].cid == 0xfff) {
3591
+ sii->axi_wrapper[wrapper_idx].wrapper_addr = 0x1810b000;
3592
+ break;
3593
+ }
3594
+ } while (wrapper_idx-- > 0);
3595
+ ASSERT(wrapper_idx >= 0); /* all addresses valid for the chiprev under test */
3596
+ }
3597
+
3598
+ if (BCM4347_CHIP(sih->chip)) {
3599
+ axi_to = AXI_TO_VAL_4347;
3600
+ }
3601
+ else {
3602
+ axi_to = AXI_TO_VAL;
3603
+ }
3604
+
3605
+ /* All required slave wrappers are added in ai_scan */
3606
+ ai_update_backplane_timeouts(sih, TRUE, axi_to, 0);
3607
+
3608
+#ifdef DISABLE_PCIE2_AXI_TIMEOUT
3609
+ ai_update_backplane_timeouts(sih, FALSE, 0, PCIE_CORE_ID);
3610
+ ai_update_backplane_timeouts(sih, FALSE, 0, PCIE2_CORE_ID);
3611
+#endif // endif
3612
+
3613
+#endif /* AXI_TIMEOUTS || BCM_BACKPLANE_TIMEOUT */
3614
+
3615
+}
32893616
32903617 void
32913618 si_pll_sr_reinit(si_t *sih)
32923619 {
3620
+}
3621
+
3622
+/* Programming d11 core oob settings for 4364
3623
+ * WARs for HW4364-237 and HW4364-166
3624
+*/
3625
+void
3626
+si_config_4364_d11_oob(si_t *sih, uint coreid)
3627
+{
3628
+ uint save_idx;
3629
+
3630
+ save_idx = si_coreidx(sih);
3631
+ si_setcore(sih, coreid, 0);
3632
+ si_wrapperreg(sih, AI_OOBSELINC30, ~0, 0x81828180);
3633
+ si_wrapperreg(sih, AI_OOBSELINC74, ~0, 0x87868183);
3634
+ si_wrapperreg(sih, AI_OOBSELOUTB74, ~0, 0x84858484);
3635
+ si_setcore(sih, coreid, 1);
3636
+ si_wrapperreg(sih, AI_OOBSELINC30, ~0, 0x81828180);
3637
+ si_wrapperreg(sih, AI_OOBSELINC74, ~0, 0x87868184);
3638
+ si_wrapperreg(sih, AI_OOBSELOUTB74, ~0, 0x84868484);
3639
+ si_setcoreidx(sih, save_idx);
32933640 }
32943641
32953642 void
....@@ -3301,6 +3648,7 @@
33013648 /* disable PLL open loop operation */
33023649 switch (CHIPID(sih->chip)) {
33033650 #ifdef SAVERESTORE
3651
+ case BCM43018_CHIP_ID:
33043652 case BCM43430_CHIP_ID:
33053653 if (SR_ENAB() && sr_isenab(sih)) {
33063654 /* read back the pll openloop state */
....@@ -3314,9 +3662,268 @@
33143662 }
33153663 break;
33163664 #endif /* SAVERESTORE */
3665
+ case BCM4347_CHIP_GRPID:
3666
+ case BCM4369_CHIP_GRPID:
3667
+ si_pmu_chipcontrol(sih, PMU_CHIPCTL1,
3668
+ PMU_CC1_ENABLE_CLOSED_LOOP_MASK, PMU_CC1_ENABLE_CLOSED_LOOP);
3669
+ break;
33173670 default:
33183671 /* any unsupported chip bail */
33193672 return;
33203673 }
3321
-#endif
3674
+#endif // endif
3675
+}
3676
+
3677
+#if defined(BCMSRPWR) && !defined(BCMSRPWR_DISABLED)
3678
+bool _bcmsrpwr = TRUE;
3679
+#else
3680
+bool _bcmsrpwr = FALSE;
3681
+#endif // endif
3682
+
3683
+#define PWRREQ_OFFSET(sih) OFFSETOF(chipcregs_t, powerctl)
3684
+
3685
+static void
3686
+si_corereg_pciefast_write(si_t *sih, uint regoff, uint val)
3687
+{
3688
+ volatile uint32 *r = NULL;
3689
+ si_info_t *sii = SI_INFO(sih);
3690
+
3691
+ ASSERT((BUSTYPE(sih->bustype) == PCI_BUS));
3692
+
3693
+ r = (volatile uint32 *)((volatile char *)sii->curmap +
3694
+ PCI_16KB0_PCIREGS_OFFSET + regoff);
3695
+
3696
+ W_REG(sii->osh, r, val);
3697
+}
3698
+
3699
+static uint
3700
+si_corereg_pciefast_read(si_t *sih, uint regoff)
3701
+{
3702
+ volatile uint32 *r = NULL;
3703
+ si_info_t *sii = SI_INFO(sih);
3704
+
3705
+ ASSERT((BUSTYPE(sih->bustype) == PCI_BUS));
3706
+
3707
+ r = (volatile uint32 *)((volatile char *)sii->curmap +
3708
+ PCI_16KB0_PCIREGS_OFFSET + regoff);
3709
+
3710
+ return R_REG(sii->osh, r);
3711
+}
3712
+
3713
+uint32
3714
+si_srpwr_request(si_t *sih, uint32 mask, uint32 val)
3715
+{
3716
+ uint32 r, offset = (BUSTYPE(sih->bustype) == SI_BUS) ?
3717
+ OFFSETOF(chipcregs_t, powerctl) : PWRREQ_OFFSET(sih);
3718
+ uint32 mask2 = mask;
3719
+ uint32 val2 = val;
3720
+ volatile uint32 *fast_srpwr_addr = (volatile uint32 *)((uintptr)SI_ENUM_BASE(sih)
3721
+ + (uintptr)offset);
3722
+
3723
+ if (mask || val) {
3724
+ mask <<= SRPWR_REQON_SHIFT;
3725
+ val <<= SRPWR_REQON_SHIFT;
3726
+
3727
+ /* Return if requested power request is already set */
3728
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3729
+ r = R_REG(OSH_NULL, fast_srpwr_addr);
3730
+ } else {
3731
+ r = si_corereg_pciefast_read(sih, offset);
3732
+ }
3733
+
3734
+ if ((r & mask) == val) {
3735
+ return r;
3736
+ }
3737
+
3738
+ r = (r & ~mask) | val;
3739
+
3740
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3741
+ W_REG(OSH_NULL, fast_srpwr_addr, r);
3742
+ r = R_REG(OSH_NULL, fast_srpwr_addr);
3743
+ } else {
3744
+ si_corereg_pciefast_write(sih, offset, r);
3745
+ r = si_corereg_pciefast_read(sih, offset);
3746
+ }
3747
+
3748
+ if (val2) {
3749
+ if ((r & (mask2 << SRPWR_STATUS_SHIFT)) ==
3750
+ (val2 << SRPWR_STATUS_SHIFT)) {
3751
+ return r;
3752
+ }
3753
+ si_srpwr_stat_spinwait(sih, mask2, val2);
3754
+ }
3755
+ } else {
3756
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3757
+ r = R_REG(OSH_NULL, fast_srpwr_addr);
3758
+ } else {
3759
+ r = si_corereg_pciefast_read(sih, offset);
3760
+ }
3761
+ }
3762
+
3763
+ return r;
3764
+}
3765
+
3766
+uint32
3767
+si_srpwr_stat_spinwait(si_t *sih, uint32 mask, uint32 val)
3768
+{
3769
+ uint32 r, offset = (BUSTYPE(sih->bustype) == SI_BUS) ?
3770
+ OFFSETOF(chipcregs_t, powerctl) : PWRREQ_OFFSET(sih);
3771
+ volatile uint32 *fast_srpwr_addr = (volatile uint32 *)((uintptr)SI_ENUM_BASE(sih)
3772
+ + (uintptr)offset);
3773
+
3774
+ ASSERT(mask);
3775
+ ASSERT(val);
3776
+
3777
+ /* spinwait on pwrstatus */
3778
+ mask <<= SRPWR_STATUS_SHIFT;
3779
+ val <<= SRPWR_STATUS_SHIFT;
3780
+
3781
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3782
+ SPINWAIT(((R_REG(OSH_NULL, fast_srpwr_addr) & mask) != val),
3783
+ PMU_MAX_TRANSITION_DLY);
3784
+ r = R_REG(OSH_NULL, fast_srpwr_addr) & mask;
3785
+ ASSERT(r == val);
3786
+ } else {
3787
+ SPINWAIT(((si_corereg_pciefast_read(sih, offset) & mask) != val),
3788
+ PMU_MAX_TRANSITION_DLY);
3789
+ r = si_corereg_pciefast_read(sih, offset) & mask;
3790
+ ASSERT(r == val);
3791
+ }
3792
+
3793
+ r = (r >> SRPWR_STATUS_SHIFT) & SRPWR_DMN_ALL_MASK(sih);
3794
+
3795
+ return r;
3796
+}
3797
+
3798
+uint32
3799
+si_srpwr_stat(si_t *sih)
3800
+{
3801
+ uint32 r, offset = (BUSTYPE(sih->bustype) == SI_BUS) ?
3802
+ OFFSETOF(chipcregs_t, powerctl) : PWRREQ_OFFSET(sih);
3803
+ uint cidx = (BUSTYPE(sih->bustype) == SI_BUS) ? SI_CC_IDX : sih->buscoreidx;
3804
+
3805
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3806
+ r = si_corereg(sih, cidx, offset, 0, 0);
3807
+ } else {
3808
+ r = si_corereg_pciefast_read(sih, offset);
3809
+ }
3810
+
3811
+ r = (r >> SRPWR_STATUS_SHIFT) & SRPWR_DMN_ALL_MASK(sih);
3812
+
3813
+ return r;
3814
+}
3815
+
3816
+uint32
3817
+si_srpwr_domain(si_t *sih)
3818
+{
3819
+ uint32 r, offset = (BUSTYPE(sih->bustype) == SI_BUS) ?
3820
+ OFFSETOF(chipcregs_t, powerctl) : PWRREQ_OFFSET(sih);
3821
+ uint cidx = (BUSTYPE(sih->bustype) == SI_BUS) ? SI_CC_IDX : sih->buscoreidx;
3822
+
3823
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3824
+ r = si_corereg(sih, cidx, offset, 0, 0);
3825
+ } else {
3826
+ r = si_corereg_pciefast_read(sih, offset);
3827
+ }
3828
+
3829
+ r = (r >> SRPWR_DMN_ID_SHIFT) & SRPWR_DMN_ID_MASK;
3830
+
3831
+ return r;
3832
+}
3833
+
3834
+uint32
3835
+si_srpwr_domain_all_mask(si_t *sih)
3836
+{
3837
+ uint32 mask = SRPWR_DMN0_PCIE_MASK |
3838
+ SRPWR_DMN1_ARMBPSD_MASK |
3839
+ SRPWR_DMN2_MACAUX_MASK |
3840
+ SRPWR_DMN3_MACMAIN_MASK;
3841
+
3842
+ if (si_scan_core_present(sih)) {
3843
+ mask |= SRPWR_DMN4_MACSCAN_MASK;
3844
+ }
3845
+
3846
+ return mask;
3847
+}
3848
+
3849
+/* Utility API to read/write the raw registers with absolute address.
3850
+ * This function can be invoked from either FW or host driver.
3851
+ */
3852
+uint32
3853
+si_raw_reg(si_t *sih, uint32 reg, uint32 val, uint32 wrire_req)
3854
+{
3855
+ si_info_t *sii = SI_INFO(sih);
3856
+ uint32 address_space = reg & ~0xFFF;
3857
+ volatile uint32 * addr = (void*)(uintptr)(reg);
3858
+ uint32 prev_value = 0;
3859
+ uint32 cfg_reg = 0;
3860
+
3861
+ if (sii == NULL) {
3862
+ return 0;
3863
+ }
3864
+
3865
+ /* No need to translate the absolute address on SI bus */
3866
+ if (BUSTYPE(sih->bustype) == SI_BUS) {
3867
+ goto skip_cfg;
3868
+ }
3869
+
3870
+ /* This API supports only the PCI host interface */
3871
+ if (BUSTYPE(sih->bustype) != PCI_BUS) {
3872
+ return ID32_INVALID;
3873
+ }
3874
+
3875
+ if (PCIE_GEN2(sii)) {
3876
+ /* Use BAR0 Secondary window is PCIe Gen2.
3877
+ * Set the secondary BAR0 Window to current register of interest
3878
+ */
3879
+ addr = (volatile uint32*)(((volatile uint8*)sii->curmap) +
3880
+ PCI_SEC_BAR0_WIN_OFFSET + (reg & 0xfff));
3881
+ cfg_reg = PCIE2_BAR0_CORE2_WIN;
3882
+
3883
+ } else {
3884
+ /* PCIe Gen1 do not have secondary BAR0 window.
3885
+ * reuse the BAR0 WIN2
3886
+ */
3887
+ addr = (volatile uint32*)(((volatile uint8*)sii->curmap) +
3888
+ PCI_BAR0_WIN2_OFFSET + (reg & 0xfff));
3889
+ cfg_reg = PCI_BAR0_WIN2;
3890
+ }
3891
+
3892
+ prev_value = OSL_PCI_READ_CONFIG(sii->osh, cfg_reg, 4);
3893
+
3894
+ if (prev_value != address_space) {
3895
+ OSL_PCI_WRITE_CONFIG(sii->osh, cfg_reg,
3896
+ sizeof(uint32), address_space);
3897
+ } else {
3898
+ prev_value = 0;
3899
+ }
3900
+
3901
+skip_cfg:
3902
+ if (wrire_req) {
3903
+ W_REG(sii->osh, addr, val);
3904
+ } else {
3905
+ val = R_REG(sii->osh, addr);
3906
+ }
3907
+
3908
+ if (prev_value) {
3909
+ /* Restore BAR0 WIN2 for PCIE GEN1 devices */
3910
+ OSL_PCI_WRITE_CONFIG(sii->osh,
3911
+ cfg_reg, sizeof(uint32), prev_value);
3912
+ }
3913
+
3914
+ return val;
3915
+}
3916
+
3917
+uint8
3918
+si_lhl_ps_mode(si_t *sih)
3919
+{
3920
+ si_info_t *sii = SI_INFO(sih);
3921
+ return sii->lhl_ps_mode;
3922
+}
3923
+
3924
+bool
3925
+BCMRAMFN(si_scan_core_present)(si_t *sih)
3926
+{
3927
+ return ((si_numcoreunits(sih, D11_CORE_ID) >= 2) &&
3928
+ (si_numcoreunits(sih, SR_CORE_ID) > 4));
33223929 }