From zajec5 at gmail.com  Mon Jan  2 02:41:23 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Mon,  2 Jan 2012 08:41:23 +0100
Subject: [PATCH 1/3] ssb: SPROM: extract each core power info
Message-ID: <1325490085-3806-1-git-send-email-zajec5@gmail.com>

We already extract some basic info but it's incomplete, reads info
about the first core only. Used data structure doesn't allow easy
adding of more cores.
This patch adds new struct and array for storing power info. The plan
is to: switch all extractors (including the ones using NVRAM) to new
struct, switch drivers, then deprecate and finally drop old SSB fields.

Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/ssb/pci.c            |   40 +++++++++++++++++++++++++++++++++++++++-
 include/linux/ssb/ssb.h      |    8 ++++++++
 include/linux/ssb/ssb_regs.h |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 1 deletions(-)

diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index 973223f..befa89e 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -523,7 +523,13 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
 static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
 {
 	int i;
-	u16 v;
+	u16 v, o;
+	u16 pwr_info_offset[] = {
+		SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
+		SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
+	};
+	BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
+			ARRAY_SIZE(out->core_pwr_info));
 
 	/* extract the MAC address */
 	for (i = 0; i < 3; i++) {
@@ -607,6 +613,38 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
 	memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
 	       sizeof(out->antenna_gain.ghz5));
 
+	/* Extract cores power info info */
+	for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
+		o = pwr_info_offset[i];
+		SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
+			SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
+		SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
+			SSB_SPROM8_2G_MAXP, 0);
+
+		SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
+
+		SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
+			SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
+		SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
+			SSB_SPROM8_5G_MAXP, 0);
+		SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
+			SSB_SPROM8_5GH_MAXP, 0);
+		SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
+			SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
+
+		SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
+	}
+
 	/* Extract FEM info */
 	SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
 		SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index dcf35b0..bbc2612 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -16,6 +16,12 @@ struct pcmcia_device;
 struct ssb_bus;
 struct ssb_driver;
 
+struct ssb_sprom_core_pwr_info {
+	u8 itssi_2g, itssi_5g;
+	u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
+	u16 pa_2g[3], pa_5gl[3], pa_5g[3], pa_5gh[3];
+};
+
 struct ssb_sprom {
 	u8 revision;
 	u8 il0mac[6];		/* MAC address for 802.11b/g */
@@ -82,6 +88,8 @@ struct ssb_sprom {
 	u16 boardflags2_hi;	/* Board flags (bits 48-63) */
 	/* TODO store board flags in a single u64 */
 
+	struct ssb_sprom_core_pwr_info core_pwr_info[4];
+
 	/* Antenna gain values for up to 4 antennas
 	 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
 	 * loss in the connectors is bigger than the gain. */
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index c814ae6..40b1ef8 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -449,6 +449,39 @@
 #define SSB_SPROM8_TS_SLP_OPT_CORRX	0x00B6
 #define SSB_SPROM8_FOC_HWIQ_IQSWP	0x00B8
 #define SSB_SPROM8_PHYCAL_TEMPDELTA	0x00BA
+
+/* There are 4 blocks with power info sharing the same layout */
+#define SSB_SROM8_PWR_INFO_CORE0	0x00C0
+#define SSB_SROM8_PWR_INFO_CORE1	0x00E0
+#define SSB_SROM8_PWR_INFO_CORE2	0x0100
+#define SSB_SROM8_PWR_INFO_CORE3	0x0120
+
+#define SSB_SROM8_2G_MAXP_ITSSI		0x00
+#define  SSB_SPROM8_2G_MAXP		0x00FF
+#define  SSB_SPROM8_2G_ITSSI		0xFF00
+#define  SSB_SPROM8_2G_ITSSI_SHIFT	8
+#define SSB_SROM8_2G_PA_0		0x02	/* 2GHz power amp settings */
+#define SSB_SROM8_2G_PA_1		0x04
+#define SSB_SROM8_2G_PA_2		0x06
+#define SSB_SROM8_5G_MAXP_ITSSI		0x08	/* 5GHz ITSSI and 5.3GHz Max Power */
+#define  SSB_SPROM8_5G_MAXP		0x00FF
+#define  SSB_SPROM8_5G_ITSSI		0xFF00
+#define  SSB_SPROM8_5G_ITSSI_SHIFT	8
+#define SSB_SPROM8_5GHL_MAXP		0x0A	/* 5.2GHz and 5.8GHz Max Power */
+#define  SSB_SPROM8_5GH_MAXP		0x00FF
+#define  SSB_SPROM8_5GL_MAXP		0xFF00
+#define  SSB_SPROM8_5GL_MAXP_SHIFT	8
+#define SSB_SROM8_5G_PA_0		0x0C	/* 5.3GHz power amp settings */
+#define SSB_SROM8_5G_PA_1		0x0E
+#define SSB_SROM8_5G_PA_2		0x10
+#define SSB_SROM8_5GL_PA_0		0x12	/* 5.2GHz power amp settings */
+#define SSB_SROM8_5GL_PA_1		0x14
+#define SSB_SROM8_5GL_PA_2		0x16
+#define SSB_SROM8_5GH_PA_0		0x18	/* 5.8GHz power amp settings */
+#define SSB_SROM8_5GH_PA_1		0x1A
+#define SSB_SROM8_5GH_PA_2		0x1C
+
+/* TODO: Make it deprecated */
 #define SSB_SPROM8_MAXP_BG		0x00C0  /* Max Power 2GHz in path 1 */
 #define  SSB_SPROM8_MAXP_BG_MASK	0x00FF  /* Mask for Max Power 2GHz */
 #define  SSB_SPROM8_ITSSI_BG		0xFF00	/* Mask for path 1 itssi_bg */
@@ -473,6 +506,7 @@
 #define SSB_SPROM8_PA1HIB0		0x00D8	/* 5.8GHz power amp settings */
 #define SSB_SPROM8_PA1HIB1		0x00DA
 #define SSB_SPROM8_PA1HIB2		0x00DC
+
 #define SSB_SPROM8_CCK2GPO		0x0140	/* CCK power offset */
 #define SSB_SPROM8_OFDM2GPO		0x0142	/* 2.4GHz OFDM power offset */
 #define SSB_SPROM8_OFDM5GPO		0x0146	/* 5.3GHz OFDM power offset */
-- 
1.7.3.4



From zajec5 at gmail.com  Mon Jan  2 02:41:24 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Mon,  2 Jan 2012 08:41:24 +0100
Subject: [PATCH 2/3] bcma: SPROM: add macro for easier extraction
In-Reply-To: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
References: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325490085-3806-2-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/bcma/sprom.c |  139 +++++++++++++++++++++++++------------------------
 1 files changed, 71 insertions(+), 68 deletions(-)

diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index 6f230fb..27f62cc 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -14,8 +14,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 
-#define SPOFF(offset)	((offset) / sizeof(u16))
-
 /**************************************************
  * R/W ops.
  **************************************************/
@@ -124,6 +122,11 @@ static int bcma_sprom_valid(const u16 *sprom)
  * SPROM extraction.
  **************************************************/
 
+#define SPOFF(offset)	((offset) / sizeof(u16))
+
+#define SPEX(_field, _offset, _mask, _shift)	\
+	bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
+
 static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
 {
 	u16 v;
@@ -137,72 +140,72 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
 		*(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
 	}
 
-	bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)];
-
-	bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
-	     SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT;
-	bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
-	     SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT;
-	bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
-	     SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT;
-	bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
-	     SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT;
-
-	bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
-	     SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT;
-	bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
-	     SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT;
-	bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
-	     SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT;
-	bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
-	     SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT;
-
-	bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
-	     SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT;
-	bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
-	     SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT;
-	bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
-	     SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT;
-	bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
-	     SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT;
-
-	bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
-	     SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT;
-	bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
-	     SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT;
-	bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
-	     SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT;
-	bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
-	     SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT;
-
-	bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)];
-	bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)];
-	bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)];
-	bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)];
-
-	bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)];
-
-	bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
-		SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
-	bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
-		SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
-	bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
-		SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
-	bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
-		SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
-	bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
-		SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
-
-	bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
-		SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
-	bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
-		SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
-	bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
-		SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
-	bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
-		SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
-	bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
-		SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
+	SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
+
+	SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
+	     SSB_SPROM4_TXPID2G0_SHIFT);
+	SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1,
+	     SSB_SPROM4_TXPID2G1_SHIFT);
+	SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2,
+	     SSB_SPROM4_TXPID2G2_SHIFT);
+	SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3,
+	     SSB_SPROM4_TXPID2G3_SHIFT);
+
+	SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0,
+	     SSB_SPROM4_TXPID5GL0_SHIFT);
+	SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1,
+	     SSB_SPROM4_TXPID5GL1_SHIFT);
+	SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2,
+	     SSB_SPROM4_TXPID5GL2_SHIFT);
+	SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3,
+	     SSB_SPROM4_TXPID5GL3_SHIFT);
+
+	SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0,
+	     SSB_SPROM4_TXPID5G0_SHIFT);
+	SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1,
+	     SSB_SPROM4_TXPID5G1_SHIFT);
+	SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2,
+	     SSB_SPROM4_TXPID5G2_SHIFT);
+	SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3,
+	     SSB_SPROM4_TXPID5G3_SHIFT);
+
+	SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0,
+	     SSB_SPROM4_TXPID5GH0_SHIFT);
+	SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1,
+	     SSB_SPROM4_TXPID5GH1_SHIFT);
+	SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2,
+	     SSB_SPROM4_TXPID5GH2_SHIFT);
+	SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3,
+	     SSB_SPROM4_TXPID5GH3_SHIFT);
+
+	SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0);
+	SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0);
+	SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
+	SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
+
+	SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0);
+
+	SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
+	     SSB_SROM8_FEM_TSSIPOS_SHIFT);
+	SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
+	     SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
+	SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE,
+	     SSB_SROM8_FEM_PDET_RANGE_SHIFT);
+	SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO,
+	     SSB_SROM8_FEM_TR_ISO_SHIFT);
+	SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT,
+	     SSB_SROM8_FEM_ANTSWLUT_SHIFT);
+
+	SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS,
+	     SSB_SROM8_FEM_TSSIPOS_SHIFT);
+	SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN,
+	     SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
+	SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE,
+	     SSB_SROM8_FEM_PDET_RANGE_SHIFT);
+	SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO,
+	     SSB_SROM8_FEM_TR_ISO_SHIFT);
+	SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
+	     SSB_SROM8_FEM_ANTSWLUT_SHIFT);
 }
 
 int bcma_sprom_get(struct bcma_bus *bus)
-- 
1.7.3.4



From zajec5 at gmail.com  Mon Jan  2 02:41:25 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Mon,  2 Jan 2012 08:41:25 +0100
Subject: [PATCH 3/3] bcma: SPROM: extract power info for cores
In-Reply-To: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
References: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325490085-3806-3-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/bcma/sprom.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index 27f62cc..cb835f0 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -129,8 +129,14 @@ static int bcma_sprom_valid(const u16 *sprom)
 
 static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
 {
-	u16 v;
+	u16 v, o;
 	int i;
+	u16 pwr_info_offset[] = {
+		SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
+		SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
+	};
+	BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
+			ARRAY_SIZE(bus->sprom.core_pwr_info));
 
 	bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
 		SSB_SPROM_REVISION_REV;
@@ -185,6 +191,38 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
 
 	SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0);
 
+	/* Extract cores power info info */
+	for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
+		o = pwr_info_offset[i];
+		SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
+			SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
+		SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
+			SSB_SPROM8_2G_MAXP, 0);
+
+		SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
+
+		SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
+			SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
+		SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
+			SSB_SPROM8_5G_MAXP, 0);
+		SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
+			SSB_SPROM8_5GH_MAXP, 0);
+		SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
+			SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
+
+		SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
+		SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
+	}
+
 	SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
 	     SSB_SROM8_FEM_TSSIPOS_SHIFT);
 	SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
-- 
1.7.3.4



From peter at stuge.se  Mon Jan  2 07:20:18 2012
From: peter at stuge.se (Peter Stuge)
Date: Mon, 2 Jan 2012 13:20:18 +0100
Subject: [PATCH 2/3] bcma: SPROM: add macro for easier extraction
In-Reply-To: <1325490085-3806-2-git-send-email-zajec5@gmail.com>
References: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
 <1325490085-3806-2-git-send-email-zajec5@gmail.com>
Message-ID: <20120102122018.30057.qmail@stuge.se>

Rafa? Mi?ecki wrote:
> +#define SPEX(_field, _offset, _mask, _shift)	\
> +	bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))

Maybe this should take at least bus as parameter too?


//Peter


From zajec5 at gmail.com  Mon Jan  2 07:39:02 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 2 Jan 2012 13:39:02 +0100
Subject: [PATCH 2/3] bcma: SPROM: add macro for easier extraction
In-Reply-To: <20120102122018.30057.qmail@stuge.se>
References: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
 <1325490085-3806-2-git-send-email-zajec5@gmail.com>
 <20120102122018.30057.qmail@stuge.se>
Message-ID: <CACna6rxjZ655nnDZjGWbNcaA8PD6BRMpdhqfBZ-StX9nECrScA@mail.gmail.com>

W dniu 2 stycznia 2012 13:20 u?ytkownik Peter Stuge <peter at stuge.se> napisa?:
> Rafa? Mi?ecki wrote:
>> +#define SPEX(_field, _offset, _mask, _shift) \
>> + ? ? bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
>
> Maybe this should take at least bus as parameter too?

I don't think we will ever want to extract SPROM info to something
else. Can't imageine such a situation right now.

Of course it may happen some new requirement will appear in the
future. But it's hard to predict it right now. And we never know what
macro will handle that future requirement. Oh, and we always can
modify existing macro or add new one :) Fortunately it's not any kind
of API :)

-- 
Rafa?


From zajec5 at gmail.com  Mon Jan  2 07:41:42 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 2 Jan 2012 13:41:42 +0100
Subject: [PATCH 2/3] bcma: SPROM: add macro for easier extraction
In-Reply-To: <20120102122018.30057.qmail@stuge.se>
References: <1325490085-3806-1-git-send-email-zajec5@gmail.com>
 <1325490085-3806-2-git-send-email-zajec5@gmail.com>
 <20120102122018.30057.qmail@stuge.se>
Message-ID: <CACna6rxiHydMmVOK18DO6X5COSUvZ+2c5=n-_oztBsP3NkxFhQ@mail.gmail.com>

W dniu 2 stycznia 2012 13:20 u?ytkownik Peter Stuge <peter at stuge.se> napisa?:
> Rafa? Mi?ecki wrote:
>> +#define SPEX(_field, _offset, _mask, _shift) \
>> + ? ? bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
>
> Maybe this should take at least bus as parameter too?

I also like the proposed solution because it let me fit some lines 80
chars length. See all the
SSB_SROM8_*_PA_[0-2]
from the next patch. Most of them are 80 char long ;)

-- 
Rafa?


From zajec5 at gmail.com  Mon Jan  2 13:31:21 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Mon,  2 Jan 2012 19:31:21 +0100
Subject: [PATCH 4/3] b43: add maskset helpers
Message-ID: <1325529082-10218-1-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/b43.h   |   12 +++++++
 drivers/net/wireless/b43/main.c  |   67 +++++++++++---------------------------
 drivers/net/wireless/b43/phy_n.c |   14 +++-----
 3 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 16e8f80..835462d 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -999,6 +999,12 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)
 	dev->dev->write16(dev->dev, offset, value);
 }
 
+static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask,
+				 u16 set)
+{
+	b43_write16(dev, offset, (b43_read16(dev, offset) & mask) | set);
+}
+
 static inline u32 b43_read32(struct b43_wldev *dev, u16 offset)
 {
 	return dev->dev->read32(dev->dev, offset);
@@ -1009,6 +1015,12 @@ static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value)
 	dev->dev->write32(dev->dev, offset, value);
 }
 
+static inline void b43_maskset32(struct b43_wldev *dev, u16 offset, u32 mask,
+				 u32 set)
+{
+	b43_write32(dev, offset, (b43_read32(dev, offset) & mask) | set);
+}
+
 static inline void b43_block_read(struct b43_wldev *dev, void *buffer,
 				 size_t count, u16 offset, u8 reg_width)
 {
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 989f654..4858e66 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -578,22 +578,14 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf)
 
 static void b43_time_lock(struct b43_wldev *dev)
 {
-	u32 macctl;
-
-	macctl = b43_read32(dev, B43_MMIO_MACCTL);
-	macctl |= B43_MACCTL_TBTTHOLD;
-	b43_write32(dev, B43_MMIO_MACCTL, macctl);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_TBTTHOLD);
 	/* Commit the write */
 	b43_read32(dev, B43_MMIO_MACCTL);
 }
 
 static void b43_time_unlock(struct b43_wldev *dev)
 {
-	u32 macctl;
-
-	macctl = b43_read32(dev, B43_MMIO_MACCTL);
-	macctl &= ~B43_MACCTL_TBTTHOLD;
-	b43_write32(dev, B43_MMIO_MACCTL, macctl);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_TBTTHOLD, 0);
 	/* Commit the write */
 	b43_read32(dev, B43_MMIO_MACCTL);
 }
@@ -2485,10 +2477,8 @@ static int b43_upload_microcode(struct b43_wldev *dev)
 	b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL);
 
 	/* Start the microcode PSM */
-	macctl = b43_read32(dev, B43_MMIO_MACCTL);
-	macctl &= ~B43_MACCTL_PSM_JMP0;
-	macctl |= B43_MACCTL_PSM_RUN;
-	b43_write32(dev, B43_MMIO_MACCTL, macctl);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_JMP0,
+		      B43_MACCTL_PSM_RUN);
 
 	/* Wait for the microcode to load and respond */
 	i = 0;
@@ -2588,10 +2578,9 @@ static int b43_upload_microcode(struct b43_wldev *dev)
 	return 0;
 
 error:
-	macctl = b43_read32(dev, B43_MMIO_MACCTL);
-	macctl &= ~B43_MACCTL_PSM_RUN;
-	macctl |= B43_MACCTL_PSM_JMP0;
-	b43_write32(dev, B43_MMIO_MACCTL, macctl);
+	/* Stop the microcode PSM. */
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN,
+		      B43_MACCTL_PSM_JMP0);
 
 	return err;
 }
@@ -2706,11 +2695,8 @@ static int b43_gpio_init(struct b43_wldev *dev)
 	struct ssb_device *gpiodev;
 	u32 mask, set;
 
-	b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
-		    & ~B43_MACCTL_GPOUTSMSK);
-
-	b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK)
-		    | 0x000F);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
+	b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF);
 
 	mask = 0x0000001F;
 	set = 0x0000000F;
@@ -2798,9 +2784,7 @@ void b43_mac_enable(struct b43_wldev *dev)
 	dev->mac_suspended--;
 	B43_WARN_ON(dev->mac_suspended < 0);
 	if (dev->mac_suspended == 0) {
-		b43_write32(dev, B43_MMIO_MACCTL,
-			    b43_read32(dev, B43_MMIO_MACCTL)
-			    | B43_MACCTL_ENABLED);
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_ENABLED);
 		b43_write32(dev, B43_MMIO_GEN_IRQ_REASON,
 			    B43_IRQ_MAC_SUSPENDED);
 		/* Commit writes */
@@ -2821,9 +2805,7 @@ void b43_mac_suspend(struct b43_wldev *dev)
 
 	if (dev->mac_suspended == 0) {
 		b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
-		b43_write32(dev, B43_MMIO_MACCTL,
-			    b43_read32(dev, B43_MMIO_MACCTL)
-			    & ~B43_MACCTL_ENABLED);
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_ENABLED, 0);
 		/* force pci to flush the write */
 		b43_read32(dev, B43_MMIO_MACCTL);
 		for (i = 35; i; i--) {
@@ -2929,15 +2911,10 @@ static void b43_adjust_opmode(struct b43_wldev *dev)
 	 *        so always disable it. If we want to implement PMQ,
 	 *        we need to enable it here (clear DISCPMQ) in AP mode.
 	 */
-	if (0  /* ctl & B43_MACCTL_AP */) {
-		b43_write32(dev, B43_MMIO_MACCTL,
-			    b43_read32(dev, B43_MMIO_MACCTL)
-			    & ~B43_MACCTL_DISCPMQ);
-	} else {
-		b43_write32(dev, B43_MMIO_MACCTL,
-			    b43_read32(dev, B43_MMIO_MACCTL)
-			    | B43_MACCTL_DISCPMQ);
-	}
+	if (0  /* ctl & B43_MACCTL_AP */)
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_DISCPMQ, 0);
+	else
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_DISCPMQ);
 }
 
 static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm)
@@ -3081,10 +3058,8 @@ static int b43_chip_init(struct b43_wldev *dev)
 	if (dev->dev->core_rev < 5)
 		b43_write32(dev, 0x010C, 0x01000000);
 
-	b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
-		    & ~B43_MACCTL_INFRA);
-	b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
-		    | B43_MACCTL_INFRA);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_INFRA, 0);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_INFRA);
 
 	/* Probe Response Timeout value */
 	/* FIXME: Default to 0, has to be set by ioctl probably... :-/ */
@@ -4562,8 +4537,6 @@ static void b43_set_pretbtt(struct b43_wldev *dev)
 /* Locking: wl->mutex */
 static void b43_wireless_core_exit(struct b43_wldev *dev)
 {
-	u32 macctl;
-
 	B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED);
 	if (!dev || b43_status(dev) != B43_STAT_INITIALIZED)
 		return;
@@ -4574,10 +4547,8 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
 	b43_set_status(dev, B43_STAT_UNINIT);
 
 	/* Stop the microcode PSM. */
-	macctl = b43_read32(dev, B43_MMIO_MACCTL);
-	macctl &= ~B43_MACCTL_PSM_RUN;
-	macctl |= B43_MACCTL_PSM_JMP0;
-	b43_write32(dev, B43_MMIO_MACCTL, macctl);
+	b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN,
+		      B43_MACCTL_PSM_JMP0);
 
 	b43_dma_free(dev);
 	b43_pio_free(dev);
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index aadfed0..c5cb0f4 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -3968,13 +3968,10 @@ static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
 #endif
 		}
 
-		b43_write32(dev, B43_MMIO_MACCTL,
-			b43_read32(dev, B43_MMIO_MACCTL) &
-			~B43_MACCTL_GPOUTSMSK);
-		b43_write16(dev, B43_MMIO_GPIO_MASK,
-			b43_read16(dev, B43_MMIO_GPIO_MASK) | 0xFC00);
-		b43_write16(dev, B43_MMIO_GPIO_CONTROL,
-			b43_read16(dev, B43_MMIO_GPIO_CONTROL) & ~0xFC00);
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
+		b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xFC00);
+		b43_maskset16(dev, B43_MMIO_GPIO_CONTROL, (~0xFC00 & 0xFFFF),
+			      0);
 
 		if (init) {
 			b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8);
@@ -4530,8 +4527,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 {
 	check_phyreg(dev, reg);
 	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-	b43_write16(dev, B43_MMIO_PHY_DATA,
-		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
+	b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
 }
 
 static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
-- 
1.7.3.4



From zajec5 at gmail.com  Mon Jan  2 13:31:22 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Mon,  2 Jan 2012 19:31:22 +0100
Subject: [PATCH 5/3] b43: N-PHY: implement TX power control setup
In-Reply-To: <1325529082-10218-1-git-send-email-zajec5@gmail.com>
References: <1325529082-10218-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325529082-10218-2-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c |  217 +++++++++++++++++++++++++++++++++++++-
 drivers/net/wireless/b43/phy_n.h |    1 +
 2 files changed, 217 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index c5cb0f4..15a0b79 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -2420,6 +2420,221 @@ static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev)
 	nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF;
 }
 
