diff mbox series

[v14,4/4] wifi: brcmfmac: add flag for random seed during firmware download

Message ID 20240910-wireless-mainline-v14-4-9d80fea5326d@wesion.com
State New
Headers show
Series Add AP6276P wireless support | expand

Commit Message

Jacobe Zang Sept. 10, 2024, 3:04 a.m. UTC
Providing the random seed to firmware was tied to the fact that the
device has a valid OTP, which worked for some Apple chips. However,
it turns out the BCM43752 device also needs the random seed in order
to get firmware running. Suspect it is simply tied to the firmware
branch used for the device. Introducing a mechanism to allow setting
it for a device through the device table.

Co-developed-by: Ondrej Jirman <megi@xff.cz>
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Co-developed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Jacobe Zang <jacobe.zang@wesion.com>
---
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 52 ++++++++++++++++++----
 .../broadcom/brcm80211/include/brcm_hw_ids.h       |  2 +
 2 files changed, 46 insertions(+), 8 deletions(-)

Comments

Sebastian Reichel Sept. 13, 2024, 5:56 p.m. UTC | #1
Hi,

On Tue, Sep 10, 2024 at 11:04:14AM GMT, Jacobe Zang wrote:
> Providing the random seed to firmware was tied to the fact that the
> device has a valid OTP, which worked for some Apple chips. However,
> it turns out the BCM43752 device also needs the random seed in order
> to get firmware running. Suspect it is simply tied to the firmware
> branch used for the device. Introducing a mechanism to allow setting
> it for a device through the device table.
> 
> Co-developed-by: Ondrej Jirman <megi@xff.cz>
> Signed-off-by: Ondrej Jirman <megi@xff.cz>
> Co-developed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Jacobe Zang <jacobe.zang@wesion.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> # On RK3588 EVB1

Greetings,

-- Sebastian

