b43-dev.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] bcma misc updates
@ 2012-06-29 23:44 Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 1/9] bcma: extend workaround for bcm4331 Hauke Mehrtens
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

These are some updates for bcma. Some are extending or completing some 
workarounds for PCIe based wireless cards. A patch adds 
bcma_pmu_spuravoid_pllupdate, used by brcmsmac and an other patch adds 
constants for the chip ids. This code is mostly based on code from 
brcmsmac and the Broadcom SDK for BCM47XX SoCs.

This was tested on a BCM4718 SoC with a BCM43224 PCIe and a BCM5357.
The Wifi part of the BCM4718 and BCM43224 is more or less working with 
brcmsmac, which need some more patches for that, but it has low speed 
and some times or with some access points I still get errors. The wifi 
of the BCM5357 does not work.

These patches are based on current wireless-testing.

Hauke Mehrtens (9):
  bcma: extend workaround for bcm4331
  bcma: add constants for chip ids
  bcma: remove fix for 4329b0 bad LPOM is detection
  bcma: add PCI ID for BCM43224
  bcma: complete workaround for BCMA43224 and BCM4313
  bcma: remove bcma_pmu_{pll,swreg}_init()
  bcma: remove chip ids doing nothing from PMU initialization.
  bcma: add bcma_pmu_spuravoid_pllupdate()
  bcma: add mdelay bcma_pmu_resources_init()
  
v2:
  - remove start of workaround for BCM4329b0
  - remove bcma_pmu_pll_init() and bcma_pmu_swreg_init()
  - do not add all the SOCs to the switch case statements in 
    bcma_pmu_workarounds() and bcma_pmu_resources_init(), but make the 
    message displayed a debug message.
  - remove code for BCM6362, this chip uses a slightly different bus 
    from bcma and ssb.

 drivers/bcma/driver_chipcommon_pmu.c        |  317 ++++++++++++++++++++-------
 drivers/bcma/driver_mips.c                  |    8 +-
 drivers/bcma/driver_pci_host.c              |    8 +-
 drivers/bcma/host_pci.c                     |    1 +
 drivers/bcma/sprom.c                        |   18 +-
 include/linux/bcma/bcma.h                   |   30 +++
 include/linux/bcma/bcma_driver_chipcommon.h |   23 ++
 7 files changed, 310 insertions(+), 95 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/9] bcma: extend workaround for bcm4331
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 2/9] bcma: add constants for chip ids Hauke Mehrtens
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

This patch is based on a recent version of the Broadcom SDK.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c        |    3 +++
 include/linux/bcma/bcma_driver_chipcommon.h |    1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 61ce405..f18df1f 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -123,8 +123,11 @@ void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
 		val |= BCMA_CHIPCTL_4331_EXTPA_EN;
 		if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
 			val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
+		else if (bus->chipinfo.rev > 0)
+			val |= BCMA_CHIPCTL_4331_EXTPA_EN2;
 	} else {
 		val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
+		val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2;
 		val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
 	}
 	bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 8bbfe31..1e523cc 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -321,6 +321,7 @@
 #define BCMA_CHIPCTL_4331_OVR_PIPEAUXPWRDOWN	BIT(9)	/* override core control on pipe_AuxPowerDown */
 #define BCMA_CHIPCTL_4331_PCIE_AUXCLKEN		BIT(10)	/* pcie_auxclkenable */
 #define BCMA_CHIPCTL_4331_PCIE_PIPE_PLLDOWN	BIT(11)	/* pcie_pipe_pllpowerdown */
+#define BCMA_CHIPCTL_4331_EXTPA_EN2		BIT(12)	/* 0 ext pa disable, 1 ext pa enabled */
 #define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4	BIT(16)	/* enable bt_shd0 at gpio4 */
 #define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5	BIT(17)	/* enable bt_shd1 at gpio5 */
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/9] bcma: add constants for chip ids
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 1/9] bcma: extend workaround for bcm4331 Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 3/9] bcma: remove fix for 4329b0 bad LPOM is detection Hauke Mehrtens
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

The chip IDs are used all over bcma and no constants where defined.
This patch adds the constants and makes bcma use them.

