[openwrt/openwrt] bcm63xx: backport upstream SSB SPROM extraction

LEDE Commits lede-commits at lists.infradead.org
Tue Feb 2 14:41:40 EST 2021


noltari pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/e23a90674e1b52a6eaa3d66a621f7ff612641243

commit e23a90674e1b52a6eaa3d66a621f7ff612641243
Author: Álvaro Fernández Rojas <noltari at gmail.com>
AuthorDate: Tue Feb 2 11:02:39 2021 +0100

    bcm63xx: backport upstream SSB SPROM extraction
    
    New upstream changes extract more SPROM values and fix the antenna gain.
    These changes can be found in linux drivers/ssb/pci.c.
    
    Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 ...0-MIPS-BCM63XX-add-support-for-raw-sproms.patch | 122 ++++++++++++++++-----
 ...X-add-raw-fallback-sproms-for-most-common.patch |   2 +-
 ...X-also-register-a-fallback-sprom-for-bcma.patch |   6 +-
 ...PS-BCM63XX-add-BCMA-based-sprom-templates.patch |   2 +-
 ...X-allow-board-files-to-provide-sprom-fixu.patch |   4 +-
 ...X-allow-setting-a-pci-bus-device-for-fall.patch |   4 +-
 6 files changed, 102 insertions(+), 38 deletions(-)

diff --git a/target/linux/bcm63xx/patches-5.4/360-MIPS-BCM63XX-add-support-for-raw-sproms.patch b/target/linux/bcm63xx/patches-5.4/360-MIPS-BCM63XX-add-support-for-raw-sproms.patch
index 42502eb062..2063cda485 100644
--- a/target/linux/bcm63xx/patches-5.4/360-MIPS-BCM63XX-add-support-for-raw-sproms.patch
+++ b/target/linux/bcm63xx/patches-5.4/360-MIPS-BCM63XX-add-support-for-raw-sproms.patch
@@ -12,7 +12,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 
 --- a/arch/mips/bcm63xx/sprom.c
 +++ b/arch/mips/bcm63xx/sprom.c
-@@ -55,13 +55,492 @@ int bcm63xx_get_fallback_sprom(struct ss
+@@ -55,13 +55,556 @@ int bcm63xx_get_fallback_sprom(struct ss
  		return -EINVAL;
  	}
  }
@@ -43,13 +43,13 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +	} while (0)
 +
 +
-+static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in,
-+			       u16 mask, u16 shift)
++static s8 sprom_extract_antgain(u8 sprom_revision, const u16 *in, u16 offset,
++				u16 mask, u16 shift)
 +{
 +	u16 v;
 +	u8 gain;
 +
-+	v = in[SPOFF(SSB_SPROM1_AGAIN)];
++	v = in[SPOFF(offset)];
 +	gain = (v & mask) >> shift;
 +	if (gain == 0xFF)
 +		gain = 2; /* If unset use 2dBm */
@@ -129,12 +129,14 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +	SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
 +
 +	/* Extract the antenna gain values. */
-+	out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
-+						    SSB_SPROM1_AGAIN_BG,
-+						    SSB_SPROM1_AGAIN_BG_SHIFT);
-+	out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
-+						    SSB_SPROM1_AGAIN_A,
-+						    SSB_SPROM1_AGAIN_A_SHIFT);
++	out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM1_AGAIN,
++						     SSB_SPROM1_AGAIN_BG,
++						     SSB_SPROM1_AGAIN_BG_SHIFT);
++	out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM1_AGAIN,
++						     SSB_SPROM1_AGAIN_A,
++						     SSB_SPROM1_AGAIN_A_SHIFT);
 +	if (out->revision >= 2)
 +		sprom_extract_r23(out, in);
 +}
