Merge the USB firmware descriptor into OTAR.
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
struct carl9170_firmware_descriptor {
struct carl9170fw_otus_desc otus;
- struct carl9170fw_usb_desc usb;
struct carl9170fw_motd_desc motd;
struct carl9170fw_dbg_desc dbg;
struct carl9170fw_last_desc last;
const struct carl9170_firmware_descriptor __section(fwdsc) carl9170fw_desc = {
FILL(otus, OTUS,
- .fw_feature_set = cpu_to_le32(BIT(CARL9170FW_DUMMY_FEATURE) |
+ .feature_set = cpu_to_le32(BIT(CARL9170FW_DUMMY_FEATURE) |
+ BIT(CARL9170FW_USB_RESP_EP2) |
+#ifdef CONFIG_CARL9170FW_USB_INIT_FIRMWARE
+ BIT(CARL9170FW_USB_INIT_FIRMWARE) |
+# ifdef CONFIG_CARL9170FW_USB_UP_STREAM
+ BIT(CARL9170FW_USB_UP_STREAM) |
+# endif /* CONFIG_CARL9170FW_USB_UP_STREAM */
+# ifdef CONFIG_CARL9170FW_USB_DOWN_STREAM
+ BIT(CARL9170FW_USB_DOWN_STREAM) |
+# endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
+#endif /* CONFIG_CARL9170FW_USB_INIT_FIRMWARE */
+#ifdef CONFIG_CARL9170FW_USB_WATCHDOG
+ BIT(CARL9170FW_USB_WATCHDOG) |
+#endif /* CONFIG_CARL9170FW_USB_WATCHDOG */
#ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
- BIT(CARL9170FW_COMMAND_PHY) |
+ BIT(CARL9170FW_COMMAND_PHY) |
#endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
#ifdef CONFIG_CARL9170FW_SECURITY_ENGINE
- BIT(CARL9170FW_COMMAND_CAM) |
+ BIT(CARL9170FW_COMMAND_CAM) |
#endif /* CONFIG_CARL9170FW_SECURITY_ENGINE */
#ifdef CONFIG_CARL9170FW_CAB_QUEUE
- BIT(CARL9170FW_WLANTX_CAB) |
+ BIT(CARL9170FW_WLANTX_CAB) |
#endif /* CONFIG_CARL9170FW_CAB_QUEUE */
#ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ
- BIT(CARL9170FW_HANDLE_BACK_REQ) |
+ BIT(CARL9170FW_HANDLE_BACK_REQ) |
#endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */
#ifdef CONFIG_CARL9170FW_UNUSABLE
- BIT(CARL9170FW_UNUSABLE) |
+ BIT(CARL9170FW_UNUSABLE) |
#endif /* CONFIG_CARL9170FW_UNUSABLE */
#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
- BIT(CARL9170FW_GPIO_INTERRUPT) |
+ BIT(CARL9170FW_GPIO_INTERRUPT) |
#endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */
#ifdef CONFIG_CARL9170FW_PSM
- BIT(CARL9170FW_PSM) |
+ BIT(CARL9170FW_PSM) |
#endif
(0)),
- .bcn_addr = (__le32) cpu_to_le32(&dma_mem.reserved.bcn),
- .bcn_len = (__le16) cpu_to_le16(sizeof(dma_mem.reserved.bcn)),
- .vif_num = CARL9170_INTF_NUM,
- .api_ver = CONFIG_CARL9170FW_RELEASE_VERSION,
- ),
-
- FILL(usb, USB,
- .usb_feature_set = cpu_to_le32(BIT(CARL9170FW_USB_DUMMY_FEATURE) |
- BIT(CARL9170FW_USB_RESP_EP2) |
-#ifdef CONFIG_CARL9170FW_USB_INIT_FIRMWARE
- BIT(CARL9170FW_USB_INIT_FIRMWARE) |
-# ifdef CONFIG_CARL9170FW_USB_UP_STREAM
- BIT(CARL9170FW_USB_UP_STREAM) |
-# endif /* CONFIG_CARL9170FW_USB_UP_STREAM */
-# ifdef CONFIG_CARL9170FW_USB_DOWN_STREAM
- BIT(CARL9170FW_USB_DOWN_STREAM) |
-# endif /* CONFIG_CARL9170FW_USB_DOWN_STREAM */
-#endif /* CONFIG_CARL9170FW_USB_INIT_FIRMWARE */
-#ifdef CONFIG_CARL9170FW_USB_WATCHDOG
- BIT(CARL9170FW_USB_WATCHDOG) |
-#endif /* CONFIG_CARL9170FW_USB_WATCHDOG */
- (0)),
.miniboot_size = cpu_to_le16(0),
.tx_descs = AR9170_TX_BLOCK_NUMBER,
.rx_max_frame_len = cpu_to_le16(CONFIG_CARL9170FW_RX_FRAME_LEN),
.tx_frag_len = cpu_to_le16(AR9170_BLOCK_SIZE),
.fw_address = cpu_to_le32(AR9170_PRAM_OFFSET),
+ .bcn_addr = (__le32) cpu_to_le32(&dma_mem.reserved.bcn),
+ .bcn_len = (__le16) cpu_to_le16(sizeof(dma_mem.reserved.bcn)),
+ .vif_num = CARL9170_INTF_NUM,
+ .api_ver = CONFIG_CARL9170FW_RELEASE_VERSION,
),
FILL(motd, MOTD,
/* Always set */
CARL9170FW_DUMMY_FEATURE,
+ /*
+ * Indicates that this image has special boot block which prevents
+ * legacy drivers to drive the firmware.
+ */
+ CARL9170FW_MINIBOOT,
+
+ /* usb registers are initialized by the firmware */
+ CARL9170FW_USB_INIT_FIRMWARE,
+
+ /* command traps & notifications are send through EP2 */
+ CARL9170FW_USB_RESP_EP2,
+
+ /* usb download (app -> fw) stream */
+ CARL9170FW_USB_DOWN_STREAM,
+
+ /* usb upload (fw -> app) stream */
+ CARL9170FW_USB_UP_STREAM,
+
+ /* USB Watchdog */
+ CARL9170FW_USB_WATCHDOG,
+
/* unusable - reserved to flag non-functional debug firmwares */
CARL9170FW_UNUSABLE,
__CARL9170FW_FEATURE_NUM
};
-enum carl9170fw_usb_feature_list {
- /* Always set */
- CARL9170FW_USB_DUMMY_FEATURE,
-
- /*
- * Indicates that this image has special boot block which prevents
- * legacy drivers to drive the firmware.
- */
- CARL9170FW_USB_MINIBOOT,
-
- /* usb registers are initialized by the firmware */
- CARL9170FW_USB_INIT_FIRMWARE,
-
- /* command traps & notifications are send through EP2 */
- CARL9170FW_USB_RESP_EP2,
-
- /* usb download (app -> fw) stream */
- CARL9170FW_USB_DOWN_STREAM,
-
- /* usb upload (fw -> app) stream */
- CARL9170FW_USB_UP_STREAM,
-
- /* USB Watchdog */
- CARL9170FW_USB_WATCHDOG,
-
- /* KEEP LAST */
- __CARL9170FW_USB_FEATURE_NUM
-};
-
#define OTUS_MAGIC "OTAR"
-#define USB_MAGIC "USB\0"
#define MOTD_MAGIC "MOTD"
#define FIX_MAGIC "FIX\0"
#define DBG_MAGIC "DBG\0"
#define CARL9170FW_DESC_HEAD_SIZE \
(sizeof(struct carl9170fw_desc_head))
-#define CARL9170FW_OTUS_DESC_MIN_VER 2
-#define CARL9170FW_OTUS_DESC_CUR_VER 2
+#define CARL9170FW_OTUS_DESC_MIN_VER 3
+#define CARL9170FW_OTUS_DESC_CUR_VER 3
struct carl9170fw_otus_desc {
struct carl9170fw_desc_head head;
- __le32 fw_feature_set;
+ __le32 feature_set;
+ __le32 fw_address;
__le32 bcn_addr;
__le16 bcn_len;
- u8 api_ver;
- u8 vif_num;
-} __packed;
-#define CARL9170FW_OTUS_DESC_SIZE \
- (sizeof(struct carl9170fw_otus_desc))
-
-#define CARL9170FW_USB_DESC_MIN_VER 3
-#define CARL9170FW_USB_DESC_CUR_VER 3
-struct carl9170fw_usb_desc {
- struct carl9170fw_desc_head head;
- __le32 usb_feature_set;
- __le32 fw_address;
+ __le16 miniboot_size;
__le16 tx_frag_len;
__le16 rx_max_frame_len;
- __le16 miniboot_size;
u8 tx_descs;
u8 cmd_bufs;
+ u8 api_ver;
+ u8 vif_num;
} __packed;
-#define CARL9170FW_USB_DESC_SIZE \
- (sizeof(struct carl9170fw_usb_desc))
+#define CARL9170FW_OTUS_DESC_SIZE \
+ (sizeof(struct carl9170fw_otus_desc))
#define CARL9170FW_MOTD_STRING_LEN 24
#define CARL9170FW_MOTD_RELEASE_LEN 20
return -EINVAL;
}
- if (!carl9170fw_supports(otus_desc->fw_feature_set, CARL9170FW_DUMMY_FEATURE)) {
+ if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_DUMMY_FEATURE)) {
err("Invalid Firmware Descriptor.\n");
return -EIO;
}
- if (carl9170fw_supports(otus_desc->fw_feature_set, CARL9170FW_UNUSABLE))
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_UNUSABLE))
dbg("Firmware is marked as unuseable.\n");
info("Firmware Version: %d.\n", otus_desc->api_ver);
int carlusb_fw_check(struct carlusb *ar)
{
- struct carl9170fw_usb_desc *usb_desc;
+ struct carl9170fw_otus_desc *otus_desc;
- usb_desc = carlfw_find_desc(ar->common.fw, (uint8_t *) USB_MAGIC,
- sizeof(*usb_desc),
- CARL9170FW_USB_DESC_CUR_VER);
+ otus_desc = carlfw_find_desc(ar->common.fw, (uint8_t *) OTUS_MAGIC,
+ sizeof(*otus_desc),
+ CARL9170FW_OTUS_DESC_CUR_VER);
- if (!usb_desc) {
+ if (!otus_desc) {
err("No valid USB descriptor found.\n");
return -ENODATA;
}
- if (!carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_DUMMY_FEATURE)) {
+ if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_DUMMY_FEATURE)) {
err("Invalid Firmware Descriptor.\n");
return -EINVAL;
}
- if (!carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_INIT_FIRMWARE)) {
+ if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_INIT_FIRMWARE)) {
err("Firmware does not know how to initialize USB core.\n");
return -EOPNOTSUPP;
}
- if (carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_DOWN_STREAM)) {
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_DOWN_STREAM)) {
dbg("Enabled tx stream mode.\n");
ar->common.tx_stream = true;
ar->common.extra_headroom = sizeof(struct ar9170_stream);
}
- if (carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_UP_STREAM)) {
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_UP_STREAM)) {
dbg("Enabled rx stream mode.\n");
ar->common.rx_stream = true;
}
- if (carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_RESP_EP2))
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_RESP_EP2))
dbg("Firmware sends traps over EP2.\n");
- ar->common.dma_chunk_size = le16_to_cpu(usb_desc->tx_frag_len);
- ar->common.dma_chunks = usb_desc->tx_descs;
- ar->rx_max = le16_to_cpu(usb_desc->rx_max_frame_len);
+ ar->common.dma_chunk_size = le16_to_cpu(otus_desc->tx_frag_len);
+ ar->common.dma_chunks = otus_desc->tx_descs;
+ ar->rx_max = le16_to_cpu(otus_desc->rx_max_frame_len);
- if (carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_MINIBOOT))
- ar->miniboot_size = le16_to_cpu(usb_desc->miniboot_size);
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_MINIBOOT))
+ ar->miniboot_size = le16_to_cpu(otus_desc->miniboot_size);
return 0;
}
#define CHECK_FOR_FEATURE_FUNC(feature_enum, _func) \
{ .id = feature_enum, .name = #feature_enum, .func = _func }
+static void show_miniboot_info(const struct carl9170fw_desc_head *head,
+ struct carlfw *fw __unused)
+{
+ const struct carl9170fw_otus_desc *otus = (const void *) head;
+
+ fprintf(stdout, "\t\t\tminiboot size: %d Bytes\n", otus->miniboot_size);
+}
+
static const struct feature_list known_otus_features_v1[] = {
CHECK_FOR_FEATURE(CARL9170FW_DUMMY_FEATURE),
+ CHECK_FOR_FEATURE_FUNC(CARL9170FW_MINIBOOT, show_miniboot_info),
+ CHECK_FOR_FEATURE(CARL9170FW_USB_INIT_FIRMWARE),
+ CHECK_FOR_FEATURE(CARL9170FW_USB_RESP_EP2),
+ CHECK_FOR_FEATURE(CARL9170FW_USB_DOWN_STREAM),
+ CHECK_FOR_FEATURE(CARL9170FW_USB_UP_STREAM),
+ CHECK_FOR_FEATURE(CARL9170FW_USB_WATCHDOG),
CHECK_FOR_FEATURE(CARL9170FW_UNUSABLE),
CHECK_FOR_FEATURE(CARL9170FW_COMMAND_PHY),
CHECK_FOR_FEATURE(CARL9170FW_COMMAND_CAM),
BUILD_BUG_ON(ARRAY_SIZE(known_otus_features_v1) != __CARL9170FW_FEATURE_NUM);
+ fprintf(stdout, "\tFirmware upload pointer: 0x%x\n",
+ otus->fw_address);
fprintf(stdout, "\tBeacon Address: %x, (reserved:%d Bytes)\n",
le32_to_cpu(otus->bcn_addr), le16_to_cpu(otus->bcn_len));
- fprintf(stdout, "\tFirmware API Version: %d\n", otus->api_ver);
- fprintf(stdout, "\tSupported Firmware Interfaces: %d\n", otus->vif_num);
-
- fprintf(stdout, "\tSupported Features: (raw:%.08x)\n",
- le32_to_cpu(otus->fw_feature_set));
-
- check_feature_list(head, otus->fw_feature_set, known_otus_features_v1,
- ARRAY_SIZE(known_otus_features_v1), fw);
-}
-
-static void show_miniboot_info(const struct carl9170fw_desc_head *head,
- struct carlfw *fw __unused)
-{
- const struct carl9170fw_usb_desc *usb = (const void *) head;
-
- fprintf(stdout, "\t\t\tminiboot size: %d Bytes\n", usb->miniboot_size);
-}
-
-static const struct feature_list known_usb_features_v1[] = {
- CHECK_FOR_FEATURE(CARL9170FW_USB_DUMMY_FEATURE),
- CHECK_FOR_FEATURE_FUNC(CARL9170FW_USB_MINIBOOT, show_miniboot_info),
- CHECK_FOR_FEATURE(CARL9170FW_USB_INIT_FIRMWARE),
- CHECK_FOR_FEATURE(CARL9170FW_USB_RESP_EP2),
- CHECK_FOR_FEATURE(CARL9170FW_USB_DOWN_STREAM),
- CHECK_FOR_FEATURE(CARL9170FW_USB_UP_STREAM),
- CHECK_FOR_FEATURE(CARL9170FW_USB_WATCHDOG),
-};
-
-static void show_usb_desc(const struct carl9170fw_desc_head *head,
- struct carlfw *fw __unused)
-{
- const struct carl9170fw_usb_desc *usb = (const void *) head;
-
- BUILD_BUG_ON(ARRAY_SIZE(known_usb_features_v1) != __CARL9170FW_USB_FEATURE_NUM);
-
fprintf(stdout, "\tTX DMA chunk size:%d Bytes, TX DMA chunks:%d\n",
- usb->tx_frag_len, usb->tx_descs);
+ otus->tx_frag_len, otus->tx_descs);
fprintf(stdout, "\t=> %d Bytes are reserved for the TX queues\n",
- usb->tx_frag_len * usb->tx_descs);
- fprintf(stdout, "\tCommand response buffers:%d\n", usb->cmd_bufs);
+ otus->tx_frag_len * otus->tx_descs);
+ fprintf(stdout, "\tCommand response buffers:%d\n", otus->cmd_bufs);
fprintf(stdout, "\tMax. RX stream block size:%d Bytes\n",
- usb->rx_max_frame_len);
- fprintf(stdout, "\tFirmware upload pointer: 0x%x\n",
- usb->fw_address);
+ otus->rx_max_frame_len);
+ fprintf(stdout, "\tSupported Firmware Interfaces: %d\n", otus->vif_num);
+ fprintf(stdout, "\tFirmware API Version: %d\n", otus->api_ver);
fprintf(stdout, "\tSupported Features: (raw:%.08x)\n",
- le32_to_cpu(usb->usb_feature_set));
+ le32_to_cpu(otus->feature_set));
- check_feature_list(head, usb->usb_feature_set, known_usb_features_v1,
- ARRAY_SIZE(known_usb_features_v1), fw);
+ check_feature_list(head, otus->feature_set, known_otus_features_v1,
+ ARRAY_SIZE(known_otus_features_v1), fw);
}
static void show_motd_desc(const struct carl9170fw_desc_head *head,
uint16_t size;
} known_magics[] = {
ADD_HANDLER(OTUS, show_otus_desc),
- ADD_HANDLER(USB, show_usb_desc),
ADD_HANDLER(MOTD, show_motd_desc),
ADD_HANDLER(DBG, show_dbg_desc),
ADD_HANDLER(FIX, show_fix_desc),
{
struct stat file_stat;
struct carl9170fw_otus_desc *otus_desc = NULL;
- struct carl9170fw_usb_desc *usb_desc = NULL;
FILE *m = NULL;
char *buf = NULL;
size_t extra;
goto fail;
}
- usb_desc = carlfw_find_desc(fw, (uint8_t *) USB_MAGIC,
- sizeof(*usb_desc),
- CARL9170FW_USB_DESC_CUR_VER);
- if (!usb_desc) {
- fprintf(stderr, "Firmware is not for USB devices.\n");
- goto fail;
- }
-
- if (carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_MINIBOOT)) {
+ if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_MINIBOOT)) {
fprintf(stderr, "Firmware has already a miniboot image.\n");
goto fail;
}
- usb_desc->usb_feature_set |= cpu_to_le32(BIT(CARL9170FW_USB_MINIBOOT));
- usb_desc->miniboot_size = cpu_to_le16(extra);
+ otus_desc->feature_set |= cpu_to_le32(BIT(CARL9170FW_MINIBOOT));
+ otus_desc->miniboot_size = cpu_to_le16(extra);
buf = carlfw_mod_headroom(fw, extra);
if (IS_ERR_OR_NULL(buf)) {
static int del_mini(struct carlfw *fw)
{
- struct carl9170fw_usb_desc *usb_desc = NULL;
+ struct carl9170fw_otus_desc *otus_desc = NULL;
void *buf;
int cut;
- usb_desc = carlfw_find_desc(fw, (uint8_t *) USB_MAGIC,
- sizeof(*usb_desc),
- CARL9170FW_USB_DESC_CUR_VER);
- if (!usb_desc) {
+ otus_desc = carlfw_find_desc(fw, (uint8_t *) OTUS_MAGIC,
+ sizeof(*otus_desc),
+ CARL9170FW_OTUS_DESC_CUR_VER);
+ if (!otus_desc) {
fprintf(stderr, "Firmware is not for USB devices.\n");
return -ENODATA;
}
- if (!carl9170fw_supports(usb_desc->usb_feature_set, CARL9170FW_USB_MINIBOOT)) {
+ if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_MINIBOOT)) {
fprintf(stderr, "Firmware has no miniboot image.\n");
return -EINVAL;
}
- cut = le16_to_cpu(usb_desc->miniboot_size);
+ cut = le16_to_cpu(otus_desc->miniboot_size);
buf = carlfw_mod_headroom(fw, -cut);
if (IS_ERR_OR_NULL(buf)) {
return PTR_ERR(buf);
}
- usb_desc->usb_feature_set &= cpu_to_le32(~BIT(CARL9170FW_USB_MINIBOOT));
- usb_desc->miniboot_size = cpu_to_le16(0);
+ otus_desc->feature_set &= cpu_to_le32(~BIT(CARL9170FW_MINIBOOT));
+ otus_desc->miniboot_size = cpu_to_le16(0);
carlfw_store(fw);
return 0;