CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Ansuel Smith <[email protected]>
CC: Matthew Hagan <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   136057256686de39cc3a07c2e39ef6bc43003ff6
commit: 6c43809bf1bee76c434e365a26546a92a5fbec14 net: dsa: qca8k: add support 
for sgmii falling edge
date:   6 weeks ago
:::::: branch date: 2 days ago
:::::: commit date: 6 weeks ago
config: x86_64-randconfig-c007-20211028 
(https://download.01.org/0day-ci/archive/20211124/[email protected]/config.gz)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6c43809bf1bee76c434e365a26546a92a5fbec14
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 6c43809bf1bee76c434e365a26546a92a5fbec14
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/qca8k.c:461:6: note: Assuming 'ret' is 0
           if (ret)
               ^~~
   drivers/net/dsa/qca8k.c:461:2: note: Taking false branch
           if (ret)
           ^
   drivers/net/dsa/qca8k.c:465:8: note: Calling 'qca8k_busy_wait'
           ret = qca8k_busy_wait(priv, QCA8K_REG_VTU_FUNC1, 
QCA8K_VTU_FUNC1_BUSY);
                 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/qca8k.c:291:2: note: 'val' declared without an initial value
           u32 val;
           ^~~~~~~
   drivers/net/dsa/qca8k.c:293:8: note: '__sleep_us' is equal to 0
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                 ^
   include/linux/iopoll.h:42:17: note: expanded from macro 'read_poll_timeout'
           might_sleep_if((__sleep_us) != 0); \
                          ^~~~~~~~~~~~
   include/linux/kernel.h:183:39: note: expanded from macro 'might_sleep_if'
   #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
                                         ^~~~
   drivers/net/dsa/qca8k.c:293:8: note: Taking false branch
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                 ^
   include/linux/iopoll.h:42:2: note: expanded from macro 'read_poll_timeout'
           might_sleep_if((__sleep_us) != 0); \
           ^
   include/linux/kernel.h:183:35: note: expanded from macro 'might_sleep_if'
   #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
                                     ^
   drivers/net/dsa/qca8k.c:293:8: note: Loop condition is false.  Exiting loop
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                 ^
   include/linux/iopoll.h:42:2: note: expanded from macro 'read_poll_timeout'
           might_sleep_if((__sleep_us) != 0); \
           ^
   include/linux/kernel.h:183:30: note: expanded from macro 'might_sleep_if'
   #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
                                ^
   drivers/net/dsa/qca8k.c:293:8: note: Left side of '&&' is false
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                 ^
   include/linux/iopoll.h:43:24: note: expanded from macro 'read_poll_timeout'
           if (sleep_before_read && __sleep_us) \
                                 ^
   drivers/net/dsa/qca8k.c:293:8: note: Loop condition is true.  Entering loop 
body
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                 ^
   include/linux/iopoll.h:45:2: note: expanded from macro 'read_poll_timeout'
           for (;;) { \
           ^
   drivers/net/dsa/qca8k.c:293:26: note: Calling 'qca8k_read'
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                                   ^
   include/linux/iopoll.h:46:11: note: expanded from macro 'read_poll_timeout'
                   (val) = op(args); \
                           ^~~~~~~~
   drivers/net/dsa/qca8k.c:163:6: note: Assuming 'ret' is < 0
           if (ret < 0)
               ^~~~~~~
   drivers/net/dsa/qca8k.c:163:2: note: Taking true branch
           if (ret < 0)
           ^
   drivers/net/dsa/qca8k.c:164:3: note: Control jumps to line 169
                   goto exit;
                   ^
   drivers/net/dsa/qca8k.c:170:2: note: Returning without writing to '*val'
           return ret;
           ^
   drivers/net/dsa/qca8k.c:293:26: note: Returning from 'qca8k_read'
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                                   ^
   include/linux/iopoll.h:46:11: note: expanded from macro 'read_poll_timeout'
                   (val) = op(args); \
                           ^~~~~~~~
   drivers/net/dsa/qca8k.c:293:50: note: The left operand of '&' is a garbage 
value
           ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
                                                           ^
   include/linux/iopoll.h:47:7: note: expanded from macro 'read_poll_timeout'
                   if (cond) \
                       ^~~~
   drivers/net/dsa/qca8k.c:906:11: warning: The left operand of '!=' is a 
garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
           if (mode != PHY_INTERFACE_MODE_RGMII_ID &&
               ~~~~ ^
   drivers/net/dsa/qca8k.c:895:2: note: 'mode' declared without an initial value
           phy_interface_t mode;
           ^~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/qca8k.c:905:2: note: Calling 'of_get_phy_mode'
           of_get_phy_mode(port_dn, &mode);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/of_net.h:23:2: note: Returning without writing to '*interface'
           return -ENODEV;
           ^
   drivers/net/dsa/qca8k.c:905:2: note: Returning from 'of_get_phy_mode'
           of_get_phy_mode(port_dn, &mode);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/qca8k.c:906:11: note: The left operand of '!=' is a garbage 
value
           if (mode != PHY_INTERFACE_MODE_RGMII_ID &&
               ~~~~ ^
>> drivers/net/dsa/qca8k.c:1336:4: warning: Value stored to 'ret' is never read 
>> [clang-analyzer-deadcode.DeadStores]
                           ret = qca8k_rmw(priv, reg,
                           ^     ~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/qca8k.c:1336:4: note: Value stored to 'ret' is never read
                           ret = qca8k_rmw(priv, reg,
                           ^     ~~~~~~~~~~~~~~~~~~~~
   Suppressed 13 warnings (13 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   kernel/rseq.c:86:6: warning: Value stored to 'cpu_id' during its 
initialization is never read [clang-analyzer-deadcode.DeadStores]
           u32 cpu_id = raw_smp_processor_id();
               ^~~~~~
   kernel/rseq.c:86:6: note: Value stored to 'cpu_id' during its initialization 
is never read
           u32 cpu_id = raw_smp_processor_id();
               ^~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   8 warnings generated.
   drivers/w1/slaves/w1_therm.c:159:8: warning: Excessive padding in 'struct 
w1_therm_family_converter' (12 padding bytes, where 4 is optimal). 
   Optimal fields order: 
   f, 
   convert, 
   get_conversion_time, 
   set_resolution, 
   get_resolution, 
   write_data, 
   reserved, 
   broken, 
   bulk_read, 
   consider reordering the fields or adding explicit padding members 
[clang-analyzer-optin.performance.Padding]
   struct w1_therm_family_converter {
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:159:8: note: Excessive padding in 'struct 
w1_therm_family_converter' (12 padding bytes, where 4 is optimal). Optimal 
fields order: f, convert, get_conversion_time, set_resolution, get_resolution, 
write_data, reserved, broken, bulk_read, consider reordering the fields or 
adding explicit padding members
   struct w1_therm_family_converter {
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:1252:5: warning: Value stored to 'ret' is never 
read [clang-analyzer-deadcode.DeadStores]
                                   ret = -EIO;
                                   ^     ~~~~
   drivers/w1/slaves/w1_therm.c:1252:5: note: Value stored to 'ret' is never 
read
                                   ret = -EIO;
                                   ^     ~~~~
   drivers/w1/slaves/w1_therm.c:1799:2: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(p_args, buf);
           ^~~~~~
   drivers/w1/slaves/w1_therm.c:1799:2: note: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119
           strcpy(p_args, buf);
           ^~~~~~
   drivers/w1/slaves/w1_therm.c:2090:22: warning: The right operand of '==' is 
a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   if (sl->reg_num.id == reg_num->id)
                                      ^  ~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2067:6: note: Assuming the condition is false
           if (w1_reset_bus(sl->master))
               ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2067:2: note: Taking false branch
           if (w1_reset_bus(sl->master))
           ^
   drivers/w1/slaves/w1_therm.c:2077:6: note: Assuming 'ack' is equal to 
W1_42_SUCCESS_CONFIRM_BYTE
           if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2077:2: note: Taking false branch
           if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
           ^
   drivers/w1/slaves/w1_therm.c:2081:2: note: Loop condition is true.  Entering 
loop body
           for (i = 0; i <= 64; i++) {
           ^
   drivers/w1/slaves/w1_therm.c:2082:7: note: Assuming the condition is false
                   if (w1_reset_bus(sl->master))
                       ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2082:3: note: Taking false branch
                   if (w1_reset_bus(sl->master))
                   ^
   drivers/w1/slaves/w1_therm.c:2088:7: note: Assuming field 'family' is not 
equal to W1_42_FINISHED_BYTE
                   if (reg_num->family == W1_42_FINISHED_BYTE)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2088:3: note: Taking false branch
                   if (reg_num->family == W1_42_FINISHED_BYTE)
                   ^
   drivers/w1/slaves/w1_therm.c:2090:22: note: The right operand of '==' is a 
garbage value
                   if (sl->reg_num.id == reg_num->id)
                                      ^  ~~~~~~~~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   7 warnings generated.
   drivers/mtd/devices/phram.c:231:2: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(str, val);
           ^~~~~~

vim +/ret +1336 drivers/net/dsa/qca8k.c

6b93fb46480a9c John Crispin      2016-09-15  1210  
9bb2289f90e671 Michal Vokáč      2018-05-23  1211  static void
b3591c2a366167 Jonathan McDowell 2020-06-20  1212  
qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
b3591c2a366167 Jonathan McDowell 2020-06-20  1213                        const 
struct phylink_link_state *state)
9bb2289f90e671 Michal Vokáč      2018-05-23  1214  {
9bb2289f90e671 Michal Vokáč      2018-05-23  1215       struct qca8k_priv *priv 
= ds->priv;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1216       u32 reg, val;
9fe99de01440d9 Yang Yingliang    2021-05-29  1217       int ret;
9bb2289f90e671 Michal Vokáč      2018-05-23  1218  
b3591c2a366167 Jonathan McDowell 2020-06-20  1219       switch (port) {
b3591c2a366167 Jonathan McDowell 2020-06-20  1220       case 0: /* 1st CPU port 
*/
b3591c2a366167 Jonathan McDowell 2020-06-20  1221               if 
(state->interface != PHY_INTERFACE_MODE_RGMII &&
b3591c2a366167 Jonathan McDowell 2020-06-20  1222                   
state->interface != PHY_INTERFACE_MODE_RGMII_ID &&
e4b9977cee1583 Ansuel Smith      2021-05-14  1223                   
state->interface != PHY_INTERFACE_MODE_RGMII_TXID &&
e4b9977cee1583 Ansuel Smith      2021-05-14  1224                   
state->interface != PHY_INTERFACE_MODE_RGMII_RXID &&
b3591c2a366167 Jonathan McDowell 2020-06-20  1225                   
state->interface != PHY_INTERFACE_MODE_SGMII)
b3591c2a366167 Jonathan McDowell 2020-06-20  1226                       return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1227  
b3591c2a366167 Jonathan McDowell 2020-06-20  1228               reg = 
QCA8K_REG_PORT0_PAD_CTRL;
b3591c2a366167 Jonathan McDowell 2020-06-20  1229               break;
b3591c2a366167 Jonathan McDowell 2020-06-20  1230       case 1:
b3591c2a366167 Jonathan McDowell 2020-06-20  1231       case 2:
b3591c2a366167 Jonathan McDowell 2020-06-20  1232       case 3:
b3591c2a366167 Jonathan McDowell 2020-06-20  1233       case 4:
b3591c2a366167 Jonathan McDowell 2020-06-20  1234       case 5:
b3591c2a366167 Jonathan McDowell 2020-06-20  1235               /* Internal 
PHY, nothing to do */
b3591c2a366167 Jonathan McDowell 2020-06-20  1236               return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1237       case 6: /* 2nd CPU port 
/ external PHY */
b3591c2a366167 Jonathan McDowell 2020-06-20  1238               if 
(state->interface != PHY_INTERFACE_MODE_RGMII &&
b3591c2a366167 Jonathan McDowell 2020-06-20  1239                   
state->interface != PHY_INTERFACE_MODE_RGMII_ID &&
e4b9977cee1583 Ansuel Smith      2021-05-14  1240                   
state->interface != PHY_INTERFACE_MODE_RGMII_TXID &&
e4b9977cee1583 Ansuel Smith      2021-05-14  1241                   
state->interface != PHY_INTERFACE_MODE_RGMII_RXID &&
b3591c2a366167 Jonathan McDowell 2020-06-20  1242                   
state->interface != PHY_INTERFACE_MODE_SGMII &&
b3591c2a366167 Jonathan McDowell 2020-06-20  1243                   
state->interface != PHY_INTERFACE_MODE_1000BASEX)
b3591c2a366167 Jonathan McDowell 2020-06-20  1244                       return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1245  
b3591c2a366167 Jonathan McDowell 2020-06-20  1246               reg = 
QCA8K_REG_PORT6_PAD_CTRL;
b3591c2a366167 Jonathan McDowell 2020-06-20  1247               break;
b3591c2a366167 Jonathan McDowell 2020-06-20  1248       default:
b3591c2a366167 Jonathan McDowell 2020-06-20  1249               
dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
9bb2289f90e671 Michal Vokáč      2018-05-23  1250               return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1251       }
9bb2289f90e671 Michal Vokáč      2018-05-23  1252  
b3591c2a366167 Jonathan McDowell 2020-06-20  1253       if (port != 6 && 
phylink_autoneg_inband(mode)) {
b3591c2a366167 Jonathan McDowell 2020-06-20  1254               
dev_err(ds->dev, "%s: in-band negotiation unsupported\n",
b3591c2a366167 Jonathan McDowell 2020-06-20  1255                       
__func__);
b3591c2a366167 Jonathan McDowell 2020-06-20  1256               return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1257       }
b3591c2a366167 Jonathan McDowell 2020-06-20  1258  
b3591c2a366167 Jonathan McDowell 2020-06-20  1259       switch 
(state->interface) {
b3591c2a366167 Jonathan McDowell 2020-06-20  1260       case 
PHY_INTERFACE_MODE_RGMII:
b3591c2a366167 Jonathan McDowell 2020-06-20  1261               /* RGMII mode 
means no delay so don't enable the delay */
b3591c2a366167 Jonathan McDowell 2020-06-20  1262               
qca8k_write(priv, reg, QCA8K_PORT_PAD_RGMII_EN);
b3591c2a366167 Jonathan McDowell 2020-06-20  1263               break;
b3591c2a366167 Jonathan McDowell 2020-06-20  1264       case 
PHY_INTERFACE_MODE_RGMII_ID:
e4b9977cee1583 Ansuel Smith      2021-05-14  1265       case 
PHY_INTERFACE_MODE_RGMII_TXID:
e4b9977cee1583 Ansuel Smith      2021-05-14  1266       case 
PHY_INTERFACE_MODE_RGMII_RXID:
b3591c2a366167 Jonathan McDowell 2020-06-20  1267               /* RGMII_ID 
needs internal delay. This is enabled through
b3591c2a366167 Jonathan McDowell 2020-06-20  1268                * 
PORT5_PAD_CTRL for all ports, rather than individual port
b3591c2a366167 Jonathan McDowell 2020-06-20  1269                * registers
b3591c2a366167 Jonathan McDowell 2020-06-20  1270                */
b3591c2a366167 Jonathan McDowell 2020-06-20  1271               
qca8k_write(priv, reg,
b3591c2a366167 Jonathan McDowell 2020-06-20  1272                           
QCA8K_PORT_PAD_RGMII_EN |
e4b9977cee1583 Ansuel Smith      2021-05-14  1273                           
QCA8K_PORT_PAD_RGMII_TX_DELAY(priv->rgmii_tx_delay) |
e4b9977cee1583 Ansuel Smith      2021-05-14  1274                           
QCA8K_PORT_PAD_RGMII_RX_DELAY(priv->rgmii_rx_delay) |
e4b9977cee1583 Ansuel Smith      2021-05-14  1275                           
QCA8K_PORT_PAD_RGMII_TX_DELAY_EN |
e4b9977cee1583 Ansuel Smith      2021-05-14  1276                           
QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
5bf9ff3b9fb5ec Ansuel Smith      2021-05-14  1277               /* QCA8337 
requires to set rgmii rx delay */
5bf9ff3b9fb5ec Ansuel Smith      2021-05-14  1278               if 
(priv->switch_id == QCA8K_ID_QCA8337)
b3591c2a366167 Jonathan McDowell 2020-06-20  1279                       
qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
b3591c2a366167 Jonathan McDowell 2020-06-20  1280                               
    QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
b3591c2a366167 Jonathan McDowell 2020-06-20  1281               break;
b3591c2a366167 Jonathan McDowell 2020-06-20  1282       case 
PHY_INTERFACE_MODE_SGMII:
b3591c2a366167 Jonathan McDowell 2020-06-20  1283       case 
PHY_INTERFACE_MODE_1000BASEX:
b3591c2a366167 Jonathan McDowell 2020-06-20  1284               /* Enable SGMII 
on the port */
b3591c2a366167 Jonathan McDowell 2020-06-20  1285               
qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
f6dadd559886f8 Jonathan McDowell 2020-06-20  1286  
f6dadd559886f8 Jonathan McDowell 2020-06-20  1287               /* 
Enable/disable SerDes auto-negotiation as necessary */
9fe99de01440d9 Yang Yingliang    2021-05-29  1288               ret = 
qca8k_read(priv, QCA8K_REG_PWS, &val);
9fe99de01440d9 Yang Yingliang    2021-05-29  1289               if (ret)
9fe99de01440d9 Yang Yingliang    2021-05-29  1290                       return;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1291               if 
(phylink_autoneg_inband(mode))
f6dadd559886f8 Jonathan McDowell 2020-06-20  1292                       val &= 
~QCA8K_PWS_SERDES_AEN_DIS;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1293               else
f6dadd559886f8 Jonathan McDowell 2020-06-20  1294                       val |= 
QCA8K_PWS_SERDES_AEN_DIS;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1295               
qca8k_write(priv, QCA8K_REG_PWS, val);
f6dadd559886f8 Jonathan McDowell 2020-06-20  1296  
f6dadd559886f8 Jonathan McDowell 2020-06-20  1297               /* Configure 
the SGMII parameters */
9fe99de01440d9 Yang Yingliang    2021-05-29  1298               ret = 
qca8k_read(priv, QCA8K_REG_SGMII_CTRL, &val);
9fe99de01440d9 Yang Yingliang    2021-05-29  1299               if (ret)
9fe99de01440d9 Yang Yingliang    2021-05-29  1300                       return;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1301  
f6dadd559886f8 Jonathan McDowell 2020-06-20  1302               val |= 
QCA8K_SGMII_EN_PLL | QCA8K_SGMII_EN_RX |
f6dadd559886f8 Jonathan McDowell 2020-06-20  1303                       
QCA8K_SGMII_EN_TX | QCA8K_SGMII_EN_SD;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1304  
f6dadd559886f8 Jonathan McDowell 2020-06-20  1305               if 
(dsa_is_cpu_port(ds, port)) {
f6dadd559886f8 Jonathan McDowell 2020-06-20  1306                       /* CPU 
port, we're talking to the CPU MAC, be a PHY */
f6dadd559886f8 Jonathan McDowell 2020-06-20  1307                       val &= 
~QCA8K_SGMII_MODE_CTRL_MASK;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1308                       val |= 
QCA8K_SGMII_MODE_CTRL_PHY;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1309               } else if 
(state->interface == PHY_INTERFACE_MODE_SGMII) {
f6dadd559886f8 Jonathan McDowell 2020-06-20  1310                       val &= 
~QCA8K_SGMII_MODE_CTRL_MASK;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1311                       val |= 
QCA8K_SGMII_MODE_CTRL_MAC;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1312               } else if 
(state->interface == PHY_INTERFACE_MODE_1000BASEX) {
f6dadd559886f8 Jonathan McDowell 2020-06-20  1313                       val &= 
~QCA8K_SGMII_MODE_CTRL_MASK;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1314                       val |= 
QCA8K_SGMII_MODE_CTRL_BASEX;
f6dadd559886f8 Jonathan McDowell 2020-06-20  1315               }
f6dadd559886f8 Jonathan McDowell 2020-06-20  1316  
f6dadd559886f8 Jonathan McDowell 2020-06-20  1317               
qca8k_write(priv, QCA8K_REG_SGMII_CTRL, val);
6c43809bf1bee7 Ansuel Smith      2021-10-14  1318  
6c43809bf1bee7 Ansuel Smith      2021-10-14  1319               /* For 
qca8327/qca8328/qca8334/qca8338 sgmii is unique and
6c43809bf1bee7 Ansuel Smith      2021-10-14  1320                * falling edge 
is set writing in the PORT0 PAD reg
6c43809bf1bee7 Ansuel Smith      2021-10-14  1321                */
6c43809bf1bee7 Ansuel Smith      2021-10-14  1322               if 
(priv->switch_id == QCA8K_ID_QCA8327 ||
6c43809bf1bee7 Ansuel Smith      2021-10-14  1323                   
priv->switch_id == QCA8K_ID_QCA8337)
6c43809bf1bee7 Ansuel Smith      2021-10-14  1324                       reg = 
QCA8K_REG_PORT0_PAD_CTRL;
6c43809bf1bee7 Ansuel Smith      2021-10-14  1325  
6c43809bf1bee7 Ansuel Smith      2021-10-14  1326               val = 0;
6c43809bf1bee7 Ansuel Smith      2021-10-14  1327  
6c43809bf1bee7 Ansuel Smith      2021-10-14  1328               /* SGMII Clock 
phase configuration */
6c43809bf1bee7 Ansuel Smith      2021-10-14  1329               if 
(priv->sgmii_rx_clk_falling_edge)
6c43809bf1bee7 Ansuel Smith      2021-10-14  1330                       val |= 
QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE;
6c43809bf1bee7 Ansuel Smith      2021-10-14  1331  
6c43809bf1bee7 Ansuel Smith      2021-10-14  1332               if 
(priv->sgmii_tx_clk_falling_edge)
6c43809bf1bee7 Ansuel Smith      2021-10-14  1333                       val |= 
QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE;
6c43809bf1bee7 Ansuel Smith      2021-10-14  1334  
6c43809bf1bee7 Ansuel Smith      2021-10-14  1335               if (val)
6c43809bf1bee7 Ansuel Smith      2021-10-14 @1336                       ret = 
qca8k_rmw(priv, reg,
6c43809bf1bee7 Ansuel Smith      2021-10-14  1337                               
        QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE |
6c43809bf1bee7 Ansuel Smith      2021-10-14  1338                               
        QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE,
6c43809bf1bee7 Ansuel Smith      2021-10-14  1339                               
        val);
b3591c2a366167 Jonathan McDowell 2020-06-20  1340               break;
b3591c2a366167 Jonathan McDowell 2020-06-20  1341       default:
b3591c2a366167 Jonathan McDowell 2020-06-20  1342               
dev_err(ds->dev, "xMII mode %s not supported for port %d\n",
b3591c2a366167 Jonathan McDowell 2020-06-20  1343                       
phy_modes(state->interface), port);
b3591c2a366167 Jonathan McDowell 2020-06-20  1344               return;
b3591c2a366167 Jonathan McDowell 2020-06-20  1345       }
b3591c2a366167 Jonathan McDowell 2020-06-20  1346  }
b3591c2a366167 Jonathan McDowell 2020-06-20  1347  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to