aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2014-09-08 16:53:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-09-09 15:33:05 -0400
commit1716bcf3f76fe71e98d4851a3eb73ea3d93d4773 (patch)
tree03a57cb6102db536a6da6811f9eb549bf8cfddb6 /drivers/bcma
parent23a2f39c8f4035eade7f226eb7ada30c78d9eee3 (diff)
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>
Diffstat (limited to 'drivers/bcma')
-rw-r--r--drivers/bcma/Makefile1
-rw-r--r--drivers/bcma/bcma_private.h4
-rw-r--r--drivers/bcma/driver_chipcommon_b.c61
-rw-r--r--drivers/bcma/main.c10
-rw-r--r--drivers/bcma/scan.c1
5 files changed, 77 insertions, 0 deletions
diff --git a/drivers/bcma/Makefile b/drivers/bcma/Makefile
index 91290f7f61b8..838b4b9d352f 100644
--- a/drivers/bcma/Makefile
+++ b/drivers/bcma/Makefile
@@ -1,5 +1,6 @@
1bcma-y += main.o scan.o core.o sprom.o 1bcma-y += main.o scan.o core.o sprom.o
2bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 2bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
3bcma-y += driver_chipcommon_b.o
3bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 4bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
4bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 5bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
5bcma-y += driver_pci.o 6bcma-y += driver_pci.o
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 09b632ad0fe2..b40be43c6f31 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -50,6 +50,10 @@ void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
50extern struct platform_device bcma_pflash_dev; 50extern struct platform_device bcma_pflash_dev;
51#endif /* CONFIG_BCMA_DRIVER_MIPS */ 51#endif /* CONFIG_BCMA_DRIVER_MIPS */
52 52
53/* driver_chipcommon_b.c */
54int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
55void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
56
53/* driver_chipcommon_pmu.c */ 57/* driver_chipcommon_pmu.c */
54u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); 58u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
55u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc); 59u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
diff --git a/drivers/bcma/driver_chipcommon_b.c b/drivers/bcma/driver_chipcommon_b.c
new file mode 100644
index 000000000000..c20b5f4ff290
--- /dev/null
+++ b/drivers/bcma/driver_chipcommon_b.c
@@ -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
14static 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
33void 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}
42EXPORT_SYMBOL_GPL(bcma_chipco_b_mii_write);
43
44int 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
57void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb)
58{
59 if (ccb->mii)
60 iounmap(ccb->mii);
61}
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 297a2d46985a..c421403cab43 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -173,6 +173,7 @@ static int bcma_register_devices(struct bcma_bus *bus)
173 switch (core->id.id) { 173 switch (core->id.id) {
174 case BCMA_CORE_4706_CHIPCOMMON: 174 case BCMA_CORE_4706_CHIPCOMMON:
175 case BCMA_CORE_CHIPCOMMON: 175 case BCMA_CORE_CHIPCOMMON:
176 case BCMA_CORE_NS_CHIPCOMMON_B:
176 case BCMA_CORE_PCI: 177 case BCMA_CORE_PCI:
177 case BCMA_CORE_PCIE: 178 case BCMA_CORE_PCIE:
178 case BCMA_CORE_PCIE2: 179 case BCMA_CORE_PCIE2:
@@ -287,6 +288,13 @@ int bcma_bus_register(struct bcma_bus *bus)
287 bcma_core_chipcommon_init(&bus->drv_cc); 288 bcma_core_chipcommon_init(&bus->drv_cc);
288 } 289 }
289 290
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
290 /* Init MIPS core */ 298 /* Init MIPS core */
291 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); 299 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
292 if (core) { 300 if (core) {
@@ -341,6 +349,8 @@ void bcma_bus_unregister(struct bcma_bus *bus)
341 else if (err) 349 else if (err)
342 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err); 350 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
343 351
352 bcma_core_chipcommon_b_free(&bus->drv_cc_b);
353
344 cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K); 354 cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
345 cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE); 355 cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
346 cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); 356 cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 06be7282cbc4..b3a403c136fb 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -314,6 +314,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
314 /* Some specific cores don't need wrappers */ 314 /* Some specific cores don't need wrappers */
315 switch (core->id.id) { 315 switch (core->id.id) {
316 case BCMA_CORE_4706_MAC_GBIT_COMMON: 316 case BCMA_CORE_4706_MAC_GBIT_COMMON:
317 case BCMA_CORE_NS_CHIPCOMMON_B:
317 /* Not used yet: case BCMA_CORE_OOB_ROUTER: */ 318 /* Not used yet: case BCMA_CORE_OOB_ROUTER: */
318 break; 319 break;
319 default: 320 default: