aboutsummaryrefslogtreecommitdiffstats
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
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>
-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
-rw-r--r--include/linux/bcma/bcma.h1
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h8
7 files changed, 86 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:
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 7fc16c991291..634597917670 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -335,6 +335,7 @@ struct bcma_bus {
335 u8 num; 335 u8 num;
336 336
337 struct bcma_drv_cc drv_cc; 337 struct bcma_drv_cc drv_cc;
338 struct bcma_drv_cc_b drv_cc_b;
338 struct bcma_drv_pci drv_pci[2]; 339 struct bcma_drv_pci drv_pci[2];
339 struct bcma_drv_pcie2 drv_pcie2; 340 struct bcma_drv_pcie2 drv_pcie2;
340 struct bcma_drv_mips drv_mips; 341 struct bcma_drv_mips drv_mips;
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 63d105cd14a3..db6fa217f98b 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -644,6 +644,12 @@ struct bcma_drv_cc {
644#endif 644#endif
645}; 645};
646 646
647struct bcma_drv_cc_b {
648 struct bcma_device *core;
649 u8 setup_done:1;
650 void __iomem *mii;
651};
652
647/* Register access */ 653/* Register access */
648#define bcma_cc_read32(cc, offset) \ 654#define bcma_cc_read32(cc, offset) \
649 bcma_read32((cc)->core, offset) 655 bcma_read32((cc)->core, offset)
@@ -699,4 +705,6 @@ extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
699 705
700extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc); 706extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
701 707
708void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value);
709
702#endif /* LINUX_BCMA_DRIVER_CC_H_ */ 710#endif /* LINUX_BCMA_DRIVER_CC_H_ */