>  .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 52 ++++++++++++++++++----
>  .../broadcom/brcm80211/include/brcm_hw_ids.h       |  2 +
>  2 files changed, 46 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> index 190e8990618c5..c0fdaa4dceda4 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -66,6 +66,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
>  BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
>  BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
>  BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
> +BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-pcie");
>  BRCMF_FW_CLM_DEF(4377B3, "brcmfmac4377b3-pcie");
>  BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
>  BRCMF_FW_CLM_DEF(4378B3, "brcmfmac4378b3-pcie");
> @@ -104,6 +105,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
>  	BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
>  	BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
>  	BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
> +	BRCMF_FW_ENTRY(BRCM_CC_43752_CHIP_ID, 0xFFFFFFFF, 43752),
>  	BRCMF_FW_ENTRY(BRCM_CC_4377_CHIP_ID, 0xFFFFFFFF, 4377B3), /* revision ID 4 */
>  	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0x0000000F, 4378B1), /* revision ID 3 */
>  	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFE0, 4378B3), /* revision ID 5 */
> @@ -353,6 +355,7 @@ struct brcmf_pciedev_info {
>  			  u16 value);
>  	struct brcmf_mp_device *settings;
>  	struct brcmf_otp_params otp;
> +	bool fwseed;
>  #ifdef DEBUG
>  	u32 console_interval;
>  	bool console_active;
> @@ -1715,14 +1718,14 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
>  		memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
>  		brcmf_fw_nvram_free(nvram);
>  
> -		if (devinfo->otp.valid) {
> +		if (devinfo->fwseed) {
>  			size_t rand_len = BRCMF_RANDOM_SEED_LENGTH;
>  			struct brcmf_random_seed_footer footer = {
>  				.length = cpu_to_le32(rand_len),
>  				.magic = cpu_to_le32(BRCMF_RANDOM_SEED_MAGIC),
>  			};
>  
> -			/* Some Apple chips/firmwares expect a buffer of random
> +			/* Some chips/firmwares expect a buffer of random
>  			 * data to be present before NVRAM
>  			 */
>  			brcmf_dbg(PCIE, "Download random seed\n");
> @@ -2394,6 +2397,37 @@ static void brcmf_pcie_debugfs_create(struct device *dev)
>  }
>  #endif
>  
> +struct brcmf_pcie_drvdata {
> +	enum brcmf_fwvendor vendor;
> +	bool fw_seed;
> +};
> +
> +enum {
> +	BRCMF_DRVDATA_CYW,
> +	BRCMF_DRVDATA_BCA,
> +	BRCMF_DRVDATA_WCC,
> +	BRCMF_DRVDATA_WCC_SEED,
> +};
> +
> +static const struct brcmf_pcie_drvdata drvdata[] = {
> +	[BRCMF_DRVDATA_CYW] = {
> +		.vendor = BRCMF_FWVENDOR_CYW,
> +		.fw_seed = false,
> +	},
> +	[BRCMF_DRVDATA_BCA] = {
> +		.vendor = BRCMF_FWVENDOR_BCA,
> +		.fw_seed = false,
> +	},
> +	[BRCMF_DRVDATA_WCC] = {
> +		.vendor = BRCMF_FWVENDOR_WCC,
> +		.fw_seed = false,
> +	},
> +	[BRCMF_DRVDATA_WCC_SEED] = {
> +		.vendor = BRCMF_FWVENDOR_WCC,
> +		.fw_seed = true,
> +	},
> +};
> +
>  /* Forward declaration for pci_match_id() call */
>  static const struct pci_device_id brcmf_pcie_devid_table[];
>  
> @@ -2475,9 +2509,10 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	bus->bus_priv.pcie = pcie_bus_dev;
>  	bus->ops = &brcmf_pcie_bus_ops;
>  	bus->proto_type = BRCMF_PROTO_MSGBUF;
> -	bus->fwvid = id->driver_data;
>  	bus->chip = devinfo->coreid;
>  	bus->wowl_supported = pci_pme_capable(pdev, PCI_D3hot);
> +	bus->fwvid = drvdata[id->driver_data].vendor;
> +	devinfo->fwseed = drvdata[id->driver_data].fw_seed;
>  	dev_set_drvdata(&pdev->dev, bus);
>  
>  	ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings);
> @@ -2663,14 +2698,14 @@ static const struct dev_pm_ops brcmf_pciedrvr_pm = {
>  		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
>  		PCI_ANY_ID, PCI_ANY_ID, \
>  		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
> -		BRCMF_FWVENDOR_ ## fw_vend \
> +		BRCMF_DRVDATA_ ## fw_vend \
>  	}
>  #define BRCMF_PCIE_DEVICE_SUB(dev_id, subvend, subdev, fw_vend) \
>  	{ \
>  		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
>  		(subvend), (subdev), \
>  		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
> -		BRCMF_FWVENDOR_ ## fw_vend \
> +		BRCMF_DRVDATA_ ## fw_vend \
>  	}
>  
>  static const struct pci_device_id brcmf_pcie_devid_table[] = {
> @@ -2698,9 +2733,10 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = {
>  	BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_5G_DEVICE_ID, BCA),
>  	BRCMF_PCIE_DEVICE(BRCM_PCIE_4371_DEVICE_ID, WCC),
>  	BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_DEVICE_ID, CYW),
> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC),
> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC),
> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC),
> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC_SEED),
> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC_SEED),
> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC_SEED),
> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_43752_DEVICE_ID, WCC_SEED),
>  
>  	{ /* end: all zeroes */ }
>  };
> 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 44684bf1b9acc..c1e22c589d85e 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
> +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
> @@ -52,6 +52,7 @@
>  #define BRCM_CC_43664_CHIP_ID		43664
>  #define BRCM_CC_43666_CHIP_ID		43666
>  #define BRCM_CC_4371_CHIP_ID		0x4371
> +#define BRCM_CC_43752_CHIP_ID		43752
>  #define BRCM_CC_4377_CHIP_ID		0x4377
>  #define BRCM_CC_4378_CHIP_ID		0x4378
>  #define BRCM_CC_4387_CHIP_ID		0x4387
> @@ -94,6 +95,7 @@
>  #define BRCM_PCIE_4366_5G_DEVICE_ID	0x43c5
>  #define BRCM_PCIE_4371_DEVICE_ID	0x440d
>  #define BRCM_PCIE_43596_DEVICE_ID	0x4415
> +#define BRCM_PCIE_43752_DEVICE_ID	0x449d
>  #define BRCM_PCIE_4377_DEVICE_ID	0x4488
>  #define BRCM_PCIE_4378_DEVICE_ID	0x4425
>  #define BRCM_PCIE_4387_DEVICE_ID	0x4433
> 
> -- 
> 2.34.1
> 
>
Jacobe Zang Sept. 14, 2024, 6:02 a.m. UTC | #2
On 2024/9/14 1:56, Sebastian Reichel wrote:
> Hi,
> 
> On Tue, Sep 10, 2024 at 11:04:14AM GMT, Jacobe Zang wrote:
>> Providing the random seed to firmware was tied to the fact that the
>> device has a valid OTP, which worked for some Apple chips. However,
>> it turns out the BCM43752 device also needs the random seed in order
>> to get firmware running. Suspect it is simply tied to the firmware
>> branch used for the device. Introducing a mechanism to allow setting
>> it for a device through the device table.
>>
>> Co-developed-by: Ondrej Jirman <megi@xff.cz>
>> Signed-off-by: Ondrej Jirman <megi@xff.cz>
>> Co-developed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> Signed-off-by: Jacobe Zang <jacobe.zang@wesion.com>
>> ---
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> # On RK3588 EVB1
> 

