Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ec7d25817 |
+2
-2
@@ -65,8 +65,8 @@ BES2600_DRV_VERSION := bes2600_0.3.5_2024.0116
|
||||
|
||||
ifeq ($(CONFIG_BES2600_CALIB_FROM_LINUX),y)
|
||||
FACTORY_CRC_CHECK ?= n
|
||||
STANDARD_FACTORY_EFUSE_FLAG ?= n
|
||||
FACTORY_PATH ?= bes2600/bes2600_factory.txt
|
||||
STANDARD_FACTORY_EFUSE_FLAG ?= y
|
||||
FACTORY_PATH ?= /lib/firmware/bes2600_factory.txt
|
||||
endif
|
||||
|
||||
# basic function
|
||||
|
||||
+19
-26
@@ -12,7 +12,6 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/crc32.h>
|
||||
@@ -31,18 +30,6 @@
|
||||
|
||||
static DEFINE_MUTEX(factory_lock);
|
||||
|
||||
/*
|
||||
* struct device * for request_firmware() context. Set once at SDIO
|
||||
* probe via bes2600_factory_set_dev(). NULL is tolerated (falls back
|
||||
* to the udev-less firmware-class path) but loses per-device logging.
|
||||
*/
|
||||
static struct device *bes2600_factory_dev;
|
||||
|
||||
void bes2600_factory_set_dev(struct device *dev)
|
||||
{
|
||||
bes2600_factory_dev = dev;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is only used for temporary storage.
|
||||
* Every time get the factory, it will read from the
|
||||
@@ -150,32 +137,38 @@ static int bes2600_factory_crc_check(struct factory_t *factory_data)
|
||||
*/
|
||||
static int factory_section_read_file(char *path, void *buffer)
|
||||
{
|
||||
const struct firmware *fw;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
struct file *fp;
|
||||
|
||||
if (!path || !buffer) {
|
||||
bes_err("%s NULL pointer err\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bes_devel("requesting firmware-class %s\n", path);
|
||||
bes_devel("reading %s \n", path);
|
||||
|
||||
ret = request_firmware(&fw, path, bes2600_factory_dev);
|
||||
if (ret) {
|
||||
bes_devel("BES2600: request_firmware(%s) failed: %d\n", path, ret);
|
||||
fp = filp_open(path, O_RDONLY, 0); //S_IRUSR
|
||||
if (IS_ERR(fp)) {
|
||||
bes_devel("BES2600 : can't open %s\n",path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fw->size == 0 || fw->size > FACTORY_MAX_SIZE) {
|
||||
bes_err("bes2600_factory.txt size check failed, read_size: %zu max_size: %d\n",
|
||||
fw->size, FACTORY_MAX_SIZE);
|
||||
release_firmware(fw);
|
||||
if (fp->f_inode->i_size <= 0 || fp->f_inode->i_size > FACTORY_MAX_SIZE) {
|
||||
bes_err( "bes2600_factory.txt size check failed, read_size: %lld max_size: %d\n",
|
||||
fp->f_inode->i_size, FACTORY_MAX_SIZE);
|
||||
filp_close(fp, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(buffer, fw->data, fw->size);
|
||||
ret = (int)fw->size;
|
||||
release_firmware(fw);
|
||||
ret = kernel_read(fp, buffer, fp->f_inode->i_size, &fp->f_pos);
|
||||
|
||||
filp_close(fp, NULL);
|
||||
|
||||
if (ret != fp->f_inode->i_size) {
|
||||
bes_err("bes2600_factory.txt read fail\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,9 +199,6 @@ enum factory_cali_status {
|
||||
/* just calibrate 11n, other protocols are automatically mapped */
|
||||
#define WIFI_RF_11N_MODE 0x15
|
||||
|
||||
/* set the struct device * used for request_firmware() context */
|
||||
void bes2600_factory_set_dev(struct device *dev);
|
||||
|
||||
/* read wifi & bt factory cali value*/
|
||||
u8* bes2600_get_factory_cali_data(u8 *file_buffer, u32 *data_len, char *path);
|
||||
void factory_little_endian_cvrt(u8 *data);
|
||||
|
||||
+38
-5
@@ -30,7 +30,6 @@
|
||||
#include "bes2600.h"
|
||||
#include "sbus.h"
|
||||
#include "bes2600_plat.h"
|
||||
#include "bes2600_factory.h"
|
||||
#include "hwio.h"
|
||||
#include "bes_chardev.h"
|
||||
#include "bes_log.h"
|
||||
@@ -95,6 +94,7 @@ struct sbus_priv {
|
||||
struct work_struct tx_work;
|
||||
struct scatterlist tx_sg[BES_SDIO_TX_MULTIPLE_NUM + 1];
|
||||
struct scatterlist tx_sg_nosignal[BES_SDIO_TX_MULTIPLE_NUM_NOSIGNAL + 1];
|
||||
u8 *tx_bounce;
|
||||
u32 tx_data_cnt;
|
||||
u32 tx_xfer_cnt;
|
||||
u32 tx_proc_cnt;
|
||||
@@ -1136,7 +1136,26 @@ static void sdio_tx_work(struct work_struct *work)
|
||||
}
|
||||
}
|
||||
|
||||
sg_set_buf(&sg[scatters], tx_buffer->buf, align);
|
||||
/*
|
||||
* The transfer length is rounded up to the SDIO block
|
||||
* size, but tx_buffer->buf is only tx_buffer->len bytes
|
||||
* long (it usually aliases into an skb linear head).
|
||||
* Copy into a driver-owned bounce buffer and zero-pad
|
||||
* to the aligned size; otherwise DMA reads past the
|
||||
* skb and leaks adjacent kernel memory on the wire --
|
||||
* observed as KFENCE OOB reads from
|
||||
* bes_sdio_memcpy_to_io_helper via dma_map_sg.
|
||||
*/
|
||||
if (WARN_ON_ONCE(total_len + align > MAX_SDIO_TRANSFER_LEN))
|
||||
goto flush_previous;
|
||||
memcpy(self->tx_bounce + total_len,
|
||||
tx_buffer->buf, tx_buffer->len);
|
||||
if (align > tx_buffer->len)
|
||||
memset(self->tx_bounce + total_len +
|
||||
tx_buffer->len, 0,
|
||||
align - tx_buffer->len);
|
||||
sg_set_buf(&sg[scatters],
|
||||
self->tx_bounce + total_len, align);
|
||||
total_len += align;
|
||||
++scatters;
|
||||
/*del_node:*/
|
||||
@@ -1835,9 +1854,6 @@ static int bes2600_sdio_probe(struct sdio_func *func,
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
/* wire struct device into factory.c for request_firmware() context */
|
||||
bes2600_factory_set_dev(dev);
|
||||
|
||||
self->pdata = bes2600_get_platform_data();
|
||||
self->func = func;
|
||||
self->dev = &func->dev;
|
||||
@@ -1857,6 +1873,17 @@ static int bes2600_sdio_probe(struct sdio_func *func,
|
||||
if (!self->single_gathered_buffer)
|
||||
return -ENOMEM;
|
||||
#endif
|
||||
#ifdef BES_SDIO_TX_MULTIPLE_ENABLE
|
||||
self->tx_bounce = (u8 *)__get_dma_pages(GFP_KERNEL,
|
||||
get_order(MAX_SDIO_TRANSFER_LEN));
|
||||
if (!self->tx_bounce) {
|
||||
#ifndef SDIO_HOST_ADMA_SUPPORT
|
||||
free_pages((unsigned long)self->single_gathered_buffer,
|
||||
get_order(MAX_SDIO_TRANSFER_LEN));
|
||||
#endif
|
||||
return -ENOMEM;
|
||||
}
|
||||
#endif
|
||||
#ifdef BES_SDIO_RXTX_TOGGLE
|
||||
self->fw_started = false;
|
||||
#endif
|
||||
@@ -1985,6 +2012,12 @@ static void bes2600_sdio_remove(struct sdio_func *func)
|
||||
if (self->single_gathered_buffer) {
|
||||
free_pages((unsigned long)self->single_gathered_buffer, get_order(MAX_SDIO_TRANSFER_LEN));
|
||||
}
|
||||
#endif
|
||||
#ifdef BES_SDIO_TX_MULTIPLE_ENABLE
|
||||
if (self->tx_bounce) {
|
||||
free_pages((unsigned long)self->tx_bounce,
|
||||
get_order(MAX_SDIO_TRANSFER_LEN));
|
||||
}
|
||||
#endif
|
||||
kfree(self);
|
||||
}
|
||||
|
||||
@@ -2236,5 +2236,7 @@ int wsm_cpu_usage_cmd(struct bes2600_common *hw_priv);
|
||||
|
||||
int wsm_wifi_status_cmd(struct bes2600_common *hw_priv, uint32_t status);
|
||||
|
||||
#if defined(STANDARD_FACTORY_EFUSE_FLAG)
|
||||
int wsm_save_factory_txt_to_mcu(struct bes2600_common *hw_priv, const u8 *data, int if_id, enum bes2600_rf_cmd_type cmd_type);
|
||||
#endif
|
||||
#endif /* BES2600_HWIO_H_INCLUDED */
|
||||
|
||||
Reference in New Issue
Block a user