2022-09-21 00:27:44

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2] brcmfmac: Add support for BCM43596 PCIe Wi-Fi

Add support for BCM43596 dual-band AC chip, found in
SONY Xperia X Performance, XZ and XZs smartphones (and
*possibly* other devices from other manufacturers).
The chip doesn't require any special handling and seems to work
just fine OOTB.

PCIe IDs taken from: https://github.com/sonyxperiadev/kernel/commit/9e43fefbac8e43c3d7792e73ca52a052dd86d7e3.patch

Signed-off-by: Konrad Dybcio <[email protected]>
---
Changes since v1:
- rebased the patch against -next

drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++
drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 4 ++++
3 files changed, 10 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index 3026166a56c1..6234e7475a1a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -727,6 +727,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
case BRCM_CC_43666_CHIP_ID:
return 0x200000;
case BRCM_CC_4359_CHIP_ID:
+ case BRCM_CC_43596_CHIP_ID:
return (ci->pub.chiprev < 9) ? 0x180000 : 0x160000;
case BRCM_CC_4364_CHIP_ID:
case CY_CC_4373_CHIP_ID:
@@ -1430,6 +1431,7 @@ bool brcmf_chip_sr_capable(struct brcmf_chip *pub)
reg = chip->ops->read32(chip->ctx, addr);
return (reg & CC_SR_CTL0_ENABLE_MASK) != 0;
case BRCM_CC_4359_CHIP_ID:
+ case BRCM_CC_43596_CHIP_ID:
case CY_CC_43752_CHIP_ID:
case CY_CC_43012_CHIP_ID:
addr = CORE_CC_REG(pmu->base, retention_ctl);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index f98641bb1528..2e7fc66adf31 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -81,6 +81,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_43570_CHIP_ID, 0xFFFFFFFF, 43570),
BRCMF_FW_ENTRY(BRCM_CC_4358_CHIP_ID, 0xFFFFFFFF, 4358),
BRCMF_FW_ENTRY(BRCM_CC_4359_CHIP_ID, 0xFFFFFFFF, 4359),
+ BRCMF_FW_ENTRY(BRCM_CC_43596_CHIP_ID, 0xFFFFFFFF, 4359),
BRCMF_FW_ENTRY(BRCM_CC_4364_CHIP_ID, 0xFFFFFFFF, 4364),
BRCMF_FW_ENTRY(BRCM_CC_4365_CHIP_ID, 0x0000000F, 4365B),
BRCMF_FW_ENTRY(BRCM_CC_4365_CHIP_ID, 0xFFFFFFF0, 4365C),
@@ -2451,6 +2452,9 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = {
BRCMF_PCIE_DEVICE(BRCM_PCIE_43570_RAW_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_4358_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_4359_DEVICE_ID),
+ BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_DEVICE_ID),
+ BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_2G_DEVICE_ID),
+ BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_5G_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_2G_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_5G_DEVICE_ID),
diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
index 1003f123ec25..c9c8701039c5 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -44,6 +44,7 @@
#define BRCM_CC_43570_CHIP_ID 43570
#define BRCM_CC_4358_CHIP_ID 0x4358
#define BRCM_CC_4359_CHIP_ID 0x4359
+#define BRCM_CC_43596_CHIP_ID 43596
#define BRCM_CC_43602_CHIP_ID 43602
#define BRCM_CC_4364_CHIP_ID 0x4364
#define BRCM_CC_4365_CHIP_ID 0x4365
@@ -77,6 +78,9 @@
#define BRCM_PCIE_43570_RAW_DEVICE_ID 0xaa31
#define BRCM_PCIE_4358_DEVICE_ID 0x43e9
#define BRCM_PCIE_4359_DEVICE_ID 0x43ef
+#define BRCM_PCIE_43596_DEVICE_ID 0x4415
+#define BRCM_PCIE_43596_2G_DEVICE_ID 0x4416
+#define BRCM_PCIE_43596_5G_DEVICE_ID 0x4417
#define BRCM_PCIE_43602_DEVICE_ID 0x43ba
#define BRCM_PCIE_43602_2G_DEVICE_ID 0x43bb
#define BRCM_PCIE_43602_5G_DEVICE_ID 0x43bc
--
2.37.3


2022-12-06 11:26:41

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH v2] brcmfmac: Add support for BCM43596 PCIe Wi-Fi