Thanks for all your reviews and tests ;-)

> Greetings,
> 
> -- Sebastian
> 
>>   .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 52 ++++++++++++++++++----
>>   .../broadcom/brcm80211/include/brcm_hw_ids.h       |  2 +
>>   2 files changed, 46 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> index 190e8990618c5..c0fdaa4dceda4 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> @@ -66,6 +66,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
>>   BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
>>   BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
>>   BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
>> +BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-pcie");
>>   BRCMF_FW_CLM_DEF(4377B3, "brcmfmac4377b3-pcie");
>>   BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
>>   BRCMF_FW_CLM_DEF(4378B3, "brcmfmac4378b3-pcie");
>> @@ -104,6 +105,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
>>   	BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
>>   	BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
>>   	BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
>> +	BRCMF_FW_ENTRY(BRCM_CC_43752_CHIP_ID, 0xFFFFFFFF, 43752),
>>   	BRCMF_FW_ENTRY(BRCM_CC_4377_CHIP_ID, 0xFFFFFFFF, 4377B3), /* revision ID 4 */
>>   	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0x0000000F, 4378B1), /* revision ID 3 */
>>   	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFE0, 4378B3), /* revision ID 5 */
>> @@ -353,6 +355,7 @@ struct brcmf_pciedev_info {
>>   			  u16 value);
>>   	struct brcmf_mp_device *settings;
>>   	struct brcmf_otp_params otp;
>> +	bool fwseed;
>>   #ifdef DEBUG
>>   	u32 console_interval;
>>   	bool console_active;
>> @@ -1715,14 +1718,14 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
>>   		memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
>>   		brcmf_fw_nvram_free(nvram);
>>   
>> -		if (devinfo->otp.valid) {
>> +		if (devinfo->fwseed) {
>>   			size_t rand_len = BRCMF_RANDOM_SEED_LENGTH;
>>   			struct brcmf_random_seed_footer footer = {
>>   				.length = cpu_to_le32(rand_len),
>>   				.magic = cpu_to_le32(BRCMF_RANDOM_SEED_MAGIC),
>>   			};
>>   
>> -			/* Some Apple chips/firmwares expect a buffer of random
>> +			/* Some chips/firmwares expect a buffer of random
>>   			 * data to be present before NVRAM
>>   			 */
>>   			brcmf_dbg(PCIE, "Download random seed\n");
>> @@ -2394,6 +2397,37 @@ static void brcmf_pcie_debugfs_create(struct device *dev)
>>   }
>>   #endif
>>   
>> +struct brcmf_pcie_drvdata {
>> +	enum brcmf_fwvendor vendor;
>> +	bool fw_seed;
>> +};
>> +
>> +enum {
>> +	BRCMF_DRVDATA_CYW,
>> +	BRCMF_DRVDATA_BCA,
>> +	BRCMF_DRVDATA_WCC,
>> +	BRCMF_DRVDATA_WCC_SEED,
>> +};
>> +
>> +static const struct brcmf_pcie_drvdata drvdata[] = {
>> +	[BRCMF_DRVDATA_CYW] = {
>> +		.vendor = BRCMF_FWVENDOR_CYW,
>> +		.fw_seed = false,
>> +	},
>> +	[BRCMF_DRVDATA_BCA] = {
>> +		.vendor = BRCMF_FWVENDOR_BCA,
>> +		.fw_seed = false,
>> +	},
>> +	[BRCMF_DRVDATA_WCC] = {
>> +		.vendor = BRCMF_FWVENDOR_WCC,
>> +		.fw_seed = false,
>> +	},
>> +	[BRCMF_DRVDATA_WCC_SEED] = {
>> +		.vendor = BRCMF_FWVENDOR_WCC,
>> +		.fw_seed = true,
>> +	},
>> +};
>> +
>>   /* Forward declaration for pci_match_id() call */
>>   static const struct pci_device_id brcmf_pcie_devid_table[];
>>   
>> @@ -2475,9 +2509,10 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>>   	bus->bus_priv.pcie = pcie_bus_dev;
>>   	bus->ops = &brcmf_pcie_bus_ops;
>>   	bus->proto_type = BRCMF_PROTO_MSGBUF;
>> -	bus->fwvid = id->driver_data;
>>   	bus->chip = devinfo->coreid;
>>   	bus->wowl_supported = pci_pme_capable(pdev, PCI_D3hot);
>> +	bus->fwvid = drvdata[id->driver_data].vendor;
>> +	devinfo->fwseed = drvdata[id->driver_data].fw_seed;
>>   	dev_set_drvdata(&pdev->dev, bus);
>>   
>>   	ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings);
>> @@ -2663,14 +2698,14 @@ static const struct dev_pm_ops brcmf_pciedrvr_pm = {
>>   		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
>>   		PCI_ANY_ID, PCI_ANY_ID, \
>>   		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
>> -		BRCMF_FWVENDOR_ ## fw_vend \
>> +		BRCMF_DRVDATA_ ## fw_vend \
>>   	}
>>   #define BRCMF_PCIE_DEVICE_SUB(dev_id, subvend, subdev, fw_vend) \
>>   	{ \
>>   		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
>>   		(subvend), (subdev), \
>>   		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
>> -		BRCMF_FWVENDOR_ ## fw_vend \
>> +		BRCMF_DRVDATA_ ## fw_vend \
>>   	}
>>   
>>   static const struct pci_device_id brcmf_pcie_devid_table[] = {
>> @@ -2698,9 +2733,10 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = {
>>   	BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_5G_DEVICE_ID, BCA),
>>   	BRCMF_PCIE_DEVICE(BRCM_PCIE_4371_DEVICE_ID, WCC),
>>   	BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_DEVICE_ID, CYW),
>> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC),
>> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC),
>> -	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC),
>> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC_SEED),
>> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC_SEED),
>> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC_SEED),
>> +	BRCMF_PCIE_DEVICE(BRCM_PCIE_43752_DEVICE_ID, WCC_SEED),
>>   
>>   	{ /* end: all zeroes */ }
>>   };
>> 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 44684bf1b9acc..c1e22c589d85e 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
>> +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
>> @@ -52,6 +52,7 @@
>>   #define BRCM_CC_43664_CHIP_ID		43664
>>   #define BRCM_CC_43666_CHIP_ID		43666
>>   #define BRCM_CC_4371_CHIP_ID		0x4371
>> +#define BRCM_CC_43752_CHIP_ID		43752
>>   #define BRCM_CC_4377_CHIP_ID		0x4377
>>   #define BRCM_CC_4378_CHIP_ID		0x4378
>>   #define BRCM_CC_4387_CHIP_ID		0x4387
>> @@ -94,6 +95,7 @@
>>   #define BRCM_PCIE_4366_5G_DEVICE_ID	0x43c5
>>   #define BRCM_PCIE_4371_DEVICE_ID	0x440d
>>   #define BRCM_PCIE_43596_DEVICE_ID	0x4415
>> +#define BRCM_PCIE_43752_DEVICE_ID	0x449d
>>   #define BRCM_PCIE_4377_DEVICE_ID	0x4488
>>   #define BRCM_PCIE_4378_DEVICE_ID	0x4425
>>   #define BRCM_PCIE_4387_DEVICE_ID	0x4433
>>
>> -- 
>> 2.34.1
>>
>>
Arend Van Spriel Sept. 15, 2024, 6:52 a.m. UTC | #3
On September 10, 2024 5:05:50 AM Jacobe Zang <jacobe.zang@wesion.com> wrote:

