Skip to contentSkip to conversation

bcma: add PCI functions from brcmsmac

PATCH New Hauke Mehrtens 3 participants 8 messages Apr 29, 2012 – May 15, 2012 Broadcom specific amba driver (bcma)

lore
Share & tools
lore
#0 lore raw

cover bcma: add PCI functions from brcmsmac

This patch series contains the functions regarding the PCIe core from brcmsmac for the supported PCIe core revisions.

Some of these functions have to be called on resume after suspend, but I do not know which or if all have to be called. I do not have a PCIe based device supported by brcmsmac, so I can not test this. Could someone which such a device do some tests and create a patch with the functions, which have to be called on resume.

The goal of theses patches is to remove the PCIe code from brcmsmac to get one step ahead in making brcmsmac support non pcie based devices.

This is based on wireless-testing/master.

Hauke Mehrtens (4):
bcma: implement setting core clock mode to dynamic
bcma: add bcma_core_pci_extend_L1timer
bcma: add bcma_core_pci_fixcfg()
bcma: add bcma_core_pci_config_fixup()

 drivers/bcma/core.c                  |    2 +-
 drivers/bcma/driver_pci.c            |   53 ++++++++++++++++++++++++++++++++--
 include/linux/bcma/bcma_driver_pci.h |   11 +++++++
 3 files changed, 63 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 bcma: implement setting core clock mode to dynamic

This patch is based on code from _ai_clkctl_cc() in brcmsmac.

---
 drivers/bcma/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bcma/core.c +1 -1
index 893f6e0..98e243c 100644
@@ -77,7 +77,7 @@ void bcma_core_set_clockmode(struct bcma_device *core,
 			pr_err("HT force timeout\n");
 		break;
 	case BCMA_CLKMODE_DYNAMIC:
-		pr_warn("Dynamic clockmode not supported yet!\n");
+		bcma_set32(core, BCMA_CLKCTLST, ~BCMA_CLKCTLST_FORCEHT);
 		break;
 	}
 }
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 bcma: add bcma_core_pci_extend_L1timer

In reply to Hauke Mehrtens

This code is based on code from pcie_extendL1timer() in brcmsmac. This patch is part of the move of pci specific code from brcmsmac to bcma.

---
 drivers/bcma/driver_pci.c            |   16 ++++++++++++++--
 include/linux/bcma/bcma_driver_pci.h |    2 ++
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/bcma/driver_pci.c +14 -2
index 4d38ae1..9492066 100644
@@ -24,14 +24,12 @@ u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
 	return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA);
 }
 
-#if 0
 static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data)
 {
 	pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
 	pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
 	pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
 }
-#endif
 
 static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
 {
@@ -224,3 +222,17 @@ out:
 	return err;
 }
 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
+
+void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
+{
+	u32 w;
+
+	w = bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
+	if (extend)
+		w |= BCMA_CORE_PCI_ASPMTIMER_EXTEND;
+	else
+		w &= ~BCMA_CORE_PCI_ASPMTIMER_EXTEND;
+	bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
+	bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
+}
+EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
include/linux/bcma/bcma_driver_pci.h +2 -0
index 46c71e2..20c9f96 100644
@@ -133,6 +133,7 @@ struct pci_dev;
 #define BCMA_CORE_PCI_DLLP_LRREG		0x120	/* Link Replay */
 #define BCMA_CORE_PCI_DLLP_LACKTOREG		0x124	/* Link Ack Timeout */
 #define BCMA_CORE_PCI_DLLP_PMTHRESHREG		0x128	/* Power Management Threshold */
+#define  BCMA_CORE_PCI_ASPMTIMER_EXTEND		0x01000000 /* > rev7: enable extend ASPM timer */
 #define BCMA_CORE_PCI_DLLP_RTRYWPREG		0x12C	/* Retry buffer write ptr */
 #define BCMA_CORE_PCI_DLLP_RTRYRPREG		0x130	/* Retry buffer Read ptr */
 #define BCMA_CORE_PCI_DLLP_RTRYPPREG		0x134	/* Retry buffer Purged ptr */
@@ -207,6 +208,7 @@ struct bcma_drv_pci {
 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
 				 struct bcma_device *core, bool enable);
+extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
 
 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
 extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/4 bcma: add bcma_core_pci_fixcfg()

In reply to Hauke Mehrtens

This code is based on code from pcicore_fixcfg() in brcmsmac. This patch is part of the move of pci specific code from brcmsmac to bcma.

