62a5aed7ee48b29b920fd8a2b5a21aafa32a184e
[openwrt.git] / target / linux / generic / patches-3.14 / 025-bcma_backport.patch
1 --- a/drivers/bcma/Makefile
2 +++ b/drivers/bcma/Makefile
3 @@ -3,6 +3,7 @@ bcma-y                                  += driver_chipcommon.o driver
4  bcma-$(CONFIG_BCMA_SFLASH)             += driver_chipcommon_sflash.o
5  bcma-$(CONFIG_BCMA_NFLASH)             += driver_chipcommon_nflash.o
6  bcma-y                                 += driver_pci.o
7 +bcma-y                                 += driver_pcie2.o
8  bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE)        += driver_pci_host.o
9  bcma-$(CONFIG_BCMA_DRIVER_MIPS)                += driver_mips.o
10  bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN)    += driver_gmac_cmn.o
11 --- a/drivers/bcma/driver_chipcommon_pmu.c
12 +++ b/drivers/bcma/driver_chipcommon_pmu.c
13 @@ -603,6 +603,8 @@ void bcma_pmu_spuravoid_pllupdate(struct
14                 tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
15                 break;
16  
17 +       case BCMA_CHIP_ID_BCM43131:
18 +       case BCMA_CHIP_ID_BCM43217:
19         case BCMA_CHIP_ID_BCM43227:
20         case BCMA_CHIP_ID_BCM43228:
21         case BCMA_CHIP_ID_BCM43428:
22 --- a/drivers/bcma/driver_gpio.c
23 +++ b/drivers/bcma/driver_gpio.c
24 @@ -218,7 +218,15 @@ int bcma_gpio_init(struct bcma_drv_cc *c
25  #if IS_BUILTIN(CONFIG_BCMA_HOST_SOC)
26         chip->to_irq            = bcma_gpio_to_irq;
27  #endif
28 -       chip->ngpio             = 16;
29 +       switch (cc->core->bus->chipinfo.id) {
30 +       case BCMA_CHIP_ID_BCM5357:
31 +       case BCMA_CHIP_ID_BCM53572:
32 +               chip->ngpio     = 32;
33 +               break;
34 +       default:
35 +               chip->ngpio     = 16;
36 +       }
37 +
38         /* There is just one SoC in one device and its GPIO addresses should be
39          * deterministic to address them more easily. The other buses could get
40          * a random base number. */
41 --- /dev/null
42 +++ b/drivers/bcma/driver_pcie2.c
43 @@ -0,0 +1,175 @@
44 +/*
45 + * Broadcom specific AMBA
46 + * PCIe Gen 2 Core
47 + *
48 + * Copyright 2014, Broadcom Corporation
49 + * Copyright 2014, Rafał Miłecki <zajec5@gmail.com>
50 + *
51 + * Licensed under the GNU/GPL. See COPYING for details.
52 + */
53 +
54 +#include "bcma_private.h"
55 +#include <linux/bcma/bcma.h>
56 +
57 +/**************************************************
58 + * R/W ops.
59 + **************************************************/
60 +
61 +#if 0
62 +static u32 bcma_core_pcie2_cfg_read(struct bcma_drv_pcie2 *pcie2, u32 addr)
63 +{
64 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr);
65 +       pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR);
66 +       return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA);
67 +}
68 +#endif
69 +
70 +static void bcma_core_pcie2_cfg_write(struct bcma_drv_pcie2 *pcie2, u32 addr,
71 +                                     u32 val)
72 +{
73 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr);
74 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, val);
75 +}
76 +
77 +/**************************************************
78 + * Init.
79 + **************************************************/
80 +
81 +static u32 bcma_core_pcie2_war_delay_perst_enab(struct bcma_drv_pcie2 *pcie2,
82 +                                               bool enable)
83 +{
84 +       u32 val;
85 +
86 +       /* restore back to default */
87 +       val = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL);
88 +       val |= PCIE2_CLKC_DLYPERST;
89 +       val &= ~PCIE2_CLKC_DISSPROMLD;
90 +       if (enable) {
91 +               val &= ~PCIE2_CLKC_DLYPERST;
92 +               val |= PCIE2_CLKC_DISSPROMLD;
93 +       }
94 +       pcie2_write32(pcie2, (BCMA_CORE_PCIE2_CLK_CONTROL), val);
95 +       /* flush */
96 +       return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL);
97 +}
98 +
99 +static void bcma_core_pcie2_set_ltr_vals(struct bcma_drv_pcie2 *pcie2)
100 +{
101 +       /* LTR0 */
102 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x844);
103 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x883c883c);
104 +       /* LTR1 */
105 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x848);
106 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x88648864);
107 +       /* LTR2 */
108 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x84C);
109 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x90039003);
110 +}
111 +
112 +static void bcma_core_pcie2_hw_ltr_war(struct bcma_drv_pcie2 *pcie2)
113 +{
114 +       u8 core_rev = pcie2->core->id.rev;
115 +       u32 devstsctr2;
116 +
117 +       if (core_rev < 2 || core_rev == 10 || core_rev > 13)
118 +               return;
119 +
120 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
121 +                     PCIE2_CAP_DEVSTSCTRL2_OFFSET);
122 +       devstsctr2 = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA);
123 +       if (devstsctr2 & PCIE2_CAP_DEVSTSCTRL2_LTRENAB) {
124 +               /* force the right LTR values */
125 +               bcma_core_pcie2_set_ltr_vals(pcie2);
126 +
127 +               /* TODO:
128 +               si_core_wrapperreg(pcie2, 3, 0x60, 0x8080, 0); */
129 +
130 +               /* enable the LTR */
131 +               devstsctr2 |= PCIE2_CAP_DEVSTSCTRL2_LTRENAB;
132 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
133 +                             PCIE2_CAP_DEVSTSCTRL2_OFFSET);
134 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, devstsctr2);
135 +
136 +               /* set the LTR state to be active */
137 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE,
138 +                             PCIE2_LTR_ACTIVE);
139 +               usleep_range(1000, 2000);
140 +
141 +               /* set the LTR state to be sleep */
142 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE,
143 +                             PCIE2_LTR_SLEEP);
144 +               usleep_range(1000, 2000);
145 +       }
146 +}
147 +
148 +static void pciedev_crwlpciegen2(struct bcma_drv_pcie2 *pcie2)
149 +{
150 +       u8 core_rev = pcie2->core->id.rev;
151 +       bool pciewar160, pciewar162;
152 +
153 +       pciewar160 = core_rev == 7 || core_rev == 9 || core_rev == 11;
154 +       pciewar162 = core_rev == 5 || core_rev == 7 || core_rev == 8 ||
155 +                    core_rev == 9 || core_rev == 11;
156 +
157 +       if (!pciewar160 && !pciewar162)
158 +               return;
159 +
160 +/* TODO */
161 +#if 0
162 +       pcie2_set32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL,
163 +                   PCIE_DISABLE_L1CLK_GATING);
164 +#if 0
165 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
166 +                     PCIEGEN2_COE_PVT_TL_CTRL_0);
167 +       pcie2_mask32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA,
168 +                    ~(1 << COE_PVT_TL_CTRL_0_PM_DIS_L1_REENTRY_BIT));
169 +#endif
170 +#endif
171 +}
172 +
173 +static void pciedev_crwlpciegen2_180(struct bcma_drv_pcie2 *pcie2)
174 +{
175 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_PMCR_REFUP);
176 +       pcie2_set32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x1f);
177 +}
178 +
179 +static void pciedev_crwlpciegen2_182(struct bcma_drv_pcie2 *pcie2)
180 +{
181 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_SBMBX);
182 +       pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 1 << 0);
183 +}
184 +
185 +static void pciedev_reg_pm_clk_period(struct bcma_drv_pcie2 *pcie2)
186 +{
187 +       struct bcma_drv_cc *drv_cc = &pcie2->core->bus->drv_cc;
188 +       u8 core_rev = pcie2->core->id.rev;
189 +       u32 alp_khz, pm_value;
190 +
191 +       if (core_rev <= 13) {
192 +               alp_khz = bcma_pmu_get_alp_clock(drv_cc) / 1000;
193 +               pm_value = (1000000 * 2) / alp_khz;
194 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
195 +                             PCIE2_PVT_REG_PM_CLK_PERIOD);
196 +               pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, pm_value);
197 +       }
198 +}
199 +
200 +void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
201 +{
202 +       struct bcma_chipinfo *ci = &pcie2->core->bus->chipinfo;
203 +       u32 tmp;
204 +
205 +       tmp = pcie2_read32(pcie2, BCMA_CORE_PCIE2_SPROM(54));
206 +       if ((tmp & 0xe) >> 1 == 2)
207 +               bcma_core_pcie2_cfg_write(pcie2, 0x4e0, 0x17);
208 +
209 +       /* TODO: Do we need pcie_reqsize? */
210 +
211 +       if (ci->id == BCMA_CHIP_ID_BCM4360 && ci->rev > 3)
212 +               bcma_core_pcie2_war_delay_perst_enab(pcie2, true);
213 +       bcma_core_pcie2_hw_ltr_war(pcie2);
214 +       pciedev_crwlpciegen2(pcie2);
215 +       pciedev_reg_pm_clk_period(pcie2);
216 +       pciedev_crwlpciegen2_180(pcie2);
217 +       pciedev_crwlpciegen2_182(pcie2);
218 +}
219 --- a/drivers/bcma/host_pci.c
220 +++ b/drivers/bcma/host_pci.c
221 @@ -279,6 +279,8 @@ static const struct pci_device_id bcma_p
222         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
223         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
224         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
225 +       { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
226 +       { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
227         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
228         { 0, },
229  };
230 --- a/drivers/bcma/main.c
231 +++ b/drivers/bcma/main.c
232 @@ -132,6 +132,7 @@ static int bcma_register_cores(struct bc
233                 case BCMA_CORE_CHIPCOMMON:
234                 case BCMA_CORE_PCI:
235                 case BCMA_CORE_PCIE:
236 +               case BCMA_CORE_PCIE2:
237                 case BCMA_CORE_MIPS_74K:
238                 case BCMA_CORE_4706_MAC_GBIT_COMMON:
239                         continue;
240 @@ -281,6 +282,13 @@ int bcma_bus_register(struct bcma_bus *b
241                 bcma_core_pci_init(&bus->drv_pci[1]);
242         }
243  
244 +       /* Init PCIe Gen 2 core */
245 +       core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0);
246 +       if (core) {
247 +               bus->drv_pcie2.core = core;
248 +               bcma_core_pcie2_init(&bus->drv_pcie2);
249 +       }
250 +
251         /* Init GBIT MAC COMMON core */
252         core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
253         if (core) {
254 --- a/drivers/bcma/sprom.c
255 +++ b/drivers/bcma/sprom.c
256 @@ -201,6 +201,23 @@ static int bcma_sprom_valid(struct bcma_
257                 SPEX(_field[7], _offset + 14, _mask, _shift);   \
258         } while (0)
259  
260 +static s8 sprom_extract_antgain(const u16 *in, u16 offset, u16 mask, u16 shift)
261 +{
262 +       u16 v;
263 +       u8 gain;
264 +
265 +       v = in[SPOFF(offset)];
266 +       gain = (v & mask) >> shift;
267 +       if (gain == 0xFF) {
268 +               gain = 8; /* If unset use 2dBm */
269 +       } else {
270 +               /* Q5.2 Fractional part is stored in 0xC0 */
271 +               gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2);
272 +       }
273 +
274 +       return (s8)gain;
275 +}
276 +
277  static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
278  {
279         u16 v, o;
280 @@ -381,14 +398,22 @@ static void bcma_sprom_extract_r8(struct
281         SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0);
282  
283         /* Extract the antenna gain values. */
284 -       SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
285 -            SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
286 -       SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
287 -            SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
288 -       SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
289 -            SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
290 -       SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
291 -            SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
292 +       bus->sprom.antenna_gain.a0 = sprom_extract_antgain(sprom,
293 +                                                          SSB_SPROM8_AGAIN01,
294 +                                                          SSB_SPROM8_AGAIN0,
295 +                                                          SSB_SPROM8_AGAIN0_SHIFT);
296 +       bus->sprom.antenna_gain.a1 = sprom_extract_antgain(sprom,
297 +                                                          SSB_SPROM8_AGAIN01,
298 +                                                          SSB_SPROM8_AGAIN1,
299 +                                                          SSB_SPROM8_AGAIN1_SHIFT);
300 +       bus->sprom.antenna_gain.a2 = sprom_extract_antgain(sprom,
301 +                                                          SSB_SPROM8_AGAIN23,
302 +                                                          SSB_SPROM8_AGAIN2,
303 +                                                          SSB_SPROM8_AGAIN2_SHIFT);
304 +       bus->sprom.antenna_gain.a3 = sprom_extract_antgain(sprom,
305 +                                                          SSB_SPROM8_AGAIN23,
306 +                                                          SSB_SPROM8_AGAIN3,
307 +                                                          SSB_SPROM8_AGAIN3_SHIFT);
308  
309         SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
310              SSB_SPROM8_LEDDC_ON_SHIFT);
311 @@ -509,6 +534,8 @@ static bool bcma_sprom_onchip_available(
312                 /* for these chips OTP is always available */
313                 present = true;
314                 break;
315 +       case BCMA_CHIP_ID_BCM43131:
316 +       case BCMA_CHIP_ID_BCM43217:
317         case BCMA_CHIP_ID_BCM43227:
318         case BCMA_CHIP_ID_BCM43228:
319         case BCMA_CHIP_ID_BCM43428:
320 --- a/include/linux/bcma/bcma.h
321 +++ b/include/linux/bcma/bcma.h
322 @@ -6,6 +6,7 @@
323  
324  #include <linux/bcma/bcma_driver_chipcommon.h>
325  #include <linux/bcma/bcma_driver_pci.h>
326 +#include <linux/bcma/bcma_driver_pcie2.h>
327  #include <linux/bcma/bcma_driver_mips.h>
328  #include <linux/bcma/bcma_driver_gmac_cmn.h>
329  #include <linux/ssb/ssb.h> /* SPROM sharing */
330 @@ -72,17 +73,17 @@ struct bcma_host_ops {
331  /* Core-ID values. */
332  #define BCMA_CORE_OOB_ROUTER           0x367   /* Out of band */
333  #define BCMA_CORE_4706_CHIPCOMMON      0x500
334 -#define BCMA_CORE_PCIEG2               0x501
335 -#define BCMA_CORE_DMA                  0x502
336 -#define BCMA_CORE_SDIO3                        0x503
337 -#define BCMA_CORE_USB20                        0x504
338 -#define BCMA_CORE_USB30                        0x505
339 -#define BCMA_CORE_A9JTAG               0x506
340 -#define BCMA_CORE_DDR23                        0x507
341 -#define BCMA_CORE_ROM                  0x508
342 -#define BCMA_CORE_NAND                 0x509
343 -#define BCMA_CORE_QSPI                 0x50A
344 -#define BCMA_CORE_CHIPCOMMON_B         0x50B
345 +#define BCMA_CORE_NS_PCIEG2            0x501
346 +#define BCMA_CORE_NS_DMA               0x502
347 +#define BCMA_CORE_NS_SDIO3             0x503
348 +#define BCMA_CORE_NS_USB20             0x504
349 +#define BCMA_CORE_NS_USB30             0x505
350 +#define BCMA_CORE_NS_A9JTAG            0x506
351 +#define BCMA_CORE_NS_DDR23             0x507
352 +#define BCMA_CORE_NS_ROM               0x508
353 +#define BCMA_CORE_NS_NAND              0x509
354 +#define BCMA_CORE_NS_QSPI              0x50A
355 +#define BCMA_CORE_NS_CHIPCOMMON_B      0x50B
356  #define BCMA_CORE_4706_SOC_RAM         0x50E
357  #define BCMA_CORE_ARMCA9               0x510
358  #define BCMA_CORE_4706_MAC_GBIT                0x52D
359 @@ -157,6 +158,9 @@ struct bcma_host_ops {
360  /* Chip IDs of PCIe devices */
361  #define BCMA_CHIP_ID_BCM4313   0x4313
362  #define BCMA_CHIP_ID_BCM43142  43142
363 +#define BCMA_CHIP_ID_BCM43131  43131
364 +#define BCMA_CHIP_ID_BCM43217  43217
365 +#define BCMA_CHIP_ID_BCM43222  43222
366  #define BCMA_CHIP_ID_BCM43224  43224
367  #define  BCMA_PKG_ID_BCM43224_FAB_CSM  0x8
368  #define  BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
369 @@ -333,6 +337,7 @@ struct bcma_bus {
370  
371         struct bcma_drv_cc drv_cc;
372         struct bcma_drv_pci drv_pci[2];
373 +       struct bcma_drv_pcie2 drv_pcie2;
374         struct bcma_drv_mips drv_mips;
375         struct bcma_drv_gmac_cmn drv_gmac_cmn;
376  
377 --- /dev/null
378 +++ b/include/linux/bcma/bcma_driver_pcie2.h
379 @@ -0,0 +1,158 @@
380 +#ifndef LINUX_BCMA_DRIVER_PCIE2_H_
381 +#define LINUX_BCMA_DRIVER_PCIE2_H_
382 +
383 +#define BCMA_CORE_PCIE2_CLK_CONTROL            0x0000
384 +#define  PCIE2_CLKC_RST_OE                     0x0001 /* When set, drives PCI_RESET out to pin */
385 +#define  PCIE2_CLKC_RST                                0x0002 /* Value driven out to pin */
386 +#define  PCIE2_CLKC_SPERST                     0x0004 /* SurvivePeRst */
387 +#define  PCIE2_CLKC_DISABLE_L1CLK_GATING       0x0010
388 +#define  PCIE2_CLKC_DLYPERST                   0x0100 /* Delay PeRst to CoE Core */
389 +#define  PCIE2_CLKC_DISSPROMLD                 0x0200 /* DisableSpromLoadOnPerst */
390 +#define  PCIE2_CLKC_WAKE_MODE_L2               0x1000 /* Wake on L2 */
391 +#define BCMA_CORE_PCIE2_RC_PM_CONTROL          0x0004
392 +#define BCMA_CORE_PCIE2_RC_PM_STATUS           0x0008
393 +#define BCMA_CORE_PCIE2_EP_PM_CONTROL          0x000C
394 +#define BCMA_CORE_PCIE2_EP_PM_STATUS           0x0010
395 +#define BCMA_CORE_PCIE2_EP_LTR_CONTROL         0x0014
396 +#define BCMA_CORE_PCIE2_EP_LTR_STATUS          0x0018
397 +#define BCMA_CORE_PCIE2_EP_OBFF_STATUS         0x001C
398 +#define BCMA_CORE_PCIE2_PCIE_ERR_STATUS                0x0020
399 +#define BCMA_CORE_PCIE2_RC_AXI_CONFIG          0x0100
400 +#define BCMA_CORE_PCIE2_EP_AXI_CONFIG          0x0104
401 +#define BCMA_CORE_PCIE2_RXDEBUG_STATUS0                0x0108
402 +#define BCMA_CORE_PCIE2_RXDEBUG_CONTROL0       0x010C
403 +#define BCMA_CORE_PCIE2_CONFIGINDADDR          0x0120
404 +#define BCMA_CORE_PCIE2_CONFIGINDDATA          0x0124
405 +#define BCMA_CORE_PCIE2_MDIOCONTROL            0x0128
406 +#define BCMA_CORE_PCIE2_MDIOWRDATA             0x012C
407 +#define BCMA_CORE_PCIE2_MDIORDDATA             0x0130
408 +#define BCMA_CORE_PCIE2_DATAINTF               0x0180
409 +#define BCMA_CORE_PCIE2_D2H_INTRLAZY_0         0x0188
410 +#define BCMA_CORE_PCIE2_H2D_INTRLAZY_0         0x018c
411 +#define BCMA_CORE_PCIE2_H2D_INTSTAT_0          0x0190
412 +#define BCMA_CORE_PCIE2_H2D_INTMASK_0          0x0194
413 +#define BCMA_CORE_PCIE2_D2H_INTSTAT_0          0x0198
414 +#define BCMA_CORE_PCIE2_D2H_INTMASK_0          0x019c
415 +#define BCMA_CORE_PCIE2_LTR_STATE              0x01A0 /* Latency Tolerance Reporting */
416 +#define  PCIE2_LTR_ACTIVE                      2
417 +#define  PCIE2_LTR_ACTIVE_IDLE                 1
418 +#define  PCIE2_LTR_SLEEP                       0
419 +#define  PCIE2_LTR_FINAL_MASK                  0x300
420 +#define  PCIE2_LTR_FINAL_SHIFT                 8
421 +#define BCMA_CORE_PCIE2_PWR_INT_STATUS         0x01A4
422 +#define BCMA_CORE_PCIE2_PWR_INT_MASK           0x01A8
423 +#define BCMA_CORE_PCIE2_CFG_ADDR               0x01F8
424 +#define BCMA_CORE_PCIE2_CFG_DATA               0x01FC
425 +#define BCMA_CORE_PCIE2_SYS_EQ_PAGE            0x0200
426 +#define BCMA_CORE_PCIE2_SYS_MSI_PAGE           0x0204
427 +#define BCMA_CORE_PCIE2_SYS_MSI_INTREN         0x0208
428 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL0          0x0210
429 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL1          0x0214
430 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL2          0x0218
431 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL3          0x021C
432 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL4          0x0220
433 +#define BCMA_CORE_PCIE2_SYS_MSI_CTRL5          0x0224
434 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD0           0x0250
435 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL0           0x0254
436 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD1           0x0258
437 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL1           0x025C
438 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD2           0x0260
439 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL2           0x0264
440 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD3           0x0268
441 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL3           0x026C
442 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD4           0x0270
443 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL4           0x0274
444 +#define BCMA_CORE_PCIE2_SYS_EQ_HEAD5           0x0278
445 +#define BCMA_CORE_PCIE2_SYS_EQ_TAIL5           0x027C
446 +#define BCMA_CORE_PCIE2_SYS_RC_INTX_EN         0x0330
447 +#define BCMA_CORE_PCIE2_SYS_RC_INTX_CSR                0x0334
448 +#define BCMA_CORE_PCIE2_SYS_MSI_REQ            0x0340
449 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR_EN       0x0344
450 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR_CSR      0x0348
451 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR0         0x0350
452 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR1         0x0354
453 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR2         0x0358
454 +#define BCMA_CORE_PCIE2_SYS_HOST_INTR3         0x035C
455 +#define BCMA_CORE_PCIE2_SYS_EP_INT_EN0         0x0360
456 +#define BCMA_CORE_PCIE2_SYS_EP_INT_EN1         0x0364
457 +#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR0                0x0370
458 +#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR1                0x0374
459 +#define BCMA_CORE_PCIE2_SPROM(wordoffset)      (0x0800 + ((wordoffset) * 2))
460 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_0          0x0C00
461 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_1          0x0C04
462 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_2          0x0C08
463 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_3          0x0C0C
464 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_4          0x0C10
465 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_5          0x0C14
466 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_6          0x0C18
467 +#define BCMA_CORE_PCIE2_FUNC0_IMAP0_7          0x0C1C
468 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_0          0x0C20
469 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_1          0x0C24
470 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_2          0x0C28
471 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_3          0x0C2C
472 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_4          0x0C30
473 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_5          0x0C34
474 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_6          0x0C38
475 +#define BCMA_CORE_PCIE2_FUNC1_IMAP0_7          0x0C3C
476 +#define BCMA_CORE_PCIE2_FUNC0_IMAP1            0x0C80
477 +#define BCMA_CORE_PCIE2_FUNC1_IMAP1            0x0C88
478 +#define BCMA_CORE_PCIE2_FUNC0_IMAP2            0x0CC0
479 +#define BCMA_CORE_PCIE2_FUNC1_IMAP2            0x0CC8
480 +#define BCMA_CORE_PCIE2_IARR0_LOWER            0x0D00
481 +#define BCMA_CORE_PCIE2_IARR0_UPPER            0x0D04
482 +#define BCMA_CORE_PCIE2_IARR1_LOWER            0x0D08
483 +#define BCMA_CORE_PCIE2_IARR1_UPPER            0x0D0C
484 +#define BCMA_CORE_PCIE2_IARR2_LOWER            0x0D10
485 +#define BCMA_CORE_PCIE2_IARR2_UPPER            0x0D14
486 +#define BCMA_CORE_PCIE2_OARR0                  0x0D20
487 +#define BCMA_CORE_PCIE2_OARR1                  0x0D28
488 +#define BCMA_CORE_PCIE2_OARR2                  0x0D30
489 +#define BCMA_CORE_PCIE2_OMAP0_LOWER            0x0D40
490 +#define BCMA_CORE_PCIE2_OMAP0_UPPER            0x0D44
491 +#define BCMA_CORE_PCIE2_OMAP1_LOWER            0x0D48
492 +#define BCMA_CORE_PCIE2_OMAP1_UPPER            0x0D4C
493 +#define BCMA_CORE_PCIE2_OMAP2_LOWER            0x0D50
494 +#define BCMA_CORE_PCIE2_OMAP2_UPPER            0x0D54
495 +#define BCMA_CORE_PCIE2_FUNC1_IARR1_SIZE       0x0D58
496 +#define BCMA_CORE_PCIE2_FUNC1_IARR2_SIZE       0x0D5C
497 +#define BCMA_CORE_PCIE2_MEM_CONTROL            0x0F00
498 +#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG0                0x0F04
499 +#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG1                0x0F08
500 +#define BCMA_CORE_PCIE2_LINK_STATUS            0x0F0C
501 +#define BCMA_CORE_PCIE2_STRAP_STATUS           0x0F10
502 +#define BCMA_CORE_PCIE2_RESET_STATUS           0x0F14
503 +#define BCMA_CORE_PCIE2_RESETEN_IN_LINKDOWN    0x0F18
504 +#define BCMA_CORE_PCIE2_MISC_INTR_EN           0x0F1C
505 +#define BCMA_CORE_PCIE2_TX_DEBUG_CFG           0x0F20
506 +#define BCMA_CORE_PCIE2_MISC_CONFIG            0x0F24
507 +#define BCMA_CORE_PCIE2_MISC_STATUS            0x0F28
508 +#define BCMA_CORE_PCIE2_INTR_EN                        0x0F30
509 +#define BCMA_CORE_PCIE2_INTR_CLEAR             0x0F34
510 +#define BCMA_CORE_PCIE2_INTR_STATUS            0x0F38
511 +
512 +/* PCIE gen2 config regs */
513 +#define PCIE2_INTSTATUS                                0x090
514 +#define PCIE2_INTMASK                          0x094
515 +#define PCIE2_SBMBX                            0x098
516 +
517 +#define PCIE2_PMCR_REFUP                       0x1814 /* Trefup time */
518 +
519 +#define PCIE2_CAP_DEVSTSCTRL2_OFFSET           0xD4
520 +#define PCIE2_CAP_DEVSTSCTRL2_LTRENAB          0x400
521 +#define PCIE2_PVT_REG_PM_CLK_PERIOD            0x184c
522 +
523 +struct bcma_drv_pcie2 {
524 +       struct bcma_device *core;
525 +};
526 +
527 +#define pcie2_read16(pcie2, offset)            bcma_read16((pcie2)->core, offset)
528 +#define pcie2_read32(pcie2, offset)            bcma_read32((pcie2)->core, offset)
529 +#define pcie2_write16(pcie2, offset, val)      bcma_write16((pcie2)->core, offset, val)
530 +#define pcie2_write32(pcie2, offset, val)      bcma_write32((pcie2)->core, offset, val)
531 +
532 +#define pcie2_set32(pcie2, offset, set)                bcma_set32((pcie2)->core, offset, set)
533 +#define pcie2_mask32(pcie2, offset, mask)      bcma_mask32((pcie2)->core, offset, mask)
534 +
535 +void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
536 +
537 +#endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */
538 --- a/drivers/bcma/scan.c
539 +++ b/drivers/bcma/scan.c
540 @@ -32,17 +32,17 @@ static const struct bcma_device_id_name
541         { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
542         { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
543         { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
544 -       { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
545 -       { BCMA_CORE_DMA, "DMA" },
546 -       { BCMA_CORE_SDIO3, "SDIO3" },
547 -       { BCMA_CORE_USB20, "USB 2.0" },
548 -       { BCMA_CORE_USB30, "USB 3.0" },
549 -       { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
550 -       { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
551 -       { BCMA_CORE_ROM, "ROM" },
552 -       { BCMA_CORE_NAND, "NAND flash controller" },
553 -       { BCMA_CORE_QSPI, "SPI flash controller" },
554 -       { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
555 +       { BCMA_CORE_NS_PCIEG2, "PCIe Gen 2" },
556 +       { BCMA_CORE_NS_DMA, "DMA" },
557 +       { BCMA_CORE_NS_SDIO3, "SDIO3" },
558 +       { BCMA_CORE_NS_USB20, "USB 2.0" },
559 +       { BCMA_CORE_NS_USB30, "USB 3.0" },
560 +       { BCMA_CORE_NS_A9JTAG, "ARM Cortex A9 JTAG" },
561 +       { BCMA_CORE_NS_DDR23, "Denali DDR2/DDR3 memory controller" },
562 +       { BCMA_CORE_NS_ROM, "ROM" },
563 +       { BCMA_CORE_NS_NAND, "NAND flash controller" },
564 +       { BCMA_CORE_NS_QSPI, "SPI flash controller" },
565 +       { BCMA_CORE_NS_CHIPCOMMON_B, "Chipcommon B" },
566         { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
567         { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
568         { BCMA_CORE_ALTA, "ALTA (I2S)" },