@@ -181,7 +183,15 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +
 +static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
 +{
++	static const u16 pwr_info_offset[] = {
++		SSB_SPROM4_PWR_INFO_CORE0, SSB_SPROM4_PWR_INFO_CORE1,
++		SSB_SPROM4_PWR_INFO_CORE2, SSB_SPROM4_PWR_INFO_CORE3
++	};
 +	u16 il0mac_offset;
++	int i;
++
++	BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
++		     ARRAY_SIZE(out->core_pwr_info));
 +
 +	if (out->revision == 4)
 +		il0mac_offset = SSB_SPROM4_IL0MAC;
@@ -235,14 +245,59 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +	}
 +
 +	/* Extract the antenna gain values. */
-+	SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
-+	     SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
-+	SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
-+	     SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
-+	SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
-+	     SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
-+	SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
-+	     SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
++	out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM4_AGAIN01,
++						     SSB_SPROM4_AGAIN0,
++						     SSB_SPROM4_AGAIN0_SHIFT);
++	out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM4_AGAIN01,
++						     SSB_SPROM4_AGAIN1,
++						     SSB_SPROM4_AGAIN1_SHIFT);
++	out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM4_AGAIN23,
++						     SSB_SPROM4_AGAIN2,
++						     SSB_SPROM4_AGAIN2_SHIFT);
++	out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM4_AGAIN23,
++						     SSB_SPROM4_AGAIN3,
++						     SSB_SPROM4_AGAIN3_SHIFT);
++
++	/* Extract cores power info info */
++	for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
++		u16 o = pwr_info_offset[i];
++
++		SPEX(core_pwr_info[i].itssi_2g, o + SSB_SPROM4_2G_MAXP_ITSSI,
++			SSB_SPROM4_2G_ITSSI, SSB_SPROM4_2G_ITSSI_SHIFT);
++		SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SPROM4_2G_MAXP_ITSSI,
++			SSB_SPROM4_2G_MAXP, 0);
++
++		SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SPROM4_2G_PA_0, ~0, 0);
++		SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SPROM4_2G_PA_1, ~0, 0);
++		SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SPROM4_2G_PA_2, ~0, 0);
++		SPEX(core_pwr_info[i].pa_2g[3], o + SSB_SPROM4_2G_PA_3, ~0, 0);
++
++		SPEX(core_pwr_info[i].itssi_5g, o + SSB_SPROM4_5G_MAXP_ITSSI,
++			SSB_SPROM4_5G_ITSSI, SSB_SPROM4_5G_ITSSI_SHIFT);
++		SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SPROM4_5G_MAXP_ITSSI,
++			SSB_SPROM4_5G_MAXP, 0);
++		SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM4_5GHL_MAXP,
++			SSB_SPROM4_5GH_MAXP, 0);
++		SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM4_5GHL_MAXP,
++			SSB_SPROM4_5GL_MAXP, SSB_SPROM4_5GL_MAXP_SHIFT);
++
++		SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SPROM4_5GL_PA_0, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SPROM4_5GL_PA_1, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SPROM4_5GL_PA_2, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gl[3], o + SSB_SPROM4_5GL_PA_3, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SPROM4_5G_PA_0, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SPROM4_5G_PA_1, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SPROM4_5G_PA_2, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5g[3], o + SSB_SPROM4_5G_PA_3, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SPROM4_5GH_PA_0, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SPROM4_5GH_PA_1, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SPROM4_5GH_PA_2, ~0, 0);
++		SPEX(core_pwr_info[i].pa_5gh[3], o + SSB_SPROM4_5GH_PA_3, ~0, 0);
++	}
 +
 +	sprom_extract_r458(out, in);
 +