Acked-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c |   81 +++++++++++++++++-----------------
 drivers/bcma/driver_mips.c           |    8 ++--
 drivers/bcma/driver_pci_host.c       |    8 ++--
 drivers/bcma/sprom.c                 |   18 ++++----
 include/linux/bcma/bcma.h            |   30 +++++++++++++
 5 files changed, 90 insertions(+), 55 deletions(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index f18df1f..89528cf 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -59,10 +59,10 @@ static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
 	struct bcma_bus *bus = cc->core->bus;
 
 	switch (bus->chipinfo.id) {
-	case 0x4313:
-	case 0x4331:
-	case 43224:
-	case 43225:
+	case BCMA_CHIP_ID_BCM4313:
+	case BCMA_CHIP_ID_BCM4331:
+	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43225:
 		break;
 	default:
 		pr_err("PLL init unknown for device 0x%04X\n",
@@ -76,13 +76,13 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 	u32 min_msk = 0, max_msk = 0;
 
 	switch (bus->chipinfo.id) {
-	case 0x4313:
+	case BCMA_CHIP_ID_BCM4313:
 		min_msk = 0x200D;
 		max_msk = 0xFFFF;
 		break;
-	case 0x4331:
-	case 43224:
-	case 43225:
+	case BCMA_CHIP_ID_BCM4331:
+	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43225:
 		break;
 	default:
 		pr_err("PMU resource config unknown for device 0x%04X\n",
@@ -101,10 +101,10 @@ void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
 	struct bcma_bus *bus = cc->core->bus;
 
 	switch (bus->chipinfo.id) {
-	case 0x4313:
-	case 0x4331:
-	case 43224:
-	case 43225:
+	case BCMA_CHIP_ID_BCM4313:
+	case BCMA_CHIP_ID_BCM4331:
+	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43225:
 		break;
 	default:
 		pr_err("PMU switch/regulators init unknown for device "
@@ -138,15 +138,15 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
 	struct bcma_bus *bus = cc->core->bus;
 
 	switch (bus->chipinfo.id) {
-	case 0x4313:
+	case BCMA_CHIP_ID_BCM4313:
 		bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
 		break;
-	case 0x4331:
-	case 43431:
+	case BCMA_CHIP_ID_BCM4331:
+	case BCMA_CHIP_ID_BCM43431:
 		/* Ext PA lines must be enabled for tx on BCM4331 */
 		bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
 		break;
-	case 43224:
+	case BCMA_CHIP_ID_BCM43224:
 		if (bus->chipinfo.rev == 0) {
 			pr_err("Workarounds for 43224 rev 0 not fully "
 				"implemented\n");
@@ -155,7 +155,7 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
 			bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
 		}
 		break;
-	case 43225:
+	case BCMA_CHIP_ID_BCM43225:
 		break;
 	default:
 		pr_err("Workarounds unknown for device 0x%04X\n",
@@ -194,17 +194,17 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
 	struct bcma_bus *bus = cc->core->bus;
 
 	switch (bus->chipinfo.id) {
-	case 0x4716:
-	case 0x4748:
-	case 47162:
-	case 0x4313:
-	case 0x5357:
-	case 0x4749:
-	case 53572:
+	case BCMA_CHIP_ID_BCM4716:
+	case BCMA_CHIP_ID_BCM4748:
+	case BCMA_CHIP_ID_BCM47162:
+	case BCMA_CHIP_ID_BCM4313:
+	case BCMA_CHIP_ID_BCM5357:
+	case BCMA_CHIP_ID_BCM4749:
+	case BCMA_CHIP_ID_BCM53572:
 		/* always 20Mhz */
 		return 20000 * 1000;
-	case 0x5356:
-	case 0x5300:
+	case BCMA_CHIP_ID_BCM5356:
+	case BCMA_CHIP_ID_BCM4706:
 		/* always 25Mhz */
 		return 25000 * 1000;
 	default:
@@ -227,7 +227,8 @@ static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
 
 	BUG_ON(!m || m > 4);
 
-	if (bus->chipinfo.id == 0x5357 || bus->chipinfo.id == 0x4749) {
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
+	    bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) {
 		/* Detect failure in clock setting */
 		tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
 		if (tmp & 0x40000)
@@ -259,22 +260,22 @@ u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
 	struct bcma_bus *bus = cc->core->bus;
 
 	switch (bus->chipinfo.id) {
-	case 0x4716:
-	case 0x4748:
-	case 47162:
+	case BCMA_CHIP_ID_BCM4716:
+	case BCMA_CHIP_ID_BCM4748:
+	case BCMA_CHIP_ID_BCM47162:
 		return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
 				      BCMA_CC_PMU5_MAINPLL_SSB);
-	case 0x5356:
+	case BCMA_CHIP_ID_BCM5356:
 		return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
 				      BCMA_CC_PMU5_MAINPLL_SSB);
-	case 0x5357:
-	case 0x4749:
+	case BCMA_CHIP_ID_BCM5357:
+	case BCMA_CHIP_ID_BCM4749:
 		return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
 				      BCMA_CC_PMU5_MAINPLL_SSB);
-	case 0x5300:
+	case BCMA_CHIP_ID_BCM4706:
 		return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
 				      BCMA_CC_PMU5_MAINPLL_SSB);
-	case 53572:
+	case BCMA_CHIP_ID_BCM53572:
 		return 75000000;
 	default:
 		pr_warn("No backplane clock specified for %04X device, "
@@ -289,17 +290,17 @@ u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
 {
 	struct bcma_bus *bus = cc->core->bus;
 
-	if (bus->chipinfo.id == 53572)
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
 		return 300000000;
 
 	if (cc->pmu.rev >= 5) {
 		u32 pll;
 		switch (bus->chipinfo.id) {
-		case 0x5356:
+		case BCMA_CHIP_ID_BCM5356:
 			pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
 			break;
-		case 0x5357:
-		case 0x4749:
+		case BCMA_CHIP_ID_BCM5357:
+		case BCMA_CHIP_ID_BCM4749:
 			pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
 			break;
 		default:
@@ -307,7 +308,7 @@ u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
 			break;
 		}
 
-		/* TODO: if (bus->chipinfo.id == 0x5300)
+		/* TODO: if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
 		  return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
 		return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
 	}
diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
index c3e9dff..73ed3017 100644
--- a/drivers/bcma/driver_mips.c
+++ b/drivers/bcma/driver_mips.c
@@ -22,15 +22,15 @@
 /* The 47162a0 hangs when reading MIPS DMP registers registers */
 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
 {
-	return dev->bus->chipinfo.id == 47162 && dev->bus->chipinfo.rev == 0 &&
-	       dev->id.id == BCMA_CORE_MIPS_74K;
+	return dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM47162 &&
+	       dev->bus->chipinfo.rev == 0 && dev->id.id == BCMA_CORE_MIPS_74K;
 }
 
 /* The 5357b0 hangs when reading USB20H DMP registers */
 static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev)
 {
-	return (dev->bus->chipinfo.id == 0x5357 ||
-		dev->bus->chipinfo.id == 0x4749) &&
+	return (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
+		dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) &&
 	       dev->bus->chipinfo.pkg == 11 &&
 	       dev->id.id == BCMA_CORE_USB20_HOST;
 }
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index b9a86ed..d6e8a37 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -215,7 +215,8 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 	} else {
 		writel(val, mmio);
 
-		if (chipid == 0x4716 || chipid == 0x4748)
+		if (chipid == BCMA_CHIP_ID_BCM4716 ||
+		    chipid == BCMA_CHIP_ID_BCM4748)
 			readl(mmio);
 	}
 
@@ -434,13 +435,14 @@ void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
 	 * as mips can't generate 64-bit address on the
 	 * backplane.
 	 */
-	if (bus->chipinfo.id == 0x4716 || bus->chipinfo.id == 0x4748) {
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4716 ||
+	    bus->chipinfo.id == BCMA_CHIP_ID_BCM4748) {
 		pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
 		pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
 					    BCMA_SOC_PCI_MEM_SZ - 1;
 		pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
 				BCMA_CORE_PCI_SBTOPCI_MEM | BCMA_SOC_PCI_MEM);
-	} else if (bus->chipinfo.id == 0x5300) {
+	} else if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
 		tmp = BCMA_CORE_PCI_SBTOPCI_MEM;
 		tmp |= BCMA_CORE_PCI_SBTOPCI_PREF;
 		tmp |= BCMA_CORE_PCI_SBTOPCI_BURST;
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index f16f42d..e1eb598 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -468,11 +468,11 @@ static bool bcma_sprom_ext_available(struct bcma_bus *bus)
 	/* older chipcommon revisions use chip status register */
 	chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
 	switch (bus->chipinfo.id) {
-	case 0x4313:
+	case BCMA_CHIP_ID_BCM4313:
 		present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT;
 		break;
 
-	case 0x4331:
+	case BCMA_CHIP_ID_BCM4331:
 		present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT;
 		break;
 
@@ -494,16 +494,16 @@ static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
 
 	chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
 	switch (bus->chipinfo.id) {
-	case 0x4313:
+	case BCMA_CHIP_ID_BCM4313:
 		present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT;
 		break;
 
-	case 0x4331:
+	case BCMA_CHIP_ID_BCM4331:
 		present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
 		break;
 
-	case 43224:
-	case 43225:
+	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43225:
 		/* for these chips OTP is always available */
 		present = true;
 		break;
@@ -579,13 +579,15 @@ int bcma_sprom_get(struct bcma_bus *bus)
 	if (!sprom)
 		return -ENOMEM;
 
-	if (bus->chipinfo.id == 0x4331 || bus->chipinfo.id == 43431)
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
+	    bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
 		bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
 
 	pr_debug("SPROM offset 0x%x\n", offset);
 	bcma_sprom_read(bus, offset, sprom);
 
-	if (bus->chipinfo.id == 0x4331 || bus->chipinfo.id == 43431)
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
+	    bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
 		bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
 
 	err = bcma_sprom_valid(sprom);
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 12334f9..03b2f30 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -137,6 +137,36 @@ struct bcma_host_ops {
 
 #define BCMA_MAX_NR_CORES		16
 
+/* Chip IDs of PCIe devices */
+#define BCMA_CHIP_ID_BCM4313	0x4313
+#define BCMA_CHIP_ID_BCM43224	43224
+#define  BCMA_PKG_ID_BCM43224_FAB_CSM	0x8
+#define  BCMA_PKG_ID_BCM43224_FAB_SMIC	0xa
+#define BCMA_CHIP_ID_BCM43225	43225
+#define BCMA_CHIP_ID_BCM43227	43227
+#define BCMA_CHIP_ID_BCM43228	43228
+#define BCMA_CHIP_ID_BCM43421	43421
+#define BCMA_CHIP_ID_BCM43428	43428
+#define BCMA_CHIP_ID_BCM43431	43431
+#define BCMA_CHIP_ID_BCM43460	43460
+#define BCMA_CHIP_ID_BCM4331	0x4331
+#define BCMA_CHIP_ID_BCM6362	0x6362
+#define BCMA_CHIP_ID_BCM4360	0x4360
+#define BCMA_CHIP_ID_BCM4352	0x4352
+
+/* Chip IDs of SoCs */
+#define BCMA_CHIP_ID_BCM4706	0x5300
+#define BCMA_CHIP_ID_BCM4716	0x4716
+#define  BCMA_PKG_ID_BCM4716	8
+#define  BCMA_PKG_ID_BCM4717	9
+#define  BCMA_PKG_ID_BCM4718	10
+#define BCMA_CHIP_ID_BCM47162	47162
+#define BCMA_CHIP_ID_BCM4748	0x4748
+#define BCMA_CHIP_ID_BCM4749	0x4749
+#define BCMA_CHIP_ID_BCM5356	0x5356
+#define BCMA_CHIP_ID_BCM5357	0x5357
+#define BCMA_CHIP_ID_BCM53572	53572
+
 struct bcma_device {
 	struct bcma_bus *bus;
 	struct bcma_device_id id;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 3/9] bcma: remove fix for 4329b0 bad LPOM is detection
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 1/9] bcma: extend workaround for bcm4331 Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 2/9] bcma: add constants for chip ids Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 4/9] bcma: add PCI ID for BCM43224 Hauke Mehrtens
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

There is not core id with 0x4329, but at the same place in the open
source part of the Broadcom SDK is a check for some device with the
chip id of 0x4329. The device with a chip id of 0x4329 is a full mac
device, so it will never be supported by bcma, this part is running in
the firmware of the device and not on the host CPU.
This code is wrong and will never be used, so just remove it.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 89528cf..2d9ac3e 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -180,9 +180,6 @@ void bcma_pmu_init(struct bcma_drv_cc *cc)
 		bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
 			     BCMA_CC_PMU_CTL_NOILPONW);
 
-	if (cc->core->id.id == 0x4329 && cc->core->id.rev == 2)
-		pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
-
 	bcma_pmu_pll_init(cc);
 	bcma_pmu_resources_init(cc);
 	bcma_pmu_swreg_init(cc);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 4/9] bcma: add PCI ID for BCM43224
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (2 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 3/9] bcma: remove fix for 4329b0 bad LPOM is detection Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 5/9] bcma: complete workaround for BCMA43224 and BCM4313 Hauke Mehrtens
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

This ID was found on the PCIe wireless card on the board of a Netgear
WNDR3400 using a bcm4716. The device with this ID is identified by b43
as "Broadcom 43224 WLAN".

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/host_pci.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 6c05cf4..c693c0b 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -268,6 +268,7 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend,
 
 static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 5/9] bcma: complete workaround for BCMA43224 and BCM4313
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (3 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 4/9] bcma: add PCI ID for BCM43224 Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 6/9] bcma: remove bcma_pmu_{pll,swreg}_init() Hauke Mehrtens
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

This code is based on the Broadcom SDK and brcmsmac.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c        |   22 +++++++++++++++++-----
 include/linux/bcma/bcma_driver_chipcommon.h |    8 ++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 2d9ac3e..a8fcdf0 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -139,7 +139,11 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
 
 	switch (bus->chipinfo.id) {
 	case BCMA_CHIP_ID_BCM4313:
-		bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
+		/* enable 12 mA drive strenth for 4313 and set chipControl
+		   register bit 1 */
+		bcma_chipco_chipctl_maskset(cc, 0,
+					    BCMA_CCTRL_4313_12MA_LED_DRIVE,
+					    BCMA_CCTRL_4313_12MA_LED_DRIVE);
 		break;
 	case BCMA_CHIP_ID_BCM4331:
 	case BCMA_CHIP_ID_BCM43431:
@@ -147,12 +151,20 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
 		bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
 		break;
 	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43421:
+		/* enable 12 mA drive strenth for 43224 and set chipControl
+		   register bit 15 */
 		if (bus->chipinfo.rev == 0) {
-			pr_err("Workarounds for 43224 rev 0 not fully "
-				"implemented\n");
-			bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0);
+			bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL,
+					  BCMA_CCTRL_43224_GPIO_TOGGLE,
+					  BCMA_CCTRL_43224_GPIO_TOGGLE);
+			bcma_chipco_chipctl_maskset(cc, 0,
+						    BCMA_CCTRL_43224A0_12MA_LED_DRIVE,
+						    BCMA_CCTRL_43224A0_12MA_LED_DRIVE);
 		} else {
-			bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
+			bcma_chipco_chipctl_maskset(cc, 0,
+						    BCMA_CCTRL_43224B0_12MA_LED_DRIVE,
+						    BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
 		}
 		break;
 	case BCMA_CHIP_ID_BCM43225:
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 1e523cc..09f31ad 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -325,6 +325,14 @@
 #define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4	BIT(16)	/* enable bt_shd0 at gpio4 */
 #define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5	BIT(17)	/* enable bt_shd1 at gpio5 */
 
+/* 43224 chip-specific ChipControl register bits */
+#define BCMA_CCTRL_43224_GPIO_TOGGLE		0x8000		/* gpio[3:0] pins as btcoex or s/w gpio */
+#define BCMA_CCTRL_43224A0_12MA_LED_DRIVE	0x00F000F0	/* 12 mA drive strength */
+#define BCMA_CCTRL_43224B0_12MA_LED_DRIVE	0xF0		/* 12 mA drive strength for later 43224s */
+
+/* 4313 Chip specific ChipControl register bits */
+#define BCMA_CCTRL_4313_12MA_LED_DRIVE		0x00000007	/* 12 mA drive strengh for later 4313 */
+
 /* Data for the PMU, if available.
  * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
  */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 6/9] bcma: remove bcma_pmu_{pll,swreg}_init()
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (4 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 5/9] bcma: complete workaround for BCMA43224 and BCM4313 Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 7/9] bcma: remove chip ids doing nothing from PMU initialization Hauke Mehrtens
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

These functions are doing nothing in the current code.

I do not think we will need these function in the future as the
corresponding functions in the Broadcom SDK are just doing something
useful on chips supported by ssb or fullmac chips.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c |   34 ----------------------------------
 1 file changed, 34 deletions(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index a8fcdf0..069fca7 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -54,22 +54,6 @@ void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask,
 }
 EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
 
-static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
-{
-	struct bcma_bus *bus = cc->core->bus;
-
-	switch (bus->chipinfo.id) {
-	case BCMA_CHIP_ID_BCM4313:
-	case BCMA_CHIP_ID_BCM4331:
-	case BCMA_CHIP_ID_BCM43224:
-	case BCMA_CHIP_ID_BCM43225:
-		break;
-	default:
-		pr_err("PLL init unknown for device 0x%04X\n",
-			bus->chipinfo.id);
-	}
-}
-
 static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 {
 	struct bcma_bus *bus = cc->core->bus;
@@ -96,22 +80,6 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 		bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
 }
 
-void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
-{
-	struct bcma_bus *bus = cc->core->bus;
-
-	switch (bus->chipinfo.id) {
-	case BCMA_CHIP_ID_BCM4313:
-	case BCMA_CHIP_ID_BCM4331:
-	case BCMA_CHIP_ID_BCM43224:
-	case BCMA_CHIP_ID_BCM43225:
-		break;
-	default:
-		pr_err("PMU switch/regulators init unknown for device "
-			"0x%04X\n", bus->chipinfo.id);
-	}
-}
-
 /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable)
 {
@@ -192,9 +160,7 @@ void bcma_pmu_init(struct bcma_drv_cc *cc)
 		bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
 			     BCMA_CC_PMU_CTL_NOILPONW);
 
-	bcma_pmu_pll_init(cc);
 	bcma_pmu_resources_init(cc);
-	bcma_pmu_swreg_init(cc);
 	bcma_pmu_workarounds(cc);
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 7/9] bcma: remove chip ids doing nothing from PMU initialization.
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (5 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 6/9] bcma: remove bcma_pmu_{pll,swreg}_init() Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 8/9] bcma: add bcma_pmu_spuravoid_pllupdate() Hauke Mehrtens
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

The list of devices where nothing has to be done in
bcma_pmu_resources_init() and bcma_pmu_workarounds() is longer as all
the SoCs are missing there and some new devices will be added in some
time later. This patch changes the default case to just log on debug
level and also let the other devices which do not need any special
handling into the default case, instead of adding the missing 8 SoC
chip ids.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 069fca7..1a7a72f 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -64,13 +64,9 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 		min_msk = 0x200D;
 		max_msk = 0xFFFF;
 		break;
-	case BCMA_CHIP_ID_BCM4331:
-	case BCMA_CHIP_ID_BCM43224:
-	case BCMA_CHIP_ID_BCM43225:
-		break;
 	default:
-		pr_err("PMU resource config unknown for device 0x%04X\n",
-			bus->chipinfo.id);
+		pr_debug("PMU resource config unknown or not needed for device 0x%04X\n",
+			 bus->chipinfo.id);
 	}
 
 	/* Set the resource masks. */
@@ -135,11 +131,9 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
 						    BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
 		}
 		break;
-	case BCMA_CHIP_ID_BCM43225:
-		break;
 	default:
-		pr_err("Workarounds unknown for device 0x%04X\n",
-			bus->chipinfo.id);
+		pr_debug("Workarounds unknown or not needed for device 0x%04X\n",
+			 bus->chipinfo.id);
 	}
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 8/9] bcma: add bcma_pmu_spuravoid_pllupdate()
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (6 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 7/9] bcma: remove chip ids doing nothing from PMU initialization Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-29 23:44 ` [PATCH v2 9/9] bcma: add mdelay bcma_pmu_resources_init() Hauke Mehrtens
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

This function is needed by brcmsmac. This code is based on code from
the Broadcom SDK.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c        |  183 ++++++++++++++++++++++++++-
 include/linux/bcma/bcma_driver_chipcommon.h |   14 ++
 2 files changed, 196 insertions(+), 1 deletion(-)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 1a7a72f..35c9130 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -3,7 +3,8 @@
  * ChipCommon Power Management Unit driver
  *
  * Copyright 2009, Michael Buesch <m@bues.ch>
- * Copyright 2007, Broadcom Corporation
+ * Copyright 2007, 2011, Broadcom Corporation
+ * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
@@ -284,3 +285,183 @@ u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
 
 	return bcma_pmu_get_clockcontrol(cc);
 }
+
+static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
+					 u32 value)
+{
+	bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
+	bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
+}
+
+void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
+{
+	u32 tmp = 0;
+	u8 phypll_offset = 0;
+	u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5};
+	u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc};
+	struct bcma_bus *bus = cc->core->bus;
+
+	switch (bus->chipinfo.id) {
+	case BCMA_CHIP_ID_BCM5357:
+	case BCMA_CHIP_ID_BCM4749:
+	case BCMA_CHIP_ID_BCM53572:
+		/* 5357[ab]0, 43236[ab]0, and 6362b0 */
+
+		/* BCM5357 needs to touch PLL1_PLLCTL[02],
+		   so offset PLL0_PLLCTL[02] by 6 */
+		phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
+		       bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 ||
+		       bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
+
+		/* RMW only the P1 divider */
+		bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
+				BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
+		tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
+		tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
+		tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
+		bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
+
+		/* RMW only the int feedback divider */
+		bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
+				BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
+		tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
+		tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
+		tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
+		bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
+
+		tmp = 1 << 10;
+		break;
+
+	case BCMA_CHIP_ID_BCM4331:
+	case BCMA_CHIP_ID_BCM43431:
+		if (spuravoid == 2) {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11500014);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x0FC00a08);
+		} else if (spuravoid == 1) {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11500014);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x0F600a08);
+		} else {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11100014);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x03000a08);
+		}
+		tmp = 1 << 10;
+		break;
+
+	case BCMA_CHIP_ID_BCM43224:
+	case BCMA_CHIP_ID_BCM43225:
+	case BCMA_CHIP_ID_BCM43421:
+		if (spuravoid == 1) {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11500010);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x000C0C06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x0F600a08);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x2001E920);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		} else {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11100010);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x000c0c06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x03000a08);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x200005c0);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		}
+		tmp = 1 << 10;
+		break;
+
+	case BCMA_CHIP_ID_BCM4716:
+	case BCMA_CHIP_ID_BCM4748:
+	case BCMA_CHIP_ID_BCM47162:
+		if (spuravoid == 1) {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11500060);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x080C0C06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x0F600000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x2001E924);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		} else {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11100060);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x080c0c06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x03000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x200005c0);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		}
+
+		tmp = 3 << 9;
+		break;
+
+	case BCMA_CHIP_ID_BCM43227:
+	case BCMA_CHIP_ID_BCM43228:
+	case BCMA_CHIP_ID_BCM43428:
+		/* LCNXN */
+		/* PLL Settings for spur avoidance on/off mode,
+		   no on2 support for 43228A0 */
+		if (spuravoid == 1) {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x01100014);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x040C0C06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x03140A08);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00333333);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x202C2820);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		} else {
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
+						     0x11100014);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
+						     0x040c0c06);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
+						     0x03000a08);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
+						     0x00000000);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
+						     0x200005c0);
+			bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
+						     0x88888815);
+		}
+		tmp = 1 << 10;
+		break;
+	default:
+		pr_err("unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
+		       bus->chipinfo.id);
+		break;
+	}
+
+	tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
+	bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
+}
+EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 09f31ad..12975ea 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -308,6 +308,19 @@
 #define BCMA_CC_PPL_PCHI_OFF		5
 #define BCMA_CC_PPL_PCHI_MASK		0x0000003f
 
+#define BCMA_CC_PMU_PLL_CTL0		0
+#define BCMA_CC_PMU_PLL_CTL1		1
+#define BCMA_CC_PMU_PLL_CTL2		2
+#define BCMA_CC_PMU_PLL_CTL3		3
+#define BCMA_CC_PMU_PLL_CTL4		4
+#define BCMA_CC_PMU_PLL_CTL5		5
+
+#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK	0x00f00000
+#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT	20
+
+#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK	0x1ff00000
+#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT	20
+
 /* BCM4331 ChipControl numbers. */
 #define BCMA_CHIPCTL_4331_BT_COEXIST		BIT(0)	/* 0 disable */
 #define BCMA_CHIPCTL_4331_SECI			BIT(1)	/* 0 SECI is disabled (JATG functional) */
@@ -420,5 +433,6 @@ extern void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
 					u32 offset, u32 mask, u32 set);
 extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
 				       u32 offset, u32 mask, u32 set);
+extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
 
 #endif /* LINUX_BCMA_DRIVER_CC_H_ */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 9/9] bcma: add mdelay bcma_pmu_resources_init()
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (7 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 8/9] bcma: add bcma_pmu_spuravoid_pllupdate() Hauke Mehrtens
@ 2012-06-29 23:44 ` Hauke Mehrtens
  2012-06-30  9:19 ` [PATCH v2 0/9] bcma misc updates Rafał Miłecki
  2012-07-03  6:51 ` REGRESSION: " Arend van Spriel
  10 siblings, 0 replies; 16+ messages in thread
