All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] r8152: PHY firmware
@ 2019-10-21  3:41 Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac Hayes Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Hayes Wang @ 2019-10-21  3:41 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, pmalani, grundler, Hayes Wang

Support loading the firmware of the PHY with the type of RTL_FW_PHY_NC.

Hayes Wang (4):
  r8152: rename fw_type_1 with fw_mac
  r8152: add checking fw_offset field of struct fw_mac
  r8152: move r8153_patch_request forward
  r8152: support firmware of PHY NC for RTL8153A

 drivers/net/usb/r8152.c | 428 +++++++++++++++++++++++++++++++++-------
 1 file changed, 357 insertions(+), 71 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac
  2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
@ 2019-10-21  3:41 ` Hayes Wang
  2019-10-28 16:48   ` Grant Grundler
  2019-10-21  3:41 ` [PATCH net-next 2/4] r8152: add checking fw_offset field of struct fw_mac Hayes Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Hayes Wang @ 2019-10-21  3:41 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, pmalani, grundler, Hayes Wang

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: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 82 ++++++++++++++++++++---------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 55d0bcb00aef..55a7674a0c06 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -867,11 +867,11 @@ struct fw_header {
 } __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:
- *	<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
- *	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.
  * @bp_ba_addr: the register to write break point base address. Depends on
  *	chip.
@@ -888,7 +888,7 @@ struct fw_header {
  * @info: additional information for debugging, and is followed by the
  *	binary data of firmware.
  */
-struct fw_type_1 {
+struct fw_mac {
 	struct fw_block blk_hdr;
 	__le16 fw_offset;
 	__le16 fw_reg;
@@ -3397,14 +3397,14 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
 	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;
 	bool rc = false;
 	u32 length, type;
 	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) {
 		switch (tp->version) {
 		case RTL_VER_01:
@@ -3461,46 +3461,46 @@ static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1)
 		goto out;
 	}
 
-	length = __le32_to_cpu(type1->blk_hdr.length);
-	if (length < __le16_to_cpu(type1->fw_offset)) {
+	length = __le32_to_cpu(mac->blk_hdr.length);
+	if (length < __le16_to_cpu(mac->fw_offset)) {
 		dev_err(&tp->intf->dev, "invalid fw_offset\n");
 		goto out;
 	}
 
-	length -= __le16_to_cpu(type1->fw_offset);
+	length -= __le16_to_cpu(mac->fw_offset);
 	if (length < 4 || (length & 3)) {
 		dev_err(&tp->intf->dev, "invalid block length\n");
 		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");
 		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");
 		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");
 		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,
 			"invalid start register of break point\n");
 		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");
 		goto out;
 	}
 
-	for (i = __le16_to_cpu(type1->bp_num); i < max_bp; i++) {
-		if (type1->bp[i]) {
+	for (i = __le16_to_cpu(mac->bp_num); i < max_bp; i++) {
+		if (mac->bp[i]) {
 			dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i);
 			goto out;
 		}
@@ -3566,7 +3566,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 {
 	const struct firmware *fw = rtl_fw->fw;
 	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;
 	int i;
 
@@ -3601,10 +3601,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 				goto fail;
 			}
 
-			pla = (struct fw_type_1 *)block;
-			if (!rtl8152_is_fw_type1_ok(tp, pla)) {
+			pla = (struct fw_mac *)block;
+			if (!rtl8152_is_fw_mac_ok(tp, pla)) {
 				dev_err(&tp->intf->dev,
-					"load PLA firmware failed\n");
+					"check PLA firmware failed\n");
 				goto fail;
 			}
 			break;
@@ -3615,10 +3615,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 				goto fail;
 			}
 
-			usb = (struct fw_type_1 *)block;
-			if (!rtl8152_is_fw_type1_ok(tp, usb)) {
+			usb = (struct fw_mac *)block;
+			if (!rtl8152_is_fw_mac_ok(tp, usb)) {
 				dev_err(&tp->intf->dev,
-					"load USB firmware failed\n");
+					"check USB firmware failed\n");
 				goto fail;
 			}
 			break;
@@ -3638,14 +3638,14 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 	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;
 	u32 length;
 	u8 *data;
 	int i;
 
-	switch (__le32_to_cpu(type1->blk_hdr.type)) {
+	switch (__le32_to_cpu(mac->blk_hdr.type)) {
 	case RTL_FW_PLA:
 		type = MCU_TYPE_PLA;
 		break;
@@ -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);
 	}
 
-	length = __le32_to_cpu(type1->blk_hdr.length);
-	length -= __le16_to_cpu(type1->fw_offset);
+	length = __le32_to_cpu(mac->blk_hdr.length);
+	length -= __le16_to_cpu(mac->fw_offset);
 
-	data = (u8 *)type1;
-	data += __le16_to_cpu(type1->fw_offset);
+	data = (u8 *)mac;
+	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);
 
-	ocp_write_word(tp, type, __le16_to_cpu(type1->bp_ba_addr),
-		       __le16_to_cpu(type1->bp_ba_value));
+	ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
+		       __le16_to_cpu(mac->bp_ba_value));
 
-	bp_index = __le16_to_cpu(type1->bp_start);
-	bp_num = __le16_to_cpu(type1->bp_num);
+	bp_index = __le16_to_cpu(mac->bp_start);
+	bp_num = __le16_to_cpu(mac->bp_num);
 	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_en_addr = __le16_to_cpu(type1->bp_en_addr);
+	bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
 	if (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)
 		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)
@@ -3720,7 +3720,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
 			goto post_fw;
 		case RTL_FW_PLA:
 		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;
 		default:
 			break;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next 2/4] r8152: add checking fw_offset field of struct fw_mac
  2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac Hayes Wang
@ 2019-10-21  3:41 ` Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 3/4] r8152: move r8153_patch_request forward Hayes Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Hayes Wang @ 2019-10-21  3:41 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, pmalani, grundler, Hayes Wang

