Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hauke Mehrtens and committed by
John W. Linville
1716bcf3 23a2f39c

+86
+1
drivers/bcma/Makefile
··· 1 1 bcma-y += main.o scan.o core.o sprom.o 2 2 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o 3 + bcma-y += driver_chipcommon_b.o 3 4 bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o 4 5 bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o 5 6 bcma-y += driver_pci.o
+4
drivers/bcma/bcma_private.h
··· 50 50 extern struct platform_device bcma_pflash_dev; 51 51 #endif /* CONFIG_BCMA_DRIVER_MIPS */ 52 52 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 + 53 57 /* driver_chipcommon_pmu.c */ 54 58 u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc); 55 59 u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
+61
drivers/bcma/driver_chipcommon_b.c
··· 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 + }
+10
drivers/bcma/main.c
··· 173 173 switch (core->id.id) { 174 174 case BCMA_CORE_4706_CHIPCOMMON: 175 175 case BCMA_CORE_CHIPCOMMON: 176 + case BCMA_CORE_NS_CHIPCOMMON_B: 176 177 case BCMA_CORE_PCI: 177 178 case BCMA_CORE_PCIE: 178 179 case BCMA_CORE_PCIE2: ··· 288 287 bcma_core_chipcommon_init(&bus->drv_cc); 289 288 } 290 289 290 + /* Init CC core */ 291 + core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B); 292 + if (core) { 293 + bus->drv_cc_b.core = core; 294 + bcma_core_chipcommon_b_init(&bus->drv_cc_b); 295 + } 296 + 291 297 /* Init MIPS core */ 292 298 core = bcma_find_core(bus, BCMA_CORE_MIPS_74K); 293 299 if (core) { ··· 348 340 bcma_err(bus, "Some GPIOs are still in use.\n"); 349 341 else if (err) 350 342 bcma_err(bus, "Can not unregister GPIO driver: %i\n", err); 343 + 344 + bcma_core_chipcommon_b_free(&bus->drv_cc_b); 351 345 352 346 cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K); 353 347 cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
+1
drivers/bcma/scan.c
··· 314 314 /* Some specific cores don't need wrappers */ 315 315 switch (core->id.id) { 316 316 case BCMA_CORE_4706_MAC_GBIT_COMMON: 317 + case BCMA_CORE_NS_CHIPCOMMON_B: 317 318 /* Not used yet: case BCMA_CORE_OOB_ROUTER: */ 318 319 break; 319 320 default:
+1
include/linux/bcma/bcma.h
··· 335 335 u8 num; 336 336 337 337 struct bcma_drv_cc drv_cc; 338 + struct bcma_drv_cc_b drv_cc_b; 338 339 struct bcma_drv_pci drv_pci[2]; 339 340 struct bcma_drv_pcie2 drv_pcie2; 340 341 struct bcma_drv_mips drv_mips;
+8
include/linux/bcma/bcma_driver_chipcommon.h
··· 644 644 #endif 645 645 }; 646 646 647 + struct bcma_drv_cc_b { 648 + struct bcma_device *core; 649 + u8 setup_done:1; 650 + void __iomem *mii; 651 + }; 652 + 647 653 /* Register access */ 648 654 #define bcma_cc_read32(cc, offset) \ 649 655 bcma_read32((cc)->core, offset) ··· 704 698 extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid); 705 699 706 700 extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc); 701 + 702 + void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value); 707 703 708 704 #endif /* LINUX_BCMA_DRIVER_CC_H_ */