+/* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */
+static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)
+{
+	struct b43_phy_n *nphy = dev->phy.n;
+
+	u8 idx, delta;
+	u8 i, stf_mode;
+
+	for (i = 0; i < 4; i++)
+		nphy->adj_pwr_tbl[i] = nphy->tx_power_offset[i];
+
+	for (stf_mode = 0; stf_mode < 4; stf_mode++) {
+		delta = 0;
+		switch (stf_mode) {
+		case 0:
+			if (dev->phy.is_40mhz && dev->phy.rev >= 5) {
+				idx = 68;
+			} else {
+				delta = 1;
+				idx = dev->phy.is_40mhz ? 52 : 4;
+			}
+			break;
+		case 1:
+			idx = dev->phy.is_40mhz ? 76 : 28;
+			break;
+		case 2:
+			idx = dev->phy.is_40mhz ? 84 : 36;
+			break;
+		case 3:
+			idx = dev->phy.is_40mhz ? 92 : 44;
+			break;
+		}
+
+		for (i = 0; i < 20; i++) {
+			nphy->adj_pwr_tbl[4 + 4 * i + stf_mode] =
+				nphy->tx_power_offset[idx];
+			if (i == 0)
+				idx += delta;
+			if (i == 14)
+				idx += 1 - delta;
+			if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 ||
+			    i == 13)
+				idx += 1;
+		}
+	}
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
+static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
+{
+	struct b43_phy_n *nphy = dev->phy.n;
+	struct ssb_sprom *sprom = dev->dev->bus_sprom;
+
+	s16 a1[2], b0[2], b1[2];
+	u8 idle[2];
+	s8 target[2];
+	s32 num, den, pwr;
+	u32 regval[64];
+
+	u16 freq = dev->phy.channel_freq;
+	u16 tmp;
+	u16 r; /* routing */
+	u8 i, c;
+
+	if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) {
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000);
+		b43_read32(dev, B43_MMIO_MACCTL);
+		udelay(1);
+	}
+
+	if (nphy->hang_avoid)
+		b43_nphy_stay_in_carrier_search(dev, true);
+
+	b43_phy_set(dev, B43_NPHY_TSSIMODE, B43_NPHY_TSSIMODE_EN);
+	if (dev->phy.rev >= 3)
+		b43_phy_mask(dev, B43_NPHY_TXPCTL_CMD,
+			     ~B43_NPHY_TXPCTL_CMD_PCTLEN & 0xFFFF);
+	else
+		b43_phy_set(dev, B43_NPHY_TXPCTL_CMD,
+			    B43_NPHY_TXPCTL_CMD_PCTLEN);
+
+	if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12)
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0);
+
+	if (sprom->revision < 4) {
+		idle[0] = nphy->pwr_ctl_info[0].idle_tssi_2g;
+		idle[1] = nphy->pwr_ctl_info[1].idle_tssi_2g;
+		target[0] = target[1] = 52;
+		a1[0] = a1[1] = -424;
+		b0[0] = b0[1] = 5612;
+		b1[0] = b1[1] = -1393;
+	} else {
+		if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
+			for (c = 0; c < 2; c++) {
+				idle[c] = nphy->pwr_ctl_info[c].idle_tssi_2g;
+				target[c] = sprom->core_pwr_info[c].maxpwr_2g;
+				a1[c] = sprom->core_pwr_info[c].pa_2g[0];
+				b0[c] = sprom->core_pwr_info[c].pa_2g[1];
+				b1[c] = sprom->core_pwr_info[c].pa_2g[2];
+			}
+		} else if (freq >= 4900 && freq < 5100) {
+			for (c = 0; c < 2; c++) {
+				idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
+				target[c] = sprom->core_pwr_info[c].maxpwr_5gl;
+				a1[c] = sprom->core_pwr_info[c].pa_5gl[0];
+				b0[c] = sprom->core_pwr_info[c].pa_5gl[1];
+				b1[c] = sprom->core_pwr_info[c].pa_5gl[2];
+			}
+		} else if (freq >= 5100 && freq < 5500) {
+			for (c = 0; c < 2; c++) {
+				idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
+				target[c] = sprom->core_pwr_info[c].maxpwr_5g;
+				a1[c] = sprom->core_pwr_info[c].pa_5g[0];
+				b0[c] = sprom->core_pwr_info[c].pa_5g[1];
+				b1[c] = sprom->core_pwr_info[c].pa_5g[2];
+			}
+		} else if (freq >= 5500) {
+			for (c = 0; c < 2; c++) {
+				idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
+				target[c] = sprom->core_pwr_info[c].maxpwr_5gh;
+				a1[c] = sprom->core_pwr_info[c].pa_5gh[0];
+				b0[c] = sprom->core_pwr_info[c].pa_5gh[1];
+				b1[c] = sprom->core_pwr_info[c].pa_5gh[2];
+			}
+		} else {
+			idle[0] = nphy->pwr_ctl_info[0].idle_tssi_5g;
+			idle[1] = nphy->pwr_ctl_info[1].idle_tssi_5g;
+			target[0] = target[1] = 52;
+			a1[0] = a1[1] = -424;
+			b0[0] = b0[1] = 5612;
+			b1[0] = b1[1] = -1393;
+		}
+	}
+	/* target[0] = target[1] = nphy->tx_power_max; */
+
+	if (dev->phy.rev >= 3) {
+		if (sprom->fem.ghz2.tssipos)
+			b43_phy_set(dev, B43_NPHY_TXPCTL_ITSSI, 0x4000);
+		if (dev->phy.rev >= 7) {
+			for (c = 0; c < 2; c++) {
+				r = c ? 0x190 : 0x170;
+				if (b43_nphy_ipa(dev))
+					b43_radio_write(dev, r + 0x9, (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) ? 0xE : 0xC);
+			}
+		} else {
+			if (b43_nphy_ipa(dev)) {
+				tmp = (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ? 0xC : 0xE;
+				b43_radio_write(dev,
+					B2056_TX0 | B2056_TX_TX_SSI_MUX, tmp);
+				b43_radio_write(dev,
+					B2056_TX1 | B2056_TX_TX_SSI_MUX, tmp);
+			} else {
+				b43_radio_write(dev,
+					B2056_TX0 | B2056_TX_TX_SSI_MUX, 0x11);
+				b43_radio_write(dev,
+					B2056_TX1 | B2056_TX_TX_SSI_MUX, 0x11);
+			}
+		}
+	}
+
+	if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) {
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000);
+		b43_read32(dev, B43_MMIO_MACCTL);
+		udelay(1);
+	}
+
+	if (dev->phy.rev >= 7) {
+		b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD,
+				~B43_NPHY_TXPCTL_CMD_INIT, 0x19);
+		b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT,
+				~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x19);
+	} else {
+		b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD,
+				~B43_NPHY_TXPCTL_CMD_INIT, 0x40);
+		if (dev->phy.rev > 1)
+			b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT,
+				~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x40);
+	}
+
+	if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12)
+		b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0);
+
+	b43_phy_write(dev, B43_NPHY_TXPCTL_N,
+		      0xF0 << B43_NPHY_TXPCTL_N_TSSID_SHIFT |
+		      3 << B43_NPHY_TXPCTL_N_NPTIL2_SHIFT);
+	b43_phy_write(dev, B43_NPHY_TXPCTL_ITSSI,
+		      idle[0] << B43_NPHY_TXPCTL_ITSSI_0_SHIFT |
+		      idle[1] << B43_NPHY_TXPCTL_ITSSI_1_SHIFT |
+		      B43_NPHY_TXPCTL_ITSSI_BINF);
+	b43_phy_write(dev, B43_NPHY_TXPCTL_TPWR,
+		      target[0] << B43_NPHY_TXPCTL_TPWR_0_SHIFT |
+		      target[1] << B43_NPHY_TXPCTL_TPWR_1_SHIFT);
+
+	for (c = 0; c < 2; c++) {
+		for (i = 0; i < 64; i++) {
+			num = 8 * (16 * b0[c] + b1[c] * i);
+			den = 32768 + a1[c] * i;
+			pwr = max((4 * num + den / 2) / den, -8);
+			if (dev->phy.rev < 3 && (i <= (31 - idle[c] + 1)))
+				pwr = max(pwr, target[c] + 1);
+			regval[i] = pwr;
+		}
+		b43_ntab_write_bulk(dev, B43_NTAB32(26 + c, 0), 64, regval);
+	}
+
+	b43_nphy_tx_prepare_adjusted_power_table(dev);
+	/*
+	b43_ntab_write_bulk(dev, B43_NTAB16(26, 64), 84, nphy->adj_pwr_tbl);
+	b43_ntab_write_bulk(dev, B43_NTAB16(27, 64), 84, nphy->adj_pwr_tbl);
+	*/
+
+	if (nphy->hang_avoid)
+		b43_nphy_stay_in_carrier_search(dev, false);
+}
+
 static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 {
 	struct b43_phy *phy = &dev->phy;
@@ -4107,7 +4322,7 @@ int b43_phy_initn(struct b43_wldev *dev)
 	b43_nphy_tx_power_ctrl(dev, false);
 	b43_nphy_tx_power_fix(dev);
 	b43_nphy_tx_power_ctl_idle_tssi(dev);
-	/* TODO N PHY TX Power Control Setup */
+	b43_nphy_tx_power_ctl_setup(dev);
 	b43_nphy_tx_gain_table_upload(dev);
 
 	if (nphy->phyrxchain != 3)
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index 5de8f74..fd12b38 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -798,6 +798,7 @@ struct b43_phy_n {
 	bool txpwrctrl;
 	bool pwg_gain_5ghz;
 	u8 tx_pwr_idx[2];
+	s8 tx_power_offset[101];
 	u16 adj_pwr_tbl[84];
 	u16 txcal_bbmult;
 	u16 txiqlocal_bestc[11];
-- 
1.7.3.4



From zajec5 at gmail.com  Tue Jan  3 16:49:18 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Tue,  3 Jan 2012 22:49:18 +0100
Subject: [PATCH 2/5] b43: N-PHY: fix typos in RF control
In-Reply-To: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
References: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325627361-3394-2-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c       |    6 +++---
 drivers/net/wireless/b43/tables_nphy.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 20394d8..1e499f0 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -211,7 +211,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
 
 		reg = (i == 0) ?
 			B43_NPHY_RFCTL_INTC1 : B43_NPHY_RFCTL_INTC2;
-		b43_phy_mask(dev, reg, 0xFBFF);
+		b43_phy_set(dev, reg, 0x400);
 
 		switch (field) {
 		case 0:
@@ -227,7 +227,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
 				b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
 						B43_NPHY_RFCTL_CMD_START);
 				for (j = 0; j < 100; j++) {
-					if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START) {
+					if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START)) {
 						j = 0;
 						break;
 					}
@@ -246,7 +246,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
 				b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
 						B43_NPHY_RFCTL_CMD_RXTX);
 				for (j = 0; j < 100; j++) {
-					if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX) {
+					if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX)) {
 						j = 0;
 						break;
 					}
diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c
index 645bc34..dc52249 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2739,11 +2739,11 @@ const struct nphy_rf_control_override_rev3 tbl_rf_control_override_rev3[] = {
 	{ 0x0001,  0, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0002 (fls 2) */
 	{ 0x0002,  1, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0004 (fls 3) */
 	{ 0x0004,  2, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0008 (fls 4) */
-	{ 0x0016,  4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */
+	{ 0x0010,  4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */
 	{ 0x0020,  5, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0020 (fls 6) */
 	{ 0x0040,  6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0040 (fls 7) */
-	{ 0x0080,  6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */
-	{ 0x0100,  7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */
+	{ 0x0080,  7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */
+	{ 0x0100,  8, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */
 	{ 0x0007,  0, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0200 (fls 10) */
 	{ 0x0070,  4, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0400 (fls 11) */
 	{ 0xE000, 13, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0800 (fls 12) */
-- 
1.7.3.4



From zajec5 at gmail.com  Tue Jan  3 16:49:17 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Tue,  3 Jan 2012 22:49:17 +0100
Subject: [PATCH 1/5] b43: N-PHY: add helper for getting gain table
Message-ID: <1325627361-3394-1-git-send-email-zajec5@gmail.com>

Also move the code to tables file.

Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c       |   81 ++-----------------------------
 drivers/net/wireless/b43/tables_nphy.c |   65 ++++++++++++++++++++++----
 drivers/net/wireless/b43/tables_nphy.h |   12 +----
 3 files changed, 64 insertions(+), 94 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index ea7cc86..20394d8 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -85,24 +85,6 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev)
 		(dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ));
 }
 
-/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
-static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
-{
-	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
-		if (dev->phy.rev >= 6) {
-			if (dev->dev->chip_id == 47162)
-				return txpwrctrl_tx_gain_ipa_rev5;
-			return txpwrctrl_tx_gain_ipa_rev6;
-		} else if (dev->phy.rev >= 5) {
-			return txpwrctrl_tx_gain_ipa_rev5;
-		} else {
-			return txpwrctrl_tx_gain_ipa;
-		}
-	} else {
-		return txpwrctrl_tx_gain_ipa_5g;
-	}
-}
-
 /**************************************************
  * RF (just without b43_nphy_rf_control_intc_override)
  **************************************************/
@@ -2229,27 +2211,12 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
 	*/
 
 	for (i = 0; i < 2; i++) {
-		if (dev->phy.rev >= 3) {
-			if (b43_nphy_ipa(dev)) {
-				txgain = *(b43_nphy_get_ipa_gain_table(dev) +
-						txpi[i]);
-			} else if (b43_current_band(dev->wl) ==
-				   IEEE80211_BAND_5GHZ) {
-				/* FIXME: use 5GHz tables */
-				txgain =
-					b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
-			} else {
-				if (dev->phy.rev >= 5 &&
-				    sprom->fem.ghz5.extpa_gain == 3)
-					; /* FIXME: 5GHz_txgain_HiPwrEPA */
-				txgain =
-					b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
-			}
+		txgain = *(b43_nphy_get_tx_gain_table(dev) + txpi[i]);
+
+		if (dev->phy.rev >= 3)
 			radio_gain = (txgain >> 16) & 0x1FFFF;
-		} else {
-			txgain = b43_ntab_tx_gain_rev0_1_2[txpi[i]];
+		else
 			radio_gain = (txgain >> 16) & 0x1FFF;
-		}
 
 		if (dev->phy.rev >= 7)
 			dac_gain = (txgain >> 8) & 0x7;
@@ -2647,24 +2614,7 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 	int i;
 #endif
 
-	if (phy->rev >= 3) {
-		if (b43_nphy_ipa(dev)) {
-			table = b43_nphy_get_ipa_gain_table(dev);
-		} else {
-			if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
-				if (phy->rev == 3)
-					table = b43_ntab_tx_gain_rev3_5ghz;
-				if (phy->rev == 4)
-					table = b43_ntab_tx_gain_rev4_5ghz;
-				else
-					table = b43_ntab_tx_gain_rev5plus_5ghz;
-			} else {
-				table = b43_ntab_tx_gain_rev3plus_2ghz;
-			}
-		}
-	} else {
-		table = b43_ntab_tx_gain_rev0_1_2;
-	}
+	table = b43_nphy_get_tx_gain_table(dev);
 	b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table);
 	b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table);
 
@@ -3354,32 +3304,13 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)
 			B43_NPHY_TXPCTL_STAT_BIDX_SHIFT;
 
 		for (i = 0; i < 2; ++i) {
+			table = b43_nphy_get_tx_gain_table(dev);
 			if (dev->phy.rev >= 3) {
-				enum ieee80211_band band =
-					b43_current_band(dev->wl);
-
-				if (b43_nphy_ipa(dev)) {
-					table = b43_nphy_get_ipa_gain_table(dev);
-				} else {
-					if (band == IEEE80211_BAND_5GHZ) {
-						if (dev->phy.rev == 3)
-							table = b43_ntab_tx_gain_rev3_5ghz;
-						else if (dev->phy.rev == 4)
-							table = b43_ntab_tx_gain_rev4_5ghz;
-						else
-							table = b43_ntab_tx_gain_rev5plus_5ghz;
-					} else {
-						table = b43_ntab_tx_gain_rev3plus_2ghz;
-					}
-				}
-
 				target.ipa[i] = (table[index[i]] >> 16) & 0xF;
 				target.pad[i] = (table[index[i]] >> 20) & 0xF;
 				target.pga[i] = (table[index[i]] >> 24) & 0xF;
 				target.txgm[i] = (table[index[i]] >> 28) & 0xF;
 			} else {
-				table = b43_ntab_tx_gain_rev0_1_2;
-
 				target.ipa[i] = (table[index[i]] >> 16) & 0x3;
 				target.pad[i] = (table[index[i]] >> 18) & 0x3;
 				target.pga[i] = (table[index[i]] >> 20) & 0x7;
diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c
index b0de03f..645bc34 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2214,7 +2214,7 @@ static const u16 b43_ntab_antswctl2g_r3[4][32] = {
 };
 
 /* TX gain tables */
-const u32 b43_ntab_tx_gain_rev0_1_2[] = {
+static const u32 b43_ntab_tx_gain_rev0_1_2[] = {
 	0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42,
 	0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44,
 	0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844,
@@ -2249,7 +2249,7 @@ const u32 b43_ntab_tx_gain_rev0_1_2[] = {
 	0x03801442, 0x03801344, 0x03801342, 0x00002b00,
 };
 
-const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
+static const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
 	0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e,
 	0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037,
 	0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e,
@@ -2284,7 +2284,7 @@ const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
 	0x1041003c, 0x1041003b, 0x10410039, 0x10410037,
 };
 
-const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
+static const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
 	0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e,
 	0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037,
 	0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e,
@@ -2319,7 +2319,7 @@ const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
 	0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037,
 };
 
-const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
+static const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
 	0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e,
 	0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037,
 	0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e,
@@ -2354,7 +2354,7 @@ const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
 	0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034,
 };
 
-const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
+static const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
 	0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044,
 	0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c,
 	0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e,
@@ -2389,7 +2389,7 @@ const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
 	0x0062003b, 0x00620039, 0x00620037, 0x00620035,
 };
 
-const u32 txpwrctrl_tx_gain_ipa[] = {
+static const u32 txpwrctrl_tx_gain_ipa[] = {
 	0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029,
 	0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025,
 	0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029,
@@ -2424,7 +2424,7 @@ const u32 txpwrctrl_tx_gain_ipa[] = {
 	0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025,
 };
 
-const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
+static const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
 	0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029,
 	0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025,
 	0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029,
@@ -2459,7 +2459,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
 	0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025,
 };
 
-const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
+static const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
 	0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029,
 	0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025,
 	0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029,
@@ -2494,7 +2494,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
 	0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025,
 };
 
-const u32 txpwrctrl_tx_gain_ipa_5g[] = {
+static const u32 txpwrctrl_tx_gain_ipa_5g[] = {
 	0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031,
 	0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b,
 	0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027,
@@ -3126,6 +3126,53 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev)
 		B43_WARN_ON(1);
 }
 
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
+static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
+{
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
+		if (dev->phy.rev >= 6) {
+			if (dev->dev->chip_id == 47162)
+				return txpwrctrl_tx_gain_ipa_rev5;
+			return txpwrctrl_tx_gain_ipa_rev6;
+		} else if (dev->phy.rev >= 5) {
+			return txpwrctrl_tx_gain_ipa_rev5;
+		} else {
+			return txpwrctrl_tx_gain_ipa;
+		}
+	} else {
+		return txpwrctrl_tx_gain_ipa_5g;
+	}
+}
+
+const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev)
+{
+	enum ieee80211_band band = b43_current_band(dev->wl);
+	struct ssb_sprom *sprom = dev->dev->bus_sprom;
+
+	if (dev->phy.rev < 3)
+		return b43_ntab_tx_gain_rev0_1_2;
+
+	/* rev 3+ */
+	if ((dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) ||
+	    (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)) {
+		return b43_nphy_get_ipa_gain_table(dev);
+	} else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
+		if (dev->phy.rev == 3)
+			return b43_ntab_tx_gain_rev3_5ghz;
+		if (dev->phy.rev == 4)
+			return sprom->fem.ghz5.extpa_gain == 3 ?
+				b43_ntab_tx_gain_rev4_5ghz :
+				b43_ntab_tx_gain_rev4_5ghz; /* FIXME */
+		else
+			return b43_ntab_tx_gain_rev5plus_5ghz;
+	} else {
+		if (dev->phy.rev >= 5 && sprom->fem.ghz5.extpa_gain == 3)
+			return b43_ntab_tx_gain_rev3plus_2ghz; /* FIXME */
+		else
+			return b43_ntab_tx_gain_rev3plus_2ghz;
+	}
+}
+
 struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
 	struct b43_wldev *dev, bool ghz5, bool ext_lna)
 {
diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h
index 97038c4..2a9d5f1 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -177,16 +177,8 @@ void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
 void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev);
 void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev);
 
-extern const u32 b43_ntab_tx_gain_rev0_1_2[];
-extern const u32 b43_ntab_tx_gain_rev3plus_2ghz[];
-extern const u32 b43_ntab_tx_gain_rev3_5ghz[];
-extern const u32 b43_ntab_tx_gain_rev4_5ghz[];
-extern const u32 b43_ntab_tx_gain_rev5plus_5ghz[];
-
-extern const u32 txpwrctrl_tx_gain_ipa[];
-extern const u32 txpwrctrl_tx_gain_ipa_rev5[];
-extern const u32 txpwrctrl_tx_gain_ipa_rev6[];
-extern const u32 txpwrctrl_tx_gain_ipa_5g[];
+const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
+
 extern const u16 tbl_iqcal_gainparams[2][9][8];
 extern const struct nphy_txiqcal_ladder ladder_lo[];
 extern const struct nphy_txiqcal_ladder ladder_iq[];
-- 
1.7.3.4



From zajec5 at gmail.com  Tue Jan  3 16:49:19 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Tue,  3 Jan 2012 22:49:19 +0100
Subject: [PATCH 3/5] b43: N-PHY: upload PAPD PGA gain delta table
In-Reply-To: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
References: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325627361-3394-3-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c       |   11 +++++------
 drivers/net/wireless/b43/tables_nphy.c |    5 +++++
 drivers/net/wireless/b43/tables_nphy.h |    2 ++
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 1e499f0..c4c310d 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -2607,12 +2607,9 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 	struct b43_phy *phy = &dev->phy;
 
 	const u32 *table = NULL;
-#if 0
-	TODO: b43_ntab_papd_pga_gain_delta_ipa_2*
 	u32 rfpwr_offset;
 	u8 pga_gain;
 	int i;
-#endif
 
 	table = b43_nphy_get_tx_gain_table(dev);
 	b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table);
@@ -2621,19 +2618,21 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 	if (phy->rev >= 3) {
 #if 0
 		nphy->gmval = (table[0] >> 16) & 0x7000;
+#endif
 
 		for (i = 0; i < 128; i++) {
 			pga_gain = (table[i] >> 24) & 0xF;
 			if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
-				rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain];
+				rfpwr_offset =
+				 b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain];
 			else
-				rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_5g[pga_gain];
+				rfpwr_offset =
+				 0; /* FIXME */
 			b43_ntab_write(dev, B43_NTAB32(26, 576 + i),
 				       rfpwr_offset);
 			b43_ntab_write(dev, B43_NTAB32(27, 576 + i),
 				       rfpwr_offset);
 		}
-#endif
 	}
 }
 
diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c
index dc52249..44d49f7 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2529,6 +2529,11 @@ static const u32 txpwrctrl_tx_gain_ipa_5g[] = {
 	0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f,
 };
 
+const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[] = {
+	-114, -108, -98, -91, -84, -78, -70, -62,
+	-54, -46, -39, -31, -23, -15, -8, 0
+};
+
 const u16 tbl_iqcal_gainparams[2][9][8] = {
 	{
 		{ 0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69 },
diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h
index 2a9d5f1..f348953 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -179,6 +179,8 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev);
 
 const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
 
+extern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[];
+
 extern const u16 tbl_iqcal_gainparams[2][9][8];
 extern const struct nphy_txiqcal_ladder ladder_lo[];
 extern const struct nphy_txiqcal_ladder ladder_iq[];
-- 
1.7.3.4



From zajec5 at gmail.com  Tue Jan  3 16:49:20 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Tue,  3 Jan 2012 22:49:20 +0100
Subject: [PATCH 4/5] b43: N-PHY: implement RSSI calibration for rev3+
In-Reply-To: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
References: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325627361-3394-4-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c |  192 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 186 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index c4c310d..d794ad9 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -85,6 +85,13 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev)
 		(dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ));
 }
 
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
+static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)
+{
+	return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >>
+		B43_NPHY_RFSEQCA_RXEN_SHIFT;
+}
+
 /**************************************************
  * RF (just without b43_nphy_rf_control_intc_override)
  **************************************************/
@@ -1290,6 +1297,185 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
 	return out;
 }
 
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
+static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
+{
+	struct b43_phy_n *nphy = dev->phy.n;
+
+	u16 saved_regs_phy_rfctl[2];
+	u16 saved_regs_phy[13];
+	u16 regs_to_store[] = {
+		B43_NPHY_AFECTL_OVER1, B43_NPHY_AFECTL_OVER,
+		B43_NPHY_AFECTL_C1, B43_NPHY_AFECTL_C2,
+		B43_NPHY_TXF_40CO_B1S1, B43_NPHY_RFCTL_OVER,
+		B43_NPHY_TXF_40CO_B1S0, B43_NPHY_TXF_40CO_B32S1,
+		B43_NPHY_RFCTL_CMD,
+		B43_NPHY_RFCTL_LUT_TRSW_UP1, B43_NPHY_RFCTL_LUT_TRSW_UP2,
+		B43_NPHY_RFCTL_RSSIO1, B43_NPHY_RFCTL_RSSIO2
+	};
+
+	u16 class;
+
+	u16 clip_state[2];
+	u16 clip_off[2] = { 0xFFFF, 0xFFFF };
+
+	u8 vcm_final = 0;
+	s8 offset[4];
+	s32 results[8][4] = { };
+	s32 results_min[4] = { };
+	s32 poll_results[4] = { };
+
+	u16 *rssical_radio_regs = NULL;
+	u16 *rssical_phy_regs = NULL;
+
+	u16 r; /* routing */
+	u8 rx_core_state;
+	u8 core, i, j;
+
+	class = b43_nphy_classifier(dev, 0, 0);
+	b43_nphy_classifier(dev, 7, 4);
+	b43_nphy_read_clip_detection(dev, clip_state);
+	b43_nphy_write_clip_detection(dev, clip_off);
+
+	saved_regs_phy_rfctl[0] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
+	saved_regs_phy_rfctl[1] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
+	for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
+		saved_regs_phy[i] = b43_phy_read(dev, regs_to_store[i]);
+
+	b43_nphy_rf_control_intc_override(dev, 0, 0, 7);
+	b43_nphy_rf_control_intc_override(dev, 1, 1, 7);
+	b43_nphy_rf_control_override(dev, 0x1, 0, 0, false);
+	b43_nphy_rf_control_override(dev, 0x2, 1, 0, false);
+	b43_nphy_rf_control_override(dev, 0x80, 1, 0, false);
+	b43_nphy_rf_control_override(dev, 0x40, 1, 0, false);
+
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
+		b43_nphy_rf_control_override(dev, 0x20, 0, 0, false);
+		b43_nphy_rf_control_override(dev, 0x10, 1, 0, false);
+	} else {
+		b43_nphy_rf_control_override(dev, 0x10, 0, 0, false);
+		b43_nphy_rf_control_override(dev, 0x20, 1, 0, false);
+	}
+
+	rx_core_state = b43_nphy_get_rx_core_state(dev);
+	for (core = 0; core < 2; core++) {
+		if (!(rx_core_state & (1 << core)))
+			continue;
+		r = core ? B2056_RX1 : B2056_RX0;
+		b43_nphy_scale_offset_rssi(dev, 0, 0, i + 1, 0, 2);
+		b43_nphy_scale_offset_rssi(dev, 0, 0, i + 1, 1, 2);
+		for (i = 0; i < 8; i++) {
+			b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
+					i << 2);
+			b43_nphy_poll_rssi(dev, 2, results[i], 8);
+		}
+		for (i = 0; i < 4; i++) {
+			s32 curr;
+			s32 mind = 40;
+			s32 minpoll = 249;
+			u8 minvcm = 0;
+			if (2 * core != i)
+				continue;
+			for (j = 0; j < 8; j++) {
+				curr = results[j][i] * results[j][i] +
+					results[j][i + 1] * results[j][i];
+				if (curr < mind) {
+					mind = curr;
+					minvcm = j;
+				}
+				if (results[j][i] < minpoll)
+					minpoll = results[j][i];
+			}
+			vcm_final = minvcm;
+			results_min[i] = minpoll;
+		}
+		b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
+				  vcm_final << 2);
+		for (i = 0; i < 4; i++) {
+			if (core != i / 2)
+				continue;
+			offset[i] = -results[vcm_final][i];
+			if (offset[i] < 0)
+				offset[i] = -((abs(offset[i]) + 4) / 8);
+			else
+				offset[i] = (offset[i] + 4) / 8;
+			if (results_min[i] == 248)
+				offset[i] = -32;
+			b43_nphy_scale_offset_rssi(dev, 0, offset[i],
+						   (i / 2 == 0) ? 1 : 2,
+						   (i % 2 == 0) ? 0 : 1,
+						   2);
+		}
+	}
+	for (core = 0; core < 2; core++) {
+		if (!(rx_core_state & (1 << core)))
+			continue;
+		for (i = 0; i < 2; i++) {
+			b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, i);
+			b43_nphy_poll_rssi(dev, i, poll_results, 8);
+			for (j = 0; j < 4; j++) {
+				if (j / 2 == core)
+					offset[j] = 232 - poll_results[j];
+				if (offset[j] < 0)
+					offset[j] = -(abs(offset[j] + 4) / 8);
+				else
+					offset[j] = (offset[j] + 4) / 8;
+				b43_nphy_scale_offset_rssi(dev, 0,
+					offset[2 * core], core + 1, j % 2, i);
+			}
+		}
+	}
+
+	b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, saved_regs_phy_rfctl[0]);
+	b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, saved_regs_phy_rfctl[1]);
+
+	b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
+
+	b43_phy_set(dev, B43_NPHY_TXF_40CO_B1S1, 0x1);
+	b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_START);
+	b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
+
+	b43_phy_set(dev, B43_NPHY_RFCTL_OVER, 0x1);
+	b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_RXTX);
+	b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
+
+	for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
+		b43_phy_write(dev, regs_to_store[i], saved_regs_phy[i]);
+
+	/* Store for future configuration */
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
+		rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
+		rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
+	} else {
+		rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
+		rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
+	}
+	rssical_radio_regs[0] = b43_radio_read(dev, 0x602B);
+	rssical_radio_regs[0] = b43_radio_read(dev, 0x702B);
+	rssical_phy_regs[0] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Z);
+	rssical_phy_regs[1] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Z);
+	rssical_phy_regs[2] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Z);
+	rssical_phy_regs[3] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Z);
+	rssical_phy_regs[4] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_X);
+	rssical_phy_regs[5] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_X);
+	rssical_phy_regs[6] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_X);
+	rssical_phy_regs[7] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_X);
+	rssical_phy_regs[8] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Y);
+	rssical_phy_regs[9] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Y);
+	rssical_phy_regs[10] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Y);
+	rssical_phy_regs[11] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Y);
+
+	/* Remember for which channel we store configuration */
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
+		nphy->rssical_chanspec_2G.center_freq = dev->phy.channel_freq;
+	else
+		nphy->rssical_chanspec_5G.center_freq = dev->phy.channel_freq;
+
+	/* End of calibration, restore configuration */
+	b43_nphy_classifier(dev, 7, class);
+	b43_nphy_write_clip_detection(dev, clip_state);
+}
+
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
 static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
 {
@@ -1454,12 +1640,6 @@ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
 	b43_nphy_reset_cca(dev);
 }
 