Make sure @fw_offset field of struct fw_mac is more than the size
of struct fw_mac.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 55a7674a0c06..090ddd5fb973 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3399,7 +3399,7 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
 
 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, fw_offset;
 	bool rc = false;
 	u32 length, type;
 	int i, max_bp;
@@ -3461,13 +3461,19 @@ static bool rtl8152_is_fw_mac_ok(struct r8152 *tp, struct fw_mac *mac)
 		goto out;
 	}
 
+	fw_offset = __le16_to_cpu(mac->fw_offset);
+	if (fw_offset < sizeof(*mac)) {
+		dev_err(&tp->intf->dev, "fw_offset too small\n");
+		goto out;
+	}
+
 	length = __le32_to_cpu(mac->blk_hdr.length);
-	if (length < __le16_to_cpu(mac->fw_offset)) {
+	if (length < fw_offset) {
 		dev_err(&tp->intf->dev, "invalid fw_offset\n");
 		goto out;
 	}
 
-	length -= __le16_to_cpu(mac->fw_offset);
+	length -= fw_offset;
 	if (length < 4 || (length & 3)) {
 		dev_err(&tp->intf->dev, "invalid block length\n");
 		goto out;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next 3/4] r8152: move r8153_patch_request forward
  2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 2/4] r8152: add checking fw_offset field of struct fw_mac Hayes Wang
