LCOV - code coverage report
Current view: top level - drivers/net/r8169 - r8169_dash.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 216 0.0 %
Date: 2025-07-01 21:32:37 Functions: 0 26 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 131 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 <stdio.h>
       6                 :            : #include <errno.h>
       7                 :            : #include <stdint.h>
       8                 :            : 
       9                 :            : #include <rte_ether.h>
      10                 :            : #include <ethdev_driver.h>
      11                 :            : 
      12                 :            : #include "r8169_compat.h"
      13                 :            : #include "r8169_dash.h"
      14                 :            : #include "r8169_hw.h"
      15                 :            : 
      16                 :            : bool
      17                 :          0 : rtl_is_allow_access_dash_ocp(struct rtl_hw *hw)
      18                 :            : {
      19                 :            :         bool allow_access = false;
      20                 :            :         u16 mac_ocp_data;
      21                 :            : 
      22         [ #  # ]:          0 :         if (!HW_DASH_SUPPORT_DASH(hw))
      23                 :          0 :                 goto exit;
      24                 :            : 
      25                 :            :         allow_access = true;
      26      [ #  #  # ]:          0 :         switch (hw->mcfg) {
      27                 :          0 :         case CFG_METHOD_48:
      28                 :            :         case CFG_METHOD_49:
      29                 :          0 :                 mac_ocp_data = rtl_mac_ocp_read(hw, 0xd460);
      30   [ #  #  #  # ]:          0 :                 if (mac_ocp_data == 0xffff || !(mac_ocp_data & BIT_0))
      31                 :            :                         allow_access = false;
      32                 :            :                 break;
      33                 :          0 :         case CFG_METHOD_54:
      34                 :            :         case CFG_METHOD_55:
      35                 :            :         case CFG_METHOD_91:
      36                 :          0 :                 mac_ocp_data = rtl_mac_ocp_read(hw, 0xd4c0);
      37   [ #  #  #  # ]:          0 :                 if (mac_ocp_data == 0xffff || (mac_ocp_data & BIT_3))
      38                 :            :                         allow_access = false;
      39                 :            :                 break;
      40                 :          0 :         default:
      41                 :          0 :                 goto exit;
      42                 :            :         }
      43                 :          0 : exit:
      44                 :          0 :         return allow_access;
      45                 :            : }
      46                 :            : 
      47                 :            : static u32
      48                 :            : rtl_get_dash_fw_ver(struct rtl_hw *hw)
      49                 :            : {
      50                 :            :         u32 ver = 0xffffffff;
      51                 :            : 
      52                 :            :         if (!HW_DASH_SUPPORT_GET_FIRMWARE_VERSION(hw))
      53                 :            :                 goto exit;
      54                 :            : 
      55                 :          0 :         ver = rtl_ocp_read(hw, OCP_REG_FIRMWARE_MAJOR_VERSION, 4);
      56                 :            : 
      57                 :            : exit:
      58                 :            :         return ver;
      59                 :            : }
      60                 :            : 
      61                 :            : static int
      62                 :          0 : _rtl_check_dash(struct rtl_hw *hw)
      63                 :            : {
      64         [ #  # ]:          0 :         if (!hw->AllowAccessDashOcp)
      65                 :            :                 return 0;
      66                 :            : 
      67   [ #  #  #  # ]:          0 :         switch (hw->HwSuppDashVer) {
      68                 :          0 :         case 2:
      69         [ #  # ]:          0 :                 if (rtl_is_8125(hw))
      70                 :            :                         return 0;
      71                 :            :         /* Fall through */
      72                 :            :         case 3:
      73                 :            :         case 4:
      74         [ #  # ]:          0 :                 if (rtl_ocp_read(hw, 0x128, 1) & BIT_0)
      75                 :            :                         return 1;
      76                 :            :                 else
      77                 :          0 :                         return 0;
      78                 :          0 :         case 1:
      79         [ #  # ]:          0 :                 if (rtl_ocp_read(hw, 0x10, 2) & 0x00008000)
      80                 :            :                         return 1;
      81                 :            :                 else
      82                 :          0 :                         return 0;
      83                 :            :         default:
      84                 :            :                 return 0;
      85                 :            :         }
      86                 :            : }
      87                 :            : 
      88                 :            : int
      89                 :          0 : rtl_check_dash(struct rtl_hw *hw)
      90                 :            : {
      91                 :            :         int dash_enabled;
      92                 :            :         u32 fw_ver;
      93                 :            : 
      94                 :          0 :         dash_enabled = _rtl_check_dash(hw);
      95                 :            : 
      96         [ #  # ]:          0 :         if (!dash_enabled)
      97                 :          0 :                 goto exit;
      98                 :            : 
      99         [ #  # ]:          0 :         if (!HW_DASH_SUPPORT_GET_FIRMWARE_VERSION(hw))
     100                 :          0 :                 goto exit;
     101                 :            : 
     102                 :            :         fw_ver = rtl_get_dash_fw_ver(hw);
     103         [ #  # ]:          0 :         if (fw_ver == 0 || fw_ver == 0xffffffff)
     104                 :            :                 dash_enabled = 0;
     105                 :          0 : exit:
     106                 :          0 :         return dash_enabled;
     107                 :            : }
     108                 :            : 
     109                 :            : static u32
     110                 :          0 : rtl8168_csi_to_cmac_r32(struct rtl_hw *hw)
     111                 :            : {
     112                 :            :         u32 cmd;
     113                 :            :         int i;
     114                 :            :         u32 value = 0;
     115                 :            : 
     116                 :            :         cmd = CSIAR_Read | CSIAR_ByteEn << CSIAR_ByteEn_shift | 0xf9;
     117                 :            : 
     118                 :            :         cmd |= 1 << 16;
     119                 :            : 
     120                 :          0 :         RTL_W32(hw, CSIAR, cmd);
     121                 :            : 
     122         [ #  # ]:          0 :         for (i = 0; i < RTL_CHANNEL_WAIT_COUNT; i++) {
     123                 :          0 :                 rte_delay_us(RTL_CHANNEL_WAIT_TIME);
     124                 :            : 
     125                 :            :                 /* Check if the RTL8168 has completed CSI read */
     126         [ #  # ]:          0 :                 if (RTL_R32(hw, CSIAR) & CSIAR_Flag) {
     127                 :          0 :                         value = RTL_R32(hw, CSIDR);
     128                 :          0 :                         break;
     129                 :            :                 }
     130                 :            :         }
     131                 :            : 
     132                 :          0 :         rte_delay_us(RTL_CHANNEL_EXIT_DELAY_TIME);
     133                 :            : 
     134                 :          0 :         return value;
     135                 :            : }
     136                 :            : 
     137                 :            : static u8
     138                 :          0 : rtl8168_csi_to_cmac_r8(struct rtl_hw *hw, u32 reg)
     139                 :            : {
     140                 :            :         u32 mask, value1 = 0;
     141                 :            :         u8 val_shift, value2 = 0;
     142                 :            : 
     143                 :          0 :         val_shift = reg - 0xf8;
     144                 :            : 
     145         [ #  # ]:          0 :         if (val_shift == 0)
     146                 :            :                 mask = 0xFF;
     147         [ #  # ]:          0 :         else if (val_shift == 1)
     148                 :            :                 mask = 0xFF00;
     149         [ #  # ]:          0 :         else if (val_shift == 2)
     150                 :            :                 mask = 0xFF0000;
     151                 :            :         else
     152                 :            :                 mask = 0xFF000000;
     153                 :            : 
     154                 :          0 :         value1 = rtl8168_csi_to_cmac_r32(hw) & mask;
     155                 :          0 :         value2 = value1 >> (val_shift * 8);
     156                 :            : 
     157                 :          0 :         return value2;
     158                 :            : }
     159                 :            : 
     160                 :            : static void
     161                 :          0 : rtl8168_csi_to_cmac_w8(struct rtl_hw *hw, u32 reg, u8 value)
     162                 :            : {
     163                 :            :         int i;
     164                 :            :         u8 val_shift;
     165                 :            :         u32 value32, cmd, mask;
     166                 :            : 
     167                 :          0 :         val_shift = reg - 0xf8;
     168                 :            : 
     169         [ #  # ]:          0 :         if (val_shift == 0)
     170                 :            :                 mask = 0xFF;
     171         [ #  # ]:          0 :         else if (val_shift == 1)
     172                 :            :                 mask = 0xFF00;
     173         [ #  # ]:          0 :         else if (val_shift == 2)
     174                 :            :                 mask = 0xFF0000;
     175                 :            :         else
     176                 :            :                 mask = 0xFF000000;
     177                 :            : 
     178                 :          0 :         value32 = rtl8168_csi_to_cmac_r32(hw) & ~mask;
     179                 :          0 :         value32 |= value << (val_shift * 8);
     180                 :          0 :         RTL_W32(hw, CSIDR, value32);
     181                 :            : 
     182                 :            :         cmd = CSIAR_Write | CSIAR_ByteEn << CSIAR_ByteEn_shift | 0xf9;
     183                 :            : 
     184                 :            :         cmd |= 1 << 16;
     185                 :            : 
     186                 :          0 :         RTL_W32(hw, CSIAR, cmd);
     187                 :            : 
     188         [ #  # ]:          0 :         for (i = 0; i < RTL_CHANNEL_WAIT_COUNT; i++) {
     189                 :          0 :                 rte_delay_us(RTL_CHANNEL_WAIT_TIME);
     190                 :            : 
     191                 :            :                 /* Check if the RTL8168 has completed CSI write */
     192         [ #  # ]:          0 :                 if (!(RTL_R32(hw, CSIAR) & CSIAR_Flag))
     193                 :            :                         break;
     194                 :            :         }
     195                 :            : 
     196                 :          0 :         rte_delay_us(RTL_CHANNEL_EXIT_DELAY_TIME);
     197                 :          0 : }
     198                 :            : 
     199                 :            : static void
     200                 :          0 : rtl_cmac_w8(struct rtl_hw *hw, u32 reg, u8 value)
     201                 :            : {
     202         [ #  # ]:          0 :         if (HW_DASH_SUPPORT_TYPE_2(hw))
     203                 :          0 :                 RTL_CMAC_W8(hw, reg, value);
     204         [ #  # ]:          0 :         else if (HW_DASH_SUPPORT_TYPE_3(hw))
     205                 :          0 :                 rtl8168_csi_to_cmac_w8(hw, reg, value);
     206                 :          0 : }
     207                 :            : 
     208                 :            : static u8
     209                 :          0 : rtl_cmac_r8(struct rtl_hw *hw, u32 reg)
     210                 :            : {
     211         [ #  # ]:          0 :         if (HW_DASH_SUPPORT_TYPE_2(hw))
     212                 :          0 :                 return RTL_CMAC_R8(hw, reg);
     213         [ #  # ]:          0 :         else if (HW_DASH_SUPPORT_TYPE_3(hw))
     214                 :          0 :                 return rtl8168_csi_to_cmac_r8(hw, reg);
     215                 :            :         else
     216                 :            :                 return 0;
     217                 :            : }
     218                 :            : 
     219                 :            : static void
     220                 :          0 : rtl_dash2_disable_tx(struct rtl_hw *hw)
     221                 :            : {
     222                 :            :         u16 wait_cnt = 0;
     223                 :            :         u8 tmp_uchar;
     224                 :            : 
     225                 :            :         /* Disable oob Tx */
     226                 :          0 :         rtl_cmac_w8(hw, CMAC_IBCR2, rtl_cmac_r8(hw, CMAC_IBCR2) & ~BIT_0);
     227                 :            : 
     228                 :            :         /* Wait oob Tx disable */
     229                 :            :         do {
     230                 :          0 :                 tmp_uchar = rtl_cmac_r8(hw, CMAC_IBISR0);
     231         [ #  # ]:          0 :                 if (tmp_uchar & ISRIMR_DASH_TYPE2_TX_DISABLE_IDLE)
     232                 :            :                         break;
     233                 :            : 
     234                 :          0 :                 rte_delay_us(50);
     235                 :          0 :                 wait_cnt++;
     236         [ #  # ]:          0 :         } while (wait_cnt < 2000);
     237                 :            : 
     238                 :            :         /* Clear ISRIMR_DASH_TYPE2_TX_DISABLE_IDLE */
     239                 :          0 :         rtl_cmac_w8(hw, CMAC_IBISR0, rtl_cmac_r8(hw, CMAC_IBISR0) |
     240                 :            :                     ISRIMR_DASH_TYPE2_TX_DISABLE_IDLE);
     241                 :          0 : }
     242                 :            : 
     243                 :            : static void
     244                 :          0 : rtl_dash2_disable_rx(struct rtl_hw *hw)
     245                 :            : {
     246                 :          0 :         rtl_cmac_w8(hw, CMAC_IBCR0, rtl_cmac_r8(hw, CMAC_IBCR0) & ~BIT_0);
     247                 :          0 : }
     248                 :            : 
     249                 :            : void
     250                 :          0 : rtl_dash2_disable_txrx(struct rtl_hw *hw)
     251                 :            : {
     252         [ #  # ]:          0 :         if (!HW_DASH_SUPPORT_CMAC(hw))
     253                 :            :                 return;
     254                 :            : 
     255         [ #  # ]:          0 :         if (!hw->DASH)
     256                 :            :                 return;
     257                 :            : 
     258                 :          0 :         rtl_dash2_disable_tx(hw);
     259                 :          0 :         rtl_dash2_disable_rx(hw);
     260                 :            : }
     261                 :            : 
     262                 :            : static void
     263                 :          0 : rtl8125_notify_dash_oob_cmac(struct rtl_hw *hw, u32 cmd)
     264                 :            : {
     265                 :            :         u32 tmp_value;
     266                 :            : 
     267         [ #  # ]:          0 :         if (!HW_DASH_SUPPORT_CMAC(hw))
     268                 :            :                 return;
     269                 :            : 
     270                 :          0 :         rtl_ocp_write(hw, 0x180, 4, cmd);
     271                 :          0 :         tmp_value = rtl_ocp_read(hw, 0x30, 4);
     272                 :          0 :         tmp_value |= BIT_0;
     273                 :          0 :         rtl_ocp_write(hw, 0x30, 4, tmp_value);
     274                 :            : }
     275                 :            : 
     276                 :            : static void
     277                 :          0 : rtl8125_notify_dash_oob_ipc2(struct rtl_hw *hw, u32 cmd)
     278                 :            : {
     279                 :          0 :         rtl_ocp_write(hw, IB2SOC_DATA, 4, cmd);
     280                 :          0 :         rtl_ocp_write(hw, IB2SOC_CMD, 4, 0x00);
     281                 :          0 :         rtl_ocp_write(hw, IB2SOC_SET, 4, 0x01);
     282                 :          0 : }
     283                 :            : 
     284                 :            : static void
     285                 :          0 : rtl8125_notify_dash_oob(struct rtl_hw *hw, u32 cmd)
     286                 :            : {
     287      [ #  #  # ]:          0 :         switch (hw->HwSuppDashVer) {
     288                 :          0 :         case 2:
     289                 :            :         case 3:
     290                 :          0 :                 rtl8125_notify_dash_oob_cmac(hw, cmd);
     291                 :          0 :                 break;
     292                 :          0 :         case 4:
     293                 :          0 :                 rtl8125_notify_dash_oob_ipc2(hw, cmd);
     294                 :          0 :                 break;
     295                 :            :         default:
     296                 :            :                 break;
     297                 :            :         }
     298                 :          0 : }
     299                 :            : 
     300                 :            : static int
     301                 :          0 : rtl_wait_dash_fw_ready(struct rtl_hw *hw)
     302                 :            : {
     303                 :            :         int rc = -1;
     304                 :            :         int timeout;
     305                 :            : 
     306         [ #  # ]:          0 :         if (!HW_DASH_SUPPORT_DASH(hw))
     307                 :          0 :                 goto out;
     308                 :            : 
     309         [ #  # ]:          0 :         if (!hw->DASH)
     310                 :          0 :                 goto out;
     311                 :            : 
     312         [ #  # ]:          0 :         if (HW_DASH_SUPPORT_TYPE_2(hw) || HW_DASH_SUPPORT_TYPE_3(hw) ||
     313                 :            :             HW_DASH_SUPPORT_TYPE_4(hw)) {
     314         [ #  # ]:          0 :                 for (timeout = 0; timeout < 10; timeout++) {
     315                 :            :                         rte_delay_ms(10);
     316         [ #  # ]:          0 :                         if (rtl_ocp_read(hw, 0x124, 1) & BIT_0) {
     317                 :            :                                 rc = 1;
     318                 :          0 :                                 goto out;
     319                 :            :                         }
     320                 :            :                 }
     321         [ #  # ]:          0 :         } else if (HW_DASH_SUPPORT_TYPE_1(hw)) {
     322         [ #  # ]:          0 :                 for (timeout = 0; timeout < 10; timeout++) {
     323                 :            :                         rte_delay_ms(10);
     324         [ #  # ]:          0 :                         if (rtl_ocp_read(hw, 0x10, 2) & BIT_11) {
     325                 :            :                                 rc = 1;
     326                 :          0 :                                 goto out;
     327                 :            :                         }
     328                 :            :                 }
     329                 :            :         } else {
     330                 :          0 :                 goto out;
     331                 :            :         }
     332                 :            : 
     333                 :            :         rc = 0;
     334                 :            : 
     335                 :          0 : out:
     336                 :          0 :         return rc;
     337                 :            : }
     338                 :            : 
     339                 :            : static void
     340                 :          0 : rtl8125_driver_start(struct rtl_hw *hw)
     341                 :            : {
     342         [ #  # ]:          0 :         if (!hw->AllowAccessDashOcp)
     343                 :            :                 return;
     344                 :            : 
     345                 :          0 :         rtl8125_notify_dash_oob(hw, OOB_CMD_DRIVER_START);
     346                 :            : 
     347                 :          0 :         rtl_wait_dash_fw_ready(hw);
     348                 :            : }
     349                 :            : 
     350                 :            : static void
     351                 :          0 : rtl8168_clear_and_set_other_fun_pci_bit(struct rtl_hw *hw, u8 multi_fun_sel_bit,
     352                 :            :                                         u32 addr, u32 clearmask, u32 setmask)
     353                 :            : {
     354                 :            :         u32 tmp_ulong;
     355                 :            : 
     356                 :          0 :         tmp_ulong = rtl_csi_other_fun_read(hw, multi_fun_sel_bit, addr);
     357                 :          0 :         tmp_ulong &= ~clearmask;
     358                 :          0 :         tmp_ulong |= setmask;
     359                 :          0 :         rtl_csi_other_fun_write(hw, multi_fun_sel_bit, addr, tmp_ulong);
     360                 :          0 : }
     361                 :            : 
     362                 :            : static void
     363                 :          0 : rtl8168_other_fun_dev_pci_setting(struct rtl_hw *hw, u32 addr, u32 clearmask,
     364                 :            :                                   u32 setmask, u8 multi_fun_sel_bit)
     365                 :            : {
     366                 :            :         u32 tmp_ulong;
     367                 :            :         u8 i;
     368                 :            :         u8 fun_bit;
     369                 :            :         u8 set_other_fun;
     370                 :            : 
     371         [ #  # ]:          0 :         for (i = 0; i < 8; i++) {
     372                 :          0 :                 fun_bit = (1 << i);
     373         [ #  # ]:          0 :                 if (!(fun_bit & multi_fun_sel_bit))
     374                 :          0 :                         continue;
     375                 :            : 
     376                 :            :                 set_other_fun = TRUE;
     377                 :            : 
     378      [ #  #  # ]:          0 :                 switch (hw->mcfg) {
     379                 :          0 :                 case CFG_METHOD_23:
     380                 :            :                 case CFG_METHOD_27:
     381                 :            :                 case CFG_METHOD_28:
     382                 :            :                         /*
     383                 :            :                          * 0: UMAC, 1: TCR1, 2: TCR2, 3: KCS,
     384                 :            :                          * 4: EHCI(Control by EHCI Driver)
     385                 :            :                          */
     386         [ #  # ]:          0 :                         if (i < 5) {
     387                 :          0 :                                 tmp_ulong = rtl_csi_other_fun_read(hw, i, 0x00);
     388         [ #  # ]:          0 :                                 if (tmp_ulong == 0xFFFFFFFF)
     389                 :            :                                         set_other_fun = TRUE;
     390                 :            :                                 else
     391                 :            :                                         set_other_fun = FALSE;
     392                 :            :                         }
     393                 :            :                         break;
     394                 :          0 :                 case CFG_METHOD_31:
     395                 :            :                 case CFG_METHOD_32:
     396                 :            :                 case CFG_METHOD_33:
     397                 :            :                 case CFG_METHOD_34:
     398                 :            :                         /*
     399                 :            :                          * 0: BMC, 1: NIC, 2: TCR, 3: VGA / PCIE_TO_USB,
     400                 :            :                          * 4: EHCI, 5: WIFI, 6: WIFI, 7: KCS
     401                 :            :                          */
     402         [ #  # ]:          0 :                         if (i == 5 || i == 6) {
     403         [ #  # ]:          0 :                                 if (hw->DASH) {
     404                 :          0 :                                         tmp_ulong = rtl_ocp_read(hw, 0x184, 4);
     405         [ #  # ]:          0 :                                         if (tmp_ulong & BIT_26)
     406                 :            :                                                 set_other_fun = FALSE;
     407                 :            :                                         else
     408                 :            :                                                 set_other_fun = TRUE;
     409                 :            :                                 }
     410                 :            :                         } else { /* Function 0/1/2/3/4/7 */
     411                 :          0 :                                 tmp_ulong = rtl_csi_other_fun_read(hw, i, 0x00);
     412         [ #  # ]:          0 :                                 if (tmp_ulong == 0xFFFFFFFF)
     413                 :            :                                         set_other_fun = TRUE;
     414                 :            :                                 else
     415                 :            :                                         set_other_fun = FALSE;
     416                 :            :                         }
     417                 :            :                         break;
     418                 :            :                 default:
     419                 :            :                         return;
     420                 :            :                 }
     421                 :            : 
     422                 :            :                 if (set_other_fun)
     423                 :          0 :                         rtl8168_clear_and_set_other_fun_pci_bit(hw, i, addr,
     424                 :            :                                                                 clearmask, setmask);
     425                 :            :         }
     426                 :            : }
     427                 :            : 
     428                 :            : static void
     429                 :          0 : rtl8168_set_dash_other_fun_dev_state_change(struct rtl_hw *hw, u8 dev_state,
     430                 :            :                                             u8 multi_fun_sel_bit)
     431                 :            : {
     432                 :            :         u32 clearmask;
     433                 :            :         u32 setmask;
     434                 :            : 
     435         [ #  # ]:          0 :         if (dev_state == 0) {
     436                 :            :                 /* Goto D0 */
     437                 :            :                 clearmask = (BIT_0 | BIT_1);
     438                 :            :                 setmask = 0;
     439                 :            : 
     440                 :          0 :                 rtl8168_other_fun_dev_pci_setting(hw, 0x44, clearmask, setmask,
     441                 :            :                                                   multi_fun_sel_bit);
     442                 :            :         } else {
     443                 :            :                 /* Goto D3 */
     444                 :            :                 clearmask = 0;
     445                 :            :                 setmask = (BIT_0 | BIT_1);
     446                 :            : 
     447                 :          0 :                 rtl8168_other_fun_dev_pci_setting(hw, 0x44, clearmask, setmask,
     448                 :            :                                                   multi_fun_sel_bit);
     449                 :            :         }
     450                 :          0 : }
     451                 :            : 
     452                 :            : static void
     453                 :            : rtl8168_set_dash_other_fun_dev_aspm_clkreq(struct rtl_hw *hw, u8 aspm_val,
     454                 :            :                                            u8 clkreq_en, u8 multi_fun_sel_bit)
     455                 :            : {
     456                 :            :         u32 clearmask;
     457                 :            :         u32 setmask;
     458                 :            : 
     459                 :            :         aspm_val &= (BIT_0 | BIT_1);
     460                 :            :         clearmask = (BIT_0 | BIT_1 | BIT_8);
     461                 :            :         setmask = aspm_val;
     462                 :            :         if (clkreq_en)
     463                 :            :                 setmask |= BIT_8;
     464                 :            : 
     465                 :          0 :         rtl8168_other_fun_dev_pci_setting(hw, 0x80, clearmask, setmask,
     466                 :            :                                           multi_fun_sel_bit);
     467                 :            : }
     468                 :            : 
     469                 :            : static void
     470                 :          0 : rtl8168_oob_notify(struct rtl_hw *hw, u8 cmd)
     471                 :            : {
     472                 :          0 :         rtl_eri_write(hw, 0xE8, 1, cmd, ERIAR_ExGMAC);
     473                 :            : 
     474                 :          0 :         rtl_ocp_write(hw, 0x30, 1, 0x01);
     475                 :          0 : }
     476                 :            : 
     477                 :            : static void
     478                 :          0 : rtl8168_driver_start(struct rtl_hw *hw)
     479                 :            : {
     480                 :            :         u32 tmp_value;
     481                 :            : 
     482                 :            :         /* Change other device state to D0. */
     483      [ #  #  # ]:          0 :         switch (hw->mcfg) {
     484                 :            :         case CFG_METHOD_23:
     485                 :            :         case CFG_METHOD_27:
     486                 :            :         case CFG_METHOD_28:
     487                 :            :                 rtl8168_set_dash_other_fun_dev_aspm_clkreq(hw, 3, 1, 0x1E);
     488                 :          0 :                 rtl8168_set_dash_other_fun_dev_state_change(hw, 3, 0x1E);
     489                 :          0 :                 break;
     490                 :            :         case CFG_METHOD_31:
     491                 :            :         case CFG_METHOD_32:
     492                 :            :         case CFG_METHOD_33:
     493                 :            :         case CFG_METHOD_34:
     494                 :            :                 rtl8168_set_dash_other_fun_dev_aspm_clkreq(hw, 3, 1, 0xFC);
     495                 :          0 :                 rtl8168_set_dash_other_fun_dev_state_change(hw, 3, 0xFC);
     496                 :          0 :                 break;
     497                 :            :         }
     498                 :            : 
     499         [ #  # ]:          0 :         if (HW_DASH_SUPPORT_TYPE_2(hw) || HW_DASH_SUPPORT_TYPE_3(hw)) {
     500                 :          0 :                 rtl_ocp_write(hw, 0x180, 1, OOB_CMD_DRIVER_START);
     501                 :          0 :                 tmp_value = rtl_ocp_read(hw, 0x30, 1);
     502                 :          0 :                 tmp_value |= BIT_0;
     503                 :          0 :                 rtl_ocp_write(hw, 0x30, 1, tmp_value);
     504                 :            :         } else {
     505                 :          0 :                 rtl8168_oob_notify(hw, OOB_CMD_DRIVER_START);
     506                 :            :         }
     507                 :            : 
     508                 :          0 :         rtl_wait_dash_fw_ready(hw);
     509                 :          0 : }
     510                 :            : 
     511                 :            : void
     512                 :          0 : rtl_driver_start(struct rtl_hw *hw)
     513                 :            : {
     514         [ #  # ]:          0 :         if (rtl_is_8125(hw))
     515                 :          0 :                 rtl8125_driver_start(hw);
     516                 :            :         else
     517                 :          0 :                 rtl8168_driver_start(hw);
     518                 :          0 : }
     519                 :            : 
     520                 :            : static void
     521                 :          0 : rtl8168_driver_stop(struct rtl_hw *hw)
     522                 :            : {
     523                 :            :         u32 tmp_value;
     524                 :            : 
     525         [ #  # ]:          0 :         if (HW_DASH_SUPPORT_TYPE_2(hw) || HW_DASH_SUPPORT_TYPE_3(hw)) {
     526                 :          0 :                 rtl_dash2_disable_txrx(hw);
     527                 :            : 
     528                 :          0 :                 rtl_ocp_write(hw, 0x180, 1, OOB_CMD_DRIVER_STOP);
     529                 :          0 :                 tmp_value = rtl_ocp_read(hw, 0x30, 1);
     530                 :          0 :                 tmp_value |= BIT_0;
     531                 :          0 :                 rtl_ocp_write(hw, 0x30, 1, tmp_value);
     532         [ #  # ]:          0 :         } else if (HW_DASH_SUPPORT_TYPE_1(hw)) {
     533                 :          0 :                 rtl8168_oob_notify(hw, OOB_CMD_DRIVER_STOP);
     534                 :            :         }
     535                 :            : 
     536                 :          0 :         rtl_wait_dash_fw_ready(hw);
     537                 :            : 
     538                 :            :         /* Change other device state to D3. */
     539      [ #  #  # ]:          0 :         switch (hw->mcfg) {
     540                 :          0 :         case CFG_METHOD_23:
     541                 :            :         case CFG_METHOD_27:
     542                 :            :         case CFG_METHOD_28:
     543                 :          0 :                 rtl8168_set_dash_other_fun_dev_state_change(hw, 3, 0x0E);
     544                 :          0 :                 break;
     545                 :          0 :         case CFG_METHOD_31:
     546                 :            :         case CFG_METHOD_32:
     547                 :            :         case CFG_METHOD_33:
     548                 :            :         case CFG_METHOD_34:
     549                 :          0 :                 rtl8168_set_dash_other_fun_dev_state_change(hw, 3, 0xFD);
     550                 :          0 :                 break;
     551                 :            :         }
     552                 :          0 : }
     553                 :            : 
     554                 :            : static void
     555                 :          0 : rtl8125_driver_stop(struct rtl_hw *hw)
     556                 :            : {
     557         [ #  # ]:          0 :         if (!hw->AllowAccessDashOcp)
     558                 :            :                 return;
     559                 :            : 
     560                 :          0 :         rtl8125_notify_dash_oob(hw, OOB_CMD_DRIVER_STOP);
     561                 :            : 
     562                 :          0 :         rtl_wait_dash_fw_ready(hw);
     563                 :            : }
     564                 :            : 
     565                 :            : void
     566                 :          0 : rtl_driver_stop(struct rtl_hw *hw)
     567                 :            : {
     568         [ #  # ]:          0 :         if (rtl_is_8125(hw))
     569                 :          0 :                 rtl8125_driver_stop(hw);
     570                 :            :         else
     571                 :          0 :                 rtl8168_driver_stop(hw);
     572                 :          0 : }
     573                 :            : 
     574                 :            : bool
     575                 :          0 : rtl8168_check_dash_other_fun_present(struct rtl_hw *hw)
     576                 :            : {
     577                 :            :         /* Check if func 2 exist */
     578         [ #  # ]:          0 :         if (rtl_csi_other_fun_read(hw, 2, 0x00) != 0xffffffff)
     579                 :            :                 return true;
     580                 :            :         else
     581                 :          0 :                 return false;
     582                 :            : }

Generated by: LCOV version 1.14