-/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
-static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
-{
-	/* TODO */
-}
-
 /*
  * RSSI Calibration
  * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
-- 
1.7.3.4



From zajec5 at gmail.com  Tue Jan  3 16:49:21 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Tue,  3 Jan 2012 22:49:21 +0100
Subject: [PATCH 5/5] b43: N-PHY: trivial: change save&rest order in RSSI
 polling
In-Reply-To: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
References: <1325627361-3394-1-git-send-email-zajec5@gmail.com>
Message-ID: <1325627361-3394-5-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 drivers/net/wireless/b43/phy_n.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index d794ad9..b779396 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1220,12 +1220,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
 	u16 s[2];
 
 	if (dev->phy.rev >= 3) {
-		save_regs_phy[0] = b43_phy_read(dev,
+		save_regs_phy[0] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
+		save_regs_phy[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
+		save_regs_phy[2] = b43_phy_read(dev,
 						B43_NPHY_RFCTL_LUT_TRSW_UP1);
-		save_regs_phy[1] = b43_phy_read(dev,
+		save_regs_phy[3] = b43_phy_read(dev,
 						B43_NPHY_RFCTL_LUT_TRSW_UP2);
-		save_regs_phy[2] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
-		save_regs_phy[3] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
 		save_regs_phy[4] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1);
 		save_regs_phy[5] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
 		save_regs_phy[6] = b43_phy_read(dev, B43_NPHY_TXF_40CO_B1S0);
@@ -1274,12 +1274,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
 		b43_phy_write(dev, B43_NPHY_GPIO_SEL, save_regs_phy[8]);
 
 	if (dev->phy.rev >= 3) {
+		b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[0]);
+		b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[1]);
 		b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1,
-				save_regs_phy[0]);
+				save_regs_phy[2]);
 		b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2,
-				save_regs_phy[1]);
-		b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[2]);
-		b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[3]);
+				save_regs_phy[3]);
 		b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, save_regs_phy[4]);
 		b43_phy_write(dev, B43_NPHY_AFECTL_OVER, save_regs_phy[5]);
 		b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S0, save_regs_phy[6]);
-- 
1.7.3.4



From xavion.0 at gmail.com  Tue Jan  3 19:41:40 2012
From: xavion.0 at gmail.com (Xavion)
Date: Wed, 4 Jan 2012 11:41:40 +1100
Subject: Some confusion over which 'b43' v5.10.x firmware I should be using
In-Reply-To: <4EFE80EB.8080906@lwfinger.net>
References: <CAKnx8Y5fHgCbG2BDgc3Tq=-PtPUiv6JRi8oT0zj6ZE8s=XCxCg@mail.gmail.com>
 <4EFE80EB.8080906@lwfinger.net>
Message-ID: <CAKnx8Y6BMTXJVXnBP9C2QBQz6xybV-eeJZKumsF=hEDxihWfWg@mail.gmail.com>

Hi Larry

Thanks for the prompt reply.  Based on your response to my question, I
decided to take the plunge and upgrade my "b43-firmware" package. My main
reason for doing so was because it could positively impact some of the
newer 'b43' devices.

A user of this package has informed me that he's run into problems using
the new (v5.10.144.3) firmware on his BCM4312 device.  After viewing the
output he's supplied, can you explain to me what's going on and how we can
overcome this issue?

I have problems with todays upgrade.
> I have a BCM4312 (http://ompldr.org/vYzFneg/wlan), which works the last
> version, but not with todays upgrade.
> Kernel-Log with 5.10.56.27.3-2 => http://ompldr.org/vYzFoMg/5.10.56.27.3-2
> Kernel-Log with 5.10.144.3-1 => http://ompldr.org/vYzFoNQ/5.10.144.3-1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120104/0bb0facf/attachment.html>

From zajec5 at gmail.com  Wed Jan  4 19:05:30 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Thu,  5 Jan 2012 01:05:30 +0100
Subject: [PATCH V2 4/5] b43: N-PHY: implement RSSI calibration for rev3+
Message-ID: <1325721930-3525-1-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
V2: fix typo in argument being not a variable increased by for(){}
add one missing b43_nphy_scale_offset_rssi call
---
 drivers/net/wireless/b43/phy_n.c |  193 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 187 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index c4c310d..06a9cd0 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -85,6 +85,13 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev)
 		(dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ));
 }
 
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
+static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)
+{
+	return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >>
+		B43_NPHY_RFSEQCA_RXEN_SHIFT;
+}
+
 /**************************************************
  * RF (just without b43_nphy_rf_control_intc_override)
  **************************************************/
@@ -1290,6 +1297,186 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
 	return out;
 }
 
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
+static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
+{
+	struct b43_phy_n *nphy = dev->phy.n;
+
+	u16 saved_regs_phy_rfctl[2];
+	u16 saved_regs_phy[13];
+	u16 regs_to_store[] = {
+		B43_NPHY_AFECTL_OVER1, B43_NPHY_AFECTL_OVER,
+		B43_NPHY_AFECTL_C1, B43_NPHY_AFECTL_C2,
+		B43_NPHY_TXF_40CO_B1S1, B43_NPHY_RFCTL_OVER,
+		B43_NPHY_TXF_40CO_B1S0, B43_NPHY_TXF_40CO_B32S1,
+		B43_NPHY_RFCTL_CMD,
+		B43_NPHY_RFCTL_LUT_TRSW_UP1, B43_NPHY_RFCTL_LUT_TRSW_UP2,
+		B43_NPHY_RFCTL_RSSIO1, B43_NPHY_RFCTL_RSSIO2
+	};
+
+	u16 class;
+
+	u16 clip_state[2];
+	u16 clip_off[2] = { 0xFFFF, 0xFFFF };
+
+	u8 vcm_final = 0;
+	s8 offset[4];
+	s32 results[8][4] = { };
+	s32 results_min[4] = { };
+	s32 poll_results[4] = { };
+
+	u16 *rssical_radio_regs = NULL;
+	u16 *rssical_phy_regs = NULL;
+
+	u16 r; /* routing */
+	u8 rx_core_state;
+	u8 core, i, j;
+
+	class = b43_nphy_classifier(dev, 0, 0);
+	b43_nphy_classifier(dev, 7, 4);
+	b43_nphy_read_clip_detection(dev, clip_state);
+	b43_nphy_write_clip_detection(dev, clip_off);
+
+	saved_regs_phy_rfctl[0] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
+	saved_regs_phy_rfctl[1] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
+	for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
+		saved_regs_phy[i] = b43_phy_read(dev, regs_to_store[i]);
+
+	b43_nphy_rf_control_intc_override(dev, 0, 0, 7);
+	b43_nphy_rf_control_intc_override(dev, 1, 1, 7);
+	b43_nphy_rf_control_override(dev, 0x1, 0, 0, false);
+	b43_nphy_rf_control_override(dev, 0x2, 1, 0, false);
+	b43_nphy_rf_control_override(dev, 0x80, 1, 0, false);
+	b43_nphy_rf_control_override(dev, 0x40, 1, 0, false);
+
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
+		b43_nphy_rf_control_override(dev, 0x20, 0, 0, false);
+		b43_nphy_rf_control_override(dev, 0x10, 1, 0, false);
+	} else {
+		b43_nphy_rf_control_override(dev, 0x10, 0, 0, false);
+		b43_nphy_rf_control_override(dev, 0x20, 1, 0, false);
+	}
+
+	rx_core_state = b43_nphy_get_rx_core_state(dev);
+	for (core = 0; core < 2; core++) {
+		if (!(rx_core_state & (1 << core)))
+			continue;
+		r = core ? B2056_RX1 : B2056_RX0;
+		b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, 2);
+		b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, 2);
+		for (i = 0; i < 8; i++) {
+			b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
+					i << 2);
+			b43_nphy_poll_rssi(dev, 2, results[i], 8);
+		}
+		for (i = 0; i < 4; i++) {
+			s32 curr;
+			s32 mind = 40;
+			s32 minpoll = 249;
+			u8 minvcm = 0;
+			if (2 * core != i)
+				continue;
+			for (j = 0; j < 8; j++) {
+				curr = results[j][i] * results[j][i] +
+					results[j][i + 1] * results[j][i];
+				if (curr < mind) {
+					mind = curr;
+					minvcm = j;
+				}
+				if (results[j][i] < minpoll)
+					minpoll = results[j][i];
+			}
+			vcm_final = minvcm;
+			results_min[i] = minpoll;
+		}
+		b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
+				  vcm_final << 2);
+		for (i = 0; i < 4; i++) {
+			if (core != i / 2)
+				continue;
+			offset[i] = -results[vcm_final][i];
+			if (offset[i] < 0)
+				offset[i] = -((abs(offset[i]) + 4) / 8);
+			else
+				offset[i] = (offset[i] + 4) / 8;
+			if (results_min[i] == 248)
+				offset[i] = -32;
+			b43_nphy_scale_offset_rssi(dev, 0, offset[i],
+						   (i / 2 == 0) ? 1 : 2,
+						   (i % 2 == 0) ? 0 : 1,
+						   2);
+		}
+	}
+	for (core = 0; core < 2; core++) {
+		if (!(rx_core_state & (1 << core)))
+			continue;
+		for (i = 0; i < 2; i++) {
+			b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, i);
+			b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, i);
+			b43_nphy_poll_rssi(dev, i, poll_results, 8);
+			for (j = 0; j < 4; j++) {
+				if (j / 2 == core)
+					offset[j] = 232 - poll_results[j];
+				if (offset[j] < 0)
+					offset[j] = -(abs(offset[j] + 4) / 8);
+				else
+					offset[j] = (offset[j] + 4) / 8;
+				b43_nphy_scale_offset_rssi(dev, 0,
+					offset[2 * core], core + 1, j % 2, i);
+			}
+		}
+	}
+
+	b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, saved_regs_phy_rfctl[0]);
+	b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, saved_regs_phy_rfctl[1]);
+
+	b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
+
+	b43_phy_set(dev, B43_NPHY_TXF_40CO_B1S1, 0x1);
+	b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_START);
+	b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
+
+	b43_phy_set(dev, B43_NPHY_RFCTL_OVER, 0x1);
+	b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_RXTX);
+	b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
+
+	for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
+		b43_phy_write(dev, regs_to_store[i], saved_regs_phy[i]);
+
+	/* Store for future configuration */
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
+		rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
+		rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
+	} else {
+		rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
+		rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
+	}
+	rssical_radio_regs[0] = b43_radio_read(dev, 0x602B);
+	rssical_radio_regs[0] = b43_radio_read(dev, 0x702B);
+	rssical_phy_regs[0] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Z);
+	rssical_phy_regs[1] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Z);
+	rssical_phy_regs[2] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Z);
+	rssical_phy_regs[3] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Z);
+	rssical_phy_regs[4] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_X);
+	rssical_phy_regs[5] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_X);
+	rssical_phy_regs[6] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_X);
+	rssical_phy_regs[7] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_X);
+	rssical_phy_regs[8] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Y);
+	rssical_phy_regs[9] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Y);
+	rssical_phy_regs[10] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Y);
+	rssical_phy_regs[11] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Y);
+
+	/* Remember for which channel we store configuration */
+	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
+		nphy->rssical_chanspec_2G.center_freq = dev->phy.channel_freq;
+	else
+		nphy->rssical_chanspec_5G.center_freq = dev->phy.channel_freq;
+
+	/* End of calibration, restore configuration */
+	b43_nphy_classifier(dev, 7, class);
+	b43_nphy_write_clip_detection(dev, clip_state);
+}
+
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
 static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
 {
@@ -1454,12 +1641,6 @@ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
 	b43_nphy_reset_cca(dev);
 }
 
-/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
-static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
-{
-	/* TODO */
-}
-
 /*
  * RSSI Calibration
  * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
-- 
1.7.3.4



From gmasgras at gmail.com  Thu Jan  5 19:48:25 2012
From: gmasgras at gmail.com (George Masgras)
Date: Thu, 5 Jan 2012 16:48:25 -0800
Subject: poor performance with BCM4331 and 3.2
Message-ID: <CAM-fOTRG63M9c350+t3nxAjfWAuxZMSH4U1gACExKq0ZxHuqtQ@mail.gmail.com>

Hello,
 I've been having issues with getting the b43 driver to work reliably
in Ubuntu 11.10 on a MacbookPro 8,1.  The problem is that the driver
seems to be losing connection very often, especially when I have
multiple programs hitting the net. (s.a. Spotify, Firefox and Chrome),
sometimes even causing kernel panics( pre kernel 3.2 final). I'm now
using kernel 3.2 vanilla with compat-wireless-2012-01-03 compiled on
top and I haven't gotten a kernel panic yet but I will post it if I
do.
I've also noticed that the less people in the office using WIFI, the
more stable the connection is (there are ~25 people in the whole
office using WIFI,  10 of them in the same room as me).
Wicd reports between 80-100% signal strength and the encryption is
WPA2 PSK. The AP is a PepWave AP One (3.1.0) and it is behind a wall,
in a room 15ft away from my desk.

more info:

$ uname -a:
Linux geomas-MacBookPro 3.2.0-custom #2 SMP PREEMPT Thu Jan 5 11:14:09
PST 2012 x86_64 x86_64 x86_64 GNU/Linux

$ sudo lspci -vvn|grep 43 -A7:
03:00.0 0280: 14e4:4331 (rev 02)
        Subsystem: 106b:00d6
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 256 bytes
        Interrupt: pin A routed to IRQ 17
        Region 0: Memory at a0600000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3

dmesg:
http://pastebin.com/0zAQzwVY

kern.log:
http://pastebin.com/Ncf21bWY


Thank you for all the great work!

George


From rfkrocktk at gmail.com  Thu Jan  5 21:51:29 2012
From: rfkrocktk at gmail.com (Tyler Kocheran)
Date: Thu, 5 Jan 2012 18:51:29 -0800
Subject: poor performance with BCM4331 and 3.2
In-Reply-To: <CAM-fOTRG63M9c350+t3nxAjfWAuxZMSH4U1gACExKq0ZxHuqtQ@mail.gmail.com>
References: <CAM-fOTRG63M9c350+t3nxAjfWAuxZMSH4U1gACExKq0ZxHuqtQ@mail.gmail.com>
Message-ID: <CAPTk+sa-vGgaTSE=UqXsf6uHM9nqG-Ne9vYgaMsxQ2yFwdCDOQ@mail.gmail.com>

George,
Also running a MacBook Pro (8,3) and seeing similar issues. I'll be
connected to the AP, but I'll lose all internet connectivity every so
often. Disconnecting and reconnecting to the AP works, or unloading and
reloading the module. I'd like to help contribute to this to help it get
fixed.

I'm even willing to donate root SSH access to the developers, if that
helps.

Thanks,
 - TK



On Thu, Jan 5, 2012 at 4:48 PM, George Masgras <gmasgras at gmail.com> wrote:

> Hello,
>  I've been having issues with getting the b43 driver to work reliably
> in Ubuntu 11.10 on a MacbookPro 8,1.  The problem is that the driver
> seems to be losing connection very often, especially when I have
> multiple programs hitting the net. (s.a. Spotify, Firefox and Chrome),
> sometimes even causing kernel panics( pre kernel 3.2 final). I'm now
> using kernel 3.2 vanilla with compat-wireless-2012-01-03 compiled on
> top and I haven't gotten a kernel panic yet but I will post it if I
> do.
> I've also noticed that the less people in the office using WIFI, the
> more stable the connection is (there are ~25 people in the whole
> office using WIFI,  10 of them in the same room as me).
> Wicd reports between 80-100% signal strength and the encryption is
> WPA2 PSK. The AP is a PepWave AP One (3.1.0) and it is behind a wall,
> in a room 15ft away from my desk.
>
> more info:
>
> $ uname -a:
> Linux geomas-MacBookPro 3.2.0-custom #2 SMP PREEMPT Thu Jan 5 11:14:09
> PST 2012 x86_64 x86_64 x86_64 GNU/Linux
>
> $ sudo lspci -vvn|grep 43 -A7:
> 03:00.0 0280: 14e4:4331 (rev 02)
>        Subsystem: 106b:00d6
>        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
> ParErr- Stepping- SERR- FastB2B- DisINTx-
>        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
> <TAbort- <MAbort- >SERR- <PERR- INTx-
>        Latency: 0, Cache Line Size: 256 bytes
>        Interrupt: pin A routed to IRQ 17
>        Region 0: Memory at a0600000 (64-bit, non-prefetchable) [size=16K]
>        Capabilities: [40] Power Management version 3
>
> dmesg:
> http://pastebin.com/0zAQzwVY
>
> kern.log:
> http://pastebin.com/Ncf21bWY
>
>
> Thank you for all the great work!
>
> George
>
> _______________________________________________
> b43-dev mailing list
> b43-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/b43-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120105/ed0ac36f/attachment.html>

From zajec5 at gmail.com  Mon Jan  9 16:31:42 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 9 Jan 2012 22:31:42 +0100
Subject: BCM43231
In-Reply-To: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
Message-ID: <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>

[RESEND without attachment]

2011/12/30 Abimanyu Gottumukkala <me at abimanyu.in>:
> Does any one have status or any info on BCM43231 USB drivers?

I've received my WNA3100, 0846:9020 (maybe BCM43231, can't confirm).

 It works with ndiswrapper and bcmwlhigh6, I can scan and even connect
 to my WPA2 network.

 Unfortunately I've no idea what hardware is this. I've dumped
 ndiswrapper USB operations but they don't tell me a single thing.
 Initialization is represented by only ~1000 lines in dumps and I've
 connected in next ~1500 lines of USB dump. I've been using "usbmon" to
 dump traffic.

 The hardware seems to have:
 1) Configuration
 2) 3 endpoints (2*bulk, 1*interrupt)

 The attached dump doesn't contain:
 1) Anything EPROM specific (like 0x4BF... or 0x0000000F)
 2) Anything SPROM specific (like 0x5372 signature)
 3) Anything Broadcom specific (like 0x14e4)
 4) Anything BCMA specific (like 0x408 aka BCMA_IOCTL)

 I've no idea what to look for on this card. I started to believe it's
 some fullmac, but didn't find anything to prove this.


 Larry: is there any chance you will give some tips on this hardware? I
 know RE of x86 driver can be really ugly, but maybe you'll find
 something somewhere anyway? At least some minimal tip.


 The only thing I've recognized in USB dump is my MAC address
 (E0:46:9A:19:58:DB):
 ea7009c0 505509888 S Bo:2:010:3 -115 24 = 14000000 21000000 2b000000
 00000000 e0469a19 58db0000
 f3dbe340 505509949 S Bo:2:010:3 -115 28 = 18000000 22000000 31000000
 48000000 08000000 e0469a19 58db0000
 f0257d40 505510010 S Bo:2:010:3 -115 24 = 14000000 23000000 2b000000
 03000000 00000000 00000000

 eea80c40 512759339 S Bo:2:010:3 -115 24 = 14000000 66010000 2b000000
 00000000 e0469a19 58db0000
 eb48d740 512759348 S Bo:2:010:3 -115 28 = 18000000 67010000 31000000
 48000000 08000000 e0469a19 58db0000
 f6275240 512759354 S Bo:2:010:3 -115 24 = 14000000 68010000 2b000000
 03000000 00000000 00000000
 f0257f40 512759360 S Bo:2:010:3 -115 24 = 14000000 69010000 2e000000
 6c0d0000 00000000 60030000
 f0257ac0 512759366 S Bo:2:010:3 -115 20 = 10000000 6a010000 30000000
 d4050000 00000000
 eb48d2c0 512759372 S Bo:2:010:3 -115 20 = 10000000 6b010000 30000000
 d6050000 10000000
 f6275740 512759378 S Bo:2:010:3 -115 20 = 10000000 6c010000 30000000
 d8050000 20000000
 f62757c0 512759384 S Bo:2:010:3 -115 20 = 10000000 6d010000 30000000
 da050000 30000000
 f0257a40 512759390 S Bo:2:010:3 -115 20 = 10000000 6e010000 30000000
 dc050000 40000000
 f2c191c0 512759396 S Bo:2:010:3 -115 20 = 10000000 6f010000 30000000
 de050000 50000000
 eb48d540 512759402 S Bo:2:010:3 -115 20 = 10000000 70010000 30000000
 e0050000 60000000
 eb48d340 512759408 S Bo:2:010:3 -115 20 = 10000000 71010000 30000000
 e2050000 70000000
 ea700d40 512759414 S Bo:2:010:3 -115 20 = 10000000 72010000 30000000
 e4050000 80000000
 f2c19ec0 512759420 S Bo:2:010:3 -115 20 = 10000000 73010000 30000000
 e6050000 90000000

 f224fec0 505489563 C Ci:2:010:0 0 20 = 10000000 03000001 35000000
 e0469a19 58db0000

-- 
Rafa?


From Larry.Finger at lwfinger.net  Mon Jan  9 17:18:34 2012
From: Larry.Finger at lwfinger.net (Larry Finger)
Date: Mon, 09 Jan 2012 16:18:34 -0600
Subject: BCM43231
In-Reply-To: <CACna6rzNrFWBJ+n3n9wrnP_Gi3LKCWt+o1Gs38_EjkMgG_k8vg@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzNrFWBJ+n3n9wrnP_Gi3LKCWt+o1Gs38_EjkMgG_k8vg@mail.gmail.com>
Message-ID: <4F0B67BA.20207@lwfinger.net>

On 01/09/2012 02:12 PM, Rafa? Mi?ecki wrote:
> 2011/12/30 Abimanyu Gottumukkala<me at abimanyu.in>:
>> Does any one have status or any info on BCM43231 USB drivers?
>
> I've received my WNA3100, 0846:9020 (maybe BCM43231, can't confirm).
>
> It works with ndiswrapper and bcmwlhigh6, I can scan and even connect
> to my WPA2 network.
>
> Unfortunately I've no idea what hardware is this. I've dumped
> ndiswrapper USB operations but they don't tell me a single thing.
> Initialization is represented by only ~1000 lines in dumps and I've
> connected in next ~1500 lines of USB dump. I've been using "usbmon" to
> dump traffic.

The evidence points to some kind of Broadcom chip. The USB data base says that 
an ID of "0846:9020" is a "WNA3100(v1) Wireless-N 300 [Broadcom BCM43231]". In 
addition, the Windows driver name of bcmwlhigh6 indicates a BroadCoM WL driver 
of some sort. Given the relatively small amount of initialization traffic, it 
must be a fullmac device that likely does not need external firmware.

I remember seeing some mail about the Broadcom guys working on a Linux driver 
for a USB fullmac device. Is this the one? (I added Arend to the Cc.)

Larry


From peter at stuge.se  Mon Jan  9 17:25:44 2012
From: peter at stuge.se (Peter Stuge)
Date: Mon, 9 Jan 2012 23:25:44 +0100
Subject: BCM43231
In-Reply-To: <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
Message-ID: <20120109222544.11008.qmail@stuge.se>

Rafa? Mi?ecki wrote:
> I've been using "usbmon" to dump traffic.

The tool at http://people.redhat.com/zaitcev/linux/usbmon-6.tar.gz
and not simply cat on the usbmon files in debugfs I hope.

debugfs only shows the first bytes of long transfers, but the API
used by the usbmon-6 tool shows complete traffic.


//Peter


From zajec5 at gmail.com  Mon Jan  9 17:28:24 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 9 Jan 2012 23:28:24 +0100
Subject: BCM43231
In-Reply-To: <20120109222544.11008.qmail@stuge.se>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
Message-ID: <CACna6rx_q6J4PU0ucX+ZJqqkzpp24pf3Mz+Od2HPtVg8w-r1pQ@mail.gmail.com>

W dniu 9 stycznia 2012 23:25 u?ytkownik Peter Stuge <peter at stuge.se> napisa?:
> Rafa? Mi?ecki wrote:
>> I've been using "usbmon" to dump traffic.
>
> The tool at http://people.redhat.com/zaitcev/linux/usbmon-6.tar.gz
> and not simply cat on the usbmon files in debugfs I hope.
>
> debugfs only shows the first bytes of long transfers, but the API
> used by the usbmon-6 tool shows complete traffic.

I was just using
cat /sys/kernel/debug/usb/usbmon/0u

I didn't see info about eating the rest of transfer in
Documentation/usb/usbmon.txt. Thanks for the tip, I'll give it a
chance tomorrow.

-- 
Rafa?


From netrolller.3d at gmail.com  Mon Jan  9 18:14:09 2012
From: netrolller.3d at gmail.com (=?ISO-8859-1?Q?G=E1bor_Stefanik?=)
Date: Tue, 10 Jan 2012 00:14:09 +0100
Subject: BCM43231
In-Reply-To: <CACna6rx_q6J4PU0ucX+ZJqqkzpp24pf3Mz+Od2HPtVg8w-r1pQ@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
 <CACna6rx_q6J4PU0ucX+ZJqqkzpp24pf3Mz+Od2HPtVg8w-r1pQ@mail.gmail.com>
Message-ID: <CA+XFjiqdiAwaZmN9PLQhmvxHNZ1Bgkr-NwHb4nLaP5PWm2eU8w@mail.gmail.com>

2012/1/9 Rafa? Mi?ecki <zajec5 at gmail.com>:
> W dniu 9 stycznia 2012 23:25 u?ytkownik Peter Stuge <peter at stuge.se> napisa?:
>> Rafa? Mi?ecki wrote:
>>> I've been using "usbmon" to dump traffic.
>>
>> The tool at http://people.redhat.com/zaitcev/linux/usbmon-6.tar.gz
>> and not simply cat on the usbmon files in debugfs I hope.
>>
>> debugfs only shows the first bytes of long transfers, but the API
>> used by the usbmon-6 tool shows complete traffic.
>
> I was just using
> cat /sys/kernel/debug/usb/usbmon/0u
>
> I didn't see info about eating the rest of transfer in
> Documentation/usb/usbmon.txt. Thanks for the tip, I'll give it a
> chance tomorrow.

This information, if true, should go into Documentation/usb/usbmon.txt.


From zajec5 at gmail.com  Tue Jan 10 02:00:48 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Tue, 10 Jan 2012 08:00:48 +0100
Subject: BCM43231
In-Reply-To: <20120109222544.11008.qmail@stuge.se>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
Message-ID: <CACna6ryJT1Nw8Yxrj8CftERjO=y7kYc-9cTP5Bj-N-=NniAhdg@mail.gmail.com>

W dniu 9 stycznia 2012 23:25 u?ytkownik Peter Stuge <peter at stuge.se> napisa?:
> Rafa? Mi?ecki wrote:
>> I've been using "usbmon" to dump traffic.
>
> The tool at http://people.redhat.com/zaitcev/linux/usbmon-6.tar.gz
> and not simply cat on the usbmon files in debugfs I hope.
>
> debugfs only shows the first bytes of long transfers, but the API
> used by the usbmon-6 tool shows complete traffic.

I think I start to understand. The number before "<" or "=" or ">" is
amount of bytes. For example:

ea700b40 493839847 S Bi:2:003:6 -115 8 <
We just asked for 8 bytes

ea700b40 493840818 C Bi:2:003:6 0 8 = 00060456 00000000
Here we received the 8 bytes.

f3dad540 493840838 S Bi:2:003:6 -115 13 <
We asked for 13 bytes.

f3dad540 493840923 C Bi:2:003:6 0 13 = 55534253 0a1a0000 00000000 00
The requested 13 bytes.

Now some bigger amount:

eb48d640 504977573 S Ci:2:010:0 s 80 06 0200 0000 0027 39 <
Asking for 39bytes?

eb48d640 504977936 C Ci:2:010:0 0 39 = 09022700 010100a0 64090400
0003ff02 ff000705 81031000 04070582 02000200
Only 32bytes received?

Is this the issue you meant? Am I correctly parsing that dumps?



I've quickly tried usbmon userspace tool, but not much more luck with
it. Example from this tool:

f2c19e40 6.317817 S Ci:2:013:0 s 80 06 0200 0000 0027 39 <
f2c19e40 6.318305 C Ci:2:013:0 0 39 =
    09022700 010100a0 64090400 0003ff02 ff000705 81031000 04070582 02000200
     . . ' .  . . . .  d . . .  . . . .  . . . .  . . . .  . . . .  . . . .

Maybe it requires some switch or sth... unfortunately it's not
documented at all ;/

-- 
Rafa?


From zajec5 at gmail.com  Tue Jan 10 02:29:33 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Tue, 10 Jan 2012 08:29:33 +0100
Subject: BCM43231
In-Reply-To: <CACna6ryJT1Nw8Yxrj8CftERjO=y7kYc-9cTP5Bj-N-=NniAhdg@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
 <CACna6ryJT1Nw8Yxrj8CftERjO=y7kYc-9cTP5Bj-N-=NniAhdg@mail.gmail.com>
Message-ID: <CACna6ryuR1hoJGH1Gy_v_N-HUhgL_8rxZf_-9q=DPQW-ERGX0w@mail.gmail.com>

W dniu 10 stycznia 2012 08:00 u?ytkownik Rafa? Mi?ecki
<zajec5 at gmail.com> napisa?:
> I've quickly tried usbmon userspace tool, but not much more luck with
> it. Example from this tool:
>
> f2c19e40 6.317817 S Ci:2:013:0 s 80 06 0200 0000 0027 39 <
> f2c19e40 6.318305 C Ci:2:013:0 0 39 =
> ? ?09022700 010100a0 64090400 0003ff02 ff000705 81031000 04070582 02000200
> ? ? . . ' . ?. . . . ?d . . . ?. . . . ?. . . . ?. . . . ?. . . . ?. . . .
>
> Maybe it requires some switch or sth... unfortunately it's not
> documented at all ;/

usbmon -s 1024 > dump.txt
:)

-- 
Rafa?


From m at bues.ch  Tue Jan 10 04:36:21 2012
From: m at bues.ch (Michael =?UTF-8?B?QsO8c2No?=)
Date: Tue, 10 Jan 2012 10:36:21 +0100
Subject: BCM43231
In-Reply-To: <CACna6ryuR1hoJGH1Gy_v_N-HUhgL_8rxZf_-9q=DPQW-ERGX0w@mail.gmail.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
 <CACna6ryJT1Nw8Yxrj8CftERjO=y7kYc-9cTP5Bj-N-=NniAhdg@mail.gmail.com>
 <CACna6ryuR1hoJGH1Gy_v_N-HUhgL_8rxZf_-9q=DPQW-ERGX0w@mail.gmail.com>
Message-ID: <20120110103621.4a1292b2@milhouse>

On Tue, 10 Jan 2012 08:29:33 +0100
Rafa? Mi?ecki <zajec5 at gmail.com> wrote:

> W dniu 10 stycznia 2012 08:00 u?ytkownik Rafa? Mi?ecki
> <zajec5 at gmail.com> napisa?:
> > I've quickly tried usbmon userspace tool, but not much more luck with
> > it. Example from this tool:
> >
> > f2c19e40 6.317817 S Ci:2:013:0 s 80 06 0200 0000 0027 39 <
> > f2c19e40 6.318305 C Ci:2:013:0 0 39 =
> > ? ?09022700 010100a0 64090400 0003ff02 ff000705 81031000 04070582 02000200
> > ? ? . . ' . ?. . . . ?d . . . ?. . . . ?. . . . ?. . . . ?. . . . ?. . . .
> >
> > Maybe it requires some switch or sth... unfortunately it's not
> > documented at all ;/
> 
> usbmon -s 1024 > dump.txt
> :)
> 

Just for reference: wireshark is perfectly usable with usbmon and
thus has all the standard wireshark features like filtering, etc, too.

-- 
Greetings, Michael.


From zajec5 at gmail.com  Tue Jan 10 06:14:14 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Tue, 10 Jan 2012 12:14:14 +0100
Subject: BCM43231
In-Reply-To: <4F0C1C0C.2020504@broadcom.com>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzNrFWBJ+n3n9wrnP_Gi3LKCWt+o1Gs38_EjkMgG_k8vg@mail.gmail.com>
 <4F0B67BA.20207@lwfinger.net> <4F0C1C0C.2020504@broadcom.com>
Message-ID: <CACna6ry75+cW=M4gAFbf6E3aBqbfKUYEpnkZNAMwTsEvLAg3JA@mail.gmail.com>

2012/1/10 Arend van Spriel <arend at broadcom.com>:
> On 01/09/2012 11:18 PM, Larry Finger wrote:
>>
>> I remember seeing some mail about the Broadcom guys working on a Linux driver
>> for a USB fullmac device. Is this the one? (I added Arend to the Cc.)
>>
>> Larry
>>
>
> As you know we currently have two linux drivers. brcmfmac is a fullmac
> architecture for cfg80211, brcmsmac is a softmac architecture for
> mac80211. The brcmfmac driver will get usb support soon (when I finish
> my testing over here) but it supports another device (ie. bcm43236).
>
> The bcm43231 has another architecture and can not be supported by either
> of the drivers.

Can you check what chipset is 0846:9020? I didn't see any prove it's
BCM43231 so far. Can you confirm/deny this?

Firmware upload of Windows driver for 0846:9020 looks similar to brcmfmac.

-- 
Rafa?


From peter at stuge.se  Tue Jan 10 11:59:37 2012
From: peter at stuge.se (Peter Stuge)
Date: Tue, 10 Jan 2012 17:59:37 +0100
Subject: BCM43231
In-Reply-To: <20120110103621.4a1292b2@milhouse>
References: <CAEWwF+bnM0bxbZR6B57H_nv3fkUdhP-ytAu30MLhUWq7QxB3GQ@mail.gmail.com>
 <CACna6rzA6ix2PrZDHXQLTDQuo942urtUAWYagDC0x9zANSVNKQ@mail.gmail.com>
 <20120109222544.11008.qmail@stuge.se>
 <CACna6ryJT1Nw8Yxrj8CftERjO=y7kYc-9cTP5Bj-N-=NniAhdg@mail.gmail.com>
 <CACna6ryuR1hoJGH1Gy_v_N-HUhgL_8rxZf_-9q=DPQW-ERGX0w@mail.gmail.com>
 <20120110103621.4a1292b2@milhouse>
Message-ID: <20120110165937.29782.qmail@stuge.se>

Michael B?sch wrote:
> Just for reference: wireshark is perfectly usable with usbmon and
> thus has all the standard wireshark features like filtering, etc, too.

Yes, wireshark also uses the same binary API as the usbmon tool.


//Peter


From Larry.Finger at lwfinger.net  Wed Jan 11 15:39:32 2012
From: Larry.Finger at lwfinger.net (Larry Finger)
Date: Wed, 11 Jan 2012 14:39:32 -0600
Subject: [PATCH] bcma: Enable logging of SPROM offset
Message-ID: <4f0df384.FkBMG6tZuMiWW0Yf%Larry.Finger@lwfinger.net>

The SPROM location has been relocated again for some devices. This patch
will log the offset when CONFIG_BCMA_DEBUG has been selected.

Signed-off-by: Larry Finger <Larry.Finger at lwfinger.net>
---
 
Index: wireless-testing-new/drivers/bcma/sprom.c
===================================================================
--- wireless-testing-new.orig/drivers/bcma/sprom.c
+++ wireless-testing-new/drivers/bcma/sprom.c
@@ -230,6 +230,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
 	 * TODO: understand this condition and use it */
 	offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
 		BCMA_CC_SPROM_PCIE6;
+	pr_debug("SPROM offset 0x%x\n", offset);
 	bcma_sprom_read(bus, offset, sprom);
 
 	if (bus->chipinfo.id == 0x4331)


From zajec5 at gmail.com  Thu Jan 12 11:11:50 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Thu, 12 Jan 2012 17:11:50 +0100
Subject: [PATCH] b43: add default option to avoid duplicating device
 support with brcmsmac
In-Reply-To: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
References: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
Message-ID: <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>

2012/1/11 John W. Linville <linville at tuxdriver.com>:
> +config B43_BCMA_EXTRA
> + ? ? ? bool "Support for devices also supported by brcmsmac"
> + ? ? ? depends on B43_BCMA
> + ? ? ? default n
> +

Is this really *the* solution? I wonder if we can do whatever you're
trying to do in a better way? To let final users try both drivers
without recompiling kernel?

The description also isn't saying too much. I can't imagine anyone
taking decision advisedly other than "n, as it's the default". On
other hand, what should we put here? The whole comparison of drivers?
Can be hard, but I really think there should be more info.

-- 
Rafa?


From zajec5 at gmail.com  Thu Jan 12 11:28:58 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Thu, 12 Jan 2012 17:28:58 +0100
Subject: [PATCH 0/2] bcma/b43: update MAINTAINERS
Message-ID: <1326385740-11203-1-git-send-email-zajec5@gmail.com>

John can you take that patches via your tree?

Rafa? Mi?ecki (2):
  MAINTAINERS: move BCMA to keep the list sorted
  MAINTAINERS: add b43 mailing list

 MAINTAINERS |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

-- 
1.7.7



From zajec5 at gmail.com  Thu Jan 12 11:28:59 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Thu, 12 Jan 2012 17:28:59 +0100
Subject: =?UTF-8?q?=5BPATCH=201/2=5D=20MAINTAINERS=3A=20move=20BCMA=20to=20keep=20the=20list=20sorted?=
In-Reply-To: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
References: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
Message-ID: <1326385740-11203-2-git-send-email-zajec5@gmail.com>

---
 MAINTAINERS |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4babed7..dc11e28 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1595,6 +1595,13 @@ L:	linux-scsi at vger.kernel.org
 S:	Supported
 F:	drivers/scsi/bnx2fc/
 
+BROADCOM SPECIFIC AMBA DRIVER (BCMA)
+M:	Rafa? Mi?ecki <zajec5 at gmail.com>
+L:	linux-wireless at vger.kernel.org
+S:	Maintained
+F:	drivers/bcma/
+F:	include/linux/bcma/
+
 BROCADE BFA FC SCSI DRIVER
 M:	Jing Huang <huangj at brocade.com>
 L:	linux-scsi at vger.kernel.org
@@ -6101,13 +6108,6 @@ S:	Maintained
 F:	drivers/ssb/
 F:	include/linux/ssb/
 
-BROADCOM SPECIFIC AMBA DRIVER (BCMA)
-M:	Rafa? Mi?ecki <zajec5 at gmail.com>
-L:	linux-wireless at vger.kernel.org
-S:	Maintained
-F:	drivers/bcma/
-F:	include/linux/bcma/
-
 SONY VAIO CONTROL DEVICE DRIVER
 M:	Mattia Dongili <malattia at linux.it>
 L:	platform-driver-x86 at vger.kernel.org
-- 
1.7.7



From zajec5 at gmail.com  Thu Jan 12 11:29:00 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Thu, 12 Jan 2012 17:29:00 +0100
Subject: [PATCH 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
References: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
Message-ID: <1326385740-11203-3-git-send-email-zajec5@gmail.com>

---
 MAINTAINERS |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dc11e28..0b39eb9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1419,6 +1419,7 @@ F:	net/ax25/
 B43 WIRELESS DRIVER
 M:	Stefano Brivio <stefano.brivio at polimi.it>
 L:	linux-wireless at vger.kernel.org
+L:	b43-dev at lists.infradead.org
 W:	http://linuxwireless.org/en/users/Drivers/b43
 S:	Maintained
 F:	drivers/net/wireless/b43/
-- 
1.7.7



From linville at tuxdriver.com  Thu Jan 12 11:17:20 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Thu, 12 Jan 2012 11:17:20 -0500
Subject: [PATCH] b43: add default option to avoid duplicating device
 support with brcmsmac
In-Reply-To: <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>
References: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
 <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>
Message-ID: <20120112161720.GI11093@tuxdriver.com>

On Thu, Jan 12, 2012 at 05:11:50PM +0100, Rafa? Mi?ecki wrote:
> 2012/1/11 John W. Linville <linville at tuxdriver.com>:
> > +config B43_BCMA_EXTRA
> > + ? ? ? bool "Support for devices also supported by brcmsmac"
> > + ? ? ? depends on B43_BCMA
> > + ? ? ? default n
> > +
> 
> Is this really *the* solution? I wonder if we can do whatever you're
> trying to do in a better way? To let final users try both drivers
> without recompiling kernel?

Saying "y" would let users try both drivers.  That is up to the
distros or other kernel builders to choose.

At present, they have no choice but to let the two drivers race to
see who gets loaded first or whatever.  I imagine that some would
prefer to have an option that prevents that.

> The description also isn't saying too much. I can't imagine anyone
> taking decision advisedly other than "n, as it's the default". On
> other hand, what should we put here? The whole comparison of drivers?
> Can be hard, but I really think there should be more info.

More info could be put in a "---help---" section.  The summary line
could be different as well, if you can think of a better way to
describe the issue.  I am open to suggestions.

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


From jonas.gorski at gmail.com  Thu Jan 12 11:33:38 2012
From: jonas.gorski at gmail.com (Jonas Gorski)
Date: Thu, 12 Jan 2012 17:33:38 +0100
Subject: [PATCH 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326385740-11203-3-git-send-email-zajec5@gmail.com>
References: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
 <1326385740-11203-3-git-send-email-zajec5@gmail.com>
Message-ID: <CAOiHx==h-CZAuU=NTy7zY40K8KjZE7RAk6zrfTkCE6GkSzNvpA@mail.gmail.com>

Hi,

2012/1/12 Rafa? Mi?ecki <zajec5 at gmail.com>:
> ---
> ?MAINTAINERS | ? ?1 +
> ?1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index dc11e28..0b39eb9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1419,6 +1419,7 @@ F: ? ? ? ?net/ax25/
> ?B43 WIRELESS DRIVER
> ?M: ? ? Stefano Brivio <stefano.brivio at polimi.it>
> ?L: ? ? linux-wireless at vger.kernel.org
> +L: ? ? b43-dev at lists.infradead.org

You might want to add "(moderated for non-subscribers)" (unless that
was changed lately).


Jonas


From zajec5 at gmail.com  Thu Jan 12 11:44:00 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Thu, 12 Jan 2012 17:44:00 +0100
Subject: [PATCH V2 2/2] MAINTAINERS: add b43 mailing list
Message-ID: <1326386640-11677-1-git-send-email-zajec5@gmail.com>

---
V2: add "(moderated for non-subscribers)"
---
 MAINTAINERS |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dc11e28..469efce 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1419,6 +1419,7 @@ F:	net/ax25/
 B43 WIRELESS DRIVER
 M:	Stefano Brivio <stefano.brivio at polimi.it>
 L:	linux-wireless at vger.kernel.org
+L:	b43-dev at lists.infradead.org (moderated for non-subscribers)
 W:	http://linuxwireless.org/en/users/Drivers/b43
 S:	Maintained
 F:	drivers/net/wireless/b43/
-- 
1.7.7



From peter at stuge.se  Thu Jan 12 20:32:48 2012
From: peter at stuge.se (Peter Stuge)
Date: Fri, 13 Jan 2012 02:32:48 +0100
Subject: [PATCH] b43: add default option to avoid duplicating device
 support with brcmsmac
In-Reply-To: <20120112161720.GI11093@tuxdriver.com>
References: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
 <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>
 <20120112161720.GI11093@tuxdriver.com>
Message-ID: <20120113013248.30123.qmail@stuge.se>

John W. Linville wrote:
> The summary line could be different as well, if you can think of a
> better way to describe the issue.  I am open to suggestions.

I think these terms are clear:

Community b43 driver
Broadcom brcmsmac driver

How to apply them I leave up to you. :)


//Peter


From linville at tuxdriver.com  Fri Jan 13 14:20:01 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Fri, 13 Jan 2012 14:20:01 -0500
Subject: [PATCH] b43: add default option to avoid duplicating device
 support with brcmsmac
In-Reply-To: <20120113013248.30123.qmail@stuge.se>
References: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
 <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>
 <20120112161720.GI11093@tuxdriver.com>
 <20120113013248.30123.qmail@stuge.se>
Message-ID: <20120113192000.GD18899@tuxdriver.com>

On Fri, Jan 13, 2012 at 02:32:48AM +0100, Peter Stuge wrote:
> John W. Linville wrote:
> > The summary line could be different as well, if you can think of a
> > better way to describe the issue.  I am open to suggestions.
> 
> I think these terms are clear:
> 
> Community b43 driver
> Broadcom brcmsmac driver
> 
> How to apply them I leave up to you. :)

Maybe you think that is clear, but it doesn't do much for me.

I could say "Support for devices already supported by the
Broadcom-supported brcmsmac driver"?

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


From linville at tuxdriver.com  Fri Jan 13 14:20:27 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Fri, 13 Jan 2012 14:20:27 -0500
Subject: [PATCH] b43: add default option to avoid duplicating device
 support with brcmsmac
In-Reply-To: <CAGRGNgUkBUvoBJydcdprBXP0ufR+PQ6nXFXdW546xjHbQ-O2Bg@mail.gmail.com>
References: <1326315180-29398-1-git-send-email-linville@tuxdriver.com>
 <CACna6rxffpPhYVqKNttu79JET=NkBP4NrAayywQHWcj=mw=T9A@mail.gmail.com>
 <CAGRGNgUkBUvoBJydcdprBXP0ufR+PQ6nXFXdW546xjHbQ-O2Bg@mail.gmail.com>
Message-ID: <20120113192027.GE18899@tuxdriver.com>

On Fri, Jan 13, 2012 at 01:07:03PM +1100, Julian Calaby wrote:
> 2012/1/13 Rafa? Mi?ecki <zajec5 at gmail.com>:
> > 2012/1/11 John W. Linville <linville at tuxdriver.com>:
> >> +config B43_BCMA_EXTRA
> >> + ? ? ? bool "Support for devices also supported by brcmsmac"
> >> + ? ? ? depends on B43_BCMA
> >> + ? ? ? default n
> >> +
> >
> > Is this really *the* solution? I wonder if we can do whatever you're
> > trying to do in a better way? To let final users try both drivers
> > without recompiling kernel?
> 
> Another issue is that this should arguably be default y if brcmsmac is disabled.

Can you help by suggesting the correct Kconfig magic to implement that?

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


From linville at tuxdriver.com  Fri Jan 13 14:38:33 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Fri, 13 Jan 2012 14:38:33 -0500
Subject: [PATCH 1/2] MAINTAINERS: move BCMA to keep the list sorted
In-Reply-To: <1326385740-11203-2-git-send-email-zajec5@gmail.com>
References: <1326385740-11203-1-git-send-email-zajec5@gmail.com>
 <1326385740-11203-2-git-send-email-zajec5@gmail.com>
Message-ID: <20120113193833.GF18899@tuxdriver.com>

Patches need Signed-off-by lines...

On Thu, Jan 12, 2012 at 05:28:59PM +0100, Rafa? Mi?ecki wrote:
> ---
>  MAINTAINERS |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4babed7..dc11e28 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1595,6 +1595,13 @@ L:	linux-scsi at vger.kernel.org
>  S:	Supported
>  F:	drivers/scsi/bnx2fc/
>  
> +BROADCOM SPECIFIC AMBA DRIVER (BCMA)
> +M:	Rafa? Mi?ecki <zajec5 at gmail.com>
> +L:	linux-wireless at vger.kernel.org
> +S:	Maintained
> +F:	drivers/bcma/
> +F:	include/linux/bcma/
> +
>  BROCADE BFA FC SCSI DRIVER
>  M:	Jing Huang <huangj at brocade.com>
>  L:	linux-scsi at vger.kernel.org
> @@ -6101,13 +6108,6 @@ S:	Maintained
>  F:	drivers/ssb/
>  F:	include/linux/ssb/
>  
> -BROADCOM SPECIFIC AMBA DRIVER (BCMA)
> -M:	Rafa? Mi?ecki <zajec5 at gmail.com>
> -L:	linux-wireless at vger.kernel.org
> -S:	Maintained
> -F:	drivers/bcma/
> -F:	include/linux/bcma/
> -
>  SONY VAIO CONTROL DEVICE DRIVER
>  M:	Mattia Dongili <malattia at linux.it>
>  L:	platform-driver-x86 at vger.kernel.org
> -- 
> 1.7.7
> 
> 

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


From linville at tuxdriver.com  Fri Jan 13 14:38:47 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Fri, 13 Jan 2012 14:38:47 -0500
Subject: [PATCH V2 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326386640-11677-1-git-send-email-zajec5@gmail.com>
References: <1326386640-11677-1-git-send-email-zajec5@gmail.com>
Message-ID: <20120113193846.GG18899@tuxdriver.com>

Signed-off-by...

On Thu, Jan 12, 2012 at 05:44:00PM +0100, Rafa? Mi?ecki wrote:
> ---
> V2: add "(moderated for non-subscribers)"
> ---
>  MAINTAINERS |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index dc11e28..469efce 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1419,6 +1419,7 @@ F:	net/ax25/
>  B43 WIRELESS DRIVER
>  M:	Stefano Brivio <stefano.brivio at polimi.it>
>  L:	linux-wireless at vger.kernel.org
> +L:	b43-dev at lists.infradead.org (moderated for non-subscribers)
>  W:	http://linuxwireless.org/en/users/Drivers/b43
>  S:	Maintained
>  F:	drivers/net/wireless/b43/
> -- 
> 1.7.7
> 
> 

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


From zajec5 at gmail.com  Fri Jan 13 16:55:05 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Fri, 13 Jan 2012 22:55:05 +0100
Subject: [PATCH V3 1/2] MAINTAINERS: move BCMA to keep the list sorted
Message-ID: <1326491706-14970-1-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
V3: S-o-b
---
 MAINTAINERS |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4babed7..dc11e28 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1595,6 +1595,13 @@ L:	linux-scsi at vger.kernel.org
 S:	Supported
 F:	drivers/scsi/bnx2fc/
 
+BROADCOM SPECIFIC AMBA DRIVER (BCMA)
+M:	Rafa? Mi?ecki <zajec5 at gmail.com>
+L:	linux-wireless at vger.kernel.org
+S:	Maintained
+F:	drivers/bcma/
+F:	include/linux/bcma/
+
 BROCADE BFA FC SCSI DRIVER
 M:	Jing Huang <huangj at brocade.com>
 L:	linux-scsi at vger.kernel.org
@@ -6101,13 +6108,6 @@ S:	Maintained
 F:	drivers/ssb/
 F:	include/linux/ssb/
 
-BROADCOM SPECIFIC AMBA DRIVER (BCMA)
-M:	Rafa? Mi?ecki <zajec5 at gmail.com>
-L:	linux-wireless at vger.kernel.org
-S:	Maintained
-F:	drivers/bcma/
-F:	include/linux/bcma/
-
 SONY VAIO CONTROL DEVICE DRIVER
 M:	Mattia Dongili <malattia at linux.it>
 L:	platform-driver-x86 at vger.kernel.org
-- 
1.7.7



From zajec5 at gmail.com  Fri Jan 13 16:55:06 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Fri, 13 Jan 2012 22:55:06 +0100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
Message-ID: <1326491706-14970-2-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
V3: S-o-b
---
 MAINTAINERS |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dc11e28..469efce 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1419,6 +1419,7 @@ F:	net/ax25/
 B43 WIRELESS DRIVER
 M:	Stefano Brivio <stefano.brivio at polimi.it>
 L:	linux-wireless at vger.kernel.org
+L:	b43-dev at lists.infradead.org (moderated for non-subscribers)
 W:	http://linuxwireless.org/en/users/Drivers/b43
 S:	Maintained
 F:	drivers/net/wireless/b43/
-- 
1.7.7



From buck at yelp.com  Tue Jan 17 15:12:13 2012
From: buck at yelp.com (Buck Golemon)
Date: Tue, 17 Jan 2012 12:12:13 -0800
Subject: Fwd: bcm4331 firmware installer package
In-Reply-To: <CANDQx1q8cZC8Qz366ET3XQrpAeVJDiurFFiR1NUQ6G0b_ASoZA@mail.gmail.com>
References: <CAG9cJm=YkvHY56LoBoUf3fuh=xb7m+c0GgUzMZX+QyG1+CBCMg@mail.gmail.com>
 <4EF21983.1020107@broadcom.com>
 <CACna6rxEjQLj_j-f7WZOtOEGfDa+TPWyLDrn2t-FGZ5T2_fz-g@mail.gmail.com>
 <CAG9cJm=XE3jQiYvGB4T6_Avj=bmc_wXe8JGMr5hePuCu-OnPuA@mail.gmail.com>
 <CACna6rxvmFptSR9WF8Whj1A0ATyygQ9Eo0nUY8n6MugQ0bjP7g@mail.gmail.com>
 <CAG9cJmmnEsLQxxbi41v6nM8D+L_cOSQE73qJmDDYhXPnopn+MA@mail.gmail.com>
 <CACna6rw_zB038mJ5XP6qvZR61pB77yRes3UwM50JFawUAhUpYg@mail.gmail.com>
 <CAG9cJmkn9HRM1TWL_P0SHBjx9mG4gZYDXeL=HucSg1FK4bf0JQ@mail.gmail.com>
 <CACna6ryy3VaL4u=fts4q0KGxXp0NibMcBaS7tnYbAG5w06sj1Q@mail.gmail.com>
 <CANDQx1q8cZC8Qz366ET3XQrpAeVJDiurFFiR1NUQ6G0b_ASoZA@mail.gmail.com>
Message-ID: <CANDQx1oD301Ltd6M3V86Smerp_qcBPrL0ncVb9jtrRpik8pcsA@mail.gmail.com>

2011/12/22 Rafa? Mi?ecki <zajec5 at gmail.com>
>
> W dniu 22 grudnia 2011 09:45 u?ytkownik lina <lina.lastname at gmail.com> napisa?:
> > On Thu, Dec 22, 2011 at 4:34 PM, Rafa? Mi?ecki <zajec5 at gmail.com> wrote:
> >> 2011/12/22 lina <lina.lastname at gmail.com>:
> >>> On Thu, Dec 22, 2011 at 3:07 PM, Rafa? Mi?ecki <zajec5 at gmail.com> wrote:
> >>>> 2011/12/22 lina <lina.lastname at gmail.com>:
> >>>>> I am still a bit confused. (First thanks for the links all of you
> >>>>> provided, but I have visited those web before).
> >>>>>
> >>>>> Here is the thing:
> >>>>> BCM4331 802.11a/b/g/n fit for
> >>>>> BCM4331 ? ? ? ? ? ? ?b/g ?HT (r1)
> >>>>>
> >>>>> What does the 802.11a for?
> >>>>
> >>>> Well, your card can operate in 5GHz band (frequencies). But I'm not
> >>>> ?really sure why you ask about this at all.
> >>>>
> >>>> ?If you want to try experimental BCM4331 support you have to:
> >>>> ?1) Install kernel 3.2-rc3 or newer
> >>> I have the 3.2.0-rc6
> >>>> ?or
> >>>> ?2) Install compat wireless
> >>>>
> >>>> ?After that you've do install firmware (check for wiki howto for kernel
> >>>> ?3.2 and newer).
> >>>
> >>> after installation of the compat-wireless,
> >>>
> >>> from
> >>> http://wireless.kernel.org/en/users/Drivers/b43#firmware
> >>>
> >>> ?# aptitude install firmware-b43-installer
> >>>
> >>>
> >>> Setting up b43-fwcutter (1:015-9) ...
> >>> Setting up firmware-b43-installer (1:015-9) ...
> >>> No chroot environment found. Starting normal installation
> >>> Unsupported device(s) found: PCI id 14e4:4331
> >>> Aborting.
> >>>
> >>> I don't know which part is wrong here.
> >>
> >> Your tool is too old (support for BCM4331 is really recent).
> > sorry, here you mean, which tool?
> >>
> >> Just do as I said and use howto for kernel 3.2, not distro-specific
> >> howto. You nede to install b43-fwcutter and manually download file for
> > I can't tell the difference. (I really need detailed instructions,
> > thanks for your patience ahead)
> >
> > I tried to follow what you said before, with the kernel 3.2-rc6
> > install the compate-wireless,
> > but have problem in the following install the firmware-installer.
> >> firmware extraction.
>
> wget http://bu3sch.de/b43/fwcutter/b43-fwcutter-015.tar.bz2
> tar xjf b43-fwcutter-015.tar.bz2
> cd b43-fwcutter-015
> make
> sudo make install
> cd ..
>
> export FIRMWARE_INSTALL_DIR="/lib/firmware"
> wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2
> tar xjf broadcom-wl-5.100.138.tar.bz2
> sudo b43-fwcutter -w "$FIRMWARE_INSTALL_DIR"
> broadcom-wl-5.100.138/linux/wl_apsta.o
>

Works for me! Again, this is the first time my wireless has worked!
I nominate this for inclusion on the wiki under heading "Bleeding-edge
kernel quickstart".

Thanks!
-buck


From francesco.gringoli at ing.unibs.it  Wed Jan 18 10:05:39 2012
From: francesco.gringoli at ing.unibs.it (francesco.gringoli at ing.unibs.it)
Date: Wed, 18 Jan 2012 16:05:39 +0100
Subject: A-phy
Message-ID: <361D6290-0077-4303-955E-7BE4854C2CCC@ing.unibs.it>

Larry, Rafal,

maybe this is not a new question on the list but I'm a little bit confused about a-phy support. I read on the http://bcm-v4.sipsolutions.net/802.11/Multiband page that a-phy should be supported on 14e4:4319 which is pointed out as being a BCM4318, and 14e4:4312 that is BCM4311 instead. On http://linuxwireless.org/en/users/Drivers/b43 I also read that "The 802.11a part of the 4311 is not supported" and, in fact, I have a couple of devices which lspci displays as

03:00.0 Network controller: Broadcom Corporation BCM4312 802.11a/b/g (rev 01)
03:00.0 0280: 14e4:4312 (rev 01)

and dmesg says:
[  428.174190] b43-phy1: Broadcom 4311 WLAN found (core revision 10)
[  428.216031] b43-phy1 debug: Found PHY: Analog 4, Type 2, Revision 8
[  428.216055] b43-phy1 debug: Found Radio: Manuf 0x17F, Version 0x2050, Revision 2

And, in fact, a-phy is not activated (it actually seems completely disabled from initialization code).

So, is there any device I can buy for which b43 supports a-phy If the answer is yes (I really hope so :-) ) do you have some pointers on ebay?

Many many thanks!
-Francesco




From Larry.Finger at lwfinger.net  Wed Jan 18 10:23:52 2012
From: Larry.Finger at lwfinger.net (Larry Finger)
Date: Wed, 18 Jan 2012 09:23:52 -0600
Subject: A-phy
In-Reply-To: <361D6290-0077-4303-955E-7BE4854C2CCC@ing.unibs.it>
References: <361D6290-0077-4303-955E-7BE4854C2CCC@ing.unibs.it>
Message-ID: <4F16E408.2070309@lwfinger.net>

On 01/18/2012 09:05 AM, francesco.gringoli at ing.unibs.it wrote:
> Larry, Rafal,
>
> maybe this is not a new question on the list but I'm a little bit confused about a-phy support. I read on the http://bcm-v4.sipsolutions.net/802.11/Multiband page that a-phy should be supported on 14e4:4319 which is pointed out as being a BCM4318, and 14e4:4312 that is BCM4311 instead. On http://linuxwireless.org/en/users/Drivers/b43 I also read that "The 802.11a part of the 4311 is not supported" and, in fact, I have a couple of devices which lspci displays as
>
> 03:00.0 Network controller: Broadcom Corporation BCM4312 802.11a/b/g (rev 01)
> 03:00.0 0280: 14e4:4312 (rev 01)
>
> and dmesg says:
> [  428.174190] b43-phy1: Broadcom 4311 WLAN found (core revision 10)
> [  428.216031] b43-phy1 debug: Found PHY: Analog 4, Type 2, Revision 8
> [  428.216055] b43-phy1 debug: Found Radio: Manuf 0x17F, Version 0x2050, Revision 2
>
> And, in fact, a-phy is not activated (it actually seems completely disabled from initialization code).
>
> So, is there any device I can buy for which b43 supports a-phy If the answer is yes (I really hope so :-) ) do you have some pointers on ebay?

No, I do not think that there are any devices that support operation in the 5 
GHz band for b43. At the time when I was working on b43 (before I started 
reverse engineering), I did not have access to a 5G router. By the time I got 
the router, I had sent that BCM4312 802.11a/b/g device to you.

I have never revisited the A PHY specs. I have, however, been including any 5G 
band information for any new routines for which I create new specs. Rafa? can 
speak to the extent that he has implemented this part of the specs.

Larry


From dwmw2 at infradead.org  Thu Jan 19 07:24:19 2012
From: dwmw2 at infradead.org (David Woodhouse)
Date: Thu, 19 Jan 2012 23:24:19 +1100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326491706-14970-2-git-send-email-zajec5@gmail.com>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
Message-ID: <1326975859.2054.14.camel@shinybook.infradead.org>

On Fri, 2012-01-13 at 22:55 +0100, Rafa? Mi?ecki wrote:
> +L:     b43-dev at lists.infradead.org (moderated for non-subscribers) 

Er, is it really moderated for non-subscribers? Why? I don't think *I*
set it up like that...

-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120119/da51c312/attachment.bin>

From zajec5 at gmail.com  Thu Jan 19 07:46:29 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Thu, 19 Jan 2012 13:46:29 +0100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326975859.2054.14.camel@shinybook.infradead.org>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
Message-ID: <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>

W dniu 19 stycznia 2012 13:24 u?ytkownik David Woodhouse
<dwmw2 at infradead.org> napisa?:
> On Fri, 2012-01-13 at 22:55 +0100, Rafa? Mi?ecki wrote:
>> +L: ? ? b43-dev at lists.infradead.org (moderated for non-subscribers)
>
> Er, is it really moderated for non-subscribers? Why? I don't think *I*
> set it up like that...

No idea. I've sent e-mail to the ML from my old address (@gazeta.pl)
and it didn't appear.

-- 
Rafa?


From dwmw2 at infradead.org  Thu Jan 19 07:48:29 2012
From: dwmw2 at infradead.org (David Woodhouse)
Date: Thu, 19 Jan 2012 23:48:29 +1100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
 <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
Message-ID: <1326977309.2054.16.camel@shinybook.infradead.org>

On Thu, 2012-01-19 at 13:46 +0100, Rafa? Mi?ecki wrote:
> No idea. I've sent e-mail to the ML from my old address (@gazeta.pl)
> and it didn't appear. 

Hm, the default action for posts my non-members was set to 'discard'.
That's just evil. I've fixed it to 'Accept'.

-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120119/415c9243/attachment.bin>

From zajec5 at gazeta.pl  Thu Jan 19 08:09:20 2012
From: zajec5 at gazeta.pl (zajec5 Gazeta.pl)
Date: Thu, 19 Jan 2012 14:09:20 +0100
Subject: Another ML test
Message-ID: <CAESoE48yRubXjzAHXpwkjmcBdXHSqccuwChUGuKyqSHdzdjenQ@mail.gmail.com>

Sent from not-subscribed address


From gregory.bellier at gmail.com  Thu Jan 19 08:16:26 2012
From: gregory.bellier at gmail.com (Gregory Bellier)
Date: Thu, 19 Jan 2012 14:16:26 +0100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326977309.2054.16.camel@shinybook.infradead.org>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
 <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
 <1326977309.2054.16.camel@shinybook.infradead.org>
Message-ID: <CAD3=kO+kLO5-1ZY-X=7TsdEBrgzqQQF8uEVwrtu2eGduhAC6jQ@mail.gmail.com>

2012/1/19 David Woodhouse <dwmw2 at infradead.org>

>
> Hm, the default action for posts my non-members was set to 'discard'.
> That's just evil. I've fixed it to 'Accept'.
>

Maybe you did that to avoid spamming? ?

I just got one from Rafa? (kidding).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120119/d3efa7e8/attachment-0001.html>

From dwmw2 at infradead.org  Thu Jan 19 08:17:50 2012
From: dwmw2 at infradead.org (David Woodhouse)
Date: Fri, 20 Jan 2012 00:17:50 +1100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <CAD3=kO+kLO5-1ZY-X=7TsdEBrgzqQQF8uEVwrtu2eGduhAC6jQ@mail.gmail.com>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
 <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
 <1326977309.2054.16.camel@shinybook.infradead.org>
 <CAD3=kO+kLO5-1ZY-X=7TsdEBrgzqQQF8uEVwrtu2eGduhAC6jQ@mail.gmail.com>
Message-ID: <1326979070.2054.17.camel@shinybook.infradead.org>

On Thu, 2012-01-19 at 14:16 +0100, Gregory Bellier wrote:
> Maybe you did that to avoid spamming? ?

It's a crappy way to avoid spamming. We should be able to do better.
Filtering out all HTML goes a long way :)

-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120120/cb0d12ed/attachment.bin>

From linville at tuxdriver.com  Thu Jan 19 09:16:45 2012
From: linville at tuxdriver.com (John W. Linville)
Date: Thu, 19 Jan 2012 09:16:45 -0500
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <1326979070.2054.17.camel@shinybook.infradead.org>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
 <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
 <1326977309.2054.16.camel@shinybook.infradead.org>
 <CAD3=kO+kLO5-1ZY-X=7TsdEBrgzqQQF8uEVwrtu2eGduhAC6jQ@mail.gmail.com>
 <1326979070.2054.17.camel@shinybook.infradead.org>
Message-ID: <20120119141644.GB3320@tuxdriver.com>

On Fri, Jan 20, 2012 at 12:17:50AM +1100, David Woodhouse wrote:
> On Thu, 2012-01-19 at 14:16 +0100, Gregory Bellier wrote:
> > Maybe you did that to avoid spamming? ?
> 
> It's a crappy way to avoid spamming. We should be able to do better.
> Filtering out all HTML goes a long way :)

So...do we need another MAINTAINERS patch now?

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


From info at omniware.fr  Thu Jan 19 11:31:17 2012
From: info at omniware.fr (OmniWare)
Date: Thu, 19 Jan 2012 17:31:17 +0100
Subject: =?windows-1252?Q?OmniWare_-_Alternative_acc=E8s_distant_TSE?=
Message-ID: <58628a8ec4759659cb8fa1dd0e73d5ad@omniware.fr>


OmniWare est un logiciel qui transforme Windows XP ou Windows 7 en v?ritable serveur d'application TSE 
  
OmniWare Terminal serveur permet aux collaborateurs de l'entreprise d'acc?der ? leurs applications professionelles depuis n'importe quel lieu : 
Domicile, h?tel, second ?tablissement, ? l'?tranger... 
Gr?ce ? OmniWare, les syst?mes Windows 7 ou XP Pro agissent en serveur TSE, permettant ainsi :  
? la centralisation des applications et des donn?es
? l'acc?s aux applications sur les postes du r?seau local
? l'acc?s ? distance s?curis? 

Quels sont les avantages procur?s par OmniWare ? 
Centralisation et mobilit? professionnelle
OmniWare s?adresse aux entreprises d?sireuses d?offrir un acc?s ? distance aux applications pour leurs collaborateurs (g?rant, commerciaux, travailleurs ? domicile, personnes en d?placement...). Cette solution s?adresse ?galement aux entreprises multi-sites souhaitant simplifier la centralisation de donn?es et eviter les synchronisations de fichiers.

Solution alternative, facile ? d?ployer
En tant qu'alternative ? Windows Serveur 2003 / 2008 / TSE / Citrix, OmniWare s?installe tr?s facilement sur Windows XP ou Seven pour en faire un v?ritable serveur d?application simple ? mettre en oeuvre et ? maintenir.

Quel est le prix des licences ?
Nos tarifs sont disponibles sur notre site web, sur la page contact.

Sur quels syst?mes d'exploitation s'installe OmniWare ?
Omniware s'installe sur Windows Seven ou XP (32 et 64bits), mais ?galement sur Windows serveur 2003 et 2008 SBS, Standard ou Entreprise (32 et 64bits). 

Portail TS Web
http & https

Acc?s TSE s?curis? depuis n'importe quel navigateur Internet
Client Java multi-plateformes (Pc, Mac, Linux...)
Mode transparent RemoteApp
Gestion des impressions locales

Option Encryption SSL 1048 bits et certificats d'authentification 2048 bits
Serveur web inclu et install? automatiquement
Tunneling SSH sur les ports 80 ou 443
Portail personnalisable
 
 
www.omniware.fr
 
Exp?diteur : www.omniware.fr - OmniPr?sence S.a.r.l. - Si vous ne souhaitez plus recevoir nos offres, cliquer ici 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120119/e1ba8c8e/attachment-0001.html>

From dwmw2 at infradead.org  Thu Jan 19 15:00:22 2012
From: dwmw2 at infradead.org (David Woodhouse)
Date: Fri, 20 Jan 2012 07:00:22 +1100
Subject: Another ML test
In-Reply-To: <CAESoE48yRubXjzAHXpwkjmcBdXHSqccuwChUGuKyqSHdzdjenQ@mail.gmail.com>
References: <CAESoE48yRubXjzAHXpwkjmcBdXHSqccuwChUGuKyqSHdzdjenQ@mail.gmail.com>
Message-ID: <1327003222.2054.31.camel@shinybook.infradead.org>

On Thu, 2012-01-19 at 14:09 +0100, zajec5 Gazeta.pl wrote:
> Sent from not-subscribed address

For some reason the block on HTML had also been dropped; I'm not sure
what happened to the list configuration. I've restored that.

-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/b43-dev/attachments/20120120/5337692f/attachment.bin>

From zajec5 at gmail.com  Thu Jan 19 15:48:54 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Thu, 19 Jan 2012 21:48:54 +0100
Subject: [PATCH V3 2/2] MAINTAINERS: add b43 mailing list
In-Reply-To: <20120119141644.GB3320@tuxdriver.com>
References: <1326491706-14970-1-git-send-email-zajec5@gmail.com>
 <1326491706-14970-2-git-send-email-zajec5@gmail.com>
 <1326975859.2054.14.camel@shinybook.infradead.org>
 <CACna6rynAD9Rxsbmxd2UROrfwEQt65yV=FUR8jGSsDgiBhRiww@mail.gmail.com>
 <1326977309.2054.16.camel@shinybook.infradead.org>
 <CAD3=kO+kLO5-1ZY-X=7TsdEBrgzqQQF8uEVwrtu2eGduhAC6jQ@mail.gmail.com>
 <1326979070.2054.17.camel@shinybook.infradead.org>
 <20120119141644.GB3320@tuxdriver.com>
Message-ID: <CACna6rwnWJTj3R61Y+fAeb8BbpiAtcN+vBpZHhv9ta3xR0CDgA@mail.gmail.com>

2012/1/19 John W. Linville <linville at tuxdriver.com>:
> On Fri, Jan 20, 2012 at 12:17:50AM +1100, David Woodhouse wrote:
>> On Thu, 2012-01-19 at 14:16 +0100, Gregory Bellier wrote:
>> > Maybe you did that to avoid spamming? ?
>>
>> It's a crappy way to avoid spamming. We should be able to do better.
>> Filtering out all HTML goes a long way :)
>
> So...do we need another MAINTAINERS patch now?

If we just make sure it's working well - yes.

-- 
Rafa?


From Larry.Finger at lwfinger.net  Wed Jan 25 07:42:49 2012
From: Larry.Finger at lwfinger.net (Larry Finger)
Date: Wed, 25 Jan 2012 06:42:49 -0600
Subject: b43: N-PHY: implement RSSI calibration for rev3+
In-Reply-To: <20120125081815.GA19911@elgon.mountain>
References: <20120125081815.GA19911@elgon.mountain>
Message-ID: <4F1FF8C9.4050803@lwfinger.net>

On 01/25/2012 02:18 AM, Dan Carpenter wrote:
> Hello Rafa? Mi?ecki,
>
> The patch e0c9a0219a8f: "b43: N-PHY: implement RSSI calibration for
> rev3+" from Jan 5, 2012, leads to the following Smatch warning:
> drivers/net/wireless/b43/phy_n.c +1381 b43_nphy_rev3_rssi_cal()
> 	 error: buffer overflow 'results[j]' 4<= 4
>
>
> +               for (i = 0; i<  4; i++) {
> +                       s32 curr;
> +                       s32 mind = 40;
> +                       s32 minpoll = 249;
> +                       u8 minvcm = 0;
> +                       if (2 * core != i)
> +                               continue;
> +                       for (j = 0; j<  8; j++) {
> +                               curr = results[j][i] * results[j][i] +
> +                                       results[j][i + 1] * results[j][i];
>                                                     ^^^^^
> On the last iteration through the loop "i + 1" = 4.
>
> +                               if (curr<  mind) {
> +                                       mind = curr;
> +                                       minvcm = j;
> +                               }
> +                               if (results[j][i]<  minpoll)
> +                                       minpoll = results[j][i];
> +                       }
> +                       vcm_final = minvcm;
> +                       results_min[i] = minpoll;
> +               }
>
> I don't know the code well enough to say if this can happen or not.
> Perhaps on the last iteration we always hit the "if (2 * core != i)
> continue" condition.  Anyway, since this is the first time this has hit
> linux-next, I thought I would let you know.

The condition you point out will occur for i equals 3. As 2 * anything will 
never be equal to 3, the continue will definitely be executed for that case.

This idea would need further investigation, but it certainly appears the the for 
loop could be changed to "for (i = 0; i < 4; i += 2)", which would accomplish 
the same end and should have the side effect of silencing the Smatch warning.

Larry



From arcimboldo at gmail.com  Thu Jan 26 17:53:14 2012
From: arcimboldo at gmail.com (Antonio Messina)
Date: Thu, 26 Jan 2012 23:53:14 +0100
Subject: b43 module doesn't work after suspend
Message-ID: <4F21D95A.4060408@gmail.com>

Hi all,

After suspend to ram my wifi doesn't work. Unloading the `b43' module 
and re-loading after resume "fix" the issue, but it would be better if 
it will deal with the suspend/resume cycle smoothly.

My card (MacBookpro8,1):
03:00.0 Network controller: Broadcom Corporation BCM4331 802.11a/b/g/n 
(rev 02)

Kernel: 3.2.1 vanilla x86_64
Distro: Debian testing
b43 firmware: 666.2 (2011-02-23 01:15:07)

.a.


From hauke at hauke-m.de  Sat Jan 28 13:25:20 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Sat, 28 Jan 2012 19:25:20 +0100
Subject: Device Database
Message-ID: <4F243D90.4080807@hauke-m.de>

While working on ssb and bcma, I often do not know if some branch
defined in the open source part of the Broacom SDK is taken only by
devices supported by ssb or bcma or both.
A database with all devices support by bcma, ssb and the Broadcom SDK
(pci(e) cards and SoCs) with the cores and their revs found on them, the
chip id and rev, if they have a pmu and what rev and so on.
I would like to start with such a database, but I do not know where.
Should I place it on a subpage of
http://linuxwireless.org/en/users/Drivers/b43 , but it should also
contain SoC which are not really related to b43 or should I place it
somewhere on http://bcm-v4.sipsolutions.net/ ?

Hauke


From zajec5 at gmail.com  Sun Jan 29 05:52:12 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Sun, 29 Jan 2012 11:52:12 +0100
Subject: Device Database
In-Reply-To: <4F243D90.4080807@hauke-m.de>
References: <4F243D90.4080807@hauke-m.de>
Message-ID: <CACna6rxw=qRxS6eroVM3qcXBUMxQNmKiXZRyqggPxmv8bOEWjw@mail.gmail.com>

2012/1/28 Hauke Mehrtens <hauke at hauke-m.de>:
> While working on ssb and bcma, I often do not know if some branch
> defined in the open source part of the Broacom SDK is taken only by
> devices supported by ssb or bcma or both.
> A database with all devices support by bcma, ssb and the Broadcom SDK
> (pci(e) cards and SoCs) with the cores and their revs found on them, the
> chip id and rev, if they have a pmu and what rev and so on.
> I would like to start with such a database, but I do not know where.
> Should I place it on a subpage of
> http://linuxwireless.org/en/users/Drivers/b43 , but it should also
> contain SoC which are not really related to b43 or should I place it
> somewhere on http://bcm-v4.sipsolutions.net/ ?

Yeah, http://linuxwireless.org/en/users/Drivers/b43 doesn't sound like
a great place for this. On the other hand access to
http://bcm-v4.sipsolutions.net/ is too limited (for editors).

Maybe we could add some new wiki page, just not under /Drivers/? Maybe
we could even use developers, like
http://linuxwireless.org/en/developers/foobar
?

-- 
Rafa?


From zajec5 at gmail.com  Sun Jan 29 05:59:42 2012
From: zajec5 at gmail.com (=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=)
Date: Sun, 29 Jan 2012 11:59:42 +0100
Subject: [PATCH] MAINTAINERS: update b43(legacy) mailing list
Message-ID: <1327834782-4800-1-git-send-email-zajec5@gmail.com>


Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
 MAINTAINERS |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6e68daa1..1adb206 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1411,7 +1411,7 @@ F:	net/ax25/
 B43 WIRELESS DRIVER
 M:	Stefano Brivio <stefano.brivio at polimi.it>
 L:	linux-wireless at vger.kernel.org
-L:	b43-dev at lists.infradead.org (moderated for non-subscribers)
+L:	b43-dev at lists.infradead.org
 W:	http://linuxwireless.org/en/users/Drivers/b43
 S:	Maintained
 F:	drivers/net/wireless/b43/
@@ -1420,6 +1420,7 @@ B43LEGACY WIRELESS DRIVER
 M:	Larry Finger <Larry.Finger at lwfinger.net>
 M:	Stefano Brivio <stefano.brivio at polimi.it>
 L:	linux-wireless at vger.kernel.org
+L:	b43-dev at lists.infradead.org
 W:	http://linuxwireless.org/en/users/Drivers/b43
 S:	Maintained
 F:	drivers/net/wireless/b43legacy/
-- 
1.7.7



From hauke at hauke-m.de  Sun Jan 29 17:12:55 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Sun, 29 Jan 2012 23:12:55 +0100
Subject: BCM5354 SoC with LP Phy Wifi
Message-ID: <4F25C467.7070805@hauke-m.de>

I got a device with a BCM5354 SoC and a LP-Phy Wifi core on it. With
current b43 it still fails with Out of memory when using a recent
firmware 666.2 and works with an old firmware 410.2160. I tried DMA and
PIO mode and had the same results. I added some printk's into the code
and implemented some parts b43 does not have but the Braodcom sdk and
brcmsmac has in the dma code, but I haven't resolved the issue.

I found out the error occurs when send some packages doing "ifconfig
wlan0 up" does not result in any problems, but when I try to scan with
"iw wlan0 scan" it oopes very soon. The problem seams to be related to
TX as there are many packages received, but the oops occurs after 4
calls to b43_dma_tx()

Larry, you wrote some more LP spec based on a newer driver is there a
list with updated docs or should I manually look into all packages if I
want to implement it like it is in the new wl driver.
As I see there are also many parts not implemented, but described in the
spec so looking over the hole code is probably needed.
My device has a sprom of revision 3 and not the expected version 8, does
this cause any trouble?

Hauke.


From hauke at hauke-m.de  Sun Jan 29 18:33:26 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Mon, 30 Jan 2012 00:33:26 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <4F25C467.7070805@hauke-m.de>
References: <4F25C467.7070805@hauke-m.de>
Message-ID: <4F25D746.2020801@hauke-m.de>

On 01/29/2012 11:12 PM, Hauke Mehrtens wrote:
> I got a device with a BCM5354 SoC and a LP-Phy Wifi core on it. With
> current b43 it still fails with Out of memory when using a recent
> firmware 666.2 and works with an old firmware 410.2160. I tried DMA and
> PIO mode and had the same results. I added some printk's into the code
> and implemented some parts b43 does not have but the Braodcom sdk and
> brcmsmac has in the dma code, but I haven't resolved the issue.
> 
> I found out the error occurs when send some packages doing "ifconfig
> wlan0 up" does not result in any problems, but when I try to scan with
> "iw wlan0 scan" it oopes very soon. The problem seams to be related to
> TX as there are many packages received, but the oops occurs after 4
> calls to b43_dma_tx()
> 
> Larry, you wrote some more LP spec based on a newer driver is there a
> list with updated docs or should I manually look into all packages if I
> want to implement it like it is in the new wl driver.
> As I see there are also many parts not implemented, but described in the
> spec so looking over the hole code is probably needed.
> My device has a sprom of revision 3 and not the expected version 8, does
> this cause any trouble?
> 
> Hauke.
My device is the following:

ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x14, vendor 0x4243)
ssb: Core 1 found: Fast Ethernet (cc 0x806, rev 0x09, vendor 0x4243)
ssb: Core 2 found: MIPS 3302 (cc 0x816, rev 0x08, vendor 0x4243)
ssb: Core 3 found: USB 2.0 Host (cc 0x819, rev 0x02, vendor 0x4243)
ssb: Core 4 found: MEMC SDRAM (cc 0x80F, rev 0x04, vendor 0x4243)
ssb: Core 5 found: IEEE 802.11 (cc 0x812, rev 0x0D, vendor 0x4243)
ssb: Core 6 found: Roboswitch (cc 0x81C, rev 0x02, vendor 0x4243)

b43-phy0: Broadcom 5354 WLAN found (core revision 13)
b43-phy0 debug: Found PHY: Analog 6, Type 5, Revision 0
b43-phy0 debug: Found Radio: Manuf 0x17F, Version 0x2062, Revision 1

When doing a passive scan with iw it works without any problems and I
get my results without any kernel oops, but when doing an active scan I
get an oops.

Hauke


From Larry.Finger at lwfinger.net  Sun Jan 29 23:51:21 2012
From: Larry.Finger at lwfinger.net (Larry Finger)
Date: Sun, 29 Jan 2012 22:51:21 -0600
Subject: [RFC/RFT] b43legacy: Convert to asychronous firmware loading
Message-ID: <4f2621c9.y1UfR8jn+ZfKThef%Larry.Finger@lwfinger.net>

Recent changes in udev are causing problems for drivers that load firmware
from the probe routine. As b43legacy is one of them, it is changed to
using asynchronous firmware loading.

Signed-off-by: Larry Finger <Larry.Finger at lwfinger.net>
---

Index: wireless-testing/drivers/net/wireless/b43legacy/b43legacy.h
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43legacy/b43legacy.h
+++ wireless-testing/drivers/net/wireless/b43legacy/b43legacy.h
@@ -10,6 +10,7 @@
 #include <linux/pci.h>
 #include <linux/atomic.h>
 #include <linux/io.h>
+#include <linux/completion.h>
 
 #include <linux/ssb/ssb.h>
 #include <linux/ssb/ssb_driver_chipcommon.h>
@@ -599,6 +600,9 @@ struct b43legacy_wl {
 	/* Stats about the wireless interface */
 	struct ieee80211_low_level_stats ieee_stats;
 
+	/* Completion queue */
+	struct completion b43legacy_fw_ready;
+
 #ifdef CONFIG_B43LEGACY_HWRNG
 	struct hwrng rng;
 	u8 rng_initialized;
@@ -633,6 +637,11 @@ struct b43legacy_wl {
 
 };
 
+struct b43legacy_fw_context {
+	struct b43legacy_wldev *dev;
+	const struct firmware *fw;
+};
+
 /* Pointers to the firmware data and meta information about it. */
 struct b43legacy_firmware {
 	/* Microcode */
Index: wireless-testing/drivers/net/wireless/b43legacy/main.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43legacy/main.c
+++ wireless-testing/drivers/net/wireless/b43legacy/main.c
@@ -1511,50 +1511,88 @@ static void b43legacy_print_fw_helptext(
 		     "and download the correct firmware (version 3).\n");
 }
 
-static int do_request_fw(struct b43legacy_wldev *dev,
-			 const char *name,
-			 const struct firmware **fw)
+static void b43legacy_fw_cb(const struct firmware *firmware, void *context)
 {
-	char path[sizeof(modparam_fwpostfix) + 32];
+	struct b43legacy_fw_context *fw_context = context;
+	struct b43legacy_wldev *dev = fw_context->dev;
+	const struct firmware *fw = fw_context->fw;
 	struct b43legacy_fw_header *hdr;
 	u32 size;
-	int err;
 
-	if (!name)
-		return 0;
-
-	snprintf(path, ARRAY_SIZE(path),
-		 "b43legacy%s/%s.fw",
-		 modparam_fwpostfix, name);
-	err = request_firmware(fw, path, dev->dev->dev);
-	if (err) {
-		b43legacyerr(dev->wl, "Firmware file \"%s\" not found "
-		       "or load failed.\n", path);
-		return err;
-	}
-	if ((*fw)->size < sizeof(struct b43legacy_fw_header))
-		goto err_format;
-	hdr = (struct b43legacy_fw_header *)((*fw)->data);
+	if (!firmware)
+		goto err_out;
+	if (firmware->size < sizeof(struct b43legacy_fw_header))
+		goto err_out;
+	hdr = (struct b43legacy_fw_header *)firmware->data;
 	switch (hdr->type) {
 	case B43legacy_FW_TYPE_UCODE:
 	case B43legacy_FW_TYPE_PCM:
 		size = be32_to_cpu(hdr->size);
-		if (size != (*fw)->size - sizeof(struct b43legacy_fw_header))
-			goto err_format;
+		if (size != firmware->size - sizeof(struct b43legacy_fw_header))
+			goto err_out;
 		/* fallthrough */
 	case B43legacy_FW_TYPE_IV:
 		if (hdr->ver != 1)
-			goto err_format;
+			goto err_out;
 		break;
 	default:
-		goto err_format;
+		goto err_out;
 	}
+	/* copy pointer to firmware */
+	fw = firmware;
 
-	return err;
+	kfree(fw_context);
 
-err_format:
-	b43legacyerr(dev->wl, "Firmware file \"%s\" format error.\n", path);
-	return -EPROTO;
+	/* check to see if all fw parts read */
+	if (!dev->fw.ucode || !dev->fw.pcm ||
+	    !dev->fw.initvals || !dev->fw.initvals_band)
+		return;
+
+	complete(&dev->wl->b43legacy_fw_ready);
+
+	/* We reach here only when all firmware files have been loaded
+	 * and copied. First detect if initvals_band is not needed,
+	 * and fix the dummy pointer.
+	 * It is now safe to start mac80211.  */
+	if (dev->fw.initvals_band == (struct firmware *)dev)
+		dev->fw.initvals_band = NULL;
+	if (ieee80211_register_hw(dev->wl->hw))
+		b43legacyerr(dev->wl, "Unable to start mac80211\n");
+	return;
+
+err_out:
+	b43legacyerr(dev->wl, "Firmware not found, or has wrong format.\n");
+	complete(&dev->wl->b43legacy_fw_ready);
+	kfree(fw_context);
+	return;
+}
+
+static int do_request_fw(struct b43legacy_wldev *dev,
+			 const char *name,
+			 const struct firmware *fw)
+{
+	struct b43legacy_fw_context *fw_context;
+	char path[sizeof(modparam_fwpostfix) + 32];
+	int err;
+
+	if (!name)
+		return 0;
+
+	fw_context = kmalloc(sizeof(struct b43legacy_fw_context), GFP_KERNEL);
+	if (!fw_context)
+		return -ENOMEM;
+	fw_context->dev = dev;
+	fw_context->fw = fw;
+
+	snprintf(path, ARRAY_SIZE(path),
+		 "b43legacy%s/%s.fw",
+		 modparam_fwpostfix, name);
+	b43legacyinfo(dev->wl, "Loading firmware file %s\n", path);
+	err = request_firmware_nowait(THIS_MODULE, 1, path, dev->dev->dev,
+				      GFP_KERNEL, fw_context, b43legacy_fw_cb);
+	if (err)
+		b43legacyerr(dev->wl, "Asynchronous firmware loading failed\n");
+	return err;
 }
 
 static int b43legacy_request_firmware(struct b43legacy_wldev *dev)
@@ -1573,16 +1611,7 @@ static int b43legacy_request_firmware(st
 			filename = "ucode4";
 		else
 			filename = "ucode5";
-		err = do_request_fw(dev, filename, &fw->ucode);
-		if (err)
-			goto err_load;
-	}
-	if (!fw->pcm) {
-		if (rev < 5)
-			filename = "pcm4";
-		else
-			filename = "pcm5";
-		err = do_request_fw(dev, filename, &fw->pcm);
+		err = do_request_fw(dev, filename, fw->ucode);
 		if (err)
 			goto err_load;
 	}
@@ -1600,7 +1629,7 @@ static int b43legacy_request_firmware(st
 		default:
 			goto err_no_initvals;
 		}
-		err = do_request_fw(dev, filename, &fw->initvals);
+		err = do_request_fw(dev, filename, fw->initvals);
 		if (err)
 			goto err_load;
 	}
@@ -1620,7 +1649,22 @@ static int b43legacy_request_firmware(st
 		default:
 			goto err_no_initvals;
 		}
-		err = do_request_fw(dev, filename, &fw->initvals_band);
+		/* not all devices need initvals_band -
+		 * supply a dummy value for now */
+		if (!filename) {
+			fw->initvals_band = (struct firmware *)dev;
+			return 0;
+		}
+		err = do_request_fw(dev, filename, fw->initvals_band);
+		if (err)
+			goto err_load;
+	}
+	if (!fw->pcm) {
+		if (rev < 5)
+			filename = "pcm4";
+		else
+			filename = "pcm5";
+		err = do_request_fw(dev, filename, fw->pcm);
 		if (err)
 			goto err_load;
 	}
@@ -2153,9 +2197,6 @@ static int b43legacy_chip_init(struct b4
 	macctl |= B43legacy_MACCTL_INFRA;
 	b43legacy_write32(dev, B43legacy_MMIO_MACCTL, macctl);
 
-	err = b43legacy_request_firmware(dev);
-	if (err)
-		goto out;
 	err = b43legacy_upload_microcode(dev);
 	if (err)
 		goto out; /* firmware is released later */
@@ -3756,6 +3797,10 @@ static int b43legacy_one_core_attach(str
 	wl->nr_devs++;
 	ssb_set_drvdata(dev, wldev);
 	b43legacy_debugfs_add_device(wldev);
+
+	err = b43legacy_request_firmware(wldev);
+	if (err)
+		goto out;
 out:
 	return err;
 
@@ -3856,21 +3901,15 @@ static int b43legacy_probe(struct ssb_de
 		wl = ssb_get_devtypedata(dev);
 		B43legacy_WARN_ON(!wl);
 	}
+	init_completion(&wl->b43legacy_fw_ready);
 	err = b43legacy_one_core_attach(dev, wl);
 	if (err)
 		goto err_wireless_exit;
 
-	if (first) {
-		err = ieee80211_register_hw(wl->hw);
-		if (err)
-			goto err_one_core_detach;
-	}
 
 out:
 	return err;
 
-err_one_core_detach:
-	b43legacy_one_core_detach(dev);
 err_wireless_exit:
 	if (first)
 		b43legacy_wireless_exit(dev, wl);
@@ -3886,6 +3925,9 @@ static void b43legacy_remove(struct ssb_
 	 * as the ieee80211 unreg will destroy the workqueue. */
 	cancel_work_sync(&wldev->restart_work);
 
+	/* make certain firmware load callbacks are complete */
+	wait_for_completion(&wl->b43legacy_fw_ready);
+
 	B43legacy_WARN_ON(!wl);
 	if (wl->current_dev == wldev)
 		ieee80211_unregister_hw(wl->hw);


From zajec5 at gmail.com  Mon Jan 30 01:29:52 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 30 Jan 2012 07:29:52 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <4F25D746.2020801@hauke-m.de>
References: <4F25C467.7070805@hauke-m.de>
	<4F25D746.2020801@hauke-m.de>
Message-ID: <CACna6rxvftL8fQpzhyUD-Q6RgoAur7+qRbb_4VyDa413aBPk+A@mail.gmail.com>

2012/1/30 Hauke Mehrtens <hauke at hauke-m.de>:
> On 01/29/2012 11:12 PM, Hauke Mehrtens wrote:
>> I got a device with a BCM5354 SoC and a LP-Phy Wifi core on it. With
>> current b43 it still fails with Out of memory when using a recent
>> firmware 666.2 and works with an old firmware 410.2160. I tried DMA and
>> PIO mode and had the same results. I added some printk's into the code
>> and implemented some parts b43 does not have but the Braodcom sdk and
>> brcmsmac has in the dma code, but I haven't resolved the issue.
>>
>> I found out the error occurs when send some packages doing "ifconfig
>> wlan0 up" does not result in any problems, but when I try to scan with
>> "iw wlan0 scan" it oopes very soon. The problem seams to be related to
>> TX as there are many packages received, but the oops occurs after 4
>> calls to b43_dma_tx()
>>
>> Larry, you wrote some more LP spec based on a newer driver is there a
>> list with updated docs or should I manually look into all packages if I
>> want to implement it like it is in the new wl driver.
>> As I see there are also many parts not implemented, but described in the
>> spec so looking over the hole code is probably needed.
>> My device has a sprom of revision 3 and not the expected version 8, does
>> this cause any trouble?
>>
>> Hauke.
> My device is the following:
>
> ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x14, vendor 0x4243)
> ssb: Core 1 found: Fast Ethernet (cc 0x806, rev 0x09, vendor 0x4243)
> ssb: Core 2 found: MIPS 3302 (cc 0x816, rev 0x08, vendor 0x4243)
> ssb: Core 3 found: USB 2.0 Host (cc 0x819, rev 0x02, vendor 0x4243)
> ssb: Core 4 found: MEMC SDRAM (cc 0x80F, rev 0x04, vendor 0x4243)
> ssb: Core 5 found: IEEE 802.11 (cc 0x812, rev 0x0D, vendor 0x4243)
> ssb: Core 6 found: Roboswitch (cc 0x81C, rev 0x02, vendor 0x4243)
>
> b43-phy0: Broadcom 5354 WLAN found (core revision 13)
> b43-phy0 debug: Found PHY: Analog 6, Type 5, Revision 0
> b43-phy0 debug: Found Radio: Manuf 0x17F, Version 0x2062, Revision 1
>
> When doing a passive scan with iw it works without any problems and I
> get my results without any kernel oops, but when doing an active scan I
> get an oops.

If you search for "out of memory b43" you will find the thread where
we were trying to find the issue. Unfortunately without the real
access to the hardware it wasn't easy to debug this. Sending patches
to someone, waiting for recompiling & testing, checking results... I
failed at that process :(

While I'll try to implement/update LP-PHY code, I think it still would
be nice to investigate this problem. Do we have some leak in b43? We
should fix it if so.

Could you check what exactly happens in b43_dma_tx please?

-- 
Rafa?


From hauke at hauke-m.de  Mon Jan 30 14:37:57 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Mon, 30 Jan 2012 20:37:57 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <CACb-4KjixkVS5pe+mucyOaKeHAMb11m=YBZ47STZAiKDwRH2rQ@mail.gmail.com>
References: <4F25C467.7070805@hauke-m.de>
 <CACb-4KjixkVS5pe+mucyOaKeHAMb11m=YBZ47STZAiKDwRH2rQ@mail.gmail.com>
Message-ID: <4F26F195.9050509@hauke-m.de>

Hi William,

On 01/30/2012 04:39 PM, William R Agosto Padilla wrote:
> Mr. Hauke,
> 
> I am new to the reverse engineering process. However I am working on a
> project that
> requires me to use printk statements in the b43 device driver code, so I
> can see how it is
> really working during initialization, resetting, and suspension of the
> networking process. 
> 
> The first problem that I encountered was finding the b43 source code for
> download.
> I was only able to find the assembly code for the b43 firmware. Do you
> know of a specific download
> location where I can get the entire b43's ''C'' source code?
Just go to https://www.kernel.org/ and download the Linux kernel it has
b43 included in it in drivers/net/wireless/b43 or use
http://wireless.kernel.org/en/users/Download/stable/

>  Reading
> your email I realized that you
> have already done what I will be attempting to do. Mainly, using printk
> statements inside the b43 code.
> I have been at this for a couple of months without any luck. Would you
> mind if I ask a few questions 
> about the way you went about on doing so? Or advice on how to do it?
> 
> Did you added the printk statements into the b43 source code or the b43
> firmware code?
I do not have access to the source code of the broadcom firmware, but
there is an open source project developing an open Source firmware
http://www.ing.unibs.it/~openfwwf/
>I would like to try
> something similar. As I mentioned earlier, I was not able to see the
> b43's 'C' source code with my
> Linux Ubuntu 11.10 distribution. I found a copy of the firmware source
> code with the
> assembly language, etc. Is that the code that you used for the printk
> statements? 
I am just working on the driver and treating the firmware as a black box.
> I thought that since the b43 driver is included in the kernel that
> Ubuntu 11.10 has, it 
> would also include the source code--no luck with that.
> 
> Any insight that you can share would be very much appreciated.
> 
> Cheers
> 
> William

Hauke


From hauke at hauke-m.de  Mon Jan 30 14:45:49 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Mon, 30 Jan 2012 20:45:49 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <CACna6rxvftL8fQpzhyUD-Q6RgoAur7+qRbb_4VyDa413aBPk+A@mail.gmail.com>
References: <4F25C467.7070805@hauke-m.de> <4F25D746.2020801@hauke-m.de>
 <CACna6rxvftL8fQpzhyUD-Q6RgoAur7+qRbb_4VyDa413aBPk+A@mail.gmail.com>
Message-ID: <4F26F36D.5050903@hauke-m.de>

On 01/30/2012 07:29 AM, Rafa? Mi?ecki wrote:
> 2012/1/30 Hauke Mehrtens <hauke at hauke-m.de>:
>> On 01/29/2012 11:12 PM, Hauke Mehrtens wrote:
>>> I got a device with a BCM5354 SoC and a LP-Phy Wifi core on it. With
>>> current b43 it still fails with Out of memory when using a recent
>>> firmware 666.2 and works with an old firmware 410.2160. I tried DMA and
>>> PIO mode and had the same results. I added some printk's into the code
>>> and implemented some parts b43 does not have but the Braodcom sdk and
>>> brcmsmac has in the dma code, but I haven't resolved the issue.
>>>
>>> I found out the error occurs when send some packages doing "ifconfig
>>> wlan0 up" does not result in any problems, but when I try to scan with
>>> "iw wlan0 scan" it oopes very soon. The problem seams to be related to
>>> TX as there are many packages received, but the oops occurs after 4
>>> calls to b43_dma_tx()
>>>
>>> Larry, you wrote some more LP spec based on a newer driver is there a
>>> list with updated docs or should I manually look into all packages if I
>>> want to implement it like it is in the new wl driver.
>>> As I see there are also many parts not implemented, but described in the
>>> spec so looking over the hole code is probably needed.
>>> My device has a sprom of revision 3 and not the expected version 8, does
>>> this cause any trouble?
>>>
>>> Hauke.
>> My device is the following:
>>
>> ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x14, vendor 0x4243)
>> ssb: Core 1 found: Fast Ethernet (cc 0x806, rev 0x09, vendor 0x4243)
>> ssb: Core 2 found: MIPS 3302 (cc 0x816, rev 0x08, vendor 0x4243)
>> ssb: Core 3 found: USB 2.0 Host (cc 0x819, rev 0x02, vendor 0x4243)
>> ssb: Core 4 found: MEMC SDRAM (cc 0x80F, rev 0x04, vendor 0x4243)
>> ssb: Core 5 found: IEEE 802.11 (cc 0x812, rev 0x0D, vendor 0x4243)
>> ssb: Core 6 found: Roboswitch (cc 0x81C, rev 0x02, vendor 0x4243)
>>
>> b43-phy0: Broadcom 5354 WLAN found (core revision 13)
>> b43-phy0 debug: Found PHY: Analog 6, Type 5, Revision 0
>> b43-phy0 debug: Found Radio: Manuf 0x17F, Version 0x2062, Revision 1
>>
>> When doing a passive scan with iw it works without any problems and I
>> get my results without any kernel oops, but when doing an active scan I
>> get an oops.
> 
> If you search for "out of memory b43" you will find the thread where
> we were trying to find the issue. Unfortunately without the real
> access to the hardware it wasn't easy to debug this. Sending patches
> to someone, waiting for recompiling & testing, checking results... I
> failed at that process :(
Yeah this will work with obvious bugs, but this seams to be hard bug. I
will investigate deeper into it.
> 
> While I'll try to implement/update LP-PHY code, I think it still would
> be nice to investigate this problem. Do we have some leak in b43? We
> should fix it if so.
I haven't found a leak in b43 yet, just one in an OpenWrt switch driver,
while searching in b43. ;-)
It's nice to hear that you will work on the LP-PHY part, to me it looks
like ~30% of the spec is not implemented. have you started implementing
the GMAC Ethernet driver?
> 
> Could you check what exactly happens in b43_dma_tx please?
Yes I will look deeper into this.
Do you have a working LP-PHY device, so that I could give you some
patches and then compare the output?

Hauke


From hauke at hauke-m.de  Mon Jan 30 15:15:06 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Mon, 30 Jan 2012 21:15:06 +0100
Subject: Broadcom sprom
Message-ID: <4F26FA4A.9090102@hauke-m.de>

I had a look at the sprom parsing, as the SoC sprom parsing code is
dated and does not fill in some fields introduced in updates of struct
ssb_sprom. I had a look at the brcm/include/bcmsrom_tbl.h file found in
the Broadcom SoC SDK containing the positions and names of the sprom
values. For the old sprom versions <= 4 our struct ssb_sprom contains
mostly all fields available in the sprom, but for more recent it misses
some/many values. I searched brcmsmac for some of them and they are
mostly parsing the same values for v8 and v9 as the Broadcom SoC SDK
does, but they do not use all of them.

How should we proceed? Should I extend struct ssb_sprom to support all
sprom values available or found in the Broadcom SDK in sprom version 1
to 9 and add the parsing code to bcm47xx arch code, ssb (for old
versions) and bcma, or just the ones currently needed by any driver? As
even brcmsmac does not use all of them some seam to be unused at all.

As the struct would be under 1KB if we put in all sprom values we know
of I am for adding all these values into it and we do not have to deal
with sproms till version 10 is released. ;-)

What are you opinions about this?

Hauke


From zajec5 at gmail.com  Mon Jan 30 15:37:40 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 30 Jan 2012 21:37:40 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <4F26F36D.5050903@hauke-m.de>
References: <4F25C467.7070805@hauke-m.de> <4F25D746.2020801@hauke-m.de>
 <CACna6rxvftL8fQpzhyUD-Q6RgoAur7+qRbb_4VyDa413aBPk+A@mail.gmail.com>
 <4F26F36D.5050903@hauke-m.de>
Message-ID: <CACna6ry+DcJe5o4SPmn1=UuUNsPYFpkhXd4Nhw-HQ+Xn=d5_hQ@mail.gmail.com>

W dniu 30 stycznia 2012 20:45 u?ytkownik Hauke Mehrtens
<hauke at hauke-m.de> napisa?:
> On 01/30/2012 07:29 AM, Rafa? Mi?ecki wrote:
>> While I'll try to implement/update LP-PHY code, I think it still would
>> be nice to investigate this problem. Do we have some leak in b43? We
>> should fix it if so.
> I haven't found a leak in b43 yet, just one in an OpenWrt switch driver,
> while searching in b43. ;-)
> It's nice to hear that you will work on the LP-PHY part, to me it looks
> like ~30% of the spec is not implemented. have you started implementing
> the GMAC Ethernet driver?

I've started fighting with my router. I've tested it's working (on
original firmware), I'm trying now to get root access to get
partitions layout. I've already opened it (this required small Torx
screwdriver) and built 3,3V console. I'm working on creating console
pins (unfortunately they were removed from production==non-beta
boards).


>> Could you check what exactly happens in b43_dma_tx please?
> Yes I will look deeper into this.
> Do you have a working LP-PHY device, so that I could give you some
> patches and then compare the output?

My LP-PHY had some performance problems, probably some important
calibration is missing.

-- 
Rafa?


From zajec5 at gmail.com  Mon Jan 30 15:39:39 2012
From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=)
Date: Mon, 30 Jan 2012 21:39:39 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <4F26F195.9050509@hauke-m.de>
References: <4F25C467.7070805@hauke-m.de>
 <CACb-4KjixkVS5pe+mucyOaKeHAMb11m=YBZ47STZAiKDwRH2rQ@mail.gmail.com>
 <4F26F195.9050509@hauke-m.de>
Message-ID: <CACna6rwfgTPfY7w0Pb0N1v2KrxhOReiyZK1dPDvY0LOE9894CA@mail.gmail.com>

2012/1/30 Hauke Mehrtens <hauke at hauke-m.de>:
> Hi William,
>
> On 01/30/2012 04:39 PM, William R Agosto Padilla wrote:
>> Mr. Hauke,
>>
>> I am new to the reverse engineering process. However I am working on a
>> project that
>> requires me to use printk statements in the b43 device driver code, so I
>> can see how it is
>> really working during initialization, resetting, and suspension of the
>> networking process.
>>
>> The first problem that I encountered was finding the b43 source code for
>> download.
>> I was only able to find the assembly code for the b43 firmware. Do you
>> know of a specific download
>> location where I can get the entire b43's ''C'' source code?
> Just go to https://www.kernel.org/ and download the Linux kernel it has
> b43 included in it in drivers/net/wireless/b43 or use
> http://wireless.kernel.org/en/users/Download/stable/
>
>> ?Reading
>> your email I realized that you
>> have already done what I will be attempting to do. Mainly, using printk
>> statements inside the b43 code.
>> I have been at this for a couple of months without any luck. Would you
>> mind if I ask a few questions
>> about the way you went about on doing so? Or advice on how to do it?
>>
>> Did you added the printk statements into the b43 source code or the b43
>> firmware code?
> I do not have access to the source code of the broadcom firmware, but
> there is an open source project developing an open Source firmware
> http://www.ing.unibs.it/~openfwwf/
>>I would like to try
>> something similar. As I mentioned earlier, I was not able to see the
>> b43's 'C' source code with my
>> Linux Ubuntu 11.10 distribution. I found a copy of the firmware source
>> code with the
>> assembly language, etc. Is that the code that you used for the printk
>> statements?
> I am just working on the driver and treating the firmware as a black box.
>> I thought that since the b43 driver is included in the kernel that
>> Ubuntu 11.10 has, it
>> would also include the source code--no luck with that.
>>
>> Any insight that you can share would be very much appreciated.

William, you're asking random people privately in random threads and
you're duplicating your questions.

If there is something we can explain to you, please just ask using
b43-devl mailing list. I'm sure you'll get some answers and we won't
waste our time responding on the questions you've already got
explained by sb else.

-- 
Rafa?


From hauke at hauke-m.de  Mon Jan 30 15:48:22 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Mon, 30 Jan 2012 21:48:22 +0100
Subject: BCM5354 SoC with LP Phy Wifi
In-Reply-To: <CACna6ry+DcJe5o4SPmn1=UuUNsPYFpkhXd4Nhw-HQ+Xn=d5_hQ@mail.gmail.com>
References: <4F25C467.7070805@hauke-m.de> <4F25D746.2020801@hauke-m.de>
 <CACna6rxvftL8fQpzhyUD-Q6RgoAur7+qRbb_4VyDa413aBPk+A@mail.gmail.com>
 <4F26F36D.5050903@hauke-m.de>
 <CACna6ry+DcJe5o4SPmn1=UuUNsPYFpkhXd4Nhw-HQ+Xn=d5_hQ@mail.gmail.com>
Message-ID: <4F270216.8000309@hauke-m.de>

On 01/30/2012 09:37 PM, Rafa? Mi?ecki wrote:
> W dniu 30 stycznia 2012 20:45 u?ytkownik Hauke Mehrtens
> <hauke at hauke-m.de> napisa?:
>> On 01/30/2012 07:29 AM, Rafa? Mi?ecki wrote:
>>> While I'll try to implement/update LP-PHY code, I think it still would
>>> be nice to investigate this problem. Do we have some leak in b43? We
>>> should fix it if so.
>> I haven't found a leak in b43 yet, just one in an OpenWrt switch driver,
>> while searching in b43. ;-)
>> It's nice to hear that you will work on the LP-PHY part, to me it looks
>> like ~30% of the spec is not implemented. have you started implementing
>> the GMAC Ethernet driver?
> 
> I've started fighting with my router. I've tested it's working (on
> original firmware), I'm trying now to get root access to get
> partitions layout. I've already opened it (this required small Torx
> screwdriver) and built 3,3V console. I'm working on creating console
> pins (unfortunately they were removed from production==non-beta
> boards).
I had the same problem with my Netgear device on the pictures made by
the FCC there are nice pins on the board and ASUS just leaves them there
for the production devices, but my Netgear devices did not had them.
The pin layout is probably the same as for the WNR3500L here:
http://wiki.openwrt.org/toh/netgear/wnr3500l

>>> Could you check what exactly happens in b43_dma_tx please?
>> Yes I will look deeper into this.
>> Do you have a working LP-PHY device, so that I could give you some
>> patches and then compare the output?
> 
> My LP-PHY had some performance problems, probably some important
> calibration is missing.

I got ~4MBit/s when running my device in AP mode with old firmware over
~0.5 meters.

Hauke


From hauke at hauke-m.de  Mon Jan 30 18:03:30 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:30 +0100
Subject: [PATCH 0/7] bcma: add PCIe host controller
Message-ID: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>

These patches are adding support for a PCIe Host controller found on 
some Broadcom SoCs using bcma as the System bus. This was tested with 
one BCM4716 based device, a Netgear WNDR3400 with a BCM43224 connected 
through PCIe.
These patches are based on wireless-testing.

Hauke Mehrtens (7):
  bcma: add the core unit number
  bcma: add constants for PCI and use them
  bcma: export bcma_pcie_read()
  bcma: make some functions __devinit
  bcma: add PCIe host controller
  bcma: add bus num counter
  bcma: add extra sprom check

 arch/mips/pci/pci-bcm47xx.c                 |   49 ++-
 drivers/bcma/bcma_private.h                 |    8 +-
 drivers/bcma/driver_pci.c                   |  168 ++++-----
 drivers/bcma/driver_pci_host.c              |  578 ++++++++++++++++++++++++++-
 drivers/bcma/host_pci.c                     |    4 +-
 drivers/bcma/main.c                         |   14 +-
 drivers/bcma/scan.c                         |   14 +
 drivers/bcma/sprom.c                        |    7 +
 include/linux/bcma/bcma.h                   |    2 +
 include/linux/bcma/bcma_driver_chipcommon.h |   16 +
 include/linux/bcma/bcma_driver_pci.h        |  125 ++++++-
 include/linux/bcma/bcma_regs.h              |   27 ++
 12 files changed, 908 insertions(+), 104 deletions(-)

-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:31 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:31 +0100
Subject: [PATCH 1/7] bcma: add the core unit number
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-2-git-send-email-hauke@hauke-m.de>

Some SoCs have two pcie or gmac cores and we need to know the number of
the specific core on the bus. This is the case for the BCM4706.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/scan.c       |   14 ++++++++++++++
 include/linux/bcma/bcma.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index cad9948..e513aa8 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -212,6 +212,17 @@ static struct bcma_device *bcma_find_core_by_index(struct bcma_bus *bus,
 	return NULL;
 }
 
+static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 coreid)
+{
+	struct bcma_device *core;
+
+	list_for_each_entry_reverse(core, &bus->cores, list) {
+		if (core->id.id == coreid)
+			return core;
+	}
+	return NULL;
+}
+
 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
 			      struct bcma_device_id *match, int core_num,
 			      struct bcma_device *core)
@@ -392,6 +403,7 @@ int bcma_bus_scan(struct bcma_bus *bus)
 	bcma_scan_switch_core(bus, erombase);
 
 	while (eromptr < eromend) {
+		struct bcma_device *other_core;
 		struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL);
 		if (!core)
 			return -ENOMEM;
@@ -411,6 +423,8 @@ int bcma_bus_scan(struct bcma_bus *bus)
 
 		core->core_index = core_num++;
 		bus->nr_cores++;