> Providing the random seed to firmware was tied to the fact that the
> device has a valid OTP, which worked for some Apple chips. However,
> it turns out the BCM43752 device also needs the random seed in order
> to get firmware running. Suspect it is simply tied to the firmware
> branch used for the device. Introducing a mechanism to allow setting
> it for a device through the device table.
>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Co-developed-by: Ondrej Jirman <megi@xff.cz>
> Signed-off-by: Ondrej Jirman <megi@xff.cz>
> Co-developed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Jacobe Zang <jacobe.zang@wesion.com>
> ---
> .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 52 ++++++++++++++++++----
> .../broadcom/brcm80211/include/brcm_hw_ids.h       |  2 +
> 2 files changed, 46 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 190e8990618c5..c0fdaa4dceda4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -66,6 +66,7 @@  BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
 BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
 BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
 BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
+BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-pcie");
 BRCMF_FW_CLM_DEF(4377B3, "brcmfmac4377b3-pcie");
 BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
 BRCMF_FW_CLM_DEF(4378B3, "brcmfmac4378b3-pcie");
@@ -104,6 +105,7 @@  static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
 	BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
 	BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
 	BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
+	BRCMF_FW_ENTRY(BRCM_CC_43752_CHIP_ID, 0xFFFFFFFF, 43752),
 	BRCMF_FW_ENTRY(BRCM_CC_4377_CHIP_ID, 0xFFFFFFFF, 4377B3), /* revision ID 4 */
 	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0x0000000F, 4378B1), /* revision ID 3 */
 	BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFE0, 4378B3), /* revision ID 5 */