@ 2019-10-21  3:41 ` Hayes Wang
  2019-10-21  3:41 ` [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A Hayes Wang
  2019-10-22 18:35 ` [PATCH net-next 0/4] r8152: PHY firmware Jakub Kicinski
  4 siblings, 0 replies; 9+ messages in thread
From: Hayes Wang @ 2019-10-21  3:41 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, pmalani, grundler, Hayes Wang

Move r8153_patch_request() forward for later patch.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 54 ++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 090ddd5fb973..ab57c672c4ca 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3397,6 +3397,33 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
 	ocp_write_word(tp, type, PLA_BP_BA, 0);
 }
 
+static int r8153_patch_request(struct r8152 *tp, bool request)
+{
+	u16 data;
+	int i;
+
+	data = ocp_reg_read(tp, OCP_PHY_PATCH_CMD);
+	if (request)
+		data |= PATCH_REQUEST;
+	else
+		data &= ~PATCH_REQUEST;
+	ocp_reg_write(tp, OCP_PHY_PATCH_CMD, data);
+
+	for (i = 0; request && i < 5000; i++) {
+		usleep_range(1000, 2000);
+		if (ocp_reg_read(tp, OCP_PHY_PATCH_STAT) & PATCH_READY)
+			break;
+	}
+
+	if (request && !(ocp_reg_read(tp, OCP_PHY_PATCH_STAT) & PATCH_READY)) {
+		netif_err(tp, drv, tp->netdev, "patch request fail\n");
+		r8153_patch_request(tp, false);
+		return -ETIME;
+	} else {
+		return 0;
+	}
+}
+
 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, fw_offset;
@@ -4056,33 +4083,6 @@ static void r8152b_enter_oob(struct r8152 *tp)
 	ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
 }
 
-static int r8153_patch_request(struct r8152 *tp, bool request)
-{
-	u16 data;
-	int i;
-
-	data = ocp_reg_read(tp, OCP_PHY_PATCH_CMD);
-	if (request)
-		data |= PATCH_REQUEST;
-	else
-		data &= ~PATCH_REQUEST;
-	ocp_reg_write(tp, OCP_PHY_PATCH_CMD, data);
-
-	for (i = 0; request && i < 5000; i++) {
-		usleep_range(1000, 2000);
-		if (ocp_reg_read(tp, OCP_PHY_PATCH_STAT) & PATCH_READY)
-			break;
-	}
-
-	if (request && !(ocp_reg_read(tp, OCP_PHY_PATCH_STAT) & PATCH_READY)) {
-		netif_err(tp, drv, tp->netdev, "patch request fail\n");
-		r8153_patch_request(tp, false);
-		return -ETIME;
-	} else {
-		return 0;
-	}
-}
-
 static int r8153_pre_firmware_1(struct r8152 *tp)
 {
 	int i;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A
  2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
                   ` (2 preceding siblings ...)
  2019-10-21  3:41 ` [PATCH net-next 3/4] r8152: move r8153_patch_request forward Hayes Wang
@ 2019-10-21  3:41 ` Hayes Wang
  2019-10-22  3:36   ` Jakub Kicinski
  2019-10-22 18:35 ` [PATCH net-next 0/4] r8152: PHY firmware Jakub Kicinski
  4 siblings, 1 reply; 9+ messages in thread
From: Hayes Wang @ 2019-10-21  3:41 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, pmalani, grundler, Hayes Wang

Support the firmware of PHY NC which is used to fix the issue found
for PHY. Currently, only RTL_VER_04, RTL_VER_05, and RTL_VER_06 need
it.

The order of loading PHY firmware would be

	RTL_FW_PHY_START
	RTL_FW_PHY_NC
	RTL_FW_PHY_STOP

The RTL_FW_PHY_START/RTL_FW_PHY_STOP are used to lock/unlock the PHY,
and set/clear the patch key from the firmware file.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 284 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 282 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ab57c672c4ca..d3c30ccc8577 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -187,6 +187,7 @@
 #define OCP_PHY_STATE		0xa708		/* nway state for 8153 */
 #define OCP_PHY_PATCH_STAT	0xb800
 #define OCP_PHY_PATCH_CMD	0xb820
+#define OCP_PHY_LOCK		0xb82e
 #define OCP_ADC_IOFFSET		0xbcfc
 #define OCP_ADC_CFG		0xbc06
 #define OCP_SYSCLK_CFG		0xc416
@@ -197,6 +198,7 @@
 #define SRAM_10M_AMP1		0x8080
 #define SRAM_10M_AMP2		0x8082
 #define SRAM_IMPEDANCE		0x8084
+#define SRAM_PHY_LOCK		0xb82e
 
 /* PLA_RCR */
 #define RCR_AAP			0x00000001
@@ -577,6 +579,9 @@ enum spd_duplex {
 /* OCP_PHY_PATCH_CMD */
 #define PATCH_REQUEST		BIT(4)
 
+/* OCP_PHY_LOCK */
+#define PATCH_LOCK		BIT(0)
+
 /* OCP_ADC_CFG */
 #define CKADSEL_L		0x0100
 #define ADC_EN			0x0080
@@ -601,6 +606,9 @@ enum spd_duplex {
 /* SRAM_IMPEDANCE */
 #define RX_DRIVING_MASK		0x6000
 
+/* SRAM_PHY_LOCK */
+#define PHY_PATCH_LOCK		0x0001
+
 /* MAC PASSTHRU */
 #define AD_MASK			0xfee0
 #define BND_MASK		0x0004
@@ -905,10 +913,65 @@ struct fw_mac {
 	char info[0];
 } __packed;
 
+/**
+ * struct fw_phy_patch_key - a firmware block used by RTL_FW_PHY_START.
+ *	This is used to set patch key when loading the firmware of PHY.
+ * @key_reg: the register to write the patch key.
+ * @key_data: patch key.
+ */
+struct fw_phy_patch_key {
+	struct fw_block blk_hdr;
+	__le16 key_reg;
+	__le16 key_data;
+	__le32 reserved;
+} __packed;
+
+/**
+ * struct fw_phy_nc - a firmware block used by RTL_FW_PHY_NC.
+ *	The layout of the firmware block is:
+ *	<struct fw_phy_nc> + <info> + <firmware data>.
+ * @fw_offset: offset of the firmware binary data. The start address of
+ *	the data would be the address of struct fw_phy_nc + @fw_offset.
+ * @fw_reg: the register to load the firmware. Depends on chip.
+ * @ba_reg: the register to write the base address. Depends on chip.
+ * @ba_data: base address. Depends on chip.
+ * @patch_en_addr: the register of enabling patch mode. Depends on chip.
+ * @patch_en_value: patch mode enabled mask. Depends on the firmware.
+ * @mode_reg: the regitster of switching the mode.
+ * @mod_pre: the mode needing to be set before loading the firmware.
+ * @mod_post: the mode to be set when finishing to load the firmware.
+ * @bp_start: the start register of break points. Depends on chip.
+ * @bp_num: the break point number which needs to be set for this firmware.
+ *	Depends on the firmware.
+ * @bp: break points. Depends on firmware.
+ * @info: additional information for debugging, and is followed by the
+ *	binary data of firmware.
+ */
+struct fw_phy_nc {
+	struct fw_block blk_hdr;
+	__le16 fw_offset;
+	__le16 fw_reg;
+	__le16 ba_reg;
+	__le16 ba_data;
+	__le16 patch_en_addr;
+	__le16 patch_en_value;
+	__le16 mode_reg;
+	__le16 mode_pre;
+	__le16 mode_post;
+	__le16 reserved;
+	__le16 bp_start;
+	__le16 bp_num;
+	__le16 bp[4];
+	char info[0];
+} __packed;
+
 enum rtl_fw_type {
 	RTL_FW_END = 0,
 	RTL_FW_PLA,
 	RTL_FW_USB,
+	RTL_FW_PHY_START,
+	RTL_FW_PHY_STOP,
+	RTL_FW_PHY_NC,
 };
 
 enum rtl_version {
@@ -3424,6 +3487,114 @@ static int r8153_patch_request(struct r8152 *tp, bool request)
 	}
 }
 
+static int r8153_pre_ram_code(struct r8152 *tp, u16 key_addr, u16 patch_key)
+{
+	if (r8153_patch_request(tp, true)) {
+		dev_err(&tp->intf->dev, "patch request fail\n");
+		return -ETIME;
+	}
+
+	sram_write(tp, key_addr, patch_key);
+	sram_write(tp, SRAM_PHY_LOCK, PHY_PATCH_LOCK);
+
+	return 0;
+}
+
+static int r8153_post_ram_code(struct r8152 *tp, u16 key_addr)
+{
+	u16 data;
+
+	sram_write(tp, 0x0000, 0x0000);
+
+	data = ocp_reg_read(tp, OCP_PHY_LOCK);
+	data &= ~PATCH_LOCK;
+	ocp_reg_write(tp, OCP_PHY_LOCK, data);
+
+	sram_write(tp, key_addr, 0x0000);
+
+	r8153_patch_request(tp, false);
+
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, tp->ocp_base);
+
+	return 0;
+}
+
+static bool rtl8152_is_fw_phy_nc_ok(struct r8152 *tp, struct fw_phy_nc *phy)
+{
+	u32 length;
+	u16 fw_offset, fw_reg, ba_reg, patch_en_addr, mode_reg, bp_start;
+	bool rc = false;
+
+	switch (tp->version) {
+	case RTL_VER_04:
+	case RTL_VER_05:
+	case RTL_VER_06:
+		fw_reg = 0xa014;
+		ba_reg = 0xa012;
+		patch_en_addr = 0xa01a;
+		mode_reg = 0xb820;
+		bp_start = 0xa000;
+		break;
+	default:
+		goto out;
+	}
+
+	fw_offset = __le16_to_cpu(phy->fw_offset);
+	if (fw_offset < sizeof(*phy)) {
+		dev_err(&tp->intf->dev, "fw_offset too small\n");
+		goto out;
+	}
+
+	length = __le32_to_cpu(phy->blk_hdr.length);
+	if (length < fw_offset) {
+		dev_err(&tp->intf->dev, "invalid fw_offset\n");
+		goto out;
+	}
+
+	length -= __le16_to_cpu(phy->fw_offset);
+	if (!length || (length & 1)) {
+		dev_err(&tp->intf->dev, "invalid block length\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->fw_reg) != fw_reg) {
+		dev_err(&tp->intf->dev, "invalid register to load firmware\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->ba_reg) != ba_reg) {
+		dev_err(&tp->intf->dev, "invalid base address register\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->patch_en_addr) != patch_en_addr) {
+		dev_err(&tp->intf->dev,
+			"invalid patch mode enabled register\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->mode_reg) != mode_reg) {
+		dev_err(&tp->intf->dev,
+			"invalid register to switch the mode\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->bp_start) != bp_start) {
+		dev_err(&tp->intf->dev,
+			"invalid start register of break point\n");
+		goto out;
+	}
+
+	if (__le16_to_cpu(phy->bp_num) > 4) {
+		dev_err(&tp->intf->dev, "invalid break point number\n");
+		goto out;
+	}
+
+	rc = true;
+out:
+	return rc;
+}
+
 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, fw_offset;
@@ -3600,6 +3771,9 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 	const struct firmware *fw = rtl_fw->fw;
 	struct fw_header *fw_hdr = (struct fw_header *)fw->data;
 	struct fw_mac *pla = NULL, *usb = NULL;
+	struct fw_phy_patch_key *start = NULL;
+	struct fw_phy_nc *phy_nc = NULL;
+	struct fw_block *stop = NULL;
 	long ret = -EFAULT;
 	int i;
 
@@ -3626,7 +3800,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 		case RTL_FW_END:
 			if (__le32_to_cpu(block->length) != sizeof(*block))
 				goto fail;
-			goto success;
+			goto fw_end;
 		case RTL_FW_PLA:
 			if (pla) {
 				dev_err(&tp->intf->dev,
@@ -3654,6 +3828,57 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 					"check USB firmware failed\n");
 				goto fail;
 			}
+			break;
+		case RTL_FW_PHY_START:
+			if (start || phy_nc || stop) {
+				dev_err(&tp->intf->dev,
+					"check PHY_START fail\n");
+				goto fail;
+			}
+
+			if (__le32_to_cpu(block->length) != sizeof(*start)) {
+				dev_err(&tp->intf->dev,
+					"Invalid length for PHY_START\n");
+				goto fail;
+			}
+
+			start = (struct fw_phy_patch_key *)block;
+			break;
+		case RTL_FW_PHY_STOP:
+			if (stop || !start) {
+				dev_err(&tp->intf->dev,
+					"Check PHY_STOP fail\n");
+				goto fail;
+			}
+
+			if (__le32_to_cpu(block->length) != sizeof(*block)) {
+				dev_err(&tp->intf->dev,
+					"Invalid length for PHY_STOP\n");
+				goto fail;
+			}
+
+			stop = block;
+			break;
+		case RTL_FW_PHY_NC:
+			if (!start || stop) {
+				dev_err(&tp->intf->dev,
+					"check PHY_NC fail\n");
+				goto fail;
+			}
+
+			if (phy_nc) {
+				dev_err(&tp->intf->dev,
+					"multiple PHY NC encountered\n");
+				goto fail;
+			}
+
+			phy_nc = (struct fw_phy_nc *)block;
+			if (!rtl8152_is_fw_phy_nc_ok(tp, phy_nc)) {
+				dev_err(&tp->intf->dev,
+					"check PHY NC firmware failed\n");
+				goto fail;
+			}
+
 			break;
 		default:
 			dev_warn(&tp->intf->dev, "Unknown type %u is found\n",
@@ -3665,12 +3890,52 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
 		i += ALIGN(__le32_to_cpu(block->length), 8);
 	}
 
-success:
+fw_end:
+	if ((phy_nc || start) && !stop) {
+		dev_err(&tp->intf->dev, "without PHY_STOP\n");
+		goto fail;
+	}
+
 	return 0;
 fail:
 	return ret;
 }
 
+static void rtl8152_fw_phy_nc_apply(struct r8152 *tp, struct fw_phy_nc *phy)
+{
+	u16 mode_reg, bp_index;
+	u32 length, i, num;
+	__le16 *data;
+
+	mode_reg = __le16_to_cpu(phy->mode_reg);
+	sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_pre));
+	sram_write(tp, __le16_to_cpu(phy->ba_reg),
+		   __le16_to_cpu(phy->ba_data));
+
+	length = __le32_to_cpu(phy->blk_hdr.length);
+	length -= __le16_to_cpu(phy->fw_offset);
+	num = length / 2;
+	data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset));
+
+	ocp_reg_write(tp, OCP_SRAM_ADDR, __le16_to_cpu(phy->fw_reg));
+	for (i = 0; i < num; i++)
+		ocp_reg_write(tp, OCP_SRAM_DATA, __le16_to_cpu(data[i]));
+
+	sram_write(tp, __le16_to_cpu(phy->patch_en_addr),
+		   __le16_to_cpu(phy->patch_en_value));
+
+	bp_index = __le16_to_cpu(phy->bp_start);
+	num = __le16_to_cpu(phy->bp_num);
+	for (i = 0; i < num; i++) {
+		sram_write(tp, bp_index, __le16_to_cpu(phy->bp[i]));
+		bp_index += 2;
+	}
+
+	sram_write(tp, mode_reg, __le16_to_cpu(phy->mode_post));
+
+	dev_dbg(&tp->intf->dev, "successfully applied %s\n", phy->info);
+}
+
 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;
@@ -3737,6 +4002,8 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
 	struct rtl_fw *rtl_fw = &tp->rtl_fw;
 	const struct firmware *fw = rtl_fw->fw;
 	struct fw_header *fw_hdr = (struct fw_header *)fw->data;
+	struct fw_phy_patch_key *key;
+	u16 key_addr = 0;
 	int i;
 
 	if (IS_ERR_OR_NULL(rtl_fw->fw))
@@ -3755,6 +4022,19 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
 		case RTL_FW_USB:
 			rtl8152_fw_mac_apply(tp, (struct fw_mac *)block);
 			break;
+		case RTL_FW_PHY_START:
+			key = (struct fw_phy_patch_key *)block;
+			key_addr = __le16_to_cpu(key->key_reg);
+			r8153_pre_ram_code(tp, key_addr,
+					   __le16_to_cpu(key->key_data));
+			break;
+		case RTL_FW_PHY_STOP:
+			WARN_ON(!key_addr);
+			r8153_post_ram_code(tp, key_addr);
+			break;
+		case RTL_FW_PHY_NC:
+			rtl8152_fw_phy_nc_apply(tp, (struct fw_phy_nc *)block);
+			break;
 		default:
 			break;
 		}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A
  2019-10-21  3:41 ` [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A Hayes Wang
@ 2019-10-22  3:36   ` Jakub Kicinski
  2019-10-22  5:56     ` Hayes Wang
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2019-10-22  3:36 UTC (permalink / raw)
  To: Hayes Wang; +Cc: netdev, nic_swsd, linux-kernel, pmalani, grundler

On Mon, 21 Oct 2019 11:41:13 +0800, Hayes Wang wrote:
> Support the firmware of PHY NC which is used to fix the issue found
> for PHY. Currently, only RTL_VER_04, RTL_VER_05, and RTL_VER_06 need
> it.
> 
> The order of loading PHY firmware would be
> 
> 	RTL_FW_PHY_START
> 	RTL_FW_PHY_NC

Perhaps that's obvious to others, but what's NC? :)

> 	RTL_FW_PHY_STOP
> 
> The RTL_FW_PHY_START/RTL_FW_PHY_STOP are used to lock/unlock the PHY,
> and set/clear the patch key from the firmware file.
> 
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A
  2019-10-22  3:36   ` Jakub Kicinski
