2 * carl9170user - userspace testing utility for ar9170 devices
6 * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include <sys/types.h>
42 int carlu_fw_check(struct carlu *ar)
44 struct carl9170fw_otus_desc *otus_desc;
46 otus_desc = carlfw_find_desc(ar->fw, (uint8_t *) OTUS_MAGIC,
48 CARL9170FW_OTUS_DESC_CUR_VER);
51 err("No valid OTUS descriptor found.\n");
55 if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_DUMMY_FEATURE)) {
56 err("Invalid Firmware Descriptor.\n");
60 if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_UNUSABLE))
61 dbg("Firmware is marked as unuseable.\n");
63 info("Firmware Version: %d.\n", otus_desc->api_ver);
68 int carlusb_fw_check(struct carlusb *ar)
70 struct carl9170fw_otus_desc *otus_desc;
72 otus_desc = carlfw_find_desc(ar->common.fw, (uint8_t *) OTUS_MAGIC,
74 CARL9170FW_OTUS_DESC_CUR_VER);
77 err("No valid USB descriptor found.\n");
81 if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_DUMMY_FEATURE)) {
82 err("Invalid Firmware Descriptor.\n");
86 if (!carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_INIT_FIRMWARE)) {
87 err("Firmware does not know how to initialize USB core.\n");
91 if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_DOWN_STREAM)) {
92 dbg("Enabled tx stream mode.\n");
93 ar->common.tx_stream = true;
94 ar->common.extra_headroom = sizeof(struct ar9170_stream);
97 if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_UP_STREAM)) {
98 dbg("Enabled rx stream mode.\n");
99 ar->common.rx_stream = true;
102 if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_USB_RESP_EP2))
103 dbg("Firmware sends traps over EP2.\n");
105 ar->common.dma_chunk_size = le16_to_cpu(otus_desc->tx_frag_len);
106 ar->common.dma_chunks = otus_desc->tx_descs;
107 ar->rx_max = le16_to_cpu(otus_desc->rx_max_frame_len);
109 if (carl9170fw_supports(otus_desc->feature_set, CARL9170FW_MINIBOOT))
110 ar->miniboot_size = le16_to_cpu(otus_desc->miniboot_size);
115 void carlu_fw_info(struct carlu *ar)
117 struct carl9170fw_motd_desc *motd_desc;
118 unsigned int fw_date;
120 motd_desc = carlfw_find_desc(ar->fw, (uint8_t *) MOTD_MAGIC,
122 CARL9170FW_MOTD_DESC_CUR_VER);
125 fw_date = le32_to_cpu(motd_desc->fw_year_month_day);
127 info("Firmware Date: 2%.3d-%.2d-%.2d\n",
128 CARL9170FW_GET_YEAR(fw_date), CARL9170FW_GET_MONTH(fw_date),
129 CARL9170FW_GET_DAY(fw_date));