@@ -353,6 +355,7 @@  struct brcmf_pciedev_info {
 			  u16 value);
 	struct brcmf_mp_device *settings;
 	struct brcmf_otp_params otp;
+	bool fwseed;
 #ifdef DEBUG
 	u32 console_interval;
 	bool console_active;
@@ -1715,14 +1718,14 @@  static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
 		memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
 		brcmf_fw_nvram_free(nvram);
 
-		if (devinfo->otp.valid) {
+		if (devinfo->fwseed) {
 			size_t rand_len = BRCMF_RANDOM_SEED_LENGTH;
 			struct brcmf_random_seed_footer footer = {
 				.length = cpu_to_le32(rand_len),
 				.magic = cpu_to_le32(BRCMF_RANDOM_SEED_MAGIC),
 			};
 
-			/* Some Apple chips/firmwares expect a buffer of random
+			/* Some chips/firmwares expect a buffer of random
 			 * data to be present before NVRAM
 			 */
 			brcmf_dbg(PCIE, "Download random seed\n");
@@ -2394,6 +2397,37 @@  static void brcmf_pcie_debugfs_create(struct device *dev)
 }
 #endif
 
+struct brcmf_pcie_drvdata {
+	enum brcmf_fwvendor vendor;
+	bool fw_seed;
+};
+
+enum {
+	BRCMF_DRVDATA_CYW,
+	BRCMF_DRVDATA_BCA,
+	BRCMF_DRVDATA_WCC,
+	BRCMF_DRVDATA_WCC_SEED,
+};
+
+static const struct brcmf_pcie_drvdata drvdata[] = {
+	[BRCMF_DRVDATA_CYW] = {
+		.vendor = BRCMF_FWVENDOR_CYW,
+		.fw_seed = false,
+	},
+	[BRCMF_DRVDATA_BCA] = {
+		.vendor = BRCMF_FWVENDOR_BCA,
+		.fw_seed = false,
+	},
+	[BRCMF_DRVDATA_WCC] = {
+		.vendor = BRCMF_FWVENDOR_WCC,
+		.fw_seed = false,
+	},
+	[BRCMF_DRVDATA_WCC_SEED] = {
+		.vendor = BRCMF_FWVENDOR_WCC,
+		.fw_seed = true,
+	},
+};
+
 /* Forward declaration for pci_match_id() call */
 static const struct pci_device_id brcmf_pcie_devid_table[];
 
@@ -2475,9 +2509,10 @@  brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	bus->bus_priv.pcie = pcie_bus_dev;
 	bus->ops = &brcmf_pcie_bus_ops;
 	bus->proto_type = BRCMF_PROTO_MSGBUF;
-	bus->fwvid = id->driver_data;
 	bus->chip = devinfo->coreid;
 	bus->wowl_supported = pci_pme_capable(pdev, PCI_D3hot);
+	bus->fwvid = drvdata[id->driver_data].vendor;
+	devinfo->fwseed = drvdata[id->driver_data].fw_seed;
 	dev_set_drvdata(&pdev->dev, bus);
 
 	ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings);