On 12/6/2022 10:58 AM, Konrad Dybcio wrote:
>
>
> On 02/12/2022 20:28, Arend Van Spriel wrote:
>>
>>
>> On 12/2/2022 4:26 PM, Arend van Spriel wrote:
>>> On 12/2/2022 11:33 AM, Konrad Dybcio wrote:
>>>>
>>>>
>>>> On 1.12.2022 12:31, Arend van Spriel wrote:
>>>>> On 11/28/2022 3:40 PM, Konrad Dybcio wrote:
>>>>>>
>>>>>>
>>>>>> On 26.11.2022 22:45, Linus Walleij wrote:
>>>>>>> On Fri, Nov 25, 2022 at 1:25 PM Kalle Valo <[email protected]> wrote:
>>>>>>>> Konrad Dybcio <[email protected]> writes:
>>>>>>>>
>>>>>>>>> On 25.11.2022 12:53, Kalle Valo wrote:
>>>>>>>>>> Konrad Dybcio <[email protected]> writes:
>>>>>>>>>>
>>>>>>>>>>> On 21.11.2022 14:56, Linus Walleij wrote:
>>>>>>>>>>>> On Fri, Nov 18, 2022 at 5:47 PM Konrad Dybcio
>>>>>>>>>>>> <[email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> I can think of a couple of hacky ways to force use of 43596
>>>>>>>>>>>>> fw, but I
>>>>>>>>>>>>> don't think any would be really upstreamable..
>>>>>>>>>>>>
>>>>>>>>>>>> If it is only known to affect the Sony Xperias mentioned then
>>>>>>>>>>>> a thing such as:
>>>>>>>>>>>>
>>>>>>>>>>>> if (of_machine_is_compatible("sony,xyz") ||
>>>>>>>>>>>>       of_machine_is_compatible("sony,zzz")... ) {
>>>>>>>>>>>>      // Enforce FW version
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> would be completely acceptable in my book. It hammers the
>>>>>>>>>>>> problem from the top instead of trying to figure out itsy witsy
>>>>>>>>>>>> details about firmware revisions.
>>>>>>>>>>>>
>>>>>>>>>>>> Yours,
>>>>>>>>>>>> Linus Walleij
>>>>>>>>>>>
>>>>>>>>>>> Actually, I think I came up with a better approach by pulling
>>>>>>>>>>> a page
>>>>>>>>>>> out of Asahi folks' book - please take a look and tell me
>>>>>>>>>>> what you
>>>>>>>>>>> think about this:
>>>>>>>>>>>
>>>>>>>>>>> [1]
>>>>>>>>>>> https://github.com/SoMainline/linux/commit/4b6fccc995cd79109b0dae4e4ab2e48db97695e7
>>>>>>>>>>> [2]
>>>>>>>>>>> https://github.com/SoMainline/linux/commit/e3ea1dc739634f734104f37fdbed046873921af7
>>>>>>>
>>>>>>> Something in this direction works too.
>>>>>>>
>>>>>>> The upside is that it tells all operating systems how to deal
>>>>>>> with the firmware for this hardware.
>>>>>>>
>>>>>>>>>> Instead of a directory path ("brcm/brcmfmac43596-pcie") why
>>>>>>>>>> not provide
>>>>>>>>>> just the chipset name ("brcmfmac43596-pcie")? IMHO it's
>>>>>>>>>> unnecessary to
>>>>>>>>>> have directory names in Device Tree.
>>>>>>>>>
>>>>>>>>> I think it's common practice to include a full
>>>>>>>>> $FIRMWARE_DIR-relative
>>>>>>>>> path when specifying firmware in DT, though here I left out the
>>>>>>>>> board
>>>>>>>>> name bit as that's assigned dynamically anyway. That said, if
>>>>>>>>> you don't
>>>>>>>>> like it, I can change it.
>>>>>>>>
>>>>>>>> It's just that I have understood that Device Tree is supposed to
>>>>>>>> describe hardware and to me a firmware directory "brcm/" is a
>>>>>>>> software
>>>>>>>> property, not a hardware property. But this is really for the
>>>>>>>> Device
>>>>>>>> Tree maintainers to decide, they know this best :)
>>>>>>>
>>>>>>> I would personally just minimize the amount of information
>>>>>>> put into the device tree to be exactly what is needed to find
>>>>>>> the right firmware.
>>>>>>>
>>>>>>> brcm,firmware-compatible = "43596";
>>>>>>>
>>>>>>> since the code already knows how to conjure the rest of the string.
>>>>>>>
>>>>>>> But check with Rob/Krzysztof.
>>>>>>>
>>>>>>> Yours,
>>>>>>> Linus Walleij
>>>>>>
>>>>>> Krzysztof, Rob [added to CC] - can I have your opinions?
>>>>>
>>>>> I tried catching up on this thread. Reading it I am not sure what
>>>>> the issue is, but I am happy to dive in. If you can provide a boot
>>>>> log with brcmfmac loaded with module parameter 'debug=0x1416' I can
>>>>> try and make sense of the chipid/devid confusion.
>>>>
>>>> Hope this helps, thanks! https://hastebin.com/xidagekuge.yaml
>>>
>>> It does to some extent. It is basically a 4359 revision 9:
>>>
>>> [   25.898782] brcmfmac: brcmf_chip_recognition found AXI chip:
>>> BCM4359/9
>>>
>>> The 4359 entry in pcie.c is applicable for revision 0 and higher
>>> (doubtful but that is in the code):
>>>
>>>      BRCMF_FW_ENTRY(BRCM_CC_4359_CHIP_ID, 0xFFFFFFFF, 4359),
>>>
>>> We need to change the mask above to 0x000001FF and add a new entry
>>> with mask 0xFFFFFE00. All we need is come up with a reasonable
>>> firmware filename. So can you run the strings command on the firmware
>>> you use:
>>>
>>> $ strings fw.bin | tail -1
>>>
>>> and let me know the output.
>>
>> Actually realized you already provided a URL to the repo containing
>> the firmware you used. So I had a look and it shows:
>>
>> 43596a0-roml/pcie-ag-apcs-pktctx-proptxstatus-ampduhostreorder-lpc-die3-olpc-pspretend-mfp-ltecx-clm_43xx_somc_mimo-phyflags-txpwrctrls-dpo Version: 9.75.119.15 (r691661) CRC: a6cf427b Date: Fri 2017-03-24 13:24:25 KST Ucode Ver: 1060.20542 FWID: 01-e4abc35c
>>
>> However, from firmware perspective this is equivalent to 4359c0 so I
>> would suggest the change below.
>>
>> Let me know if that works.
> Sorry for the late reply.
>
> Yes, it does seem to work just fine! The kernel now looks for
> brcm/brcmfmac4359c-pcie.sony,kagura-row.bin as we would expect.
>
> Could you submit this patch below to supersede my one?

I have no problem when you include this patch in yours and submit it to
the linux-wireless list.

Regards,
Arend


Attachments:
smime.p7s (4.12 kB)
S/MIME Cryptographic Signature