From: Hauke Mehrtens @ 2012-06-29 23:44 UTC (permalink / raw)
  To: linville
  Cc: zajec5, b43-dev, arend, linux-wireless, brcm80211-dev-list,
	Hauke Mehrtens

This is based on code from brcmsmac.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/bcma/driver_chipcommon_pmu.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c
index 35c9130..ca5a919 100644
--- a/drivers/bcma/driver_chipcommon_pmu.c
+++ b/drivers/bcma/driver_chipcommon_pmu.c
@@ -75,6 +75,9 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
 		bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
 	if (max_msk)
 		bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
+
+	/* Add some delay; allow resources to come up and settle. */
+	mdelay(2);
 }
 
 /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 0/9] bcma misc updates
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (8 preceding siblings ...)
  2012-06-29 23:44 ` [PATCH v2 9/9] bcma: add mdelay bcma_pmu_resources_init() Hauke Mehrtens
@ 2012-06-30  9:19 ` Rafał Miłecki
  2012-07-03  6:51 ` REGRESSION: " Arend van Spriel
  10 siblings, 0 replies; 16+ messages in thread
From: Rafał Miłecki @ 2012-06-30  9:19 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: linville, b43-dev, arend, linux-wireless, brcm80211-dev-list

2012/6/30 Hauke Mehrtens <hauke@hauke-m.de>:
> These are some updates for bcma. Some are extending or completing some
> workarounds for PCIe based wireless cards. A patch adds
> bcma_pmu_spuravoid_pllupdate, used by brcmsmac and an other patch adds
> constants for the chip ids. This code is mostly based on code from
> brcmsmac and the Broadcom SDK for BCM47XX SoCs.
>
> This was tested on a BCM4718 SoC with a BCM43224 PCIe and a BCM5357.
> The Wifi part of the BCM4718 and BCM43224 is more or less working with
> brcmsmac, which need some more patches for that, but it has low speed
> and some times or with some access points I still get errors. The wifi
> of the BCM5357 does not work.
>
> These patches are based on current wireless-testing.

Look fine for me. I'll need to rebase my logging patch...

-- 
Rafa?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* REGRESSION: [PATCH v2 0/9] bcma misc updates
  2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
                   ` (9 preceding siblings ...)
  2012-06-30  9:19 ` [PATCH v2 0/9] bcma misc updates Rafał Miłecki
@ 2012-07-03  6:51 ` Arend van Spriel
  2012-07-03  7:44   ` Hauke Mehrtens
  10 siblings, 1 reply; 16+ messages in thread
From: Arend van Spriel @ 2012-07-03  6:51 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: linville, zajec5, b43-dev, linux-wireless, brcm80211-dev-list

On 06/30/2012 01:44 AM, Hauke Mehrtens wrote:
> These are some updates for bcma. Some are extending or completing some 
> workarounds for PCIe based wireless cards. A patch adds 
> bcma_pmu_spuravoid_pllupdate, used by brcmsmac and an other patch adds 
> constants for the chip ids. This code is mostly based on code from 
> brcmsmac and the Broadcom SDK for BCM47XX SoCs.
> 
> This was tested on a BCM4718 SoC with a BCM43224 PCIe and a BCM5357.
> The Wifi part of the BCM4718 and BCM43224 is more or less working with 
> brcmsmac, which need some more patches for that, but it has low speed 
> and some times or with some access points I still get errors. The wifi 
> of the BCM5357 does not work.
> 

Hi Hauke,

This patch series caused a regression in one of our smoketest machines
last night. I have not looked at the exact patch causing it (suspect
2/9). The failure happens on a BCM43224 chip with external SPROM. Here
is the log info:

[317752.101665] bcma: Found chip with id 0xA8D8, rev 0x01 and package 0x08
[317752.101809] bcma: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800,
rev 0x22, class 0x0)
[317752.101827] bcma: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812,
rev 0x17, class 0x0)
[317752.101870] bcma: Core 2 found: PCIe (manuf 0x4BF, id 0x820, rev
0x0F, class 0x0)
[317752.171926] bcma: Failed to get SPROM: -71 <== -EPROTO (crc failed).
[317752.171982] bcma: Bus registered
[317753.184455] brcmsmac bcma0:0: mfg 4bf core 812 rev 23 class 0 irq 16
[317753.191868] brcmsmac: Applying 43224B0+ WARs
[317753.193918] ieee80211 phy0: wl0: brcms_b_attach: bad macaddr
[317753.193924] ieee80211 phy0: wl0: brcms_b_attach: failed with err 22
[317753.193928] ieee80211 phy0: wl0: brcms_c_attach: failed with err 22
[317753.193959] ieee80211 phy0: brcmsmac: attach() failed with code 22
[317753.193966] brcmsmac: brcms_bcma_probe: brcms_attach failed!

I suspect it tries reading OTP instead of the external SPROM.

Gr. AvS

^ permalink raw reply	[flat|nested] 16+ messages in thread

* REGRESSION: [PATCH v2 0/9] bcma misc updates
  2012-07-03  6:51 ` REGRESSION: " Arend van Spriel
