License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 08:07:57 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2009-11-03 02:17:11 -07:00
|
|
|
/**************************************************************************************************
|
|
|
|
* Procedure: Init boot code/firmware code/data session
|
|
|
|
*
|
2010-09-01 07:40:25 -06:00
|
|
|
* Description: This routine will initialize firmware. If any error occurs during the initialization
|
2012-12-05 13:40:18 -07:00
|
|
|
* process, the routine shall terminate immediately and return fail.
|
2009-11-03 02:17:11 -07:00
|
|
|
* NIC driver should call NdisOpenFile only from MiniportInitialize.
|
|
|
|
*
|
|
|
|
* Arguments: The pointer of the adapter
|
|
|
|
|
|
|
|
* Returns:
|
|
|
|
* NDIS_STATUS_FAILURE - the following initialization process should be terminated
|
|
|
|
* NDIS_STATUS_SUCCESS - if firmware initialization process success
|
2017-02-11 02:52:58 -07:00
|
|
|
**************************************************************************************************/
|
2010-07-02 21:04:44 -06:00
|
|
|
|
2009-11-03 02:17:11 -07:00
|
|
|
#include "r8192U.h"
|
|
|
|
#include "r8192U_hw.h"
|
|
|
|
#include "r819xU_firmware_img.h"
|
|
|
|
#include "r819xU_firmware.h"
|
|
|
|
#include <linux/firmware.h>
|
2014-03-19 05:47:24 -06:00
|
|
|
|
|
|
|
static void firmware_init_param(struct net_device *dev)
|
2009-11-03 02:17:11 -07:00
|
|
|
{
|
2012-12-05 13:40:18 -07:00
|
|
|
struct r8192_priv *priv = ieee80211_priv(dev);
|
2009-11-03 02:17:11 -07:00
|
|
|
rt_firmware *pfirmware = priv->pFirmware;
|
|
|
|
|
2018-10-23 10:56:01 -06:00
|
|
|
pfirmware->cmdpacket_frag_threshold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE);
|
2009-11-03 02:17:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* segment the img and use the ptr and length to remember info on each segment
|
|
|
|
*
|
|
|
|
*/
|
2014-03-19 05:47:24 -06:00
|
|
|
static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
|
|
|
|
u32 buffer_len)
|
2009-11-03 02:17:11 -07:00
|
|
|
{
|
|
|
|
struct r8192_priv *priv = ieee80211_priv(dev);
|
2012-12-05 13:40:18 -07:00
|
|
|
bool rt_status = true;
|
2009-11-03 02:17:11 -07:00
|
|
|
u16 frag_threshold;
|
|
|
|
u16 frag_length, frag_offset = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
rt_firmware *pfirmware = priv->pFirmware;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
unsigned char *seg_ptr;
|
2017-02-12 00:26:23 -07:00
|
|
|
struct cb_desc *tcb_desc;
|
2009-11-03 02:17:11 -07:00
|
|
|
u8 bLastIniPkt;
|
2014-10-03 06:36:13 -06:00
|
|
|
u8 index;
|
2009-11-03 02:17:11 -07:00
|
|
|
|
|
|
|
firmware_init_param(dev);
|
2015-02-19 22:54:10 -07:00
|
|
|
/* Fragmentation might be required */
|
2018-10-23 10:56:01 -06:00
|
|
|
frag_threshold = pfirmware->cmdpacket_frag_threshold;
|
2009-11-03 02:17:11 -07:00
|
|
|
do {
|
2013-05-13 11:15:56 -06:00
|
|
|
if ((buffer_len - frag_offset) > frag_threshold) {
|
2014-09-27 08:32:52 -06:00
|
|
|
frag_length = frag_threshold;
|
2009-11-03 02:17:11 -07:00
|
|
|
bLastIniPkt = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
frag_length = buffer_len - frag_offset;
|
|
|
|
bLastIniPkt = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate skb buffer to contain firmware info and tx descriptor info
|
|
|
|
* add 4 to avoid packet appending overflow.
|
2017-02-11 02:52:58 -07:00
|
|
|
*/
|
2009-11-03 02:17:11 -07:00
|
|
|
skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
|
2013-09-21 14:42:26 -06:00
|
|
|
if (!skb)
|
|
|
|
return false;
|
2015-06-20 10:06:48 -06:00
|
|
|
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
|
2017-02-12 00:26:23 -07:00
|
|
|
tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
|
2009-11-03 02:17:11 -07:00
|
|
|
tcb_desc->queue_index = TXCMD_QUEUE;
|
|
|
|
tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
|
|
|
|
tcb_desc->bLastIniPkt = bLastIniPkt;
|
|
|
|
|
|
|
|
skb_reserve(skb, USB_HWDESC_HEADER_LEN);
|
|
|
|
seg_ptr = skb->data;
|
|
|
|
/*
|
|
|
|
* Transform from little endian to big endian
|
2009-11-03 02:42:46 -07:00
|
|
|
* and pending zero
|
2009-11-03 02:17:11 -07:00
|
|
|
*/
|
2014-10-03 06:36:11 -06:00
|
|
|
for (i = 0; i < frag_length; i += 4) {
|
|
|
|
*seg_ptr++ = ((i+0) < frag_length)?code_virtual_address[i+3] : 0;
|
|
|
|
*seg_ptr++ = ((i+1) < frag_length)?code_virtual_address[i+2] : 0;
|
|
|
|
*seg_ptr++ = ((i+2) < frag_length)?code_virtual_address[i+1] : 0;
|
|
|
|
*seg_ptr++ = ((i+3) < frag_length)?code_virtual_address[i+0] : 0;
|
2009-11-03 02:17:11 -07:00
|
|
|
}
|
2014-10-03 06:36:11 -06:00
|
|
|
tcb_desc->txbuf_size = (u16)i;
|
2009-11-03 02:17:11 -07:00
|
|
|
skb_put(skb, i);
|
|
|
|
|
2014-10-03 06:36:13 -06:00
|
|
|
index = tcb_desc->queue_index;
|
|
|
|
if (!priv->ieee80211->check_nic_enough_desc(dev, index) ||
|
|
|
|
(!skb_queue_empty(&priv->ieee80211->skb_waitQ[index])) ||
|
|
|
|
(priv->ieee80211->queue_stop)) {
|
2015-07-27 00:37:25 -06:00
|
|
|
RT_TRACE(COMP_FIRMWARE, "=====================================================> tx full!\n");
|
2009-11-03 02:17:11 -07:00
|
|
|
skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
|
|
|
|
} else {
|
2014-08-24 03:57:36 -06:00
|
|
|
priv->ieee80211->softmac_hard_start_xmit(skb, dev);
|
2009-11-03 02:17:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
code_virtual_address += frag_length;
|
|
|
|
frag_offset += frag_length;
|
|
|
|
|
2014-09-27 08:18:38 -06:00
|
|
|
} while (frag_offset < buffer_len);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-19 22:54:10 -07:00
|
|
|
/*
|
|
|
|
* Procedure: Check whether main code is download OK. If OK, turn on CPU
|
|
|
|
*
|
|
|
|
* Description: CPU register locates in different page against general register.
|
|
|
|
* Switch to CPU register in the begin and switch back before return
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Arguments: The pointer of the adapter
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* NDIS_STATUS_FAILURE - the following initialization process should
|
|
|
|
* be terminated
|
|
|
|
* NDIS_STATUS_SUCCESS - if firmware initialization process success
|
|
|
|
*/
|
2014-03-19 05:47:24 -06:00
|
|
|
static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
|
2009-11-03 02:17:11 -07:00
|
|
|
{
|
|
|
|
bool rt_status = true;
|
|
|
|
int check_putcodeOK_time = 200000, check_bootOk_time = 200000;
|
2009-11-03 02:42:46 -07:00
|
|
|
u32 CPU_status = 0;
|
2009-11-03 02:17:11 -07:00
|
|
|
|
|
|
|
/* Check whether put code OK */
|
|
|
|
do {
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 07:40:51 -06:00
|
|
|
read_nic_dword(dev, CPU_GEN, &CPU_status);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (CPU_status&CPU_GEN_PUT_CODE_OK)
|
2009-11-03 02:17:11 -07:00
|
|
|
break;
|
|
|
|
|
2014-09-27 08:18:38 -06:00
|
|
|
} while (check_putcodeOK_time--);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) {
|
2009-11-03 02:17:11 -07:00
|
|
|
RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
|
|
|
|
goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
|
|
|
|
} else {
|
|
|
|
RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn On CPU */
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 07:40:51 -06:00
|
|
|
read_nic_dword(dev, CPU_GEN, &CPU_status);
|
2015-08-02 10:14:50 -06:00
|
|
|
write_nic_byte(dev, CPU_GEN,
|
|
|
|
(u8)((CPU_status | CPU_GEN_PWR_STB_CPU) & 0xff));
|
2009-11-03 02:17:11 -07:00
|
|
|
mdelay(1000);
|
|
|
|
|
|
|
|
/* Check whether CPU boot OK */
|
|
|
|
do {
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 07:40:51 -06:00
|
|
|
read_nic_dword(dev, CPU_GEN, &CPU_status);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (CPU_status&CPU_GEN_BOOT_RDY)
|
2009-11-03 02:17:11 -07:00
|
|
|
break;
|
2014-09-27 08:18:38 -06:00
|
|
|
} while (check_bootOk_time--);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2014-09-04 09:11:03 -06:00
|
|
|
if (!(CPU_status&CPU_GEN_BOOT_RDY))
|
2009-11-03 02:17:11 -07:00
|
|
|
goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
|
2014-09-04 09:11:03 -06:00
|
|
|
else
|
2009-11-03 02:17:11 -07:00
|
|
|
RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n");
|
|
|
|
|
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
CPUCheckMainCodeOKAndTurnOnCPU_Fail:
|
2014-05-23 23:13:20 -06:00
|
|
|
RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
|
2015-02-27 16:14:34 -07:00
|
|
|
rt_status = false;
|
2009-11-03 02:17:11 -07:00
|
|
|
return rt_status;
|
|
|
|
}
|
|
|
|
|
2014-03-19 05:47:24 -06:00
|
|
|
static bool CPUcheck_firmware_ready(struct net_device *dev)
|
2009-11-03 02:17:11 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
bool rt_status = true;
|
|
|
|
int check_time = 200000;
|
|
|
|
u32 CPU_status = 0;
|
|
|
|
|
|
|
|
/* Check Firmware Ready */
|
|
|
|
do {
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 07:40:51 -06:00
|
|
|
read_nic_dword(dev, CPU_GEN, &CPU_status);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (CPU_status&CPU_GEN_FIRM_RDY)
|
2009-11-03 02:17:11 -07:00
|
|
|
break;
|
|
|
|
|
2014-09-27 08:18:38 -06:00
|
|
|
} while (check_time--);
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (!(CPU_status&CPU_GEN_FIRM_RDY))
|
2009-11-03 02:17:11 -07:00
|
|
|
goto CPUCheckFirmwareReady_Fail;
|
|
|
|
else
|
|
|
|
RT_TRACE(COMP_FIRMWARE, "Download Firmware: Firmware ready!\n");
|
|
|
|
|
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
CPUCheckFirmwareReady_Fail:
|
2014-05-23 23:13:20 -06:00
|
|
|
RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
|
2009-11-03 02:17:11 -07:00
|
|
|
rt_status = false;
|
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool init_firmware(struct net_device *dev)
|
|
|
|
{
|
2012-12-05 13:40:18 -07:00
|
|
|
struct r8192_priv *priv = ieee80211_priv(dev);
|
2015-02-27 16:14:34 -07:00
|
|
|
bool rt_status = true;
|
2009-11-03 02:17:11 -07:00
|
|
|
|
|
|
|
u32 file_length = 0;
|
|
|
|
u8 *mapped_file = NULL;
|
|
|
|
u32 init_step = 0;
|
2018-09-08 03:44:09 -06:00
|
|
|
enum opt_rst_type_e rst_opt = OPT_SYSTEM_RESET;
|
2018-09-08 03:44:08 -06:00
|
|
|
enum firmware_init_step_e starting_state = FW_INIT_STEP0_BOOT;
|
2009-11-03 02:17:11 -07:00
|
|
|
|
|
|
|
rt_firmware *pfirmware = priv->pFirmware;
|
2012-12-05 13:40:18 -07:00
|
|
|
const struct firmware *fw_entry;
|
2009-11-03 02:17:11 -07:00
|
|
|
const char *fw_name[3] = { "RTL8192U/boot.img",
|
2009-11-03 02:42:46 -07:00
|
|
|
"RTL8192U/main.img",
|
2009-11-03 02:17:11 -07:00
|
|
|
"RTL8192U/data.img"};
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n");
|
|
|
|
|
2014-09-27 08:47:21 -06:00
|
|
|
if (pfirmware->firmware_status == FW_STATUS_0_INIT) {
|
2009-11-03 02:17:11 -07:00
|
|
|
/* it is called by reset */
|
|
|
|
rst_opt = OPT_SYSTEM_RESET;
|
|
|
|
starting_state = FW_INIT_STEP0_BOOT;
|
2015-02-19 22:54:10 -07:00
|
|
|
/* TODO: system reset */
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2014-09-27 08:18:38 -06:00
|
|
|
} else if (pfirmware->firmware_status == FW_STATUS_5_READY) {
|
2009-11-03 02:17:11 -07:00
|
|
|
/* it is called by Initialize */
|
|
|
|
rst_opt = OPT_FIRMWARE_RESET;
|
|
|
|
starting_state = FW_INIT_STEP2_DATA;
|
2014-09-27 08:18:38 -06:00
|
|
|
} else {
|
2009-11-03 02:17:11 -07:00
|
|
|
RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Download boot, main, and data image for System reset.
|
2012-04-30 08:41:36 -06:00
|
|
|
* Download data image for firmware reset
|
2009-11-03 02:17:11 -07:00
|
|
|
*/
|
2014-09-27 04:25:29 -06:00
|
|
|
for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) {
|
2009-11-03 02:17:11 -07:00
|
|
|
/*
|
2012-04-30 15:39:21 -06:00
|
|
|
* Open image file, and map file to continuous memory if open file success.
|
2009-11-03 02:17:11 -07:00
|
|
|
* or read image file from array. Default load from IMG file
|
|
|
|
*/
|
2013-05-13 11:15:56 -06:00
|
|
|
if (rst_opt == OPT_SYSTEM_RESET) {
|
2015-07-27 00:37:25 -06:00
|
|
|
rc = request_firmware(&fw_entry, fw_name[init_step], &priv->udev->dev);
|
2014-09-27 08:47:21 -06:00
|
|
|
if (rc < 0) {
|
2011-01-08 21:20:04 -07:00
|
|
|
RT_TRACE(COMP_ERR, "request firmware fail!\n");
|
|
|
|
goto download_firmware_fail;
|
2009-11-03 02:17:11 -07:00
|
|
|
}
|
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (fw_entry->size > sizeof(pfirmware->firmware_buf)) {
|
2011-01-08 21:20:04 -07:00
|
|
|
RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n");
|
|
|
|
goto download_firmware_fail;
|
|
|
|
}
|
2009-11-03 02:17:11 -07:00
|
|
|
|
2013-05-13 11:15:56 -06:00
|
|
|
if (init_step != FW_INIT_STEP1_MAIN) {
|
2015-07-27 00:37:25 -06:00
|
|
|
memcpy(pfirmware->firmware_buf, fw_entry->data, fw_entry->size);
|
2011-01-08 21:20:04 -07:00
|
|
|
mapped_file = pfirmware->firmware_buf;
|
|
|
|
file_length = fw_entry->size;
|
|
|
|
} else {
|
2014-08-24 03:57:36 -06:00
|
|
|
memset(pfirmware->firmware_buf, 0, 128);
|
2015-07-27 00:37:25 -06:00
|
|
|
memcpy(&pfirmware->firmware_buf[128], fw_entry->data, fw_entry->size);
|
2011-01-08 21:20:04 -07:00
|
|
|
mapped_file = pfirmware->firmware_buf;
|
|
|
|
file_length = fw_entry->size + 128;
|
|
|
|
}
|
|
|
|
pfirmware->firmware_buf_size = file_length;
|
2014-09-27 08:47:21 -06:00
|
|
|
} else if (rst_opt == OPT_FIRMWARE_RESET) {
|
2009-11-03 02:17:11 -07:00
|
|
|
/* we only need to download data.img here */
|
|
|
|
mapped_file = pfirmware->firmware_buf;
|
|
|
|
file_length = pfirmware->firmware_buf_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Download image file */
|
|
|
|
/* The firmware download process is just as following,
|
|
|
|
* 1. that is each packet will be segmented and inserted to the wait queue.
|
|
|
|
* 2. each packet segment will be put in the skb_buff packet.
|
|
|
|
* 3. each skb_buff packet data content will already include the firmware info
|
|
|
|
* and Tx descriptor info
|
2017-02-11 02:52:58 -07:00
|
|
|
*/
|
2014-08-24 03:57:36 -06:00
|
|
|
rt_status = fw_download_code(dev, mapped_file, file_length);
|
2014-04-28 05:12:54 -06:00
|
|
|
if (rst_opt == OPT_SYSTEM_RESET)
|
2009-11-03 02:17:11 -07:00
|
|
|
release_firmware(fw_entry);
|
|
|
|
|
2015-03-13 13:21:31 -06:00
|
|
|
if (!rt_status)
|
2009-11-03 02:17:11 -07:00
|
|
|
goto download_firmware_fail;
|
|
|
|
|
2013-05-11 18:15:08 -06:00
|
|
|
switch (init_step) {
|
2012-12-05 13:40:22 -07:00
|
|
|
case FW_INIT_STEP0_BOOT:
|
|
|
|
/* Download boot
|
|
|
|
* initialize command descriptor.
|
|
|
|
* will set polling bit when firmware code is also configured
|
|
|
|
*/
|
|
|
|
pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
|
2015-02-19 22:54:10 -07:00
|
|
|
/* mdelay(1000); */
|
2012-12-05 13:40:22 -07:00
|
|
|
/*
|
|
|
|
* To initialize IMEM, CPU move code from 0x80000080,
|
|
|
|
* hence, we send 0x80 byte packet
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FW_INIT_STEP1_MAIN:
|
|
|
|
/* Download firmware code. Wait until Boot Ready and Turn on CPU */
|
|
|
|
pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE;
|
|
|
|
|
|
|
|
/* Check Put Code OK and Turn On CPU */
|
|
|
|
rt_status = CPUcheck_maincodeok_turnonCPU(dev);
|
2015-03-13 13:21:31 -06:00
|
|
|
if (!rt_status) {
|
2012-12-05 13:40:22 -07:00
|
|
|
RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
|
|
|
|
goto download_firmware_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FW_INIT_STEP2_DATA:
|
|
|
|
/* download initial data code */
|
|
|
|
pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE;
|
|
|
|
mdelay(1);
|
|
|
|
|
|
|
|
rt_status = CPUcheck_firmware_ready(dev);
|
2015-03-13 13:21:31 -06:00
|
|
|
if (!rt_status) {
|
2015-07-27 00:37:25 -06:00
|
|
|
RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n", rt_status);
|
2012-12-05 13:40:22 -07:00
|
|
|
goto download_firmware_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wait until data code is initialized ready.*/
|
|
|
|
pfirmware->firmware_status = FW_STATUS_5_READY;
|
|
|
|
break;
|
2009-11-03 02:17:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n");
|
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
download_firmware_fail:
|
2014-05-23 23:13:20 -06:00
|
|
|
RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
|
2015-02-27 16:14:34 -07:00
|
|
|
rt_status = false;
|
2009-11-03 02:17:11 -07:00
|
|
|
return rt_status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-08-02 14:17:25 -06:00
|
|
|
MODULE_FIRMWARE("RTL8192U/boot.img");
|
|
|
|
MODULE_FIRMWARE("RTL8192U/main.img");
|
|
|
|
MODULE_FIRMWARE("RTL8192U/data.img");
|