Skip to contentSkip to conversation

wifi: brcm80211: move the USB bootloader definitions to a shared header

PATCH In review Ragul Balaji 3 participants 4 messages Nov 12 – Nov 19 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: brcm80211: move the USB bootloader definitions to a shared header

The Broadcom USB bootloader downloads firmware the same way for other USB chips than the FullMAC ones of brcmfmac. Move its commands, states, firmware header and response layouts from brcmfmac's usb.c to a header in the shared include directory, so that other drivers can use them.

---
In preparation for the brcmbmac driver.

 .../broadcom/brcm80211/brcmfmac/usb.c         | 68 +---------------
 .../broadcom/brcm80211/include/brcm_usb_rdl.h | 78 +++++++++++++++++++
 2 files changed, 79 insertions(+), 67 deletions(-)
 create mode 100644 drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +1 -67
index b41949a9bd..e48f064682 100644
@@ -12,6 +12,7 @@
 #include <brcmu_utils.h>
 #include <brcm_hw_ids.h>
 #include <brcmu_wifi.h>
+#include <brcm_usb_rdl.h>
 #include "bus.h"
 #include "debug.h"
 #include "firmware.h"
@@ -26,8 +27,6 @@
 #define BRCMF_USB_RESET_GETVER_SPINWAIT	100	/* in unit of ms */
 #define BRCMF_USB_RESET_GETVER_LOOP_CNT	10
 
-#define BRCMF_POSTBOOT_ID		0xA123  /* ID to detect if dongle
-						   has boot up */
 #define BRCMF_USB_NRXQ			50
 #define BRCMF_USB_NTXQ			50
 
@@ -52,71 +51,6 @@ static const struct brcmf_firmware_mapping brcmf_usb_fwnames[] = {
 	BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373)
 };
 