@@ -253,7 +308,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +{
 +	int i;
 +	u16 o;
-+	u16 pwr_info_offset[] = {
++	static const u16 pwr_info_offset[] = {
 +		SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
 +		SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
 +	};
@@ -329,14 +384,22 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +	SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
 +
 +	/* Extract the antenna gain values. */
-+	SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
-+	     SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
-+	SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
-+	     SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
-+	SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
-+	     SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
-+	SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
-+	     SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
++	out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM8_AGAIN01,
++						     SSB_SPROM8_AGAIN0,
++						     SSB_SPROM8_AGAIN0_SHIFT);
++	out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM8_AGAIN01,
++						     SSB_SPROM8_AGAIN1,
++						     SSB_SPROM8_AGAIN1_SHIFT);
++	out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM8_AGAIN23,
++						     SSB_SPROM8_AGAIN2,
++						     SSB_SPROM8_AGAIN2_SHIFT);
++	out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in,
++						     SSB_SPROM8_AGAIN23,
++						     SSB_SPROM8_AGAIN3,
++						     SSB_SPROM8_AGAIN3_SHIFT);
 +
 +	/* Extract cores power info info */
 +	for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
@@ -460,6 +523,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +	memset(out, 0, sizeof(*out));
 +
 +	out->revision = in[size - 1] & 0x00FF;
++
 +	memset(out->et0mac, 0xFF, 6);		/* preset et0 and et1 mac */
 +	memset(out->et1mac, 0xFF, 6);
 +
@@ -478,7 +542,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 +		break;
 +	default:
 +		pr_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
-+			 out->revision);
++			out->revision);
 +		out->revision = 1;
 +		sprom_extract_r123(out, in);
 +	}
@@ -505,7 +569,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  	switch (data->type) {
  	case SPROM_DEFAULT:
  		memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
-@@ -71,6 +550,9 @@ int __init bcm63xx_register_fallback_spr
+@@ -71,6 +614,9 @@ int __init bcm63xx_register_fallback_spr
  		return -EINVAL;
  	}
  
diff --git a/target/linux/bcm63xx/patches-5.4/361-MIPS-BCM63XX-add-raw-fallback-sproms-for-most-common.patch b/target/linux/bcm63xx/patches-5.4/361-MIPS-BCM63XX-add-raw-fallback-sproms-for-most-common.patch
index 65c00b5197..0017cc2f6a 100644
--- a/target/linux/bcm63xx/patches-5.4/361-MIPS-BCM63XX-add-raw-fallback-sproms-for-most-common.patch
+++ b/target/linux/bcm63xx/patches-5.4/361-MIPS-BCM63XX-add-raw-fallback-sproms-for-most-common.patch
@@ -137,7 +137,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  static struct ssb_sprom bcm63xx_sprom;
  
  int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
-@@ -542,6 +658,26 @@ int __init bcm63xx_register_fallback_spr
+@@ -606,6 +722,26 @@ int __init bcm63xx_register_fallback_spr
  	u16 size = 0;
  
  	switch (data->type) {
diff --git a/target/linux/bcm63xx/patches-5.4/362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch b/target/linux/bcm63xx/patches-5.4/362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch
index 24ae8c35c7..eaabbeb432 100644
--- a/target/linux/bcm63xx/patches-5.4/362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch
+++ b/target/linux/bcm63xx/patches-5.4/362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch
@@ -84,7 +84,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  
  /* FIXME: use lib_sprom after submission upstream */
  
-@@ -654,10 +671,11 @@ int __init bcm63xx_register_fallback_spr
+@@ -718,10 +735,11 @@ int __init bcm63xx_register_fallback_spr
  {
  	int ret = 0;
  
@@ -97,7 +97,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  	case SPROM_BCM4306:
  		memcpy(&template_sprom, &bcm4306_sprom, sizeof(bcm4306_sprom));
  		size = ARRAY_SIZE(bcm4306_sprom);
-@@ -678,6 +696,7 @@ int __init bcm63xx_register_fallback_spr
+@@ -742,6 +760,7 @@ int __init bcm63xx_register_fallback_spr
  		memcpy(&template_sprom, &bcm43222_sprom, sizeof(bcm43222_sprom));
  		size = ARRAY_SIZE(bcm43222_sprom);
  		break;
@@ -105,7 +105,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  	case SPROM_DEFAULT:
  		memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
  		       sizeof(bcm63xx_sprom));
-@@ -692,8 +711,19 @@ int __init bcm63xx_register_fallback_spr
+@@ -756,8 +775,19 @@ int __init bcm63xx_register_fallback_spr
  	memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
  	memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
  	memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);