@ 2012-07-03  7:44   ` Hauke Mehrtens
  2012-07-03  8:22     ` Arend van Spriel
  0 siblings, 1 reply; 16+ messages in thread
From: Hauke Mehrtens @ 2012-07-03  7:44 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linville, zajec5, b43-dev, linux-wireless, brcm80211-dev-list

On 07/03/2012 08:51 AM, Arend van Spriel wrote:
> On 06/30/2012 01:44 AM, Hauke Mehrtens wrote:
>> These are some updates for bcma. Some are extending or completing some 
>> workarounds for PCIe based wireless cards. A patch adds 
>> bcma_pmu_spuravoid_pllupdate, used by brcmsmac and an other patch adds 
>> constants for the chip ids. This code is mostly based on code from 
>> brcmsmac and the Broadcom SDK for BCM47XX SoCs.
>>
>> This was tested on a BCM4718 SoC with a BCM43224 PCIe and a BCM5357.
>> The Wifi part of the BCM4718 and BCM43224 is more or less working with 
>> brcmsmac, which need some more patches for that, but it has low speed 
>> and some times or with some access points I still get errors. The wifi 
>> of the BCM5357 does not work.
>>
> 
> Hi Hauke,
> 
> This patch series caused a regression in one of our smoketest machines
> last night. I have not looked at the exact patch causing it (suspect
> 2/9). The failure happens on a BCM43224 chip with external SPROM. Here
> is the log info:
> 
> [317752.101665] bcma: Found chip with id 0xA8D8, rev 0x01 and package 0x08
> [317752.101809] bcma: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800,
> rev 0x22, class 0x0)
> [317752.101827] bcma: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812,
> rev 0x17, class 0x0)
> [317752.101870] bcma: Core 2 found: PCIe (manuf 0x4BF, id 0x820, rev
> 0x0F, class 0x0)
> [317752.171926] bcma: Failed to get SPROM: -71 <== -EPROTO (crc failed).
> [317752.171982] bcma: Bus registered
> [317753.184455] brcmsmac bcma0:0: mfg 4bf core 812 rev 23 class 0 irq 16
> [317753.191868] brcmsmac: Applying 43224B0+ WARs
> [317753.193918] ieee80211 phy0: wl0: brcms_b_attach: bad macaddr
> [317753.193924] ieee80211 phy0: wl0: brcms_b_attach: failed with err 22
> [317753.193928] ieee80211 phy0: wl0: brcms_c_attach: failed with err 22
> [317753.193959] ieee80211 phy0: brcmsmac: attach() failed with code 22
> [317753.193966] brcmsmac: brcms_bcma_probe: brcms_attach failed!
> 
> I suspect it tries reading OTP instead of the external SPROM.
> 
> Gr. AvS
> 
Hi Arend,