---
 drivers/bcma/driver_pci.c            |   19 +++++++++++++++++++
 include/linux/bcma/bcma_driver_pci.h |    5 +++++
 2 files changed, 24 insertions(+)
drivers/bcma/driver_pci.c +19 -0
index 9492066..472d14f 100644
@@ -168,12 +168,31 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
 		                     tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
 }
 
+static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
+{
+	struct bcma_device *core = pc->core;
+	u16 val16, core_index;
+	uint regoff;
+
+	regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
+	core_index = (u16)core->core_index;
+
+	val16 = pcicore_read16(pc, regoff);
+	if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
+	     != core_index) {
+		val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
+			(val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
+		pcicore_write16(pc, regoff, val16);
+	}
+}
+
 /**************************************************
  * Init.
  **************************************************/
 
 static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 {
+	bcma_core_pci_fixcfg(pc);
 	bcma_pcicore_serdes_workaround(pc);
 }
 
include/linux/bcma/bcma_driver_pci.h +5 -0
index 20c9f96..5b0542c 100644
@@ -87,6 +87,9 @@ struct pci_dev;
 #define BCMA_CORE_PCI_PCICFG2			0x0600	/* PCI config space 2 (rev >= 8) */
 #define BCMA_CORE_PCI_PCICFG3			0x0700	/* PCI config space 3 (rev >= 8) */
 #define BCMA_CORE_PCI_SPROM(wordoffset)		(0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
+#define  BCMA_CORE_PCI_SPROM_PI_OFFSET		0	/* first word */
+#define   BCMA_CORE_PCI_SPROM_PI_MASK		0xf000	/* bit 15:12 */
+#define   BCMA_CORE_PCI_SPROM_PI_SHIFT		12	/* bit 15:12 */
 
 /* SBtoPCIx */
 #define BCMA_CORE_PCI_SBTOPCI_MEM		0x00000000
@@ -202,7 +205,9 @@ struct bcma_drv_pci {
 };
 
 /* Register access */
+#define pcicore_read16(pc, offset)		bcma_read16((pc)->core, offset)
 #define pcicore_read32(pc, offset)		bcma_read32((pc)->core, offset)
+#define pcicore_write16(pc, offset, val)	bcma_write16((pc)->core, offset, val)
 #define pcicore_write32(pc, offset, val)	bcma_write32((pc)->core, offset, val)
 
 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/4 bcma: add bcma_core_pci_config_fixup()

In reply to Hauke Mehrtens

This code is based on code from pcie_misc_config_fixup() in brcmsmac. This patch is part of the move of pci specific code from brcmsmac to bcma.

---
 drivers/bcma/driver_pci.c            |   18 ++++++++++++++++++
 include/linux/bcma/bcma_driver_pci.h |    4 ++++
 2 files changed, 22 insertions(+)
drivers/bcma/driver_pci.c +18 -0
index 472d14f..9a96f14 100644
@@ -186,6 +186,23 @@ static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
 	}
 }
 
+/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
+/* Needs to happen when coming out of 'standby'/'hibernate' */
+static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
+{
+	u16 val16;
+	uint regoff;
+
+	regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_MISC_CONFIG);
+
+	val16 = pcicore_read16(pc, regoff);
+
+	if (!(val16 & BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST)) {
+		val16 |= BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST;
+		pcicore_write16(pc, regoff, val16);
+	}
+}
+
 /**************************************************
  * Init.
  **************************************************/
@@ -194,6 +211,7 @@ static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 {
 	bcma_core_pci_fixcfg(pc);
 	bcma_pcicore_serdes_workaround(pc);
+	bcma_core_pci_config_fixup(pc);
 }
 
 void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
include/linux/bcma/bcma_driver_pci.h +4 -0
index 5b0542c..41da581 100644
@@ -90,6 +90,10 @@ struct pci_dev;
 #define  BCMA_CORE_PCI_SPROM_PI_OFFSET		0	/* first word */
 #define   BCMA_CORE_PCI_SPROM_PI_MASK		0xf000	/* bit 15:12 */
 #define   BCMA_CORE_PCI_SPROM_PI_SHIFT		12	/* bit 15:12 */
