LCOV - code coverage report
Current view: top level - drivers/net/r8169/base - rtl8168fp.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 128 0.0 %
Date: 2025-07-01 21:32:37 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 10 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 "rtl8168fp.h"
       9                 :            : 
      10                 :            : /* For RTL8168FP, CFG_METHOD_31,32,33,34 */
      11                 :            : 
      12                 :            : static void
      13                 :          0 : hw_init_rxcfg_8168fp(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                 :            : static void
      20                 :          0 : hw_ephy_config_8168fp(struct rtl_hw *hw)
      21                 :            : {
      22                 :          0 :         rtl_clear_and_set_pcie_phy_bit(hw, 0x19, BIT_6, BIT_12 | BIT_8);
      23                 :          0 :         rtl_clear_and_set_pcie_phy_bit(hw, 0x59, BIT_6, BIT_12 | BIT_8);
      24                 :            : 
      25                 :          0 :         rtl_clear_pcie_phy_bit(hw, 0x0C, BIT_4);
      26                 :          0 :         rtl_clear_pcie_phy_bit(hw, 0x4C, BIT_4);
      27                 :          0 :         rtl_clear_pcie_phy_bit(hw, 0x0B, BIT_0);
      28                 :          0 : }
      29                 :            : 
      30                 :            : static void
      31                 :          0 : hw_phy_config_8168fp(struct rtl_hw *hw)
      32                 :            : {
      33                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
      34                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808E);
      35                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x4800);
      36                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8090);
      37                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0xCC00);
      38                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8092);
      39                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0xB000);
      40                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8088);
      41                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x6000);
      42                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808B);
      43                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x3F00, 0x0B00);
      44                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808D);
      45                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x1F00, 0x0600);
      46                 :          0 :         rtl_mdio_write(hw, 0x13, 0x808C);
      47                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0xB000);
      48                 :            : 
      49                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80A0);
      50                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x2800);
      51                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80A2);
      52                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x5000);
      53                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809B);
      54                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xF800, 0xB000);
      55                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809A);
      56                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x4B00);
      57                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809D);
      58                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x3F00, 0x0800);
      59                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80A1);
      60                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x7000);
      61                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809F);
      62                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x1F00, 0x0300);
      63                 :          0 :         rtl_mdio_write(hw, 0x13, 0x809E);
      64                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x8800);
      65                 :            : 
      66                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80B2);
      67                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x2200);
      68                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80AD);
      69                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xF800, 0x9800);
      70                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80AF);
      71                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x3F00, 0x0800);
      72                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80B3);
      73                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x6F00);
      74                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80B1);
      75                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0x1F00, 0x0300);
      76                 :          0 :         rtl_mdio_write(hw, 0x13, 0x80B0);
      77                 :          0 :         rtl_clear_and_set_eth_phy_bit(hw, 0x14, 0xFF00, 0x9300);
      78                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
      79                 :            : 
      80                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
      81                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8011);
      82                 :          0 :         rtl_set_eth_phy_bit(hw, 0x14, BIT_11);
      83                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
      84                 :            : 
      85                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A44);
      86                 :          0 :         rtl_set_eth_phy_bit(hw, 0x11, BIT_11);
      87                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
      88                 :            : 
      89                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A43);
      90                 :          0 :         rtl_mdio_write(hw, 0x13, 0x8016);
      91                 :          0 :         rtl_set_eth_phy_bit(hw, 0x14, BIT_10);
      92                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
      93                 :            : 
      94                 :            :         /* Enable EthPhyPPSW */
      95                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0A44);
      96                 :          0 :         rtl_clear_eth_phy_bit(hw, 0x11, BIT_7);
      97                 :          0 :         rtl_mdio_write(hw, 0x1F, 0x0000);
      98                 :          0 : }
      99                 :            : 
     100                 :            : static void
     101                 :          0 : hw_config_8168fp(struct rtl_hw *hw)
     102                 :            : {
     103                 :            :         u16 mac_ocp_data;
     104                 :            :         u32 csi_tmp;
     105                 :            : 
     106                 :          0 :         rtl_eri_write(hw, 0xC8, 4, 0x00080002, ERIAR_ExGMAC);
     107                 :          0 :         rtl_eri_write(hw, 0xCC, 1, 0x2F, ERIAR_ExGMAC);
     108                 :          0 :         rtl_eri_write(hw, 0xD0, 1, 0x5F, ERIAR_ExGMAC);
     109                 :          0 :         rtl_eri_write(hw, 0xE8, 4, 0x00100006, ERIAR_ExGMAC);
     110                 :            : 
     111                 :            :         /* Adjust the trx fifo*/
     112                 :          0 :         rtl_eri_write(hw, 0xCA, 2, 0x0370, ERIAR_ExGMAC);
     113                 :          0 :         rtl_eri_write(hw, 0xEA, 1, 0x10, ERIAR_ExGMAC);
     114                 :            : 
     115                 :            :         /* Disable share fifo */
     116                 :          0 :         RTL_W32(hw, TxConfig, RTL_R32(hw, TxConfig) & ~BIT_7);
     117                 :            : 
     118                 :          0 :         csi_tmp = rtl_eri_read(hw, 0xDC, 1, ERIAR_ExGMAC);
     119                 :          0 :         csi_tmp &= ~BIT_0;
     120                 :          0 :         rtl_eri_write(hw, 0xDC, 1, csi_tmp, ERIAR_ExGMAC);
     121                 :          0 :         csi_tmp |= BIT_0;
     122                 :          0 :         rtl_eri_write(hw, 0xDC, 1, csi_tmp, ERIAR_ExGMAC);
     123                 :            : 
     124                 :            :         /* EEE pwrsave params */
     125                 :          0 :         mac_ocp_data = rtl_mac_ocp_read(hw, 0xE056);
     126                 :          0 :         mac_ocp_data &= ~(BIT_7 | BIT_6 | BIT_5 | BIT_4);
     127                 :          0 :         rtl_mac_ocp_write(hw, 0xE056, mac_ocp_data);
     128                 :            : 
     129         [ #  # ]:          0 :         if (hw->HwPkgDet == 0x0F)
     130                 :          0 :                 rtl_mac_ocp_write(hw, 0xEA80, 0x0003);
     131                 :            :         else
     132                 :          0 :                 rtl_mac_ocp_write(hw, 0xEA80, 0x0000);
     133                 :            : 
     134                 :          0 :         rtl_oob_mutex_lock(hw);
     135                 :          0 :         mac_ocp_data = rtl_mac_ocp_read(hw, 0xE052);
     136                 :          0 :         mac_ocp_data &= ~(BIT_3 | BIT_0);
     137         [ #  # ]:          0 :         if (hw->HwPkgDet == 0x0F)
     138                 :          0 :                 mac_ocp_data |= BIT_0;
     139                 :          0 :         rtl_mac_ocp_write(hw, 0xE052, mac_ocp_data);
     140                 :          0 :         rtl_oob_mutex_unlock(hw);
     141                 :            : 
     142                 :          0 :         RTL_W8(hw, Config3, RTL_R8(hw, Config3) & ~Beacon_en);
     143                 :            : 
     144                 :          0 :         RTL_W8(hw, 0x1B, RTL_R8(hw, 0x1B) & ~0x07);
     145                 :            : 
     146                 :          0 :         RTL_W8(hw, Config2, RTL_R8(hw, Config2) & ~PMSTS_En);
     147                 :            : 
     148         [ #  # ]:          0 :         if (!HW_SUPP_SERDES_PHY(hw)) {
     149                 :          0 :                 RTL_W8(hw, 0xD0, RTL_R8(hw, 0xD0) | BIT_6);
     150                 :          0 :                 RTL_W8(hw, 0xF2, RTL_R8(hw, 0xF2) | BIT_6);
     151                 :          0 :                 RTL_W8(hw, 0xD0, RTL_R8(hw, 0xD0) | BIT_7);
     152                 :            :         } else {
     153                 :          0 :                 RTL_W8(hw, 0xD0, RTL_R8(hw, 0xD0) & ~BIT_6);
     154                 :          0 :                 RTL_W8(hw, 0xF2, RTL_R8(hw, 0xF2) & ~BIT_6);
     155                 :          0 :                 RTL_W8(hw, 0xD0, RTL_R8(hw, 0xD0) & ~BIT_7);
     156                 :            :         }
     157                 :            : 
     158                 :          0 :         rtl_oob_mutex_lock(hw);
     159         [ #  # ]:          0 :         if (hw->HwPkgDet == 0x0F)
     160                 :          0 :                 rtl_eri_write(hw, 0x5F0, 2, 0x4F00, ERIAR_ExGMAC);
     161                 :            :         else
     162                 :          0 :                 rtl_eri_write(hw, 0x5F0, 2, 0x4000, ERIAR_ExGMAC);
     163                 :          0 :         rtl_oob_mutex_unlock(hw);
     164                 :            : 
     165                 :          0 :         csi_tmp = rtl_eri_read(hw, 0xDC, 4, ERIAR_ExGMAC);
     166                 :          0 :         csi_tmp |= (BIT_2 | BIT_3);
     167                 :          0 :         rtl_eri_write(hw, 0xDC, 4, csi_tmp, ERIAR_ExGMAC);
     168                 :            : 
     169         [ #  # ]:          0 :         if (hw->mcfg == CFG_METHOD_32 || hw->mcfg == CFG_METHOD_33 ||
     170                 :            :             hw->mcfg == CFG_METHOD_34) {
     171                 :          0 :                 csi_tmp = rtl_eri_read(hw, 0xD4, 4, ERIAR_ExGMAC);
     172                 :          0 :                 csi_tmp |= BIT_4;
     173                 :          0 :                 rtl_eri_write(hw, 0xD4, 4, csi_tmp, ERIAR_ExGMAC);
     174                 :            :         }
     175                 :            : 
     176                 :          0 :         rtl_mac_ocp_write(hw, 0xC140, 0xFFFF);
     177                 :          0 :         rtl_mac_ocp_write(hw, 0xC142, 0xFFFF);
     178                 :            : 
     179                 :          0 :         csi_tmp = rtl_eri_read(hw, 0x2FC, 1, ERIAR_ExGMAC);
     180                 :          0 :         csi_tmp &= ~(BIT_0 | BIT_1);
     181                 :          0 :         csi_tmp |= BIT_0;
     182                 :          0 :         rtl_eri_write(hw, 0x2FC, 1, csi_tmp, ERIAR_ExGMAC);
     183                 :            : 
     184                 :          0 :         csi_tmp = rtl_eri_read(hw, 0x1D0, 1, ERIAR_ExGMAC);
     185                 :          0 :         csi_tmp &= ~BIT_1;
     186                 :          0 :         rtl_eri_write(hw, 0x1D0, 1, csi_tmp, ERIAR_ExGMAC);
     187                 :          0 : }
     188                 :            : 
     189                 :            : const struct rtl_hw_ops rtl8168fp_ops = {
     190                 :            :         .hw_config         = hw_config_8168fp,
     191                 :            :         .hw_init_rxcfg     = hw_init_rxcfg_8168fp,
     192                 :            :         .hw_ephy_config    = hw_ephy_config_8168fp,
     193                 :            :         .hw_phy_config     = hw_phy_config_8168fp,
     194                 :            :         .hw_mac_mcu_config = hw_mac_mcu_config_8168fp,
     195                 :            : };

Generated by: LCOV version 1.14