my BCM43224 uses a Sprom from the flash chip of the SoC, so it could be
that something is wrong in the sprom reading, but I haven't touched the
sprom code expect for using constants.

Do you know which patch is causing this issue?

Hauke

^ permalink raw reply	[flat|nested] 16+ messages in thread

* REGRESSION: [PATCH v2 0/9] bcma misc updates
  2012-07-03  7:44   ` Hauke Mehrtens
@ 2012-07-03  8:22     ` Arend van Spriel
  2012-07-16 21:44       ` Hauke Mehrtens
  0 siblings, 1 reply; 16+ messages in thread
From: Arend van Spriel @ 2012-07-03  8:22 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: linville, zajec5, b43-dev, linux-wireless, brcm80211-dev-list

On 07/03/2012 09:44 AM, Hauke Mehrtens wrote:
>> I suspect it tries reading OTP instead of the external SPROM.
>> > 
>> > Gr. AvS
>> > 
> Hi Arend,
> 
> my BCM43224 uses a Sprom from the flash chip of the SoC, so it could be
> that something is wrong in the sprom reading, but I haven't touched the
> sprom code expect for using constants.
> 
> Do you know which patch is causing this issue?
> 
> Hauke
> 

I intended to bisect the series. I will let you know what I find.

Gr. AvS

^ permalink raw reply	[flat|nested] 16+ messages in thread

* REGRESSION: [PATCH v2 0/9] bcma misc updates
  2012-07-03  8:22     ` Arend van Spriel
