LCOV - code coverage report
Current view: top level - drivers/net/r8169/base - rtl8168h.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 276 0.0 %
Date: 2025-08-01 17:49:26 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 30 0.0 %

           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_compat.h"
       6                 :            : #include "../r8169_hw.h"
       7                 :            : #include "../r8169_phy.h"
       8                 :            : #include "rtl8168h.h"
       9                 :            : 
      10                 :            : /* For RTL8168H, CFG_METHOD_29,30,35,36 */
      11                 :            : 
      12                 :            : void
      13                 :          0 : hw_init_rxcfg_8168h(struct rtl_hw *hw)
      14                 :            : {
      15                 :          0 :         RTL_W32(hw, RxConfig, Rx_Single_fetch_V2 |
      16                 :            :                 (RX_DMA_BURST_unlimited << RxCfgDMAShift) | RxEarly_off_V2);
      17                 :          0 : }
      18                 :            : 
      19                 :            : void
      20                 :          0 : hw_ephy_config_8168h(struct rtl_hw *hw)
      21                 :            : {
      22   [ #  #  #  # ]:          0 :         switch (hw->mcfg) {
      23                 :          0 :         case CFG_METHOD_29:
      24                 :            :         case CFG_METHOD_30:
      25                 :            :         case CFG_METHOD_37:
      26                 :          0 :                 rtl_clear_pcie_phy_bit(hw, 0x1E, BIT_11);
      27                 :            : 
      28                 :          0 :                 rtl_set_pcie_phy_bit(hw, 0x1E, BIT_0);
      29                 :          0 :                 rtl_set_pcie_phy_bit(hw, 0x1D, BIT_11);
      30                 :            : 
      31                 :          0 :                 rtl_ephy_write(hw, 0x05, 0x2089);
      32                 :          0 :                 rtl_ephy_write(hw, 0x06, 0x5881);
      33                 :            : 
      34                 :          0 :                 rtl_ephy_write(hw, 0x04, 0x854A);
      35                 :          0 :                 rtl_ephy_write(hw, 0x01, 0x068B);
      36                 :            : 
      37                 :          0 :                 break;
      38                 :          0 :         case CFG_METHOD_35:
      39                 :          0 :                 rtl8168_clear_mcu_ocp_bit(hw, 0xD438, BIT_2);
      40                 :            : 
      41                 :          0 :                 rtl_clear_pcie_phy_bit(hw, 0x24, BIT_9);
      42                 :            : 
      43                 :          0 :                 rtl8168_clear_mcu_ocp_bit(hw, 0xDE28, (BIT_1 | BIT_0));
      44                 :            : 
      45                 :          0 :                 rtl8168_set_mcu_ocp_bit(hw, 0xD438, BIT_2);
      46                 :            : 
      47                 :          0 :                 break;
      48                 :          0 :         case CFG_METHOD_36:
      49                 :          0 :                 rtl8168_clear_mcu_ocp_bit(hw, 0xD438, BIT_2);
      50                 :            : 
      51                 :          0 :                 rtl8168_clear_mcu_ocp_bit(hw, 0xDE28, (BIT_1 | BIT_0));
      52                 :            : 
      53                 :          0 :                 rtl8168_set_mcu_ocp_bit(hw, 0xD438, BIT_2);
      54                 :            : 
      55                 :          0 :                 break;
      56                 :            :         default:
      57                 :            :                 break;
      58                 :            :         }
      59                 :          0 : }
      60                 :            : 
      61                 :            : static int
      62                 :          0 : rtl8168h_require_adc_bias_patch_check(struct rtl_hw *hw, u16 *offset)
      63                 :            : {
      64                 :            :         int ret;
      65                 :            :         u16 ioffset_p3, ioffset_p2, ioffset_p1, ioffset_p0;
      66                 :            :         u16 tmp_ushort;
      67                 :            : 
      68                 :          0 :         rtl_mac_ocp_write(hw, 0xDD02, 0x807D);
      69                 :          0 :         tmp_ushort = rtl_mac_ocp_read(hw, 0xDD02);
      70                 :          0 :         ioffset_p3 = ((tmp_ushort & BIT_7) >> 7);
      71                 :          0 :         ioffset_p3 <<= 3;
      72                 :          0 :         tmp_ushort = rtl_mac_ocp_read(hw, 0xDD00);
      73                 :            : 
      74                 :          0 :         ioffset_p3 |= ((tmp_ushort & (BIT_15 | BIT_14 | BIT_13)) >> 13);
      75                 :            : 
      76                 :          0 :         ioffset_p2 = ((tmp_ushort & (BIT_12 | BIT_11 | BIT_10 | BIT_9)) >> 9);
      77                 :          0 :         ioffset_p1 = ((tmp_ushort & (BIT_8 | BIT_7 | BIT_6 | BIT_5)) >> 5);
      78                 :            : 
      79                 :          0 :         ioffset_p0 = ((tmp_ushort & BIT_4) >> 4);
      80                 :          0 :         ioffset_p0 <<= 3;
      81                 :          0 :         ioffset_p0 |= (tmp_ushort & (BIT_2 | BIT_1 | BIT_0));
      82                 :            : 
      83         [ #  # ]:          0 :         if (ioffset_p3 == 0x0F && ioffset_p2 == 0x0F && ioffset_p1 == 0x0F &&
      84         [ #  # ]:          0 :             ioffset_p0 == 0x0F) {
      85                 :            :                 ret = FALSE;
      86                 :            :         } else {
      87                 :            :                 ret = TRUE;
      88                 :          0 :                 *offset = (ioffset_p3 << 12) | (ioffset_p2 << 8) |
      89                 :          0 :                            (ioffset_p1 << 4) | ioffset_p0;
      90                 :            :         }
      91                 :            : 
      92                 :          0 :         return ret;
      93                 :            : }
      94                 :            : 
      95                 :            : static void
      96                 :          0 : hw_phy_config_8168h_1(struct rtl_hw *hw)
      97                 :            : {
      98                 :            :         u16 dout_tapbin;
      99                 :            :         u16 gphy_val;
     100                 :            : 
     101                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     102                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809b);
     103                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xF800, 0x8000);
     104                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80A2);
     105                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x8000);
     106                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80A4);
     107                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x8500);
     108                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809C);
     109                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0xbd00);
     110                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     111                 :            : 
     112                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     113                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80AD);
     114                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xF800, 0x7000);
     115                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80B4);
     116                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x5000);
     117                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80AC);
     118                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x4000);
     119                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     120                 :            : 
     121                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     122                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808E);
     123                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x1200);
     124                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8090);
     125                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0xE500);
     126                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8092);
     127                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x9F00);
     128                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     129                 :            : 
     130         [ #  # ]:          0 :         if (HW_HAS_WRITE_PHY_MCU_RAM_CODE(hw)) {
     131                 :            :                 dout_tapbin = 0x0000;
     132                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A46);
     133                 :          0 :                 gphy_val = rtl_mdio_read(hw, 0x13);
     134                 :            :                 gphy_val &= (BIT_1 | BIT_0);
     135                 :          0 :                 gphy_val <<= 2;
     136                 :            :                 dout_tapbin |= gphy_val;
     137                 :            : 
     138                 :          0 :                 gphy_val = rtl_mdio_read(hw, 0x12);
     139                 :            :                 gphy_val &= (BIT_15 | BIT_14);
     140                 :            :                 gphy_val >>= 14;
     141                 :          0 :                 dout_tapbin |= gphy_val;
     142                 :            : 
     143                 :            :                 dout_tapbin = ~(dout_tapbin ^ BIT_3);
     144                 :          0 :                 dout_tapbin <<= 12;
     145                 :            :                 dout_tapbin &= 0xF000;
     146                 :            : 
     147                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A43);
     148                 :            : 
     149                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x827A);
     150                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     151                 :            :                                               (BIT_15 | BIT_14 | BIT_13 | BIT_12),
     152                 :            :                                               dout_tapbin);
     153                 :            : 
     154                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x827B);
     155                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     156                 :            :                                               (BIT_15 | BIT_14 | BIT_13 | BIT_12),
     157                 :            :                                               dout_tapbin);
     158                 :            : 
     159                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x827C);
     160                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     161                 :            :                                               (BIT_15 | BIT_14 | BIT_13 | BIT_12),
     162                 :            :                                               dout_tapbin);
     163                 :            : 
     164                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x827D);
     165                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     166                 :            :                                               (BIT_15 | BIT_14 | BIT_13 | BIT_12),
     167                 :            :                                               dout_tapbin);
     168                 :            : 
     169                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A43);
     170                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x8011);
     171                 :          0 :                 rtl_set_eth_phy_bit(hw, 0x14, BIT_11);
     172                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A42);
     173                 :          0 :                 rtl_set_eth_phy_bit(hw, 0x16, BIT_1);
     174                 :            :         }
     175                 :            : 
     176                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A44);
     177                 :          0 :         rtl_set_eth_phy_bit(hw, 0x11, BIT_11);
     178                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     179                 :            : 
     180                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0BCA);
     181                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x17, (BIT_13 | BIT_12), BIT_14);
     182                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     183                 :            : 
     184                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     185                 :          0 :         rtl_mdio_write(hw, 0x13, 0x803F);
     186                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     187                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8047);
     188                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     189                 :          0 :         rtl_mdio_write(hw, 0x13, 0x804F);
     190                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     191                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8057);
     192                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     193                 :          0 :         rtl_mdio_write(hw, 0x13, 0x805F);
     194                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     195                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8067);
     196                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     197                 :          0 :         rtl_mdio_write(hw, 0x13, 0x806F);
     198                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x14, (BIT_13 | BIT_12));
     199                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     200                 :          0 : }
     201                 :            : 
     202                 :            : static void
     203                 :          0 : hw_phy_config_8168h_2(struct rtl_hw *hw)
     204                 :            : {
     205                 :            :         u16 gphy_val;
     206                 :            :         u16 offset;
     207                 :            :         u16 rlen;
     208                 :            : 
     209                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     210                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808A);
     211                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     212                 :            :                                       (BIT_5 | BIT_4 | BIT_3 | BIT_2 | BIT_1 | BIT_0),
     213                 :            :                                       0x0A);
     214                 :            : 
     215         [ #  # ]:          0 :         if (HW_HAS_WRITE_PHY_MCU_RAM_CODE(hw)) {
     216                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A43);
     217                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x8011);
     218                 :          0 :                 rtl_set_eth_phy_bit(hw, 0x14, BIT_11);
     219                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A42);
     220                 :          0 :                 rtl_set_eth_phy_bit(hw, 0x16, BIT_1);
     221                 :            :         }
     222                 :            : 
     223                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A44);
     224                 :          0 :         rtl_set_eth_phy_bit(hw, 0x11, BIT_11);
     225                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     226                 :            : 
     227         [ #  # ]:          0 :         if (rtl8168h_require_adc_bias_patch_check(hw, &offset)) {
     228                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0BCF);
     229                 :          0 :                 rtl_mdio_write(hw, 0x16, offset);
     230                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0000);
     231                 :            :         }
     232                 :            : 
     233                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0BCD);
     234                 :          0 :         gphy_val = rtl_mdio_read(hw, 0x16);
     235                 :          0 :         gphy_val &= 0x000F;
     236                 :            : 
     237         [ #  # ]:          0 :         if (gphy_val > 3)
     238                 :          0 :                 rlen = gphy_val - 3;
     239                 :            :         else
     240                 :            :                 rlen = 0;
     241                 :            : 
     242                 :          0 :         gphy_val = rlen | (rlen << 4) | (rlen << 8) | (rlen << 12);
     243                 :            : 
     244                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0BCD);
     245                 :          0 :         rtl_mdio_write(hw, 0x17, gphy_val);
     246                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     247                 :            : 
     248         [ #  # ]:          0 :         if (HW_HAS_WRITE_PHY_MCU_RAM_CODE(hw)) {
     249                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A43);
     250                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x85FE);
     251                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14, (BIT_15 | BIT_14 |
     252                 :            :                                               BIT_13 | BIT_12 | BIT_11 | BIT_10 | BIT_8),
     253                 :            :                                               BIT_9);
     254                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x85FF);
     255                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     256                 :            :                                               (BIT_15 | BIT_14 | BIT_13 | BIT_12),
     257                 :            :                                               (BIT_11 | BIT_10 | BIT_9 | BIT_8));
     258                 :          0 :                 rtl_mdio_write(hw, 0x13, 0x814B);
     259                 :          0 :                 rtl_clear_and_set_eth_phy_bit(hw, 0x14,
     260                 :            :                                               (BIT_15 | BIT_14 | BIT_13 |
     261                 :            :                                               BIT_11 | BIT_10 | BIT_9 | BIT_8),
     262                 :            :                                               BIT_12);
     263                 :            :         }
     264                 :            : 
     265                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0C41);
     266                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x15, BIT_1);
     267                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     268                 :            : 
     269                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     270                 :          0 :         rtl_set_eth_phy_bit(hw, 0x10, BIT_0);
     271                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     272                 :          0 : }
     273                 :            : 
     274                 :            : static void
     275                 :          0 : hw_phy_config_8168h_3(struct rtl_hw *hw)
     276                 :            : {
     277                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A44);
     278                 :          0 :         rtl_set_eth_phy_bit(hw, 0x11, BIT_11);
     279                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     280                 :            : 
     281                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A4C);
     282                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x15, (BIT_14 | BIT_13));
     283                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     284                 :            : 
     285                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     286                 :          0 :         rtl_mdio_write(hw, 0x13, 0x81B9);
     287                 :          0 :         rtl_mdio_write(hw, 0x14, 0x2000);
     288                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     289                 :            : 
     290                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     291                 :          0 :         rtl_mdio_write(hw, 0x13, 0x81D4);
     292                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x6600);
     293                 :          0 :         rtl_mdio_write(hw, 0x13, 0x81CB);
     294                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x3500);
     295                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     296                 :            : 
     297                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A80);
     298                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x16, 0x000F, 0x0005);
     299                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     300                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8016);
     301                 :          0 :         rtl_set_eth_phy_bit(hw, 0x14, BIT_13);
     302                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     303                 :            : 
     304                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     305                 :          0 :         rtl_mdio_write(hw, 0x13, 0x811E);
     306                 :          0 :         rtl_mdio_write(hw, 0x14, 0xDECA);
     307                 :            : 
     308                 :          0 :         rtl_mdio_write(hw, 0x13, 0x811C);
     309                 :          0 :         rtl_mdio_write(hw, 0x14, 0x8008);
     310                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8118);
     311                 :          0 :         rtl_mdio_write(hw, 0x14, 0xF8B4);
     312                 :          0 :         rtl_mdio_write(hw, 0x13, 0x811A);
     313                 :          0 :         rtl_mdio_write(hw, 0x14, 0x1A04);
     314                 :            : 
     315                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8134);
     316                 :          0 :         rtl_mdio_write(hw, 0x14, 0xDECA);
     317                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8132);
     318                 :          0 :         rtl_mdio_write(hw, 0x14, 0xA008);
     319                 :          0 :         rtl_mdio_write(hw, 0x13, 0x812E);
     320                 :          0 :         rtl_mdio_write(hw, 0x14, 0x00B5);
     321                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8130);
     322                 :          0 :         rtl_mdio_write(hw, 0x14, 0x1A04);
     323                 :            : 
     324                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8112);
     325                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x7300);
     326                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8106);
     327                 :          0 :         rtl_mdio_write(hw, 0x14, 0xA209);
     328                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8108);
     329                 :          0 :         rtl_mdio_write(hw, 0x14, 0x13B0);
     330                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8103);
     331                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xF800, 0xB800);
     332                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8105);
     333                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x0A00);
     334                 :            : 
     335                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     336                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87EB);
     337                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0018);
     338                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87EB);
     339                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0018);
     340                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87ED);
     341                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0733);
     342                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87EF);
     343                 :          0 :         rtl_mdio_write(hw, 0x14, 0x08DC);
     344                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87F1);
     345                 :          0 :         rtl_mdio_write(hw, 0x14, 0x08DF);
     346                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87F3);
     347                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0C79);
     348                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87F5);
     349                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0D93);
     350                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87F9);
     351                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0010);
     352                 :          0 :         rtl_mdio_write(hw, 0x13, 0x87FB);
     353                 :          0 :         rtl_mdio_write(hw, 0x14, 0x0800);
     354                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8015);
     355                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x7000, 0x7000);
     356                 :            : 
     357                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
     358                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8111);
     359                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x7C00);
     360                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
     361                 :          0 : }
     362                 :            : 
     363                 :            : void
     364                 :          0 : hw_phy_config_8168h(struct rtl_hw *hw)
     365                 :            : {
     366         [ #  # ]:          0 :         if (hw->mcfg == CFG_METHOD_29)
     367                 :          0 :                 hw_phy_config_8168h_1(hw);
     368         [ #  # ]:          0 :         else if (hw->mcfg == CFG_METHOD_30 || hw->mcfg == CFG_METHOD_37)
     369                 :          0 :                 hw_phy_config_8168h_2(hw);
     370         [ #  # ]:          0 :         else if (hw->mcfg == CFG_METHOD_35)
     371                 :          0 :                 hw_phy_config_8168h_3(hw);
     372                 :            : 
     373                 :            :         /* Enable EthPhyPPSW */
     374         [ #  # ]:          0 :         if (hw->mcfg != CFG_METHOD_37) {
     375                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0A44);
     376                 :          0 :                 rtl_clear_eth_phy_bit(hw, 0x11, BIT_7);
     377                 :          0 :                 rtl_mdio_write(hw, 0x1F, 0x0000);
     378                 :            :         }
     379                 :          0 : }
     380                 :            : 
     381                 :            : void
     382                 :          0 : hw_config_8168h(struct rtl_hw *hw)
     383                 :            : {
     384                 :            :         u32 csi_tmp;
     385                 :            :         u16 mac_ocp_data;
     386                 :            : 
     387                 :            :         /* Share fifo rx params */
     388                 :          0 :         rtl_eri_write(hw, 0xC8, 4, 0x00080002, ERIAR_ExGMAC);
     389                 :          0 :         rtl_eri_write(hw, 0xCC, 1, 0x38, ERIAR_ExGMAC);
     390                 :          0 :         rtl_eri_write(hw, 0xD0, 1, 0x48, ERIAR_ExGMAC);
     391                 :          0 :         rtl_eri_write(hw, 0xE8, 4, 0x00100006, ERIAR_ExGMAC);
     392                 :            : 
     393                 :            :         /* Adjust the trx fifo*/
     394                 :          0 :         rtl_eri_write(hw, 0xCA, 2, 0x0370, ERIAR_ExGMAC);
     395                 :          0 :         rtl_eri_write(hw, 0xEA, 1, 0x10, ERIAR_ExGMAC);
     396                 :            : 
     397                 :            :         /* Disable share fifo */
     398                 :          0 :         RTL_W32(hw, TxConfig, RTL_R32(hw, TxConfig) & ~BIT_7);
     399                 :            : 
     400         [ #  # ]:          0 :         if (hw->mcfg == CFG_METHOD_35 || hw->mcfg == CFG_METHOD_36)
     401                 :          0 :                 rtl8168_set_mcu_ocp_bit(hw, 0xD438, (BIT_1 | BIT_0));
     402                 :            : 
     403                 :            :         /* EPHY err mask */
     404                 :          0 :         mac_ocp_data = rtl_mac_ocp_read(hw, 0xE0D6);
     405                 :          0 :         mac_ocp_data &= ~(BIT_8 | BIT_7 | BIT_6 | BIT_5 | BIT_4 | BIT_3 |
     406                 :            :                           BIT_2 | BIT_1 | BIT_0);
     407                 :          0 :         mac_ocp_data |= 0x17F;
     408                 :          0 :         rtl_mac_ocp_write(hw, 0xE0D6, mac_ocp_data);
     409                 :            : 
     410                 :          0 :         RTL_W8(hw, Config3, RTL_R8(hw, Config3) & ~Beacon_en);
     411                 :            : 
     412                 :            :         /* EEE led enable */
     413                 :          0 :         RTL_W8(hw, 0x1B, RTL_R8(hw, 0x1B) & ~0x07);
     414                 :            : 
     415                 :          0 :         RTL_W8(hw, Config2, RTL_R8(hw, Config2) & ~PMSTS_En);
     416                 :            : 
     417                 :          0 :         csi_tmp = rtl_eri_read(hw, 0xDC, 4, ERIAR_ExGMAC);
     418                 :          0 :         csi_tmp |= (BIT_2 | BIT_3 | BIT_4);
     419                 :          0 :         rtl_eri_write(hw, 0xDC, 4, csi_tmp, ERIAR_ExGMAC);
     420                 :            : 
     421                 :            :         /* CRC wake disable */
     422                 :          0 :         rtl_mac_ocp_write(hw, 0xC140, 0xFFFF);
     423                 :          0 :         rtl_mac_ocp_write(hw, 0xC142, 0xFFFF);
     424                 :            : 
     425                 :          0 :         csi_tmp = rtl_eri_read(hw, 0x1B0, 4, ERIAR_ExGMAC);
     426                 :          0 :         csi_tmp &= ~BIT_12;
     427                 :          0 :         rtl_eri_write(hw, 0x1B0, 4, csi_tmp, ERIAR_ExGMAC);
     428                 :            : 
     429                 :          0 :         csi_tmp = rtl_eri_read(hw, 0x2FC, 1, ERIAR_ExGMAC);
     430                 :          0 :         csi_tmp &= ~BIT_2;
     431                 :          0 :         rtl_eri_write(hw, 0x2FC, 1, csi_tmp, ERIAR_ExGMAC);
     432                 :            : 
     433         [ #  # ]:          0 :         if (hw->mcfg != CFG_METHOD_37) {
     434                 :          0 :                 csi_tmp = rtl_eri_read(hw, 0x1D0, 1, ERIAR_ExGMAC);
     435                 :          0 :                 csi_tmp |= BIT_1;
     436                 :          0 :                 rtl_eri_write(hw, 0x1D0, 1, csi_tmp, ERIAR_ExGMAC);
     437                 :            :         }
     438                 :          0 : }
     439                 :            : 
     440                 :            : const struct rtl_hw_ops rtl8168h_ops = {
     441                 :            :         .hw_config         = hw_config_8168h,
     442                 :            :         .hw_init_rxcfg     = hw_init_rxcfg_8168h,
     443                 :            :         .hw_ephy_config    = hw_ephy_config_8168h,
     444                 :            :         .hw_phy_config     = hw_phy_config_8168h,
     445                 :            :         .hw_mac_mcu_config = hw_mac_mcu_config_8168h,
     446                 :            :         .hw_phy_mcu_config = hw_phy_mcu_config_8168h,
     447                 :            : };

Generated by: LCOV version 1.14