@ 2019-10-22  5:56     ` Hayes Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Hayes Wang @ 2019-10-22  5:56 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, nic_swsd, linux-kernel, pmalani, grundler

Jakub Kicinski [mailto:jakub.kicinski@netronome.com]
> Sent: Tuesday, October 22, 2019 11:36 AM
> To: Hayes Wang
> Cc: netdev@vger.kernel.org; nic_swsd; linux-kernel@vger.kernel.org;
> pmalani@chromium.org; grundler@chromium.org
> Subject: Re: [PATCH net-next 4/4] r8152: support firmware of PHY NC for
> RTL8153A
> 
> On Mon, 21 Oct 2019 11:41:13 +0800, Hayes Wang wrote:
> > Support the firmware of PHY NC which is used to fix the issue found
> > for PHY. Currently, only RTL_VER_04, RTL_VER_05, and RTL_VER_06 need
> > it.
> >
> > The order of loading PHY firmware would be
> >
> > 	RTL_FW_PHY_START
> > 	RTL_FW_PHY_NC
> 
> Perhaps that's obvious to others, but what's NC? :)

The PHY has several micro controllers which deal with different features.
The NC is our internal name helping us to know which one is specified.

Best Regards,
Hayes



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 0/4] r8152: PHY firmware
  2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
                   ` (3 preceding siblings ...)
  2019-10-21  3:41 ` [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A Hayes Wang
@ 2019-10-22 18:35 ` Jakub Kicinski
  4 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2019-10-22 18:35 UTC (permalink / raw)
  To: Hayes Wang; +Cc: netdev, nic_swsd, linux-kernel, pmalani, grundler