@@ -2663,14 +2698,14 @@  static const struct dev_pm_ops brcmf_pciedrvr_pm = {
 		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
 		PCI_ANY_ID, PCI_ANY_ID, \
 		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
-		BRCMF_FWVENDOR_ ## fw_vend \
+		BRCMF_DRVDATA_ ## fw_vend \
 	}
 #define BRCMF_PCIE_DEVICE_SUB(dev_id, subvend, subdev, fw_vend) \
 	{ \
 		BRCM_PCIE_VENDOR_ID_BROADCOM, (dev_id), \
 		(subvend), (subdev), \
 		PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, \
-		BRCMF_FWVENDOR_ ## fw_vend \
+		BRCMF_DRVDATA_ ## fw_vend \
 	}
 
 static const struct pci_device_id brcmf_pcie_devid_table[] = {
@@ -2698,9 +2733,10 @@  static const struct pci_device_id brcmf_pcie_devid_table[] = {
 	BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_5G_DEVICE_ID, BCA),
 	BRCMF_PCIE_DEVICE(BRCM_PCIE_4371_DEVICE_ID, WCC),
 	BRCMF_PCIE_DEVICE(BRCM_PCIE_43596_DEVICE_ID, CYW),
-	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC),
-	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC),
-	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC),
+	BRCMF_PCIE_DEVICE(BRCM_PCIE_4377_DEVICE_ID, WCC_SEED),
+	BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC_SEED),
+	BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC_SEED),
+	BRCMF_PCIE_DEVICE(BRCM_PCIE_43752_DEVICE_ID, WCC_SEED),
 
 	{ /* end: all zeroes */ }
 };
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 44684bf1b9acc..c1e22c589d85e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -52,6 +52,7 @@ 
 #define BRCM_CC_43664_CHIP_ID		43664
 #define BRCM_CC_43666_CHIP_ID		43666
 #define BRCM_CC_4371_CHIP_ID		0x4371
+#define BRCM_CC_43752_CHIP_ID		43752
 #define BRCM_CC_4377_CHIP_ID		0x4377
 #define BRCM_CC_4378_CHIP_ID		0x4378
 #define BRCM_CC_4387_CHIP_ID		0x4387
@@ -94,6 +95,7 @@ 
 #define BRCM_PCIE_4366_5G_DEVICE_ID	0x43c5
 #define BRCM_PCIE_4371_DEVICE_ID	0x440d
 #define BRCM_PCIE_43596_DEVICE_ID	0x4415
+#define BRCM_PCIE_43752_DEVICE_ID	0x449d
 #define BRCM_PCIE_4377_DEVICE_ID	0x4488
 #define BRCM_PCIE_4378_DEVICE_ID	0x4425
 #define BRCM_PCIE_4387_DEVICE_ID	0x4433