+		other_core = bcma_find_core_reverse(bus, core->id.id);
+		core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1;
 
 		pr_info("Core %d found: %s "
 			"(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 83c209f..024a6e2 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -136,6 +136,7 @@ struct bcma_device {
 	bool dev_registered;
 
 	u8 core_index;
+	u8 core_unit;
 
 	u32 addr;
 	u32 wrap;
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:33 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:33 +0100
Subject: [PATCH 3/7] bcma: export bcma_pcie_read()
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-4-git-send-email-hauke@hauke-m.de>

This will be needed by the host controller.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/bcma_private.h |    3 +++
 drivers/bcma/driver_pci.c   |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 0def898..6109da5 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -48,6 +48,9 @@ extern int __init bcma_host_pci_init(void);
 extern void __exit bcma_host_pci_exit(void);
 #endif /* CONFIG_BCMA_HOST_PCI */
 
+/* driver_pci.c */
+u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
+
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 970a38e..20ceebd 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -17,7 +17,7 @@
  * R/W ops.
  **************************************************/
 
-static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
+u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
 {
 	pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
 	pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:32 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:32 +0100
Subject: [PATCH 2/7] bcma: add constants for PCI and use them
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-3-git-send-email-hauke@hauke-m.de>

There are many magic numbers used in the PCIe code. Replace them with
some constants from the Broadcom SDK and also use them in the pcie host
controller.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/driver_pci.c            |  124 +++++++++++++++++++---------------
 include/linux/bcma/bcma_driver_pci.h |   85 +++++++++++++++++++++++
 2 files changed, 155 insertions(+), 54 deletions(-)

diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 4fde625..970a38e 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -4,6 +4,7 @@
  *
  * Copyright 2005, Broadcom Corporation
  * Copyright 2006, 2007, Michael Buesch <m at bues.ch>
+ * Copyright 2011, 2012, Hauke Mehrtens <hauke at hauke-m.de>
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
@@ -18,38 +19,39 @@
 
 static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
 {
-	pcicore_write32(pc, 0x130, address);
-	pcicore_read32(pc, 0x130);
-	return pcicore_read32(pc, 0x134);
+	pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
+	pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
+	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, 0x130, address);
-	pcicore_read32(pc, 0x130);
-	pcicore_write32(pc, 0x134, 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)
 {
-	const u16 mdio_control = 0x128;
-	const u16 mdio_data = 0x12C;
 	u32 v;
 	int i;
 
-	v = (1 << 30); /* Start of Transaction */
-	v |= (1 << 28); /* Write Transaction */
-	v |= (1 << 17); /* Turnaround */
-	v |= (0x1F << 18);
+	v = BCMA_CORE_PCI_MDIODATA_START;
+	v |= BCMA_CORE_PCI_MDIODATA_WRITE;
+	v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
+	      BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
+	v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR <<
+	      BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
+	v |= BCMA_CORE_PCI_MDIODATA_TA;
 	v |= (phy << 4);
-	pcicore_write32(pc, mdio_data, v);
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
 
 	udelay(10);
 	for (i = 0; i < 200; i++) {
-		v = pcicore_read32(pc, mdio_control);
-		if (v & 0x100 /* Trans complete */)
+		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
+		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
 		msleep(1);
 	}
@@ -57,79 +59,84 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
 
 static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
 {
-	const u16 mdio_control = 0x128;
-	const u16 mdio_data = 0x12C;
 	int max_retries = 10;
 	u16 ret = 0;
 	u32 v;
 	int i;
 
-	v = 0x80; /* Enable Preamble Sequence */
-	v |= 0x2; /* MDIO Clock Divisor */
-	pcicore_write32(pc, mdio_control, v);
+	/* enable mdio access to SERDES */
+	v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
+	v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
 
 	if (pc->core->id.rev >= 10) {
 		max_retries = 200;
 		bcma_pcie_mdio_set_phy(pc, device);
+		v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
+		     BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
+		v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
+	} else {
+		v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
+		v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
 	}
 
-	v = (1 << 30); /* Start of Transaction */
-	v |= (1 << 29); /* Read Transaction */
-	v |= (1 << 17); /* Turnaround */
-	if (pc->core->id.rev < 10)
-		v |= (u32)device << 22;
-	v |= (u32)address << 18;
-	pcicore_write32(pc, mdio_data, v);
+	v = BCMA_CORE_PCI_MDIODATA_START;
+	v |= BCMA_CORE_PCI_MDIODATA_READ;
+	v |= BCMA_CORE_PCI_MDIODATA_TA;
+
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
 	/* Wait for the device to complete the transaction */
 	udelay(10);
 	for (i = 0; i < max_retries; i++) {
-		v = pcicore_read32(pc, mdio_control);
-		if (v & 0x100 /* Trans complete */) {
+		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
+		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) {
 			udelay(10);
-			ret = pcicore_read32(pc, mdio_data);
+			ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
 			break;
 		}
 		msleep(1);
 	}
-	pcicore_write32(pc, mdio_control, 0);
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 	return ret;
 }
 
 static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
 				u8 address, u16 data)
 {
-	const u16 mdio_control = 0x128;
-	const u16 mdio_data = 0x12C;
 	int max_retries = 10;
 	u32 v;
 	int i;
 
-	v = 0x80; /* Enable Preamble Sequence */
-	v |= 0x2; /* MDIO Clock Divisor */
-	pcicore_write32(pc, mdio_control, v);
+	/* enable mdio access to SERDES */
+	v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
+	v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
 
 	if (pc->core->id.rev >= 10) {
 		max_retries = 200;
 		bcma_pcie_mdio_set_phy(pc, device);
+		v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
+		     BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
+		v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
+	} else {
+		v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
+		v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
 	}
 
-	v = (1 << 30); /* Start of Transaction */
-	v |= (1 << 28); /* Write Transaction */
-	v |= (1 << 17); /* Turnaround */
-	if (pc->core->id.rev < 10)
-		v |= (u32)device << 22;
-	v |= (u32)address << 18;
+	v = BCMA_CORE_PCI_MDIODATA_START;
+	v |= BCMA_CORE_PCI_MDIODATA_WRITE;
+	v |= BCMA_CORE_PCI_MDIODATA_TA;
 	v |= data;
-	pcicore_write32(pc, mdio_data, v);
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
 	/* Wait for the device to complete the transaction */
 	udelay(10);
 	for (i = 0; i < max_retries; i++) {
-		v = pcicore_read32(pc, mdio_control);
-		if (v & 0x100 /* Trans complete */)
+		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
+		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
 		msleep(1);
 	}
-	pcicore_write32(pc, mdio_control, 0);
+	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 }
 
 /**************************************************
@@ -138,20 +145,29 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
 
 static u8 bcma_pcicore_polarity_workaround(struct bcma_drv_pci *pc)
 {
-	return (bcma_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
+	u32 tmp;
+	
+	tmp = bcma_pcie_read(pc, BCMA_CORE_PCI_PLP_STATUSREG);
+	if (tmp & BCMA_CORE_PCI_PLP_POLARITYINV_STAT)
+		return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE |
+		       BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY;
+	else
+		return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE;
 }
 
 static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
 {
-	const u8 serdes_pll_device = 0x1D;
-	const u8 serdes_rx_device = 0x1F;
 	u16 tmp;
 
-	bcma_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
-			      bcma_pcicore_polarity_workaround(pc));
-	tmp = bcma_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
-	if (tmp & 0x4000)
-		bcma_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
+	bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX,
+	                     BCMA_CORE_PCI_SERDES_RX_CTRL,
+			     bcma_pcicore_polarity_workaround(pc));
+	tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
+	                          BCMA_CORE_PCI_SERDES_PLL_CTRL);
+	if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN)
+		bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
+		                     BCMA_CORE_PCI_SERDES_PLL_CTRL,
+		                     tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
 }
 
 /**************************************************
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
index 3871b66..67ea7be 100644
--- a/include/linux/bcma/bcma_driver_pci.h
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -53,6 +53,35 @@ struct pci_dev;
 #define  BCMA_CORE_PCI_SBTOPCI1_MASK		0xFC000000
 #define BCMA_CORE_PCI_SBTOPCI2			0x0108	/* Backplane to PCI translation 2 (sbtopci2) */
 #define  BCMA_CORE_PCI_SBTOPCI2_MASK		0xC0000000
+#define BCMA_CORE_PCI_CONFIG_ADDR		0x0120	/* pcie config space access */
+#define BCMA_CORE_PCI_CONFIG_DATA		0x0124	/* pcie config space access */
+#define BCMA_CORE_PCI_MDIO_CONTROL		0x0128	/* controls the mdio access */
+#define  BCMA_CORE_PCI_MDIOCTL_DIVISOR_MASK	0x7f	/* clock to be used on MDIO */
+#define  BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL	0x2
+#define  BCMA_CORE_PCI_MDIOCTL_PREAM_EN		0x80	/* Enable preamble sequnce */
+#define  BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE	0x100	/* Tranaction complete */
+#define BCMA_CORE_PCI_MDIO_DATA			0x012c	/* Data to the mdio access */
+#define  BCMA_CORE_PCI_MDIODATA_MASK		0x0000ffff /* data 2 bytes */
+#define  BCMA_CORE_PCI_MDIODATA_TA		0x00020000 /* Turnaround */
+#define  BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD	18	/* Regaddr shift (rev < 10) */
+#define  BCMA_CORE_PCI_MDIODATA_REGADDR_MASK_OLD	0x003c0000 /* Regaddr Mask (rev < 10) */
+#define  BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD	22	/* Physmedia devaddr shift (rev < 10) */
+#define  BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK_OLD	0x0fc00000 /* Physmedia devaddr Mask (rev < 10) */
+#define  BCMA_CORE_PCI_MDIODATA_REGADDR_SHF	18	/* Regaddr shift */
+#define  BCMA_CORE_PCI_MDIODATA_REGADDR_MASK	0x007c0000 /* Regaddr Mask */
+#define  BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF	23	/* Physmedia devaddr shift */
+#define  BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK	0x0f800000 /* Physmedia devaddr Mask */
+#define  BCMA_CORE_PCI_MDIODATA_WRITE		0x10000000 /* write Transaction */
+#define  BCMA_CORE_PCI_MDIODATA_READ		0x20000000 /* Read Transaction */
+#define  BCMA_CORE_PCI_MDIODATA_START		0x40000000 /* start of Transaction */
+#define  BCMA_CORE_PCI_MDIODATA_DEV_ADDR	0x0	/* dev address for serdes */
+#define  BCMA_CORE_PCI_MDIODATA_BLK_ADDR	0x1F	/* blk address for serdes */
+#define  BCMA_CORE_PCI_MDIODATA_DEV_PLL		0x1d	/* SERDES PLL Dev */
+#define  BCMA_CORE_PCI_MDIODATA_DEV_TX		0x1e	/* SERDES TX Dev */
+#define  BCMA_CORE_PCI_MDIODATA_DEV_RX		0x1f	/* SERDES RX Dev */
+#define BCMA_CORE_PCI_PCIEIND_ADDR		0x0130	/* indirect access to the internal register */
+#define BCMA_CORE_PCI_PCIEIND_DATA		0x0134	/* Data to/from the internal regsiter */
+#define BCMA_CORE_PCI_CLKREQENCTRL		0x0138	/*  >= rev 6, Clkreq rdma control */
 #define BCMA_CORE_PCI_PCICFG0			0x0400	/* PCI config space 0 (rev >= 8) */
 #define BCMA_CORE_PCI_PCICFG1			0x0500	/* PCI config space 1 (rev >= 8) */
 #define BCMA_CORE_PCI_PCICFG2			0x0600	/* PCI config space 2 (rev >= 8) */
@@ -72,6 +101,62 @@ struct pci_dev;
 #define  BCMA_CORE_PCI_SBTOPCI_RC_READL		0x00000010 /* Memory read line */
 #define  BCMA_CORE_PCI_SBTOPCI_RC_READM		0x00000020 /* Memory read multiple */
 
+/* PCIE protocol PHY diagnostic registers */
+#define BCMA_CORE_PCI_PLP_MODEREG		0x200	/* Mode */
+#define BCMA_CORE_PCI_PLP_STATUSREG		0x204	/* Status */
+#define  BCMA_CORE_PCI_PLP_POLARITYINV_STAT	0x10	/* Status reg PCIE_PLP_STATUSREG */
+#define BCMA_CORE_PCI_PLP_LTSSMCTRLREG		0x208	/* LTSSM control */
+#define BCMA_CORE_PCI_PLP_LTLINKNUMREG		0x20c	/* Link Training Link number */
+#define BCMA_CORE_PCI_PLP_LTLANENUMREG		0x210	/* Link Training Lane number */
+#define BCMA_CORE_PCI_PLP_LTNFTSREG		0x214	/* Link Training N_FTS */
+#define BCMA_CORE_PCI_PLP_ATTNREG		0x218	/* Attention */
+#define BCMA_CORE_PCI_PLP_ATTNMASKREG		0x21C	/* Attention Mask */
+#define BCMA_CORE_PCI_PLP_RXERRCTR		0x220	/* Rx Error */
+#define BCMA_CORE_PCI_PLP_RXFRMERRCTR		0x224	/* Rx Framing Error */
+#define BCMA_CORE_PCI_PLP_RXERRTHRESHREG	0x228	/* Rx Error threshold */
+#define BCMA_CORE_PCI_PLP_TESTCTRLREG		0x22C	/* Test Control reg */
+#define BCMA_CORE_PCI_PLP_SERDESCTRLOVRDREG	0x230	/* SERDES Control Override */
+#define BCMA_CORE_PCI_PLP_TIMINGOVRDREG		0x234	/* Timing param override */
+#define BCMA_CORE_PCI_PLP_RXTXSMDIAGREG		0x238	/* RXTX State Machine Diag */
+#define BCMA_CORE_PCI_PLP_LTSSMDIAGREG		0x23C	/* LTSSM State Machine Diag */
+
+/* PCIE protocol DLLP diagnostic registers */
+#define BCMA_CORE_PCI_DLLP_LCREG		0x100	/* Link Control */
+#define BCMA_CORE_PCI_DLLP_LSREG		0x104	/* Link Status */
+#define BCMA_CORE_PCI_DLLP_LAREG		0x108	/* Link Attention */
+#define  BCMA_CORE_PCI_DLLP_LSREG_LINKUP	(1 << 16)
+#define BCMA_CORE_PCI_DLLP_LAMASKREG		0x10C	/* Link Attention Mask */
+#define BCMA_CORE_PCI_DLLP_NEXTTXSEQNUMREG	0x110	/* Next Tx Seq Num */
+#define BCMA_CORE_PCI_DLLP_ACKEDTXSEQNUMREG	0x114	/* Acked Tx Seq Num */
+#define BCMA_CORE_PCI_DLLP_PURGEDTXSEQNUMREG	0x118	/* Purged Tx Seq Num */
+#define BCMA_CORE_PCI_DLLP_RXSEQNUMREG		0x11C	/* Rx Sequence Number */
+#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_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 */
+#define BCMA_CORE_PCI_DLLP_RTRRWREG		0x138	/* Retry buffer Read/Write */
+#define BCMA_CORE_PCI_DLLP_ECTHRESHREG		0x13C	/* Error Count Threshold */
+#define BCMA_CORE_PCI_DLLP_TLPERRCTRREG		0x140	/* TLP Error Counter */
+#define BCMA_CORE_PCI_DLLP_ERRCTRREG		0x144	/* Error Counter */
+#define BCMA_CORE_PCI_DLLP_NAKRXCTRREG		0x148	/* NAK Received Counter */
+#define BCMA_CORE_PCI_DLLP_TESTREG		0x14C	/* Test */
+#define BCMA_CORE_PCI_DLLP_PKTBIST		0x150	/* Packet BIST */
+#define BCMA_CORE_PCI_DLLP_PCIE11		0x154	/* DLLP PCIE 1.1 reg */
+
+/* SERDES RX registers */
+#define BCMA_CORE_PCI_SERDES_RX_CTRL		1	/* Rx cntrl */
+#define  BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE	0x80	/* rxpolarity_force */
+#define  BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY	0x40	/* rxpolarity_value */
+#define BCMA_CORE_PCI_SERDES_RX_TIMER1		2	/* Rx Timer1 */
+#define BCMA_CORE_PCI_SERDES_RX_CDR		6	/* CDR */
+#define BCMA_CORE_PCI_SERDES_RX_CDRBW		7	/* CDR BW */
+
+/* SERDES PLL registers */
+#define BCMA_CORE_PCI_SERDES_PLL_CTRL		1	/* PLL control reg */
+#define BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN	0x4000	/* bit 14 is FREQDET on */
+
 /* PCIcore specific boardflags */
 #define BCMA_CORE_PCI_BFL_NOPCI			0x00000400 /* Board leaves PCI floating */
 
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:34 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:34 +0100
Subject: [PATCH 4/7] bcma: make some functions __devinit
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-5-git-send-email-hauke@hauke-m.de>

bcma_core_pci_hostmode_init() has to be in __devinit as it will call a
function in that section and so all functions calling it also have to
be in __devinit.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/bcma_private.h          |    4 ++--
 drivers/bcma/driver_pci.c            |    6 +++---
 drivers/bcma/driver_pci_host.c       |    2 +-
 drivers/bcma/host_pci.c              |    4 ++--
 drivers/bcma/main.c                  |    2 +-
 include/linux/bcma/bcma_driver_pci.h |    2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 6109da5..63c5242 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -13,7 +13,7 @@
 struct bcma_bus;
 
 /* main.c */
-int bcma_bus_register(struct bcma_bus *bus);
+int __devinit bcma_bus_register(struct bcma_bus *bus);
 void bcma_bus_unregister(struct bcma_bus *bus);
 int __init bcma_bus_early_register(struct bcma_bus *bus,
 				   struct bcma_device *core_cc,
@@ -52,7 +52,7 @@ extern void __exit bcma_host_pci_exit(void);
 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
 
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
-void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
+void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
 #endif
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 20ceebd..161c8ba 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -174,12 +174,12 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
  * Init.
  **************************************************/
 
-static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
+static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 {
 	bcma_pcicore_serdes_workaround(pc);
 }
 
-static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
+static bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
 {
 	struct bcma_bus *bus = pc->core->bus;
 	u16 chipid_top;
@@ -204,7 +204,7 @@ static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
 	return true;
 }
 
-void bcma_core_pci_init(struct bcma_drv_pci *pc)
+void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
 {
 	if (pc->setup_done)
 		return;
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index eb332b7..99e040b 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -8,7 +8,7 @@
 #include "bcma_private.h"
 #include <linux/bcma/bcma.h>
 
-void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
+void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
 {
 	pr_err("No support for PCI core in hostmode yet\n");
 }
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index f59244e..e3928d6 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -154,8 +154,8 @@ const struct bcma_host_ops bcma_host_pci_ops = {
 	.awrite32	= bcma_host_pci_awrite32,
 };
 
-static int bcma_host_pci_probe(struct pci_dev *dev,
-			     const struct pci_device_id *id)
+static int __devinit bcma_host_pci_probe(struct pci_dev *dev,
+					 const struct pci_device_id *id)
 {
 	struct bcma_bus *bus;
 	int err = -ENOMEM;
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index febbc0a..3363036 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -132,7 +132,7 @@ static void bcma_unregister_cores(struct bcma_bus *bus)
 	}
 }
 
-int bcma_bus_register(struct bcma_bus *bus)
+int __devinit bcma_bus_register(struct bcma_bus *bus)
 {
 	int err;
 	struct bcma_device *core;
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
index 67ea7be..679d4ca 100644
--- a/include/linux/bcma/bcma_driver_pci.h
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -169,7 +169,7 @@ struct bcma_drv_pci {
 #define pcicore_read32(pc, offset)		bcma_read32((pc)->core, offset)
 #define pcicore_write32(pc, offset, val)	bcma_write32((pc)->core, offset, val)
 
-extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
+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);
 
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:36 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:36 +0100
Subject: [PATCH 6/7] bcma: add bus num counter
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-7-git-send-email-hauke@hauke-m.de>

If we have two bcma buses on one computer the second will not work
without this patch. Now each bus gets an own number.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/main.c       |   12 +++++++++++-
 include/linux/bcma/bcma.h |    1 +
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 3363036..bcd1c01 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -13,6 +13,12 @@
 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
 MODULE_LICENSE("GPL");
 
+/* contains the number the next bus should get. */
+static unsigned int bcma_bus_next_num = 0;
+
+/* bcma_buses_mutex locks the bcma_bus_next_num */
+static DEFINE_MUTEX(bcma_buses_mutex);
+
 static int bcma_bus_match(struct device *dev, struct device_driver *drv);
 static int bcma_device_probe(struct device *dev);
 static int bcma_device_remove(struct device *dev);
@@ -93,7 +99,7 @@ static int bcma_register_cores(struct bcma_bus *bus)
 
 		core->dev.release = bcma_release_core_dev;
 		core->dev.bus = &bcma_bus_type;
-		dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id);
+		dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
 
 		switch (bus->hosttype) {
 		case BCMA_HOSTTYPE_PCI:
@@ -137,6 +143,10 @@ int __devinit bcma_bus_register(struct bcma_bus *bus)
 	int err;
 	struct bcma_device *core;
 
+	mutex_lock(&bcma_buses_mutex);
+	bus->num = bcma_bus_next_num++;
+	mutex_unlock(&bcma_buses_mutex);
+
 	/* Scan for devices (cores) */
 	err = bcma_bus_scan(bus);
 	if (err) {
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 024a6e2..b9f65fb 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -196,6 +196,7 @@ struct bcma_bus {
 	struct list_head cores;
 	u8 nr_cores;
 	u8 init_done:1;
+	u8 num;
 
 	struct bcma_drv_cc drv_cc;
 	struct bcma_drv_pci drv_pci;
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:37 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:37 +0100
Subject: [PATCH 7/7] bcma: add extra sprom check
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-8-git-send-email-hauke@hauke-m.de>

This check is needed on the BCM43224 device as it says in the
capabilities it has an sprom but is extra check says it has not.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/sprom.c                        |    7 +++++++
 include/linux/bcma/bcma_driver_chipcommon.h |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index e35134f..ca77525 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -250,6 +250,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
 {
 	u16 offset;
 	u16 *sprom;
+	u32 sromctrl;
 	int err = 0;
 
 	if (!bus->drv_cc.core)
@@ -258,6 +259,12 @@ int bcma_sprom_get(struct bcma_bus *bus)
 	if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
 		return -ENOENT;
 
+	if (bus->drv_cc.core->id.rev >= 32) {
+		sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL);
+		if (!(sromctrl & BCMA_CC_SROM_CONTROL_PRESENT))
+			return -ENOENT;
+	}
+
 	sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
 			GFP_KERNEL);
 	if (!sprom)
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index a33086a..e72938b 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -181,6 +181,22 @@
 #define BCMA_CC_FLASH_CFG		0x0128
 #define  BCMA_CC_FLASH_CFG_DS		0x0010	/* Data size, 0=8bit, 1=16bit */
 #define BCMA_CC_FLASH_WAITCNT		0x012C
+#define BCMA_CC_SROM_CONTROL		0x0190
+#define  BCMA_CC_SROM_CONTROL_START	0x80000000
+#define  BCMA_CC_SROM_CONTROL_BUSY	0x80000000
+#define  BCMA_CC_SROM_CONTROL_OPCODE	0x60000000
+#define  BCMA_CC_SROM_CONTROL_OP_READ	0x00000000
+#define  BCMA_CC_SROM_CONTROL_OP_WRITE	0x20000000
+#define  BCMA_CC_SROM_CONTROL_OP_WRDIS	0x40000000
+#define  BCMA_CC_SROM_CONTROL_OP_WREN	0x60000000
+#define  BCMA_CC_SROM_CONTROL_OTPSEL	0x00000010
+#define  BCMA_CC_SROM_CONTROL_LOCK	0x00000008
+#define  BCMA_CC_SROM_CONTROL_SIZE_MASK	0x00000006
+#define  BCMA_CC_SROM_CONTROL_SIZE_1K	0x00000000
+#define  BCMA_CC_SROM_CONTROL_SIZE_4K	0x00000002
+#define  BCMA_CC_SROM_CONTROL_SIZE_16K	0x00000004
+#define  BCMA_CC_SROM_CONTROL_SIZE_SHIFT	1
+#define  BCMA_CC_SROM_CONTROL_PRESENT	0x00000001
 /* 0x1E0 is defined as shared BCMA_CLKCTLST */
 #define BCMA_CC_HW_WORKAROUND		0x01E4 /* Hardware workaround (rev >= 20) */
 #define BCMA_CC_UART0_DATA		0x0300
-- 
1.7.5.4



From hauke at hauke-m.de  Mon Jan 30 18:03:35 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Tue, 31 Jan 2012 00:03:35 +0100
Subject: [PATCH 5/7] bcma: add PCIe host controller
In-Reply-To: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
References: <1327964617-7910-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1327964617-7910-6-git-send-email-hauke@hauke-m.de>

Some SoCs have a PCIe host controller to make it possible to attach
some other devices to it, like an other Wifi card.
This code was tested with an Netgear WNDR3400 (bcm4716 based), but
should work with all bcma based SoCs.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 arch/mips/pci/pci-bcm47xx.c          |   49 +++-
 drivers/bcma/bcma_private.h          |    1 +
 drivers/bcma/driver_pci.c            |   38 +--
 drivers/bcma/driver_pci_host.c       |  576 +++++++++++++++++++++++++++++++++-
 include/linux/bcma/bcma_driver_pci.h |   38 +++
 include/linux/bcma/bcma_regs.h       |   27 ++
 6 files changed, 690 insertions(+), 39 deletions(-)

diff --git a/arch/mips/pci/pci-bcm47xx.c b/arch/mips/pci/pci-bcm47xx.c
index 400535a..c682468 100644
--- a/arch/mips/pci/pci-bcm47xx.c
+++ b/arch/mips/pci/pci-bcm47xx.c
@@ -25,6 +25,7 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/ssb/ssb.h>
+#include <linux/bcma/bcma.h>
 #include <bcm47xx.h>
 
 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
@@ -32,15 +33,12 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 	return 0;
 }
 
-int pcibios_plat_dev_init(struct pci_dev *dev)
-{
 #ifdef CONFIG_BCM47XX_SSB
+static int bcm47xx_pcibios_plat_dev_init_ssb(struct pci_dev *dev)
+{
 	int res;
 	u8 slot, pin;
 
-	if (bcm47xx_bus_type !=  BCM47XX_BUS_TYPE_SSB)
-		return 0;
-
 	res = ssb_pcibios_plat_dev_init(dev);
 	if (res < 0) {
 		printk(KERN_ALERT "PCI: Failed to init device %s\n",
@@ -60,6 +58,47 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
 	}
 
 	dev->irq = res;
+	return 0;
+}
 #endif
+
+#ifdef CONFIG_BCM47XX_BCMA
+static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev)
+{
+	int res;
+
+	res = bcma_core_pci_plat_dev_init(dev);
+	if (res < 0) {
+		printk(KERN_ALERT "PCI: Failed to init device %s\n",
+		       pci_name(dev));
+		return res;
+	}
+
+	res = bcma_core_pci_pcibios_map_irq(dev);
+
+	/* IRQ-0 and IRQ-1 are software interrupts. */
+	if (res < 2) {
+		printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n",
+		       pci_name(dev));
+		return res;
+	}
+
+	dev->irq = res;
 	return 0;
 }
+#endif
+
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+#ifdef CONFIG_BCM47XX_SSB
+	if (bcm47xx_bus_type ==  BCM47XX_BUS_TYPE_SSB)
+		return bcm47xx_pcibios_plat_dev_init_ssb(dev);
+	else
+#endif
+#ifdef CONFIG_BCM47XX_BCMA
+	if  (bcm47xx_bus_type ==  BCM47XX_BUS_TYPE_BCMA)
+		return bcm47xx_pcibios_plat_dev_init_bcma(dev);
+	else
+#endif
+		return 0;
+}
diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 63c5242..b81755b 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -52,6 +52,7 @@ extern void __exit bcma_host_pci_exit(void);
 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
 
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
+bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 161c8ba..82e4898 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -2,7 +2,7 @@
  * Broadcom specific AMBA
  * PCI Core
  *
- * Copyright 2005, Broadcom Corporation
+ * Copyright 2005, 2011, Broadcom Corporation
  * Copyright 2006, 2007, Michael Buesch <m at bues.ch>
  * Copyright 2011, 2012, Hauke Mehrtens <hauke at hauke-m.de>
  *
@@ -179,47 +179,19 @@ static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 	bcma_pcicore_serdes_workaround(pc);
 }
 
-static bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
-{
-	struct bcma_bus *bus = pc->core->bus;
-	u16 chipid_top;
-
-	chipid_top = (bus->chipinfo.id & 0xFF00);
-	if (chipid_top != 0x4700 &&
-	    chipid_top != 0x5300)
-		return false;
-
-#ifdef CONFIG_SSB_DRIVER_PCICORE
-	if (bus->sprom.boardflags_lo & SSB_BFL_NOPCI)
-		return false;
-#endif /* CONFIG_SSB_DRIVER_PCICORE */
-
-#if 0
-	/* TODO: on BCMA we use address from EROM instead of magic formula */
-	u32 tmp;
-	return !mips_busprobe32(tmp, (bus->mmio +
-		(pc->core->core_index * BCMA_CORE_SIZE)));
-#endif
-
-	return true;
-}
-
 void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
 {
 	if (pc->setup_done)
 		return;
 
-	if (bcma_core_pci_is_in_hostmode(pc)) {
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
+	pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
+	if (pc->hostmode)
 		bcma_core_pci_hostmode_init(pc);
-#else
-		pr_err("Driver compiled without support for hostmode PCI\n");
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
-	} else {
-		bcma_core_pci_clientmode_init(pc);
-	}
 
-	pc->setup_done = true;
+	if (!pc->hostmode)
+		bcma_core_pci_clientmode_init(pc);
 }
 
 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 99e040b..4e20bcf 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -2,13 +2,587 @@
  * Broadcom specific AMBA
  * PCI Core in hostmode
  *
+ * Copyright 2005 - 2011, Broadcom Corporation
+ * Copyright 2006, 2007, Michael Buesch <m at bues.ch>
+ * Copyright 2011, 2012, Hauke Mehrtens <hauke at hauke-m.de>
+ *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 #include "bcma_private.h"
+#include <linux/export.h>
 #include <linux/bcma/bcma.h>
+#include <asm/paccess.h>
+
+/* Probe a 32bit value on the bus and catch bus exceptions.
+ * Returns nonzero on a bus exception.
+ * This is MIPS specific */
+#define mips_busprobe32(val, addr)	get_dbe((val), ((u32 *)(addr)))
+
+/* Assume one-hot slot wiring */
+#define BCMA_PCI_SLOT_MAX	16
+#define	PCI_CONFIG_SPACE_SIZE	256
+
+bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
+{
+	struct bcma_bus *bus = pc->core->bus;
+	u16 chipid_top;
+	u32 tmp;
+
+	chipid_top = (bus->chipinfo.id & 0xFF00);
+	if (chipid_top != 0x4700 &&
+	    chipid_top != 0x5300)
+		return false;
+
+	if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
+		pr_info("This PCI core is disabled and not working\n");
+		return false;
+	}
+
+	bcma_core_enable(pc->core, 0);
+
+	return !mips_busprobe32(tmp, pc->core->io_addr);
+}
+
+static u32 bcma_pcie_read_config(struct bcma_drv_pci *pc, u32 address)
+{
+	pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
+	pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
+	return pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_DATA);
+}
+
+static void bcma_pcie_write_config(struct bcma_drv_pci *pc, u32 address,
+				   u32 data)
+{
+	pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
+	pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
+	pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_DATA, data);
+}
+
+static u32 bcma_get_cfgspace_addr(struct bcma_drv_pci *pc, unsigned int dev,
+			     unsigned int func, unsigned int off)
+{
+	u32 addr = 0;
+
+	/* Issue config commands only when the data link is up (atleast
+	 * one external pcie device is present).
+	 */
+	if (dev >= 2 || !(bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_LSREG)
+			  & BCMA_CORE_PCI_DLLP_LSREG_LINKUP))
+		goto out;
+
+	/* Type 0 transaction */
+	/* Slide the PCI window to the appropriate slot */
+	pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
+	/* Calculate the address */
+	addr = pc->host_controller->host_cfg_addr;
+	addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT);
+	addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT);
+	addr |= (off & ~3);
+
+out:
+	return addr;
+}
+
+static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
+				  unsigned int func, unsigned int off,
+				  void *buf, int len)
+{
+	int err = -EINVAL;
+	u32 addr, val;
+	void __iomem *mmio = 0;
+
+	WARN_ON(!pc->hostmode);
+	if (unlikely(len != 1 && len != 2 && len != 4))
+		goto out;
+	if (dev == 0) {
+		/* we support only two functions on device 0 */
+		if (func > 1)
+			return -EINVAL;
+
+		/* accesses to config registers with offsets >= 256
+		 * requires indirect access.
+		 */
+		if (off >= PCI_CONFIG_SPACE_SIZE) {
+			addr = (func << 12);
+			addr |= (off & 0x0FFF);
+			val = bcma_pcie_read_config(pc, addr);
+		} else {
+			addr = BCMA_CORE_PCI_PCICFG0;
+			addr |= (func << 8);
+			addr |= (off & 0xfc);
+			val = pcicore_read32(pc, addr);
+		}
+	} else {
+		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
+		if (unlikely(!addr))
+			goto out;
+		err = -ENOMEM;
+		mmio = ioremap_nocache(addr, len);
+		if (!mmio)
+			goto out;
+
+		if (mips_busprobe32(val, mmio)) {
+			val = 0xffffffff;
+			goto unmap;
+		}
+
+		val = readl(mmio);
+	}
+	val >>= (8 * (off & 3));
+
+	switch (len) {
+	case 1:
+		*((u8 *)buf) = (u8)val;
+		break;
+	case 2:
+		*((u16 *)buf) = (u16)val;
+		break;
+	case 4:
+		*((u32 *)buf) = (u32)val;
+		break;
+	}
+	err = 0;
+unmap:
+	if (mmio)
+		iounmap(mmio);
+out:
+	return err;
+}
+
+static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
+				   unsigned int func, unsigned int off,
+				   const void *buf, int len)
+{
+	int err = -EINVAL;
+	u32 addr = 0, val = 0;
+	void __iomem *mmio = 0;
+	u16 chipid = pc->core->bus->chipinfo.id;
+
+	WARN_ON(!pc->hostmode);
+	if (unlikely(len != 1 && len != 2 && len != 4))
+		goto out;
+	if (dev == 0) {
+		/* accesses to config registers with offsets >= 256
+		 * requires indirect access.
+		 */
+		if (off < PCI_CONFIG_SPACE_SIZE) {
+			addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
+			addr |= (func << 8);
+			addr |= (off & 0xfc);
+			mmio = ioremap_nocache(addr, len);
+			if (!mmio)
+				goto out;
+		}
+	} else {
+		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
+		if (unlikely(!addr))
+			goto out;
+		err = -ENOMEM;
+		mmio = ioremap_nocache(addr, len);
+		if (!mmio)
+			goto out;
+
+		if (mips_busprobe32(val, mmio)) {
+			val = 0xffffffff;
+			goto unmap;
+		}
+	}
+
+	switch (len) {
+	case 1:
+		val = readl(mmio);
+		val &= ~(0xFF << (8 * (off & 3)));
+		val |= *((const u8 *)buf) << (8 * (off & 3));
+		break;
+	case 2:
+		val = readl(mmio);
+		val &= ~(0xFFFF << (8 * (off & 3)));
+		val |= *((const u16 *)buf) << (8 * (off & 3));
+		break;
+	case 4:
+		val = *((const u32 *)buf);
+		break;
+	}
+	if (dev == 0 && !addr) {
+		/* accesses to config registers with offsets >= 256
+		 * requires indirect access.
+		 */
+		addr = (func << 12);
+		addr |= (off & 0x0FFF);
+		bcma_pcie_write_config(pc, addr, val);
+	} else {
+		writel(val, mmio);
+
+		if (chipid == 0x4716 || chipid == 0x4748)
+			readl(mmio);
+	}
+
+	err = 0;
+unmap:
+	if (mmio)
+		iounmap(mmio);
+out:
+	return err;
+}
+
+static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus,
+					      unsigned int devfn,
+					      int reg, int size, u32 *val)
+{
+	unsigned long flags;
+	int err;
+	struct bcma_drv_pci *pc;
+	struct bcma_drv_pci_host *pc_host;
+
+	pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
+	pc = pc_host->pdev;
+
+	spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
+	err = bcma_extpci_read_config(pc, PCI_SLOT(devfn),
+				     PCI_FUNC(devfn), reg, val, size);
+	spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
+
+	return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
+}
+
+static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus,
+					       unsigned int devfn,
+					       int reg, int size, u32 val)
+{
+	unsigned long flags;
+	int err;
+	struct bcma_drv_pci *pc;
+	struct bcma_drv_pci_host *pc_host;
+
+	pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
+	pc = pc_host->pdev;
+
+	spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
+	err = bcma_extpci_write_config(pc, PCI_SLOT(devfn),
+				      PCI_FUNC(devfn), reg, &val, size);
+	spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
+
+	return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
+}
+
+/* return cap_offset if requested capability exists in the PCI config space */
+static u8 __devinit bcma_find_pci_capability(struct bcma_drv_pci *pc,
+					     unsigned int dev,
+					     unsigned int func, u8 req_cap_id,
+					     unsigned char *buf, u32 *buflen)
+{
+	u8 cap_id;
+	u8 cap_ptr = 0;
+	u32 bufsize;
+	u8 byte_val;
+
+	/* check for Header type 0 */
+	bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
+				sizeof(u8));
+	if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
+		return cap_ptr;
+
+	/* check if the capability pointer field exists */
+	bcma_extpci_read_config(pc, dev, func, PCI_STATUS, &byte_val,
+				sizeof(u8));
+	if (!(byte_val & PCI_STATUS_CAP_LIST))
+		return cap_ptr;
+
+	/* check if the capability pointer is 0x00 */
+	bcma_extpci_read_config(pc, dev, func, PCI_CAPABILITY_LIST, &cap_ptr,
+				sizeof(u8));
+	if (cap_ptr == 0x00)
+		return cap_ptr;
+
+	/* loop thr'u the capability list and see if the requested capabilty
+	 * exists */
+	bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, sizeof(u8));
+	while (cap_id != req_cap_id) {
+		bcma_extpci_read_config(pc, dev, func, cap_ptr + 1, &cap_ptr,
+					sizeof(u8));
+		if (cap_ptr == 0x00)
+			return cap_ptr;
+		bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id,
+					sizeof(u8));
+	}
+
+	/* found the caller requested capability */
+	if ((buf != NULL) && (buflen != NULL)) {
+		u8 cap_data;
+
+		bufsize = *buflen;
+		if (!bufsize)
+			return cap_ptr;
+
+		*buflen = 0;
+
+		/* copy the cpability data excluding cap ID and next ptr */
+		cap_data = cap_ptr + 2;
+		if ((bufsize + cap_data)  > PCI_CONFIG_SPACE_SIZE)
+			bufsize = PCI_CONFIG_SPACE_SIZE - cap_data;
+		*buflen = bufsize;
+		while (bufsize--) {
+			bcma_extpci_read_config(pc, dev, func, cap_data, buf,
+						sizeof(u8));
+			cap_data++;
+			buf++;
+		}
+	}
+
+	return cap_ptr;
+}
+
+/* If the root port is capable of returning Config Request
+ * Retry Status (CRS) Completion Status to software then
+ * enable the feature.
+ */
+static void __devinit bcma_core_pci_enable_crs(struct bcma_drv_pci *pc)
+{
+	u8 cap_ptr, root_ctrl, root_cap, dev;
+	u16 val16;
+	int i;
+
+	cap_ptr = bcma_find_pci_capability(pc, 0, 0, PCI_CAP_ID_EXP, NULL,
+					   NULL);
+	root_cap = cap_ptr + PCI_EXP_RTCAP;
+	bcma_extpci_read_config(pc, 0, 0, root_cap, &val16, sizeof(u16));
+	if (val16 & BCMA_CORE_PCI_RC_CRS_VISIBILITY) {
+		/* Enable CRS software visibility */
+		root_ctrl = cap_ptr + PCI_EXP_RTCTL;
+		val16 = PCI_EXP_RTCTL_CRSSVE;
+		bcma_extpci_read_config(pc, 0, 0, root_ctrl, &val16,
+					sizeof(u16));
+
+		/* Initiate a configuration request to read the vendor id
+		 * field of the device function's config space header after
+		 * 100 ms wait time from the end of Reset. If the device is
+		 * not done with its internal initialization, it must at
+		 * least return a completion TLP, with a completion status
+		 * of "Configuration Request Retry Status (CRS)". The root
+		 * complex must complete the request to the host by returning
+		 * a read-data value of 0001h for the Vendor ID field and
+		 * all 1s for any additional bytes included in the request.
+		 * Poll using the config reads for max wait time of 1 sec or
+		 * until we receive the successful completion status. Repeat
+		 * the procedure for all the devices.
+		 */
+		for (dev = 1; dev < BCMA_PCI_SLOT_MAX; dev++) {
+			for (i = 0; i < 100000; i++) {
+				bcma_extpci_read_config(pc, dev, 0,
+							PCI_VENDOR_ID, &val16,
+							sizeof(val16));
+				if (val16 != 0x1)
+					break;
+				udelay(10);
+			}
+			if (val16 == 0x1)
+				pr_err("PCI: Broken device in slot %d\n", dev);
+		}
+	}
+}
 
 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
 {
-	pr_err("No support for PCI core in hostmode yet\n");
+	struct bcma_bus *bus = pc->core->bus;
+	struct bcma_drv_pci_host *pc_host;
+	u32 tmp;
+	u32 pci_membase_1G;
+	unsigned long io_map_base;
+
+	pr_info("PCIEcore in host mode found\n");
+
+	pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
+	if (!pc_host)  {
+		pr_err("can not allocate memory");
+		return;
+	}
+
+	pc->host_controller = pc_host;
+	pc_host->pci_controller.io_resource = &pc_host->io_resource;
+	pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
+	pc_host->pci_controller.pci_ops = &pc_host->pci_ops;
+	pc_host->pdev = pc;
+
+	pci_membase_1G = BCMA_SOC_PCI_DMA;
+	pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG;
+
+	pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config;
+	pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config;
+
+	pc_host->mem_resource.name = "BCMA PCIcore external memory",
+	pc_host->mem_resource.start = BCMA_SOC_PCI_DMA;
+	pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1;
+	pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
+
+	pc_host->io_resource.name = "BCMA PCIcore external I/O",
+	pc_host->io_resource.start = 0x100;
+	pc_host->io_resource.end = 0x7FF;
+	pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
+
+	/* Reset RC */
+	udelay(3000);
+	pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
+	udelay(1000);
+	pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
+			BCMA_CORE_PCI_CTL_RST_OE);
+
+	/* 64 MB I/O access window. On 4716, use
+	 * sbtopcie0 to access the device registers. We
+	 * can't use address match 2 (1 GB window) region
+	 * as mips can't generate 64-bit address on the
+	 * backplane.
+	 */
+	if (bus->chipinfo.id == 0x4716 || bus->chipinfo.id == 0x4748) {
+		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) {
+		tmp = BCMA_CORE_PCI_SBTOPCI_MEM;
+		tmp |= BCMA_CORE_PCI_SBTOPCI_PREF;
+		tmp |= BCMA_CORE_PCI_SBTOPCI_BURST;
+		if (pc->core->core_unit == 0) {
+			pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
+			pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
+						    BCMA_SOC_PCI_MEM_SZ - 1;
+			pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
+			pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
+					tmp | BCMA_SOC_PCI_MEM);
+		} else if (pc->core->core_unit == 1) {
+			pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
+			pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
+						    BCMA_SOC_PCI_MEM_SZ - 1;
+			pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
+			pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
+			pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
+					tmp | BCMA_SOC_PCI1_MEM);
+		}
+	} else
+		pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
+				BCMA_CORE_PCI_SBTOPCI_IO);
+
+	/* 64 MB configuration access window */
+	pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
+
+	/* 1 GB memory access window */
+	pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI2,
+			BCMA_CORE_PCI_SBTOPCI_MEM | pci_membase_1G);
+
+
+	/* As per PCI Express Base Spec 1.1 we need to wait for
+	 * at least 100 ms from the end of a reset (cold/warm/hot)
+	 * before issuing configuration requests to PCI Express
+	 * devices.
+	 */
+	udelay(100000);
+
+	bcma_core_pci_enable_crs(pc);
+
+	/* Enable PCI bridge BAR0 memory & master access */
+	tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+	bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
+
+	/* Enable PCI interrupts */
+	pcicore_write32(pc, BCMA_CORE_PCI_IMASK, BCMA_CORE_PCI_IMASK_INTA);
+
+	/* Ok, ready to run, register it to the system.
+	 * The following needs change, if we want to port hostmode
+	 * to non-MIPS platform. */
+	io_map_base = (unsigned long)ioremap_nocache(BCMA_SOC_PCI_MEM,
+						     0x04000000);
+	pc_host->pci_controller.io_map_base = io_map_base;
+	set_io_port_base(pc_host->pci_controller.io_map_base);
+	/* Give some time to the PCI controller to configure itself with the new
+	 * values. Not waiting at this point causes crashes of the machine. */
+	mdelay(10);
+	register_pci_controller(&pc_host->pci_controller);
+	return;
+}
+
+/* Early PCI fixup for a device on the PCI-core bridge. */
+static void bcma_core_pci_fixup_pcibridge(struct pci_dev *dev)
+{
+	if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
+		/* This is not a device on the PCI-core bridge. */
+		return;
+	}
+	if (PCI_SLOT(dev->devfn) != 0)
+		return;
+
+	pr_info("PCI: Fixing up bridge %s\n", pci_name(dev));
+
+	/* Enable PCI bridge bus mastering and memory space */
+	pci_set_master(dev);
+	if (pcibios_enable_device(dev, ~0) < 0) {
+		pr_err("PCI: BCMA bridge enable failed\n");
+		return;
+	}
+
+	/* Enable PCI bridge BAR1 prefetch and burst */
+	pci_write_config_dword(dev, BCMA_PCI_BAR1_CONTROL, 3);
+}
+DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_pcibridge);
+
+/* Early PCI fixup for all PCI-cores to set the correct memory address. */
+static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
+{
+	struct resource *res;
+	int pos;
+
+	if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
+		/* This is not a device on the PCI-core bridge. */
+		return;
+	}
+	if (PCI_SLOT(dev->devfn) == 0)
+		return;
+
+	pr_info("PCI: Fixing up addresses %s\n", pci_name(dev));
+
+	for (pos = 0; pos < 6; pos++) {
+		res = &dev->resource[pos];
+		if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
+			pci_assign_resource(dev, pos);
+	}
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
+
+/* This function is called when doing a pci_enable_device().
+ * We must first check if the device is a device on the PCI-core bridge. */
+int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
+{
+	struct bcma_drv_pci_host *pc_host;
+
+	if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
+		/* This is not a device on the PCI-core bridge. */
+		return -ENODEV;
+	}
+	pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
+			       pci_ops);
+
+	pr_info("PCI: Fixing up device %s\n", pci_name(dev));
+
+	/* Fix up interrupt lines */
+	dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
+
+	return 0;
+}
+EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
+
+/* PCI device IRQ mapping. */
+int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
+{
+	struct bcma_drv_pci_host *pc_host;
+
+	if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
+		/* This is not a device on the PCI-core bridge. */
+		return -ENODEV;
+	}
+
+	pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
+			       pci_ops);
+	return bcma_core_mips_irq(pc_host->pdev->core) + 2;
 }
+EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
index 679d4ca..46c71e2 100644
--- a/include/linux/bcma/bcma_driver_pci.h
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -160,9 +160,44 @@ struct pci_dev;
 /* PCIcore specific boardflags */
 #define BCMA_CORE_PCI_BFL_NOPCI			0x00000400 /* Board leaves PCI floating */
 
+/* PCIE Config space accessing MACROS */
+#define BCMA_CORE_PCI_CFG_BUS_SHIFT		24	/* Bus shift */
+#define BCMA_CORE_PCI_CFG_SLOT_SHIFT		19	/* Slot/Device shift */
+#define BCMA_CORE_PCI_CFG_FUN_SHIFT		16	/* Function shift */
+#define BCMA_CORE_PCI_CFG_OFF_SHIFT		0	/* Register shift */
+
+#define BCMA_CORE_PCI_CFG_BUS_MASK		0xff	/* Bus mask */
+#define BCMA_CORE_PCI_CFG_SLOT_MASK		0x1f	/* Slot/Device mask */
+#define BCMA_CORE_PCI_CFG_FUN_MASK		7	/* Function mask */
+#define BCMA_CORE_PCI_CFG_OFF_MASK		0xfff	/* Register mask */
+
+/* PCIE Root Capability Register bits (Host mode only) */
+#define BCMA_CORE_PCI_RC_CRS_VISIBILITY		0x0001
+
+struct bcma_drv_pci;
+
+#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
+struct bcma_drv_pci_host {
+	struct bcma_drv_pci *pdev;
+
+	u32 host_cfg_addr;
+	spinlock_t cfgspace_lock;
+
+	struct pci_controller pci_controller;
+	struct pci_ops pci_ops;
+	struct resource mem_resource;
+	struct resource io_resource;
+};
+#endif
+
 struct bcma_drv_pci {
 	struct bcma_device *core;
 	u8 setup_done:1;
+	u8 hostmode:1;
+
+#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
+	struct bcma_drv_pci_host *host_controller;
+#endif
 };
 
 /* Register access */
@@ -173,4 +208,7 @@ 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 int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
+extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
+
 #endif /* LINUX_BCMA_DRIVER_PCI_H_ */
diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
index 9faae2a..5a71d57 100644
--- a/include/linux/bcma/bcma_regs.h
+++ b/include/linux/bcma/bcma_regs.h
@@ -56,4 +56,31 @@
 #define  BCMA_PCI_GPIO_XTAL		0x40	/* PCI config space GPIO 14 for Xtal powerup */
 #define  BCMA_PCI_GPIO_PLL		0x80	/* PCI config space GPIO 15 for PLL powerdown */
 
+/* SiliconBackplane Address Map.
+ * All regions may not exist on all chips.
+ */
+#define BCMA_SOC_SDRAM_BASE		0x00000000U	/* Physical SDRAM */
+#define BCMA_SOC_PCI_MEM		0x08000000U	/* Host Mode sb2pcitranslation0 (64 MB) */
+#define BCMA_SOC_PCI_MEM_SZ		(64 * 1024 * 1024)
+#define BCMA_SOC_PCI_CFG		0x0c000000U	/* Host Mode sb2pcitranslation1 (64 MB) */
+#define BCMA_SOC_SDRAM_SWAPPED		0x10000000U	/* Byteswapped Physical SDRAM */
+#define BCMA_SOC_SDRAM_R2		0x80000000U	/* Region 2 for sdram (512 MB) */
+
+
+#define BCMA_SOC_PCI_DMA		0x40000000U	/* Client Mode sb2pcitranslation2 (1 GB) */
+#define BCMA_SOC_PCI_DMA2		0x80000000U	/* Client Mode sb2pcitranslation2 (1 GB) */
+#define BCMA_SOC_PCI_DMA_SZ		0x40000000U	/* Client Mode sb2pcitranslation2 size in bytes */
+#define BCMA_SOC_PCIE_DMA_L32		0x00000000U	/* PCIE Client Mode sb2pcitranslation2
+							 * (2 ZettaBytes), low 32 bits
+							 */
+#define BCMA_SOC_PCIE_DMA_H32		0x80000000U	/* PCIE Client Mode sb2pcitranslation2
+							 * (2 ZettaBytes), high 32 bits
+							 */
+
+#define BCMA_SOC_PCI1_MEM		0x40000000U	/* Host Mode sb2pcitranslation0 (64 MB) */
+#define BCMA_SOC_PCI1_CFG		0x44000000U	/* Host Mode sb2pcitranslation1 (64 MB) */
+#define BCMA_SOC_PCIE1_DMA_H32		0xc0000000U	/* PCIE Client Mode sb2pcitranslation2
+							 * (2 ZettaBytes), high 32 bits
+							 */
+
 #endif /* LINUX_BCMA_REGS_H_ */
-- 
1.7.5.4



From hauke at hauke-m.de  Tue Jan 31 18:13:52 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Wed,  1 Feb 2012 00:13:52 +0100
Subject: [PATCH 0/4] ssb/bcma: misc fixes
Message-ID: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>

This contains a fix which makes cardbus work with the PCI host 
controller found on some ssb based SoCs. It also add a log entry for 
informations about the bcma/ssb chip used. The last patch adds support 
for the BCM5354 SoC.

Hauke Mehrtens (4):
  ssb: fix cardbus slot in hostmode
  bcma: log the id, rev and pkg of the chip found
  ssb: log the id, rev and pkg of the chip found
  ssb: add support for bcm5354

 drivers/bcma/scan.c                 |   10 +++++--
 drivers/ssb/driver_chipcommon_pmu.c |   48 +++++++++++++++++++++++++++++++---
 drivers/ssb/driver_mipscore.c       |    3 ++
 drivers/ssb/driver_pcicore.c        |    2 +-
 drivers/ssb/main.c                  |    3 ++
 drivers/ssb/scan.c                  |    3 ++
 drivers/ssb/ssb_private.h           |    4 +++
 7 files changed, 64 insertions(+), 9 deletions(-)

-- 
1.7.5.4



From hauke at hauke-m.de  Tue Jan 31 18:13:53 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Wed,  1 Feb 2012 00:13:53 +0100
Subject: [PATCH 1/4] ssb: fix cardbus slot in hostmode
In-Reply-To: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
References: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1328051636-15449-2-git-send-email-hauke@hauke-m.de>

ssb supports one extra device on the cardbus. This results in two
devices in total, one beeing the host controller itself and the other
the external device connected to the hostcontroller over cardbus.

This makes the cardbus slot work on the Linksys WRT150N.

Reported-by: Aaron Z <aaronz at pls-net.org>
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/ssb/driver_pcicore.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ssb/driver_pcicore.c b/drivers/ssb/driver_pcicore.c
index 520e828..49d2091 100644
--- a/drivers/ssb/driver_pcicore.c
+++ b/drivers/ssb/driver_pcicore.c
@@ -75,7 +75,7 @@ static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
 	u32 tmp;
 
 	/* We do only have one cardbus device behind the bridge. */
-	if (pc->cardbusmode && (dev >= 1))
+	if (pc->cardbusmode && (dev > 1))
 		goto out;
 
 	if (bus == 0) {
-- 
1.7.5.4



From hauke at hauke-m.de  Tue Jan 31 18:13:55 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Wed,  1 Feb 2012 00:13:55 +0100
Subject: [PATCH 3/4] ssb: log the id, rev and pkg of the chip found
In-Reply-To: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
References: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1328051636-15449-4-git-send-email-hauke@hauke-m.de>

This makes us see what type of hardware someone uses by the dmesg
output.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/ssb/scan.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/ssb/scan.c b/drivers/ssb/scan.c
index 3e84487..266c7c5 100644
--- a/drivers/ssb/scan.c
+++ b/drivers/ssb/scan.c
@@ -318,6 +318,9 @@ int ssb_bus_scan(struct ssb_bus *bus,
 			bus->chip_package = 0;
 		}
 	}
+	ssb_printk(KERN_INFO PFX "Found chip with id 0x%04X, rev 0x%02X and "
+		   "package 0x%02X\n", bus->chip_id, bus->chip_rev,
+		   bus->chip_package);
 	if (!bus->nr_devices)
 		bus->nr_devices = chipid_to_nrcores(bus->chip_id);
 	if (bus->nr_devices > ARRAY_SIZE(bus->devices)) {
-- 
1.7.5.4



From hauke at hauke-m.de  Tue Jan 31 18:13:54 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Wed,  1 Feb 2012 00:13:54 +0100
Subject: [PATCH 2/4] bcma: log the id, rev and pkg of the chip found
In-Reply-To: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
References: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1328051636-15449-3-git-send-email-hauke@hauke-m.de>

This makes us see what type of hardware someone uses by the dmesg
output.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/bcma/scan.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index cad9948..a6f17fe 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -353,6 +353,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
 void bcma_init_bus(struct bcma_bus *bus)
 {
 	s32 tmp;
+	struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
 
 	if (bus->init_done)
 		return;
@@ -363,9 +364,12 @@ void bcma_init_bus(struct bcma_bus *bus)
 	bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
 
 	tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
-	bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
-	bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
-	bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
+	chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
+	chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
+	chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
+	pr_info("Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
+		chipinfo->id, chipinfo->rev, chipinfo->pkg);
+
 	bus->init_done = true;
 }
 
-- 
1.7.5.4



From hauke at hauke-m.de  Tue Jan 31 18:13:56 2012
From: hauke at hauke-m.de (Hauke Mehrtens)
Date: Wed,  1 Feb 2012 00:13:56 +0100
Subject: [PATCH 4/4] ssb: add support for bcm5354
In-Reply-To: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
References: <1328051636-15449-1-git-send-email-hauke@hauke-m.de>
Message-ID: <1328051636-15449-5-git-send-email-hauke@hauke-m.de>

This patch adds support the the BCM5354 SoC.
It has a PMU and a constant not configurable clock.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 drivers/ssb/driver_chipcommon_pmu.c |   48 +++++++++++++++++++++++++++++++---
 drivers/ssb/driver_mipscore.c       |    3 ++
 drivers/ssb/main.c                  |    3 ++
 drivers/ssb/ssb_private.h           |    4 +++
 4 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c
index e5a2e0e..b58fef7 100644
--- a/drivers/ssb/driver_chipcommon_pmu.c
+++ b/drivers/ssb/driver_chipcommon_pmu.c
@@ -13,6 +13,9 @@
 #include <linux/ssb/ssb_driver_chipcommon.h>
 #include <linux/delay.h>
 #include <linux/export.h>
+#ifdef CONFIG_BCM47XX
+#include <asm/mach-bcm47xx/nvram.h>
+#endif
 
 #include "ssb_private.h"
 
@@ -92,10 +95,6 @@ static void ssb_pmu0_pllinit_r0(struct ssb_chipcommon *cc,
 	u32 pmuctl, tmp, pllctl;
 	unsigned int i;
 
-	if ((bus->chip_id == 0x5354) && !crystalfreq) {
-		/* The 5354 crystal freq is 25MHz */
-		crystalfreq = 25000;
-	}
 	if (crystalfreq)
 		e = pmu0_plltab_find_entry(crystalfreq);
 	if (!e)
@@ -321,7 +320,11 @@ static void ssb_pmu_pll_init(struct ssb_chipcommon *cc)
 	u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
 
 	if (bus->bustype == SSB_BUSTYPE_SSB) {
-		/* TODO: The user may override the crystal frequency. */
+#ifdef CONFIG_BCM47XX
+		char buf[20];
+		if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
+			crystalfreq = simple_strtoul(buf, NULL, 0);
+#endif
 	}
 
 	switch (bus->chip_id) {
@@ -330,7 +333,11 @@ static void ssb_pmu_pll_init(struct ssb_chipcommon *cc)
 		ssb_pmu1_pllinit_r0(cc, crystalfreq);
 		break;
 	case 0x4328:
+		ssb_pmu0_pllinit_r0(cc, crystalfreq);
+		break;
 	case 0x5354:
+		if (crystalfreq == 0)
+			crystalfreq = 25000;
 		ssb_pmu0_pllinit_r0(cc, crystalfreq);
 		break;
 	case 0x4322:
@@ -607,3 +614,34 @@ void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on)
 
 EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
 EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
+
+u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc)
+{
+	struct ssb_bus *bus = cc->dev->bus;
+
+	switch (bus->chip_id) {
+	case 0x5354:
+		/* 5354 chip uses a non programmable PLL of frequency 240MHz */
+		return 240000000;
+	default:
+		ssb_printk(KERN_ERR PFX
+			   "ERROR: PMU cpu clock unknown for device %04X\n",
+			   bus->chip_id);
+		return 0;
+	}
+}
+
+u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc)
+{
+	struct ssb_bus *bus = cc->dev->bus;
+
+	switch (bus->chip_id) {
+	case 0x5354:
+		return 120000000;
+	default:
+		ssb_printk(KERN_ERR PFX
+			   "ERROR: PMU controlclock unknown for device %04X\n",
+			   bus->chip_id);
+		return 0;
+	}
+}
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index ced5015..d784ec8 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -208,6 +208,9 @@ u32 ssb_cpu_clock(struct ssb_mipscore *mcore)
 	struct ssb_bus *bus = mcore->dev->bus;
 	u32 pll_type, n, m, rate = 0;
 
+	if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
+	    	return ssb_pmu_get_cpu_clock(&bus->chipco);
+
 	if (bus->extif.dev) {
 		ssb_extif_get_clockcontrol(&bus->extif, &pll_type, &n, &m);
 	} else if (bus->chipco.dev) {
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index bb6317f..d109cf0 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -1094,6 +1094,9 @@ u32 ssb_clockspeed(struct ssb_bus *bus)
 	u32 plltype;
 	u32 clkctl_n, clkctl_m;
 
+	if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
+	    	return ssb_pmu_get_controlclock(&bus->chipco);
+
 	if (ssb_extif_available(&bus->extif))
 		ssb_extif_get_clockcontrol(&bus->extif, &plltype,
 					   &clkctl_n, &clkctl_m);
diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
index 7765301..a305550 100644
--- a/drivers/ssb/ssb_private.h
+++ b/drivers/ssb/ssb_private.h
@@ -207,4 +207,8 @@ static inline void b43_pci_ssb_bridge_exit(void)
 }
 #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
 
+/* driver_chipcommon_pmu.c */
+extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
+extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
+
 #endif /* LINUX_SSB_PRIVATE_H_ */
-- 
1.7.5.4