On Mon, 21 Oct 2019 11:41:09 +0800, Hayes Wang wrote:
> Support loading the firmware of the PHY with the type of RTL_FW_PHY_NC.

Applied, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac
  2019-10-21  3:41 ` [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac Hayes Wang
@ 2019-10-28 16:48   ` Grant Grundler
  0 siblings, 0 replies; 9+ messages in thread
From: Grant Grundler @ 2019-10-28 16:48 UTC (permalink / raw)
  To: Hayes Wang; +Cc: netdev, nic_swsd, LKML, Prashant Malani, Grant Grundler

On Sun, Oct 20, 2019 at 8:41 PM Hayes Wang <hayeswang@realtek.com> wrote:
>
> 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: Hayes Wang <hayeswang@realtek.com>

Looks good to me.

Reviewed-by: Grant Grundler <grundler@chromium.org>

cheers,
grant

> ---
>  drivers/net/usb/r8152.c | 82 ++++++++++++++++++++---------------------
>  1 file changed, 41 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 55d0bcb00aef..55a7674a0c06 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -867,11 +867,11 @@ struct fw_header {
>  } __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:
> - *     <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
> - *     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.
>   * @bp_ba_addr: the register to write break point base address. Depends on
>   *     chip.
> @@ -888,7 +888,7 @@ struct fw_header {
>   * @info: additional information for debugging, and is followed by the
>   *     binary data of firmware.
>   */
> -struct fw_type_1 {
> +struct fw_mac {
>         struct fw_block blk_hdr;
>         __le16 fw_offset;
>         __le16 fw_reg;
> @@ -3397,14 +3397,14 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
>         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;
>         bool rc = false;
>         u32 length, type;
>         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) {
>                 switch (tp->version) {
>                 case RTL_VER_01:
> @@ -3461,46 +3461,46 @@ static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1)
>                 goto out;
>         }
>
> -       length = __le32_to_cpu(type1->blk_hdr.length);
> -       if (length < __le16_to_cpu(type1->fw_offset)) {
> +       length = __le32_to_cpu(mac->blk_hdr.length);
> +       if (length < __le16_to_cpu(mac->fw_offset)) {
>                 dev_err(&tp->intf->dev, "invalid fw_offset\n");
>                 goto out;
>         }
>
> -       length -= __le16_to_cpu(type1->fw_offset);
> +       length -= __le16_to_cpu(mac->fw_offset);
>         if (length < 4 || (length & 3)) {
>                 dev_err(&tp->intf->dev, "invalid block length\n");
>                 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");
>                 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");
>                 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");
>                 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,
>                         "invalid start register of break point\n");
>                 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");
>                 goto out;
>         }
>
> -       for (i = __le16_to_cpu(type1->bp_num); i < max_bp; i++) {
> -               if (type1->bp[i]) {
> +       for (i = __le16_to_cpu(mac->bp_num); i < max_bp; i++) {
> +               if (mac->bp[i]) {
>                         dev_err(&tp->intf->dev, "unused bp%u is not zero\n", i);
>                         goto out;
>                 }
> @@ -3566,7 +3566,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
>  {
>         const struct firmware *fw = rtl_fw->fw;
>         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;
>         int i;
>
> @@ -3601,10 +3601,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
>                                 goto fail;
>                         }
>
> -                       pla = (struct fw_type_1 *)block;
> -                       if (!rtl8152_is_fw_type1_ok(tp, pla)) {
> +                       pla = (struct fw_mac *)block;
> +                       if (!rtl8152_is_fw_mac_ok(tp, pla)) {
>                                 dev_err(&tp->intf->dev,
> -                                       "load PLA firmware failed\n");
> +                                       "check PLA firmware failed\n");
>                                 goto fail;
>                         }
>                         break;
> @@ -3615,10 +3615,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
>                                 goto fail;
>                         }
>
> -                       usb = (struct fw_type_1 *)block;
> -                       if (!rtl8152_is_fw_type1_ok(tp, usb)) {
> +                       usb = (struct fw_mac *)block;
> +                       if (!rtl8152_is_fw_mac_ok(tp, usb)) {
>                                 dev_err(&tp->intf->dev,
> -                                       "load USB firmware failed\n");
> +                                       "check USB firmware failed\n");
>                                 goto fail;
>                         }
>                         break;
> @@ -3638,14 +3638,14 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
>         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;
>         u32 length;
>         u8 *data;
>         int i;
>
> -       switch (__le32_to_cpu(type1->blk_hdr.type)) {
> +       switch (__le32_to_cpu(mac->blk_hdr.type)) {
>         case RTL_FW_PLA:
>                 type = MCU_TYPE_PLA;
>                 break;
> @@ -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);
>         }
>
> -       length = __le32_to_cpu(type1->blk_hdr.length);
> -       length -= __le16_to_cpu(type1->fw_offset);
> +       length = __le32_to_cpu(mac->blk_hdr.length);
> +       length -= __le16_to_cpu(mac->fw_offset);
>
> -       data = (u8 *)type1;
> -       data += __le16_to_cpu(type1->fw_offset);
> +       data = (u8 *)mac;
> +       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);
>
> -       ocp_write_word(tp, type, __le16_to_cpu(type1->bp_ba_addr),
> -                      __le16_to_cpu(type1->bp_ba_value));
> +       ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
> +                      __le16_to_cpu(mac->bp_ba_value));
>
> -       bp_index = __le16_to_cpu(type1->bp_start);
> -       bp_num = __le16_to_cpu(type1->bp_num);
> +       bp_index = __le16_to_cpu(mac->bp_start);
> +       bp_num = __le16_to_cpu(mac->bp_num);
>         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_en_addr = __le16_to_cpu(type1->bp_en_addr);
> +       bp_en_addr = __le16_to_cpu(mac->bp_en_addr);
>         if (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)
>                 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)
> @@ -3720,7 +3720,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
>                         goto post_fw;
>                 case RTL_FW_PLA:
>                 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;
>                 default:
>                         break;
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-28 16:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  3:41 [PATCH net-next 0/4] r8152: PHY firmware Hayes Wang
2019-10-21  3:41 ` [PATCH net-next 1/4] r8152: rename fw_type_1 with fw_mac Hayes Wang
2019-10-28 16:48   ` Grant Grundler
2019-10-21  3:41 ` [PATCH net-next 2/4] r8152: add checking fw_offset field of struct fw_mac Hayes Wang
2019-10-21  3:41 ` [PATCH net-next 3/4] r8152: move r8153_patch_request forward Hayes Wang
2019-10-21  3:41 ` [PATCH net-next 4/4] r8152: support firmware of PHY NC for RTL8153A Hayes Wang
2019-10-22  3:36   ` Jakub Kicinski
2019-10-22  5:56     ` Hayes Wang
2019-10-22 18:35 ` [PATCH net-next 0/4] r8152: PHY firmware Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.