+#define  BCMA_CORE_PCI_SPROM_MISC_CONFIG	5	/* word 5 */
+#define   BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST	0x8000	/* bit 15 */
+#define   BCMA_CORE_PCI_SPROM_CLKREQ_OFFSET_REV5	20	/* word 20 for srom rev <= 5 */
+#define   BCMA_CORE_PCI_SPROM_CLKREQ_ENB	0x0800	/* bit 11 */
 
 /* SBtoPCIx */
 #define BCMA_CORE_PCI_SBTOPCI_MEM		0x00000000
Signature · 1 line
1.7.9.5
#5 lore raw

cover bcma: add PCI functions from brcmsmac

In reply to Hauke Mehrtens
Quoted 8 lines · Hauke Mehrtens

This patch series contains the functions regarding the PCIe core from brcmsmac for the supported PCIe core revisions.

Some of these functions have to be called on resume after suspend, but I do not know which or if all have to be called. I do not have a PCIe based device supported by brcmsmac, so I can not test this. Could someone which such a device do some tests and create a patch with the functions, which have to be called on resume.

I do have some devices and feel it is my/our responsibility to get this tested. I let you know the results.

Quoted 5 lines

The goal of theses patches is to remove the PCIe code from brcmsmac to get one step ahead in making brcmsmac support non pcie based devices.

This is based on wireless-testing/master.

Gr. AvS

#6 lore raw

cover bcma: add PCI functions from brcmsmac

In reply to Hauke Mehrtens
Quoted 20 lines · Hauke Mehrtens

This patch series contains the functions regarding the PCIe core from brcmsmac for the supported PCIe core revisions.

Some of these functions have to be called on resume after suspend, but I do not know which or if all have to be called. I do not have a PCIe based device supported by brcmsmac, so I can not test this. Could someone which such a device do some tests and create a patch with the functions, which have to be called on resume.

The goal of theses patches is to remove the PCIe code from brcmsmac to get one step ahead in making brcmsmac support non pcie based devices.

This is based on wireless-testing/master.

Hauke Mehrtens (4):
bcma: implement setting core clock mode to dynamic
bcma: add bcma_core_pci_extend_L1timer
bcma: add bcma_core_pci_fixcfg()
bcma: add bcma_core_pci_config_fixup()

Quoted 5 lines
 drivers/bcma/core.c                  |    2 +-
 drivers/bcma/driver_pci.c            |   53 ++++++++++++++++++++++++++++++++--
 include/linux/bcma/bcma_driver_pci.h |   11 +++++++
 3 files changed, 63 insertions(+), 3 deletions(-)

Hi Rafa?,

could you give me an ack or a nack about this patch series and the other (ssb/bcma/bcm47xx: extend boardinfo and sprom).

I have tested them with b43 and brcmsmac on bcma and ssb based SoCs (bcm4718 + bcm43224, bcm4705 + 2x bcm4322, bcm4704 + bcm4318) and have not found any problems.

Hauke

#7 lore raw

cover bcma: add PCI functions from brcmsmac

Quoted 29 lines · Hauke Mehrtens
Quoted 20 lines · Hauke Mehrtens

This patch series contains the functions regarding the PCIe core from brcmsmac for the supported PCIe core revisions.

Some of these functions have to be called on resume after suspend, but I do not know which or if all have to be called. I do not have a PCIe based device supported by brcmsmac, so I can not test this. Could someone which such a device do some tests and create a patch with the functions, which have to be called on resume.

The goal of theses patches is to remove the PCIe code from brcmsmac to get one step ahead in making brcmsmac support non pcie based devices.

This is based on wireless-testing/master.

Hauke Mehrtens (4):
bcma: implement setting core clock mode to dynamic
bcma: add bcma_core_pci_extend_L1timer
bcma: add bcma_core_pci_fixcfg()
bcma: add bcma_core_pci_config_fixup()

Quoted 5 lines
 drivers/bcma/core.c                  |    2 +-
 drivers/bcma/driver_pci.c            |   53 ++++++++++++++++++++++++++++++++--
 include/linux/bcma/bcma_driver_pci.h |   11 +++++++
 3 files changed, 63 insertions(+), 3 deletions(-)

Hi Rafa?,

Quoted 8 lines

could you give me an ack or a nack about this patch series and the other (ssb/bcma/bcm47xx: extend boardinfo and sprom).

I have tested them with b43 and brcmsmac on bcma and ssb based SoCs (bcm4718 + bcm43224, bcm4705 + 2x bcm4322, bcm4704 + bcm4318) and have not found any problems.

Hauke

Rafa?, ping?

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
linville at tuxdriver.com			might be all we have.  Be ready.