Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2024 Realtek Corporation. All rights reserved
3 : : */
4 : :
5 : : #include "../r8169_ethdev.h"
6 : : #include "../r8169_hw.h"
7 : : #include "../r8169_phy.h"
8 : : #include "rtl8125cp_mcu.h"
9 : :
10 : : /* For RTL8125CP, CFG_METHOD_58 */
11 : :
12 : : static void
13 : 0 : hw_init_rxcfg_8125cp(struct rtl_hw *hw)
14 : : {
15 : 0 : RTL_W32(hw, RxConfig, Rx_Fetch_Number_8 | Rx_Close_Multiple |
16 : : RxCfg_pause_slot_en | (RX_DMA_BURST_256 << RxCfgDMAShift));
17 : 0 : }
18 : :
19 : : static void
20 : 0 : hw_ephy_config_8125cp(struct rtl_hw *hw)
21 : : {
22 : : switch (hw->mcfg) {
23 : : case CFG_METHOD_58:
24 : : /* nothing to do */
25 : : break;
26 : : }
27 : 0 : }
28 : :
29 : : static void
30 : 0 : rtl_tgphy_irq_mask_and_ack(struct rtl_hw *hw)
31 : : {
32 [ # # ]: 0 : if (hw->mcfg == CFG_METHOD_58) {
33 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA4D2, 0x0000);
34 : 0 : (void)rtl_mdio_direct_read_phy_ocp(hw, 0xA4D4);
35 : : }
36 : 0 : }
37 : :
38 : : static void
39 : 0 : rtl_hw_phy_config_8125cp_1(struct rtl_hw *hw)
40 : : {
41 : 0 : rtl_tgphy_irq_mask_and_ack(hw);
42 : :
43 : 0 : rtl_set_eth_phy_ocp_bit(hw, 0xA442, BIT_11);
44 : :
45 : 0 : rtl_clear_and_set_eth_phy_ocp_bit(hw, 0xad0e, 0x007F, 0x000B);
46 : 0 : rtl_set_eth_phy_ocp_bit(hw, 0xad78, BIT_4);
47 : :
48 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xB87C, 0x807F);
49 : 0 : rtl_clear_and_set_eth_phy_ocp_bit(hw, 0xB87E, 0xFF00, 0x5300);
50 : :
51 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA436, 0x81B8);
52 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA438, 0x00B4);
53 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA436, 0x81BA);
54 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA438, 0x00E4);
55 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA436, 0x81C5);
56 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA438, 0x0104);
57 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA436, 0x81D0);
58 : 0 : rtl_mdio_direct_write_phy_ocp(hw, 0xA438, 0x054D);
59 : :
60 : 0 : rtl_set_eth_phy_ocp_bit(hw, 0xA430, BIT_1 | BIT_0);
61 : 0 : rtl_set_eth_phy_ocp_bit(hw, 0xA442, BIT_7);
62 : 0 : rtl_clear_eth_phy_ocp_bit(hw, 0xA430, BIT_12);
63 : 0 : }
64 : :
65 : : static void
66 : 0 : hw_phy_config_8125cp(struct rtl_hw *hw)
67 : : {
68 [ # # ]: 0 : switch (hw->mcfg) {
69 : 0 : case CFG_METHOD_58:
70 : 0 : rtl_hw_phy_config_8125cp_1(hw);
71 : 0 : break;
72 : : }
73 : 0 : }
74 : :
75 : : static void
76 : 0 : hw_mac_mcu_config_8125cp(struct rtl_hw *hw)
77 : : {
78 [ # # ]: 0 : if (hw->NotWrMcuPatchCode)
79 : : return;
80 : :
81 : 0 : rtl_hw_disable_mac_mcu_bps(hw);
82 : :
83 : : /* Get H/W mac mcu patch code version */
84 : 0 : hw->hw_mcu_patch_code_ver = rtl_get_hw_mcu_patch_code_ver(hw);
85 : :
86 [ # # ]: 0 : switch (hw->mcfg) {
87 : 0 : case CFG_METHOD_58:
88 : 0 : rtl_set_mac_mcu_8125cp_1(hw);
89 : 0 : break;
90 : : }
91 : : }
92 : :
93 : : static void
94 : 0 : hw_phy_mcu_config_8125cp(struct rtl_hw *hw)
95 : : {
96 [ # # ]: 0 : switch (hw->mcfg) {
97 : 0 : case CFG_METHOD_58:
98 : 0 : rtl_set_phy_mcu_8125cp_1(hw);
99 : 0 : break;
100 : : }
101 : 0 : }
102 : :
103 : : const struct rtl_hw_ops rtl8125cp_ops = {
104 : : .hw_init_rxcfg = hw_init_rxcfg_8125cp,
105 : : .hw_ephy_config = hw_ephy_config_8125cp,
106 : : .hw_phy_config = hw_phy_config_8125cp,
107 : : .hw_mac_mcu_config = hw_mac_mcu_config_8125cp,
108 : : .hw_phy_mcu_config = hw_phy_mcu_config_8125cp,
109 : : };
|