-#define TRX_MAGIC		0x30524448	/* "HDR0" */
-#define TRX_MAX_OFFSET		3		/* Max number of file offsets */
-#define TRX_UNCOMP_IMAGE	0x20		/* Trx holds uncompressed img */
-#define TRX_RDL_CHUNK		1500		/* size of each dl transfer */
-#define TRX_OFFSETS_DLFWLEN_IDX	0
-
-/* Control messages: bRequest values */
-#define DL_GETSTATE	0	/* returns the rdl_state_t struct */
-#define DL_CHECK_CRC	1	/* currently unused */
-#define DL_GO		2	/* execute downloaded image */
-#define DL_START	3	/* initialize dl state */
-#define DL_REBOOT	4	/* reboot the device in 2 seconds */
-#define DL_GETVER	5	/* returns the bootrom_id_t struct */
-#define DL_GO_PROTECTED	6	/* execute the downloaded code and set reset
-				 * event to occur in 2 seconds.  It is the
-				 * responsibility of the downloaded code to
-				 * clear this event
-				 */
-#define DL_EXEC		7	/* jump to a supplied address */
-#define DL_RESETCFG	8	/* To support single enum on dongle
-				 * - Not used by bootloader
-				 */
-#define DL_DEFER_RESP_OK 9	/* Potentially defer the response to setup
-				 * if resp unavailable
-				 */
-
-/* states */
-#define DL_WAITING	0	/* waiting to rx first pkt */
-#define DL_READY	1	/* hdr was good, waiting for more of the
-				 * compressed image
-				 */
-#define DL_BAD_HDR	2	/* hdr was corrupted */
-#define DL_BAD_CRC	3	/* compressed image was corrupted */
-#define DL_RUNNABLE	4	/* download was successful,waiting for go cmd */
-#define DL_START_FAIL	5	/* failed to initialize correctly */
-#define DL_NVRAM_TOOBIG	6	/* host specified nvram data exceeds DL_NVRAM
-				 * value
-				 */
-#define DL_IMAGE_TOOBIG	7	/* firmware image too big */
-
-
-struct trx_header_le {
-	__le32 magic;		/* "HDR0" */
-	__le32 len;		/* Length of file including header */
-	__le32 crc32;		/* CRC from flag_version to end of file */
-	__le32 flag_version;	/* 0:15 flags, 16:31 version */
-	__le32 offsets[TRX_MAX_OFFSET];	/* Offsets of partitions from start of
-					 * header
-					 */
-};
-
-struct rdl_state_le {
-	__le32 state;
-	__le32 bytes;
-};
-
-struct bootrom_id_le {
-	__le32 chip;		/* Chip id */
-	__le32 chiprev;		/* Chip rev */
-	__le32 ramsize;		/* Size of  RAM */
-	__le32 remapbase;	/* Current remap base address */
-	__le32 boardtype;	/* Type of board */
-	__le32 boardrev;	/* Board revision */
-};
-
 struct brcmf_usbdev_info {
 	struct brcmf_usbdev bus_pub; /* MUST BE FIRST */
 	spinlock_t qlock;
drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 11 lines · Ragul Balaji

The Broadcom USB bootloader downloads firmware the same way for other USB chips than the FullMAC ones of brcmfmac. Move its commands, states, firmware header and response layouts from brcmfmac's usb.c to a header in the shared include directory, so that other drivers can use them.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 68 +---------------
 .../broadcom/brcm80211/include/brcm_usb_rdl.h      | 78 ++++++++++++++++++++++
 2 files changed, 79 insertions(+), 67 deletions(-)

[...]

drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h line 14

Quoted 9 lines
drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h new file +9 -0
+#ifndef	_BRCM_USB_RDL_H_
+#define	_BRCM_USB_RDL_H_
+
+#include <linux/types.h>
+
+#define BRCMF_POSTBOOT_ID		0xA123  /* ID to detect if dongle
+						   has boot up */
+
+#define TRX_MAGIC		0x30524448	/* "HDR0" */

[...]

The move itself looks fine. Like the series "Move brcmsmac code into brcmutil in preparation for brcmbmac" (posted a few minutes later), it is part of the reorganization that has to go in before the brcmbmac driver is sent again, and nothing else in the tree uses this header yet. Keeping the brcmfmac and the brcmsmac parts as separate patches is fine, but please send them as one series with a common cover letter, so the shared pieces are reviewed together. Since the series then touches more than brcmsmac, rename it to something like "Reorganize brcm80211 code into shared directories in preparation for brcmbmac". Can you clarify the additional sign-off from Ho Jie Feng? Did he co-author the patch or did you use his (earlier) work?

Regards,
Arend

#2 lore raw
Quoted 28 lines · Arend van Spriel
Quoted 11 lines · Ragul Balaji

The Broadcom USB bootloader downloads firmware the same way for other USB chips than the FullMAC ones of brcmfmac. Move its commands, states, firmware header and response layouts from brcmfmac's usb.c to a header in the shared include directory, so that other drivers can use them.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 68 +---------------
 .../broadcom/brcm80211/include/brcm_usb_rdl.h      | 78 ++++++++++++++++++++++
 2 files changed, 79 insertions(+), 67 deletions(-)

[...]

Quoted 9 lines
drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h new file +9 -0
+#ifndef      _BRCM_USB_RDL_H_
+#define      _BRCM_USB_RDL_H_
+
+#include <linux/types.h>
+
+#define BRCMF_POSTBOOT_ID            0xA123  /* ID to detect if dongle
+                                                has boot up */
+
+#define TRX_MAGIC            0x30524448      /* "HDR0" */

[...]

Quoted 8 lines

The move itself looks fine. Like the series "Move brcmsmac code into brcmutil in preparation for brcmbmac" (posted a few minutes later), it is part of the reorganization that has to go in before the brcmbmac driver is sent again, and nothing else in the tree uses this header yet. Keeping the brcmfmac and the brcmsmac parts as separate patches is fine, but please send them as one series with a common cover letter, so the shared pieces are reviewed together. Since the series then touches more than brcmsmac, rename it to something like "Reorganize brcm80211 code into

Thanks for the review and suggestions. I'll combine the brcmfmac and brcmsmac changes into a single patch series with a common cover letter, and update the series title as suggested.

Quoted 3 lines

shared directories in preparation for brcmbmac". Can you clarify the additional sign-off from Ho Jie Feng? Did he co-author the patch or did you use his (earlier) work?

Regarding Ho Jie Feng's sign-off, this is my first time working on this kind of contribution, and Jie Feng has been guiding me through the process. We've worked on this together, including the implementation, hardware setup, and review. His contributions have been significant throughout the process, which is why I've included his sign-off.

Quoted 3 lines

Regards,
Arend

#3 lore raw
In reply to Arend van Spriel
Quoted 28 lines · Arend van Spriel
Quoted 11 lines · Ragul Balaji

The Broadcom USB bootloader downloads firmware the same way for other USB chips than the FullMAC ones of brcmfmac. Move its commands, states, firmware header and response layouts from brcmfmac's usb.c to a header in the shared include directory, so that other drivers can use them.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 68 +---------------
 .../broadcom/brcm80211/include/brcm_usb_rdl.h      | 78 ++++++++++++++++++++++
 2 files changed, 79 insertions(+), 67 deletions(-)

[...]

Quoted 9 lines
drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h new file +9 -0
+#ifndef      _BRCM_USB_RDL_H_
+#define      _BRCM_USB_RDL_H_
+
+#include <linux/types.h>
+
+#define BRCMF_POSTBOOT_ID            0xA123  /* ID to detect if dongle
+                                                has boot up */
+
+#define TRX_MAGIC            0x30524448      /* "HDR0" */

[...]

Quoted 11 lines

The move itself looks fine. Like the series "Move brcmsmac code into brcmutil in preparation for brcmbmac" (posted a few minutes later), it is part of the reorganization that has to go in before the brcmbmac driver is sent again, and nothing else in the tree uses this header yet. Keeping the brcmfmac and the brcmsmac parts as separate patches is fine, but please send them as one series with a common cover letter, so the shared pieces are reviewed together. Since the series then touches more than brcmsmac, rename it to something like "Reorganize brcm80211 code into shared directories in preparation for brcmbmac". Can you clarify the additional sign-off from Ho Jie Feng? Did he co-author the patch or did you use his (earlier) work?

Yes, the driver was co-developed with me over a few months.

Quoted 2 lines

Regards,
Arend