Contributors: 9
Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
Forest Bond |
151 |
38.52% |
1 |
4.17% |
Malcolm Priestley |
94 |
23.98% |
14 |
58.33% |
Quentin Deslandes |
80 |
20.41% |
1 |
4.17% |
Ben Hutchings |
57 |
14.54% |
1 |
4.17% |
Cédric Cabessa |
3 |
0.77% |
1 |
4.17% |
Andres More |
3 |
0.77% |
2 |
8.33% |
Greg Kroah-Hartman |
2 |
0.51% |
2 |
8.33% |
Nandini Hanumanthagowda |
1 |
0.26% |
1 |
4.17% |
Randy Dunlap |
1 |
0.26% |
1 |
4.17% |
Total |
392 |
|
24 |
|
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* File: baseband.c
*
* Purpose: Implement functions to access baseband
*
* Author: Yiching Chen
*
* Date: May 20, 2004
*
* Functions:
*
* Revision History:
*
*/
#include <linux/compiler.h>
#include "firmware.h"
#include "usbpipe.h"
#define FIRMWARE_VERSION 0x133 /* version 1.51 */
#define FIRMWARE_NAME "vntwusb.fw"
#define FIRMWARE_CHUNK_SIZE 0x400
int vnt_download_firmware(struct vnt_private *priv)
{
struct device *dev = &priv->usb->dev;
const struct firmware *fw;
u16 length;
int ii;
int ret = 0;
dev_dbg(dev, "---->Download firmware\n");
ret = request_firmware(&fw, FIRMWARE_NAME, dev);
if (ret) {
dev_err(dev, "firmware file %s request failed (%d)\n",
FIRMWARE_NAME, ret);
goto end;
}
for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length,
fw->data + ii);
if (ret)
goto free_fw;
dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
}
free_fw:
release_firmware(fw);
end:
return ret;
}
MODULE_FIRMWARE(FIRMWARE_NAME);
int vnt_firmware_branch_to_sram(struct vnt_private *priv)
{
dev_dbg(&priv->usb->dev, "---->Branch to Sram\n");
return vnt_control_out(priv, 1, 0x1200, 0x0000, 0, NULL);
}
int vnt_check_firmware_version(struct vnt_private *priv)
{
int ret = 0;
ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
MESSAGE_REQUEST_VERSION, 2,
(u8 *)&priv->firmware_version);
if (ret) {
dev_dbg(&priv->usb->dev,
"Could not get firmware version: %d.\n", ret);
goto end;
}
dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n",
priv->firmware_version);
if (priv->firmware_version == 0xFFFF) {
dev_dbg(&priv->usb->dev, "In Loader.\n");
ret = -EINVAL;
goto end;
}
if (priv->firmware_version < FIRMWARE_VERSION) {
/* branch to loader for download new firmware */
ret = vnt_firmware_branch_to_sram(priv);
if (ret) {
dev_dbg(&priv->usb->dev,
"Could not branch to SRAM: %d.\n", ret);
} else {
ret = -EINVAL;
}
}
end:
return ret;
}