diff --git a/target/linux/bcm63xx/patches-5.4/363-MIPS-BCM63XX-add-BCMA-based-sprom-templates.patch b/target/linux/bcm63xx/patches-5.4/363-MIPS-BCM63XX-add-BCMA-based-sprom-templates.patch
index 5c0abb90e3..d3c40fff43 100644
--- a/target/linux/bcm63xx/patches-5.4/363-MIPS-BCM63XX-add-BCMA-based-sprom-templates.patch
+++ b/target/linux/bcm63xx/patches-5.4/363-MIPS-BCM63XX-add-BCMA-based-sprom-templates.patch
@@ -241,7 +241,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  static struct ssb_sprom bcm63xx_sprom;
  
  #if defined(CONFIG_SSB_PCIHOST)
-@@ -697,6 +917,42 @@ int __init bcm63xx_register_fallback_spr
+@@ -761,6 +981,42 @@ int __init bcm63xx_register_fallback_spr
  		size = ARRAY_SIZE(bcm43222_sprom);
  		break;
  #endif
diff --git a/target/linux/bcm63xx/patches-5.4/364-MIPS-BCM63XX-allow-board-files-to-provide-sprom-fixu.patch b/target/linux/bcm63xx/patches-5.4/364-MIPS-BCM63XX-allow-board-files-to-provide-sprom-fixu.patch
index 74c2846d5f..ad5ccbab0c 100644
--- a/target/linux/bcm63xx/patches-5.4/364-MIPS-BCM63XX-allow-board-files-to-provide-sprom-fixu.patch
+++ b/target/linux/bcm63xx/patches-5.4/364-MIPS-BCM63XX-allow-board-files-to-provide-sprom-fixu.patch
@@ -16,7 +16,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
 
 --- a/arch/mips/bcm63xx/sprom.c
 +++ b/arch/mips/bcm63xx/sprom.c
-@@ -883,6 +883,14 @@ static int sprom_extract(struct ssb_spro
+@@ -947,6 +947,14 @@ static int sprom_extract(struct ssb_spro
  	return 0;
  }
  
@@ -31,7 +31,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  static __initdata u16 template_sprom[220];
  #endif
  
-@@ -961,8 +969,12 @@ int __init bcm63xx_register_fallback_spr
+@@ -1025,8 +1033,12 @@ int __init bcm63xx_register_fallback_spr
  		return -EINVAL;
  	}
  
diff --git a/target/linux/bcm63xx/patches-5.4/365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch b/target/linux/bcm63xx/patches-5.4/365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch
index 40591e5f2e..4b994a22c6 100644
--- a/target/linux/bcm63xx/patches-5.4/365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch
+++ b/target/linux/bcm63xx/patches-5.4/365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch
@@ -57,7 +57,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  		return 0;
  	} else {
  		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
-@@ -962,8 +980,8 @@ int __init bcm63xx_register_fallback_spr
+@@ -1026,8 +1044,8 @@ int __init bcm63xx_register_fallback_spr
  		break;
  #endif
  	case SPROM_DEFAULT:
@@ -68,7 +68,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
  		break;
  	default:
  		return -EINVAL;
-@@ -973,12 +991,15 @@ int __init bcm63xx_register_fallback_spr
+@@ -1037,12 +1055,15 @@ int __init bcm63xx_register_fallback_spr
  		sprom_apply_fixups(template_sprom, data->board_fixups,
  				   data->num_board_fixups);
  



More information about the lede-commits mailing list