[PATCH u-boot v2 3/4] eth/r8152: modify rtl_clear_bp function
Hayes Wang
hayeswang at realtek.com
Tue Jun 16 11:09:46 CEST 2020
The original rtl_clear_bp() is used to clear the firmware of both
PLA and USB MCU. The new one could clear the firmware of PLA or
USB independently. It is unnecessary to clear firmware, if there
is no one to be updated.
Besides, clear the firmware by writing the relative registers in
bulk.
Signed-off-by: Hayes Wang <hayeswang at realtek.com>
---
drivers/usb/eth/r8152.h | 13 ++-------
drivers/usb/eth/r8152_fw.c | 58 ++++++++++++++++++++++----------------
2 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/drivers/usb/eth/r8152.h b/drivers/usb/eth/r8152.h
index 4daf4ee87d..710637d7a2 100644
--- a/drivers/usb/eth/r8152.h
+++ b/drivers/usb/eth/r8152.h
@@ -95,16 +95,9 @@
#define USB_MISC_0 0xd81a
#define USB_AFE_CTRL2 0xd824
#define USB_WDT11_CTRL 0xe43c
-#define USB_BP_BA 0xfc26
-#define USB_BP_0 0xfc28
-#define USB_BP_1 0xfc2a
-#define USB_BP_2 0xfc2c
-#define USB_BP_3 0xfc2e
-#define USB_BP_4 0xfc30
-#define USB_BP_5 0xfc32
-#define USB_BP_6 0xfc34
-#define USB_BP_7 0xfc36
-#define USB_BP_EN 0xfc38
+#define USB_BP_BA PLA_BP_BA
+#define USB_BP(n) (0xfc28 + 2 * (n))
+#define USB_BP_EN PLA_BP_EN
/* OCP Registers */
#define OCP_ALDPS_CONFIG 0x2010
diff --git a/drivers/usb/eth/r8152_fw.c b/drivers/usb/eth/r8152_fw.c
index f953b0384b..2da1f221b4 100644
--- a/drivers/usb/eth/r8152_fw.c
+++ b/drivers/usb/eth/r8152_fw.c
@@ -729,28 +729,30 @@ static u16 r8153_pla_patch_d_bp[] = {
0xfc2e, 0x0000, 0xfc30, 0x0000, 0xfc32, 0x0000, 0xfc34, 0x0000,
0xfc36, 0x0000, 0xfc38, 0x0007 };
-static void rtl_clear_bp(struct r8152 *tp)
+static void rtl_clear_bp(struct r8152 *tp, u16 type)
{
- ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_0, 0);
- ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_2, 0);
- ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_4, 0);
- ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_6, 0);
- ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_0, 0);
- ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_2, 0);
- ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_4, 0);
- ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_6, 0);
+ u8 zeros[16] = {0};
+
+ switch (tp->version) {
+ case RTL_VER_01:
+ case RTL_VER_02:
+ case RTL_VER_07:
+ break;
+ case RTL_VER_03:
+ case RTL_VER_04:
+ case RTL_VER_05:
+ case RTL_VER_06:
+ ocp_write_byte(tp, type, PLA_BP_EN, 0);
+ break;
+ default:
+ break;
+ }
- mdelay(6);
+ generic_ocp_write(tp, USB_BP(0), 0xff, sizeof(zeros), zeros, type);
- ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_BA, 0);
- ocp_write_word(tp, MCU_TYPE_USB, USB_BP_BA, 0);
-}
+ mdelay(6);
-static void r8153_clear_bp(struct r8152 *tp)
-{
- ocp_write_byte(tp, MCU_TYPE_PLA, PLA_BP_EN, 0);
- ocp_write_byte(tp, MCU_TYPE_USB, USB_BP_EN, 0);
- rtl_clear_bp(tp);
+ ocp_write_word(tp, type, PLA_BP_BA, 0);
}
static void r8152b_set_dq_desc(struct r8152 *tp)
@@ -826,7 +828,7 @@ void r8152b_firmware(struct r8152 *tp)
int i;
r8152b_set_dq_desc(tp);
- rtl_clear_bp(tp);
+ rtl_clear_bp(tp, MCU_TYPE_PLA);
generic_ocp_write(tp, 0xf800, 0x3f,
sizeof(r8152b_pla_patch_a),
@@ -847,7 +849,7 @@ void r8152b_firmware(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_PLA, 0xb098, 0x0200);
ocp_write_word(tp, MCU_TYPE_PLA, 0xb092, 0x7030);
} else if (tp->version == RTL_VER_02) {
- rtl_clear_bp(tp);
+ rtl_clear_bp(tp, MCU_TYPE_PLA);
generic_ocp_write(tp, 0xf800, 0xff,
sizeof(r8152b_pla_patch_a2),
@@ -866,8 +868,6 @@ void r8153_firmware(struct r8152 *tp)
int i;
if (tp->version == RTL_VER_03) {
- r8153_clear_bp(tp);
-
r8153_pre_ram_code(tp, 0x7000);
for (i = 0; i < ARRAY_SIZE(r8153_ram_code_a); i += 2)
@@ -887,7 +887,8 @@ void r8153_firmware(struct r8152 *tp)
r8153_post_ram_code(tp);
r8153_wdt1_end(tp);
- r8153_clear_bp(tp);
+
+ rtl_clear_bp(tp, MCU_TYPE_USB);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff,
@@ -904,6 +905,8 @@ void r8153_firmware(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_PLA, 0xd38e, 0x0082);
}
+ rtl_clear_bp(tp, MCU_TYPE_PLA);
+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff,
sizeof(r8153_pla_patch_b),
@@ -932,7 +935,8 @@ void r8153_firmware(struct r8152 *tp)
r8153_post_ram_code(tp);
r8153_wdt1_end(tp);
- r8153_clear_bp(tp);
+
+ rtl_clear_bp(tp, MCU_TYPE_USB);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff,
@@ -951,6 +955,8 @@ void r8153_firmware(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_EN, 0x00ef);
}
+ rtl_clear_bp(tp, MCU_TYPE_PLA);
+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff,
sizeof(r8153_pla_patch_c),
@@ -985,7 +991,7 @@ void r8153_firmware(struct r8152 *tp)
r8153_post_ram_code(tp);
- r8153_clear_bp(tp);
+ rtl_clear_bp(tp, MCU_TYPE_USB);
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff, sizeof(usb_patch_d),
@@ -996,6 +1002,8 @@ void r8153_firmware(struct r8152 *tp)
r8153_usb_patch_d_bp[i],
r8153_usb_patch_d_bp[i+1]);
+ rtl_clear_bp(tp, MCU_TYPE_PLA);
+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x0000);
generic_ocp_write(tp, 0xf800, 0xff, sizeof(pla_patch_d),
pla_patch_d, MCU_TYPE_PLA);
--
2.21.1
More information about the U-Boot
mailing list