Commit a66edaaf authored by Hayes Wang's avatar Hayes Wang Committed by Jakub Kicinski

r8152: rename fw_type_1 with fw_mac

The struct fw_type_1 is used by MAC only, so rename it to a meaningful one.

Besides, adjust two messages. Replace "load xxx fail" with "check xxx fail"
Signed-off-by: default avatarHayes Wang <hayeswang@realtek.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent 39438490
...@@ -867,11 +867,11 @@ struct fw_header { ...@@ -867,11 +867,11 @@ struct fw_header {
} __packed; } __packed;
/** /**
* struct fw_type_1 - a firmware block used by RTL_FW_PLA and RTL_FW_USB. * struct fw_mac - a firmware block used by RTL_FW_PLA and RTL_FW_USB.
* The layout of the firmware block is: * The layout of the firmware block is:
* <struct fw_type_1> + <info> + <firmware data>. * <struct fw_mac> + <info> + <firmware data>.
* @fw_offset: offset of the firmware binary data. The start address of * @fw_offset: offset of the firmware binary data. The start address of
* the data would be the address of struct fw_type_1 + @fw_offset. * the data would be the address of struct fw_mac + @fw_offset.
* @fw_reg: the register to load the firmware. Depends on chip. * @fw_reg: the register to load the firmware. Depends on chip.
* @bp_ba_addr: the register to write break point base address. Depends on * @bp_ba_addr: the register to write break point base address. Depends on
* chip. * chip.
...@@ -888,7 +888,7 @@ struct fw_header { ...@@ -888,7 +888,7 @@ struct fw_header {
* @info: additional information for debugging, and is followed by the * @info: additional information for debugging, and is followed by the
* binary data of firmware. * binary data of firmware.
*/ */
struct fw_type_1 { struct fw_mac {
struct fw_block blk_hdr; struct fw_block blk_hdr;
__le16 fw_offset; __le16 fw_offset;
__le16 fw_reg; __le16 fw_reg;
...@@ -3397,14 +3397,14 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type) ...@@ -3397,14 +3397,14 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
ocp_write_word(tp, type, PLA_BP_BA, 0); ocp_write_word(tp, type, PLA_BP_BA, 0);
} }
static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1) static bool rtl8152_is_fw_mac_ok(struct r8152 *tp, struct fw_mac *mac)
{ {
u16 fw_reg, bp_ba_addr, bp_en_addr, bp_start; u16 fw_reg, bp_ba_addr, bp_en_addr, bp_start;
bool rc = false; bool rc = false;
u32 length, type; u32 length, type;
int i, max_bp; int i, max_bp;
type = __le32_to_cpu(type1->blk_hdr.type); type = __le32_to_cpu(mac->blk_hdr.type);
if (type == RTL_FW_PLA) { if (type == RTL_FW_PLA) {
switch (tp->version) { switch (tp->version) {
case RTL_VER_01: case RTL_VER_01:
...@@ -3461,46 +3461,46 @@ static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1) ...@@ -3461,46 +3461,46 @@ static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1)
goto out; goto out;
} }
length = __le32_to_cpu(type1->blk_hdr.length); length = __le32_to_cpu(mac->blk_hdr.length);
if (length < __le16_to_cpu(type1->fw_offset)) { if (length < __le16_to_cpu(mac->fw_offset)) {
dev_err(&tp->intf->dev, "invalid fw_offset\n"); dev_err(&tp->intf->dev, "invalid fw_offset\n");
goto out; goto out;
} }
length -= __le16_to_cpu(type1->fw_offset); length -= __le16_to_cpu(mac->fw_offset);
if (length < 4 || (length & 3)) { if (length < 4 || (length & 3)) {
dev_err(&tp->intf->dev, "invalid block length\n"); dev_err(&tp->intf->dev, "invalid block length\n");
goto out; goto out;
} }
if (__le16_to_cpu(type1->fw_reg) != fw_reg) { if (__le16_to_cpu(mac->fw_reg) != fw_reg) {
dev_err(&tp->intf->dev, "invalid register to load firmware\n"); dev_err(&tp->intf->dev, "invalid register to load firmware\n");
goto out; goto out;
} }
if (__le16_to_cpu(type1->bp_ba_addr) != bp_ba_addr) { if (__le16_to_cpu(mac->bp_ba_addr) != bp_ba_addr) {
dev_err(&tp->intf->dev, "invalid base address register\n"); dev_err(&tp->intf->dev, "invalid base address register\n");
goto out; goto out;
} }
if (__le16_to_cpu(type1->bp_en_addr) != bp_en_addr) { if (__le16_to_cpu(mac->bp_en_addr) != bp_en_addr) {
dev_err(&tp->intf->dev, "invalid enabled mask register\n"); dev_err(&tp->intf->dev, "invalid enabled mask register\n");
goto out; goto out;
} }
if (__le16_to_cpu(type1->bp_start) != bp_start) { if (__le16_to_cpu(mac->bp_start) != bp_start) {
dev_err(&tp->intf->dev, dev_err(&tp->intf->dev,
"invalid start register of break point\n"); "invalid start register of break point\n");
goto out; goto out;
} }
if (__le16_to_cpu(type1->bp_num) > max_bp) { if (__le16_to_cpu(mac->bp_num) > max_bp) {
dev_err(&tp->intf->dev, "invalid break point number\n"); dev_err(&tp->intf->dev, "invalid break point number\n");
goto out; goto out;
} }
for (i = __le16_to_cpu(type1->bp_num); i < max_bp; i++) { for (i = __le16_to_cpu(mac->bp_num); i < max_bp; i++) {
if (type1->bp[i]) { if (mac->bp[i]) {
dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i); dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i);
goto out; goto out;
} }
...@@ -3566,7 +3566,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw) ...@@ -3566,7 +3566,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
{ {
const struct firmware *fw = rtl_fw->fw; const struct firmware *fw = rtl_fw->fw;
struct fw_header *fw_hdr = (struct fw_header *)fw->data; struct fw_header *fw_hdr = (struct fw_header *)fw->data;
struct fw_type_1 *pla = NULL, *usb = NULL; struct fw_mac *pla = NULL, *usb = NULL;
long ret = -EFAULT; long ret = -EFAULT;
int i; int i;
...@@ -3601,10 +3601,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw) ...@@ -3601,10 +3601,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
goto fail; goto fail;
} }
pla = (struct fw_type_1 *)block; pla = (struct fw_mac *)block;
if (!rtl8152_is_fw_type1_ok(tp, pla)) { if (!rtl8152_is_fw_mac_ok(tp, pla)) {
dev_err(&tp->intf->dev, dev_err(&tp->intf->dev,
"load PLA firmware failed\n"); "check PLA firmware failed\n");
goto fail; goto fail;
} }
break; break;
...@@ -3615,10 +3615,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw) ...@@ -3615,10 +3615,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
goto fail; goto fail;
} }
usb = (struct fw_type_1 *)block; usb = (struct fw_mac *)block;
if (!rtl8152_is_fw_type1_ok(tp, usb)) { if (!rtl8152_is_fw_mac_ok(tp, usb)) {
dev_err(&tp->intf->dev, dev_err(&tp->intf->dev,
"load USB firmware failed\n"); "check USB firmware failed\n");
goto fail; goto fail;
} }
break; break;
...@@ -3638,14 +3638,14 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw) ...@@ -3638,14 +3638,14 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
return ret; return ret;
} }
static void rtl8152_fw_type_1_apply(struct r8152 *tp, struct fw_type_1 *type1) static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
{ {
u16 bp_en_addr, bp_index, type, bp_num, fw_ver_reg; u16 bp_en_addr, bp_index, type, bp_num, fw_ver_reg;
u32 length; u32 length;
u8 *data; u8 *data;
int i; int i;
switch (__le32_to_cpu(type1->blk_hdr.type)) { switch (__le32_to_cpu(mac->blk_hdr.type)) {
case RTL_FW_PLA: case RTL_FW_PLA:
type = MCU_TYPE_PLA; type = MCU_TYPE_PLA;
break; break;
...@@ -3667,36 +3667,36 @@ static void rtl8152_fw_type_1_apply(struct r8152 *tp, struct fw_type_1 *type1) ...@@ -3667,36 +3667,36 @@ static void rtl8152_fw_type_1_apply(struct r8152 *tp, struct fw_type_1 *type1)
ocp_write_word(tp, MCU_TYPE_PLA, PLA_MACDBG_POST, DEBUG_LTSSM); ocp_write_word(tp, MCU_TYPE_PLA, PLA_MACDBG_POST, DEBUG_LTSSM);
} }
length = __le32_to_cpu(type1->blk_hdr.length); length = __le32_to_cpu(mac->blk_hdr.length);
length -= __le16_to_cpu(type1->fw_offset); length -= __le16_to_cpu(mac->fw_offset);
data = (u8 *)type1; data = (u8 *)mac;
data += __le16_to_cpu(type1->fw_offset); data += __le16_to_cpu(mac->fw_offset);
generic_ocp_write(tp, __le16_to_cpu(type1->fw_reg), 0xff, length, data, generic_ocp_write(tp, __le16_to_cpu(mac->fw_reg), 0xff, length, data,
type); type);
ocp_write_word(tp, type, __le16_to_cpu(type1->bp_ba_addr), ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
__le16_to_cpu(type1->bp_ba_value)); __le16_to_cpu(mac->bp_ba_value));
bp_index = __le16_to_cpu(type1->bp_start); bp_index = __le16_to_cpu(mac->bp_start);
bp_num = __le16_to_cpu(type1->bp_num); bp_num = __le16_to_cpu(mac->bp_num);
for (i = 0; i < bp_num; i++) { for (i = 0; i < bp_num; i++) {
ocp_write_word(tp, type, bp_index, __le16_to_cpu(type1->bp[i])); ocp_write_word(tp, type, bp_index, __le16_to_cpu(mac->bp[i]));
bp_index += 2; bp_index += 2;
} }
bp_en_addr = __le16_to_cpu(type1->bp_en_addr); bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
if (bp_en_addr) if (bp_en_addr)
ocp_write_word(tp, type, bp_en_addr, ocp_write_word(tp, type, bp_en_addr,
__le16_to_cpu(type1->bp_en_value)); __le16_to_cpu(mac->bp_en_value));
fw_ver_reg = __le16_to_cpu(type1->fw_ver_reg); fw_ver_reg = __le16_to_cpu(mac->fw_ver_reg);
if (fw_ver_reg) if (fw_ver_reg)
ocp_write_byte(tp, MCU_TYPE_USB, fw_ver_reg, ocp_write_byte(tp, MCU_TYPE_USB, fw_ver_reg,
type1->fw_ver_data); mac->fw_ver_data);
dev_dbg(&tp->intf->dev, "successfully applied %s\n", type1->info); dev_dbg(&tp->intf->dev, "successfully applied %s\n", mac->info);
} }
static void rtl8152_apply_firmware(struct r8152 *tp) static void rtl8152_apply_firmware(struct r8152 *tp)
...@@ -3720,7 +3720,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp) ...@@ -3720,7 +3720,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
goto post_fw; goto post_fw;
case RTL_FW_PLA: case RTL_FW_PLA:
case RTL_FW_USB: case RTL_FW_USB:
rtl8152_fw_type_1_apply(tp, (struct fw_type_1 *)block); rtl8152_fw_mac_apply(tp, (struct fw_mac *)block);
break; break;
default: default:
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment