2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: Implement functions to access baseband
24 * Author: Yiching Chen
34 #include <linux/compiler.h>
38 static int msglevel = MSG_LEVEL_INFO;
39 /* static int msglevel = MSG_LEVEL_DEBUG; */
41 #define FIRMWARE_VERSION 0x133 /* version 1.51 */
42 #define FIRMWARE_NAME "vntwusb.fw"
44 #define FIRMWARE_CHUNK_SIZE 0x400
46 int FIRMWAREbDownload(struct vnt_private *pDevice)
48 struct device *dev = &pDevice->usb->dev;
49 const struct firmware *fw;
56 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
58 rc = request_firmware(&fw, FIRMWARE_NAME, dev);
60 dev_err(dev, "firmware file %s request failed (%d)\n",
65 pBuffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
69 for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
70 wLength = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
71 memcpy(pBuffer, fw->data + ii, wLength);
73 NdisStatus = vnt_control_out(pDevice,
80 DBG_PRT(MSG_LEVEL_DEBUG,
81 KERN_INFO"Download firmware...%d %zu\n", ii, fw->size);
82 if (NdisStatus != STATUS_SUCCESS)
95 MODULE_FIRMWARE(FIRMWARE_NAME);
97 int FIRMWAREbBrach2Sram(struct vnt_private *pDevice)
101 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n");
103 NdisStatus = vnt_control_out(pDevice,
109 if (NdisStatus != STATUS_SUCCESS)
115 int FIRMWAREbCheckVersion(struct vnt_private *pDevice)
119 ntStatus = vnt_control_in(pDevice,
122 MESSAGE_REQUEST_VERSION,
124 (u8 *) &(pDevice->wFirmwareVersion));
126 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n",
127 pDevice->wFirmwareVersion);
128 if (ntStatus != STATUS_SUCCESS) {
129 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Invalid.\n");
132 if (pDevice->wFirmwareVersion == 0xFFFF) {
133 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"In Loader.\n");
136 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Firmware Version [%04x]\n",
137 pDevice->wFirmwareVersion);
138 if (pDevice->wFirmwareVersion < FIRMWARE_VERSION) {
139 /* branch to loader for download new firmware */
140 FIRMWAREbBrach2Sram(pDevice);