Skip to content

Commit 1716bcf

Browse files
haukelinvjw
authored andcommitted
bcma: add support for chipcommon B core
This core is used on BCM4708 to configure the PCIe and USB3 PHYs and it contains the addresses to the Device Management unit. This will be used by the PCIe driver first. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 23a2f39 commit 1716bcf

7 files changed

Lines changed: 86 additions & 0 deletions

File tree

‎drivers/bcma/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bcma-y += main.o scan.o core.o sprom.o
22
bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
3+
bcma-y += driver_chipcommon_b.o
34
bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
45
bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
56
bcma-y += driver_pci.o

‎drivers/bcma/bcma_private.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
5050
extern struct platform_device bcma_pflash_dev;
5151
#endif /* CONFIG_BCMA_DRIVER_MIPS */
5252

53+
/* driver_chipcommon_b.c */
54+
int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
55+
void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
56+
5357
/* driver_chipcommon_pmu.c */
5458
u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
5559
u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);

‎drivers/bcma/driver_chipcommon_b.c‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Broadcom specific AMBA
3+
* ChipCommon B Unit driver
4+
*
5+
* Copyright 2014, Hauke Mehrtens <hauke@hauke-m.de>
6+
*
7+
* Licensed under the GNU/GPL. See COPYING for details.
8+
*/
9+
10+
#include "bcma_private.h"
11+
#include <linux/export.h>
12+
#include <linux/bcma/bcma.h>
13+
14+
static bool bcma_wait_reg(struct bcma_bus *bus, void __iomem *addr, u32 mask,
15+
u32 value, int timeout)
16+
{
17+
unsigned long deadline = jiffies + timeout;
18+
u32 val;
19+
20+
do {
21+
val = readl(addr);
22+
if ((val & mask) == value)
23+
return true;
24+
cpu_relax();
25+
udelay(10);
26+
} while (!time_after_eq(jiffies, deadline));
27+
28+
bcma_err(bus, "Timeout waiting for register %p\n", addr);
29+
30+
return false;
31+
}
32+
33+
void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value)
34+
{
35+
struct bcma_bus *bus = ccb->core->bus;
36+
37+
writel(offset, ccb->mii + 0x00);
38+
bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100);
39+
writel(value, ccb->mii + 0x04);
40+
bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100);
41+
}
42+
EXPORT_SYMBOL_GPL(bcma_chipco_b_mii_write);
43+
44+
int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb)
45+
{
46+
if (ccb->setup_done)
47+
return 0;
48+
49+
ccb->setup_done = 1;
50+
ccb->mii = ioremap_nocache(ccb->core->addr_s[1], BCMA_CORE_SIZE);
51+
if (!ccb->mii)
52+
return -ENOMEM;
53+
54+
return 0;
55+
}
56+
57+
void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb)
58+
{
59+
if (ccb->mii)
60+
iounmap(ccb->mii);
61+
}

‎drivers/bcma/main.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static int bcma_register_devices(struct bcma_bus *bus)
173173
switch (core->id.id) {
174174
case BCMA_CORE_4706_CHIPCOMMON:
175175
case BCMA_CORE_CHIPCOMMON:
176+
case BCMA_CORE_NS_CHIPCOMMON_B:
176177
case BCMA_CORE_PCI:
177178
case BCMA_CORE_PCIE:
178179
case BCMA_CORE_PCIE2:
@@ -287,6 +288,13 @@ int bcma_bus_register(struct bcma_bus *bus)
287288
bcma_core_chipcommon_init(&bus->drv_cc);
288289
}
289290

291+
/* Init CC core */
292+
core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B);
293+
if (core) {
294+
bus->drv_cc_b.core = core;
295+
bcma_core_chipcommon_b_init(&bus->drv_cc_b);
296+
}
297+
290298
/* Init MIPS core */
291299
core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
292300
if (core) {
@@ -341,6 +349,8 @@ void bcma_bus_unregister(struct bcma_bus *bus)
341349
else if (err)
342350
bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
343351

352+
bcma_core_chipcommon_b_free(&bus->drv_cc_b);
353+
344354
cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
345355
cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
346356
cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);

‎drivers/bcma/scan.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
314314
/* Some specific cores don't need wrappers */
315315
switch (core->id.id) {
316316
case BCMA_CORE_4706_MAC_GBIT_COMMON:
317+
case BCMA_CORE_NS_CHIPCOMMON_B:
317318
/* Not used yet: case BCMA_CORE_OOB_ROUTER: */
318319
break;
319320
default:

‎include/linux/bcma/bcma.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ struct bcma_bus {
335335
u8 num;
336336

337337
struct bcma_drv_cc drv_cc;
338+
struct bcma_drv_cc_b drv_cc_b;
338339
struct bcma_drv_pci drv_pci[2];
339340
struct bcma_drv_pcie2 drv_pcie2;
340341
struct bcma_drv_mips drv_mips;

‎include/linux/bcma/bcma_driver_chipcommon.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ struct bcma_drv_cc {
644644
#endif
645645
};
646646

647+
struct bcma_drv_cc_b {
648+
struct bcma_device *core;
649+
u8 setup_done:1;
650+
void __iomem *mii;
651+
};
652+
647653
/* Register access */
648654
#define bcma_cc_read32(cc, offset) \
649655
bcma_read32((cc)->core, offset)
@@ -699,4 +705,6 @@ extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
699705

700706
extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
701707

708+
void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value);
709+
702710
#endif /* LINUX_BCMA_DRIVER_CC_H_ */

0 commit comments

Comments
 (0)