@ 2012-07-16 21:44       ` Hauke Mehrtens
  2012-07-17  7:31         ` Arend van Spriel
  0 siblings, 1 reply; 16+ messages in thread
From: Hauke Mehrtens @ 2012-07-16 21:44 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linville, zajec5, b43-dev, linux-wireless, brcm80211-dev-list

On 07/03/2012 10:22 AM, Arend van Spriel wrote:
> On 07/03/2012 09:44 AM, Hauke Mehrtens wrote:
>>> I suspect it tries reading OTP instead of the external SPROM.
>>>>
>>>> Gr. AvS
>>>>
>> Hi Arend,
>>
>> my BCM43224 uses a Sprom from the flash chip of the SoC, so it could be
>> that something is wrong in the sprom reading, but I haven't touched the
>> sprom code expect for using constants.
>>
>> Do you know which patch is causing this issue?
>>
>> Hauke
>>
> 
> I intended to bisect the series. I will let you know what I find.
> 
> Gr. AvS

Hi Arend,

Did you bisect this? I still have no idea which or why any of the
patches could cause this.

Hauke

^ permalink raw reply	[flat|nested] 16+ messages in thread

* REGRESSION: [PATCH v2 0/9] bcma misc updates
  2012-07-16 21:44       ` Hauke Mehrtens
@ 2012-07-17  7:31         ` Arend van Spriel
  0 siblings, 0 replies; 16+ messages in thread
From: Arend van Spriel @ 2012-07-17  7:31 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: linville, zajec5, b43-dev, linux-wireless, brcm80211-dev-list

On 07/16/2012 11:44 PM, Hauke Mehrtens wrote:
> On 07/03/2012 10:22 AM, Arend van Spriel wrote:
>> On 07/03/2012 09:44 AM, Hauke Mehrtens wrote:
>>>> I suspect it tries reading OTP instead of the external SPROM.
>>>>>
>>>>> Gr. AvS
>>>>>
>>> Hi Arend,
>>>
>>> my BCM43224 uses a Sprom from the flash chip of the SoC, so it could be
>>> that something is wrong in the sprom reading, but I haven't touched the
>>> sprom code expect for using constants.
>>>
>>> Do you know which patch is causing this issue?
>>>
>>> Hauke
>>>
>>
>> I intended to bisect the series. I will let you know what I find.
>>
>> Gr. Av
> 
> Hi Arend,
> 
> Did you bisect this? I still have no idea which or why any of the
> patches could cause this.
> 
> Hauke
> 

Hi Hauke,

I seem to have a number of issues with BCMA, which all seem host_pci
related. It looks like there is some merge issue in PCI API. It may be
due to the fact that wireless-testing got rebased by John and I merged
it into our internal branch.

So my plan is to rebase our internal branch to wireless-testing instead
of a merge. I did not come back to you because I wanted to make sense of
the issues I was seeing.

Gr. AvS

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-07-17  7:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-29 23:44 [PATCH v2 0/9] bcma misc updates Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 1/9] bcma: extend workaround for bcm4331 Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 2/9] bcma: add constants for chip ids Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 3/9] bcma: remove fix for 4329b0 bad LPOM is detection Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 4/9] bcma: add PCI ID for BCM43224 Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 5/9] bcma: complete workaround for BCMA43224 and BCM4313 Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 6/9] bcma: remove bcma_pmu_{pll,swreg}_init() Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 7/9] bcma: remove chip ids doing nothing from PMU initialization Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 8/9] bcma: add bcma_pmu_spuravoid_pllupdate() Hauke Mehrtens
2012-06-29 23:44 ` [PATCH v2 9/9] bcma: add mdelay bcma_pmu_resources_init() Hauke Mehrtens
2012-06-30  9:19 ` [PATCH v2 0/9] bcma misc updates Rafał Miłecki
2012-07-03  6:51 ` REGRESSION: " Arend van Spriel
2012-07-03  7:44   ` Hauke Mehrtens
2012-07-03  8:22     ` Arend van Spriel
2012-07-16 21:44       ` Hauke Mehrtens
2012-07-17  7:31         ` Arend van Spriel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).