]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/vt6656/firmware.c
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 #define FIRMWARE_VERSION 0x133 /* version 1.51 */
39 #define FIRMWARE_NAME "vntwusb.fw"
41 #define FIRMWARE_CHUNK_SIZE 0x400
43 int vnt_download_firmware(struct vnt_private
*priv
)
45 struct device
*dev
= &priv
->usb
->dev
;
46 const struct firmware
*fw
;
53 dev_dbg(dev
, "---->Download firmware\n");
55 rc
= request_firmware(&fw
, FIRMWARE_NAME
, dev
);
57 dev_err(dev
, "firmware file %s request failed (%d)\n",
62 buffer
= kmalloc(FIRMWARE_CHUNK_SIZE
, GFP_KERNEL
);
66 for (ii
= 0; ii
< fw
->size
; ii
+= FIRMWARE_CHUNK_SIZE
) {
67 length
= min_t(int, fw
->size
- ii
, FIRMWARE_CHUNK_SIZE
);
68 memcpy(buffer
, fw
->data
+ ii
, length
);
70 status
= vnt_control_out(priv
,
77 dev_dbg(dev
, "Download firmware...%d %zu\n", ii
, fw
->size
);
79 if (status
!= STATUS_SUCCESS
)
92 MODULE_FIRMWARE(FIRMWARE_NAME
);
94 int vnt_firmware_branch_to_sram(struct vnt_private
*priv
)
98 dev_dbg(&priv
->usb
->dev
, "---->Branch to Sram\n");
100 status
= vnt_control_out(priv
,
106 if (status
!= STATUS_SUCCESS
)
112 int vnt_check_firmware_version(struct vnt_private
*priv
)
116 status
= vnt_control_in(priv
,
119 MESSAGE_REQUEST_VERSION
,
121 (u8
*)&priv
->firmware_version
);
123 dev_dbg(&priv
->usb
->dev
, "Firmware Version [%04x]\n",
124 priv
->firmware_version
);
126 if (status
!= STATUS_SUCCESS
) {
127 dev_dbg(&priv
->usb
->dev
, "Firmware Invalid.\n");
130 if (priv
->firmware_version
== 0xFFFF) {
131 dev_dbg(&priv
->usb
->dev
, "In Loader.\n");
135 dev_dbg(&priv
->usb
->dev
, "Firmware Version [%04x]\n",
136 priv
->firmware_version
);
138 if (priv
->firmware_version
< FIRMWARE_VERSION
) {
139 /* branch to loader for download new firmware */
140 vnt_firmware_branch_to_sram(priv
);