Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: qcom: qmp: move common functions to common header

Move common init tables code to the common header phy-qcom-qmp-common.h.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240126-phy-qmp-merge-common-v2-3-a463d0b57836@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dmitry Baryshkov and committed by
Vinod Koul
53d7776e d3e7e79c

+120 -348
+16 -64
drivers/phy/qualcomm/phy-qcom-qmp-combo.c
··· 25 25 26 26 #include <dt-bindings/phy/phy-qcom-qmp.h> 27 27 28 + #include "phy-qcom-qmp-common.h" 29 + 28 30 #include "phy-qcom-qmp.h" 29 31 #include "phy-qcom-qmp-pcs-misc-v3.h" 30 32 #include "phy-qcom-qmp-pcs-usb-v4.h" ··· 73 71 #define SW_PORTSELECT_MUX BIT(1) 74 72 75 73 #define PHY_INIT_COMPLETE_TIMEOUT 10000 76 - 77 - struct qmp_phy_init_tbl { 78 - unsigned int offset; 79 - unsigned int val; 80 - /* 81 - * mask of lanes for which this register is written 82 - * for cases when second lane needs different values 83 - */ 84 - u8 lane_mask; 85 - }; 86 - 87 - #define QMP_PHY_INIT_CFG(o, v) \ 88 - { \ 89 - .offset = o, \ 90 - .val = v, \ 91 - .lane_mask = 0xff, \ 92 - } 93 - 94 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 95 - { \ 96 - .offset = o, \ 97 - .val = v, \ 98 - .lane_mask = l, \ 99 - } 100 74 101 75 /* set of registers with offsets different per-PHY */ 102 76 enum qphy_reg_layout { ··· 2009 2031 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 2010 2032 }; 2011 2033 2012 - static void qmp_combo_configure_lane(void __iomem *base, 2013 - const struct qmp_phy_init_tbl tbl[], 2014 - int num, 2015 - u8 lane_mask) 2016 - { 2017 - int i; 2018 - const struct qmp_phy_init_tbl *t = tbl; 2019 - 2020 - if (!t) 2021 - return; 2022 - 2023 - for (i = 0; i < num; i++, t++) { 2024 - if (!(t->lane_mask & lane_mask)) 2025 - continue; 2026 - 2027 - writel(t->val, base + t->offset); 2028 - } 2029 - } 2030 - 2031 - static void qmp_combo_configure(void __iomem *base, 2032 - const struct qmp_phy_init_tbl tbl[], 2033 - int num) 2034 - { 2035 - qmp_combo_configure_lane(base, tbl, num, 0xff); 2036 - } 2037 - 2038 2034 static int qmp_combo_dp_serdes_init(struct qmp_combo *qmp) 2039 2035 { 2040 2036 const struct qmp_phy_cfg *cfg = qmp->cfg; 2041 2037 void __iomem *serdes = qmp->dp_serdes; 2042 2038 const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; 2043 2039 2044 - qmp_combo_configure(serdes, cfg->dp_serdes_tbl, cfg->dp_serdes_tbl_num); 2040 + qmp_configure(serdes, cfg->dp_serdes_tbl, cfg->dp_serdes_tbl_num); 2045 2041 2046 2042 switch (dp_opts->link_rate) { 2047 2043 case 1620: 2048 - qmp_combo_configure(serdes, cfg->serdes_tbl_rbr, 2044 + qmp_configure(serdes, cfg->serdes_tbl_rbr, 2049 2045 cfg->serdes_tbl_rbr_num); 2050 2046 break; 2051 2047 case 2700: 2052 - qmp_combo_configure(serdes, cfg->serdes_tbl_hbr, 2048 + qmp_configure(serdes, cfg->serdes_tbl_hbr, 2053 2049 cfg->serdes_tbl_hbr_num); 2054 2050 break; 2055 2051 case 5400: 2056 - qmp_combo_configure(serdes, cfg->serdes_tbl_hbr2, 2052 + qmp_configure(serdes, cfg->serdes_tbl_hbr2, 2057 2053 cfg->serdes_tbl_hbr2_num); 2058 2054 break; 2059 2055 case 8100: 2060 - qmp_combo_configure(serdes, cfg->serdes_tbl_hbr3, 2056 + qmp_configure(serdes, cfg->serdes_tbl_hbr3, 2061 2057 cfg->serdes_tbl_hbr3_num); 2062 2058 break; 2063 2059 default: ··· 2633 2681 2634 2682 qmp_combo_dp_serdes_init(qmp); 2635 2683 2636 - qmp_combo_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1); 2637 - qmp_combo_configure_lane(tx2, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 2); 2684 + qmp_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1); 2685 + qmp_configure_lane(tx2, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 2); 2638 2686 2639 2687 /* Configure special DP tx tunings */ 2640 2688 cfg->configure_dp_tx(qmp); ··· 2676 2724 unsigned int val; 2677 2725 int ret; 2678 2726 2679 - qmp_combo_configure(serdes, cfg->serdes_tbl, cfg->serdes_tbl_num); 2727 + qmp_configure(serdes, cfg->serdes_tbl, cfg->serdes_tbl_num); 2680 2728 2681 2729 ret = clk_prepare_enable(qmp->pipe_clk); 2682 2730 if (ret) { ··· 2685 2733 } 2686 2734 2687 2735 /* Tx, Rx, and PCS configurations */ 2688 - qmp_combo_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2689 - qmp_combo_configure_lane(tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); 2736 + qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2737 + qmp_configure_lane(tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); 2690 2738 2691 - qmp_combo_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2692 - qmp_combo_configure_lane(rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); 2739 + qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2740 + qmp_configure_lane(rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); 2693 2741 2694 - qmp_combo_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2742 + qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2695 2743 2696 2744 if (pcs_usb) 2697 - qmp_combo_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); 2745 + qmp_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); 2698 2746 2699 2747 if (cfg->has_pwrdn_delay) 2700 2748 usleep_range(10, 20);
+59
drivers/phy/qualcomm/phy-qcom-qmp-common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (c) 2017, The Linux Foundation. All rights reserved. 4 + */ 5 + 6 + #ifndef QCOM_PHY_QMP_COMMON_H_ 7 + #define QCOM_PHY_QMP_COMMON_H_ 8 + 9 + struct qmp_phy_init_tbl { 10 + unsigned int offset; 11 + unsigned int val; 12 + /* 13 + * mask of lanes for which this register is written 14 + * for cases when second lane needs different values 15 + */ 16 + u8 lane_mask; 17 + }; 18 + 19 + #define QMP_PHY_INIT_CFG(o, v) \ 20 + { \ 21 + .offset = o, \ 22 + .val = v, \ 23 + .lane_mask = 0xff, \ 24 + } 25 + 26 + #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 27 + { \ 28 + .offset = o, \ 29 + .val = v, \ 30 + .lane_mask = l, \ 31 + } 32 + 33 + static inline void qmp_configure_lane(void __iomem *base, 34 + const struct qmp_phy_init_tbl tbl[], 35 + int num, 36 + u8 lane_mask) 37 + { 38 + int i; 39 + const struct qmp_phy_init_tbl *t = tbl; 40 + 41 + if (!t) 42 + return; 43 + 44 + for (i = 0; i < num; i++, t++) { 45 + if (!(t->lane_mask & lane_mask)) 46 + continue; 47 + 48 + writel(t->val, base + t->offset); 49 + } 50 + } 51 + 52 + static inline void qmp_configure(void __iomem *base, 53 + const struct qmp_phy_init_tbl tbl[], 54 + int num) 55 + { 56 + qmp_configure_lane(base, tbl, num, 0xff); 57 + } 58 + 59 + #endif
+6 -54
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
··· 19 19 #include <linux/reset.h> 20 20 #include <linux/slab.h> 21 21 22 + #include "phy-qcom-qmp-common.h" 23 + 22 24 #include "phy-qcom-qmp.h" 23 25 24 26 /* QPHY_SW_RESET bit */ ··· 40 38 #define PHY_INIT_COMPLETE_TIMEOUT 10000 41 39 #define POWER_DOWN_DELAY_US_MIN 10 42 40 #define POWER_DOWN_DELAY_US_MAX 20 43 - 44 - struct qmp_phy_init_tbl { 45 - unsigned int offset; 46 - unsigned int val; 47 - /* 48 - * mask of lanes for which this register is written 49 - * for cases when second lane needs different values 50 - */ 51 - u8 lane_mask; 52 - }; 53 - 54 - #define QMP_PHY_INIT_CFG(o, v) \ 55 - { \ 56 - .offset = o, \ 57 - .val = v, \ 58 - .lane_mask = 0xff, \ 59 - } 60 - 61 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 62 - { \ 63 - .offset = o, \ 64 - .val = v, \ 65 - .lane_mask = l, \ 66 - } 67 41 68 42 /* set of registers with offsets different per-PHY */ 69 43 enum qphy_reg_layout { ··· 285 307 .regs = pciephy_regs_layout, 286 308 }; 287 309 288 - static void qmp_pcie_msm8996_configure_lane(void __iomem *base, 289 - const struct qmp_phy_init_tbl tbl[], 290 - int num, 291 - u8 lane_mask) 292 - { 293 - int i; 294 - const struct qmp_phy_init_tbl *t = tbl; 295 - 296 - if (!t) 297 - return; 298 - 299 - for (i = 0; i < num; i++, t++) { 300 - if (!(t->lane_mask & lane_mask)) 301 - continue; 302 - 303 - writel(t->val, base + t->offset); 304 - } 305 - } 306 - 307 - static void qmp_pcie_msm8996_configure(void __iomem *base, 308 - const struct qmp_phy_init_tbl tbl[], 309 - int num) 310 - { 311 - qmp_pcie_msm8996_configure_lane(base, tbl, num, 0xff); 312 - } 313 - 314 310 static int qmp_pcie_msm8996_serdes_init(struct qmp_phy *qphy) 315 311 { 316 312 struct qcom_qmp *qmp = qphy->qmp; ··· 296 344 unsigned int val; 297 345 int ret; 298 346 299 - qmp_pcie_msm8996_configure(serdes, serdes_tbl, serdes_tbl_num); 347 + qmp_configure(serdes, serdes_tbl, serdes_tbl_num); 300 348 301 349 qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET); 302 350 qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], ··· 439 487 } 440 488 441 489 /* Tx, Rx, and PCS configurations */ 442 - qmp_pcie_msm8996_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 443 - qmp_pcie_msm8996_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 444 - qmp_pcie_msm8996_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 490 + qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 491 + qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 492 + qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 445 493 446 494 /* 447 495 * Pull out PHY from POWER DOWN state.
+15 -63
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
··· 22 22 #include <linux/reset.h> 23 23 #include <linux/slab.h> 24 24 25 + #include "phy-qcom-qmp-common.h" 26 + 25 27 #include "phy-qcom-qmp.h" 26 28 #include "phy-qcom-qmp-pcs-misc-v3.h" 27 29 #include "phy-qcom-qmp-pcs-pcie-v4.h" ··· 47 45 #define PHYSTATUS_4_20 BIT(7) 48 46 49 47 #define PHY_INIT_COMPLETE_TIMEOUT 10000 50 - 51 - struct qmp_phy_init_tbl { 52 - unsigned int offset; 53 - unsigned int val; 54 - /* 55 - * mask of lanes for which this register is written 56 - * for cases when second lane needs different values 57 - */ 58 - u8 lane_mask; 59 - }; 60 - 61 - #define QMP_PHY_INIT_CFG(o, v) \ 62 - { \ 63 - .offset = o, \ 64 - .val = v, \ 65 - .lane_mask = 0xff, \ 66 - } 67 - 68 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 69 - { \ 70 - .offset = o, \ 71 - .val = v, \ 72 - .lane_mask = l, \ 73 - } 74 48 75 49 /* set of registers with offsets different per-PHY */ 76 50 enum qphy_reg_layout { ··· 3343 3365 .has_nocsr_reset = true, 3344 3366 }; 3345 3367 3346 - static void qmp_pcie_configure_lane(void __iomem *base, 3347 - const struct qmp_phy_init_tbl tbl[], 3348 - int num, 3349 - u8 lane_mask) 3350 - { 3351 - int i; 3352 - const struct qmp_phy_init_tbl *t = tbl; 3353 - 3354 - if (!t) 3355 - return; 3356 - 3357 - for (i = 0; i < num; i++, t++) { 3358 - if (!(t->lane_mask & lane_mask)) 3359 - continue; 3360 - 3361 - writel(t->val, base + t->offset); 3362 - } 3363 - } 3364 - 3365 - static void qmp_pcie_configure(void __iomem *base, 3366 - const struct qmp_phy_init_tbl tbl[], 3367 - int num) 3368 - { 3369 - qmp_pcie_configure_lane(base, tbl, num, 0xff); 3370 - } 3371 - 3372 3368 static void qmp_pcie_init_port_b(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tbls *tbls) 3373 3369 { 3374 3370 const struct qmp_phy_cfg *cfg = qmp->cfg; ··· 3354 3402 tx4 = qmp->port_b + offs->tx2; 3355 3403 rx4 = qmp->port_b + offs->rx2; 3356 3404 3357 - qmp_pcie_configure_lane(tx3, tbls->tx, tbls->tx_num, 1); 3358 - qmp_pcie_configure_lane(rx3, tbls->rx, tbls->rx_num, 1); 3405 + qmp_configure_lane(tx3, tbls->tx, tbls->tx_num, 1); 3406 + qmp_configure_lane(rx3, tbls->rx, tbls->rx_num, 1); 3359 3407 3360 - qmp_pcie_configure_lane(tx4, tbls->tx, tbls->tx_num, 2); 3361 - qmp_pcie_configure_lane(rx4, tbls->rx, tbls->rx_num, 2); 3408 + qmp_configure_lane(tx4, tbls->tx, tbls->tx_num, 2); 3409 + qmp_configure_lane(rx4, tbls->rx, tbls->rx_num, 2); 3362 3410 } 3363 3411 3364 3412 static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tbls *tbls) ··· 3376 3424 if (!tbls) 3377 3425 return; 3378 3426 3379 - qmp_pcie_configure(serdes, tbls->serdes, tbls->serdes_num); 3427 + qmp_configure(serdes, tbls->serdes, tbls->serdes_num); 3380 3428 3381 - qmp_pcie_configure_lane(tx, tbls->tx, tbls->tx_num, 1); 3382 - qmp_pcie_configure_lane(rx, tbls->rx, tbls->rx_num, 1); 3429 + qmp_configure_lane(tx, tbls->tx, tbls->tx_num, 1); 3430 + qmp_configure_lane(rx, tbls->rx, tbls->rx_num, 1); 3383 3431 3384 3432 if (cfg->lanes >= 2) { 3385 - qmp_pcie_configure_lane(tx2, tbls->tx, tbls->tx_num, 2); 3386 - qmp_pcie_configure_lane(rx2, tbls->rx, tbls->rx_num, 2); 3433 + qmp_configure_lane(tx2, tbls->tx, tbls->tx_num, 2); 3434 + qmp_configure_lane(rx2, tbls->rx, tbls->rx_num, 2); 3387 3435 } 3388 3436 3389 - qmp_pcie_configure(pcs, tbls->pcs, tbls->pcs_num); 3390 - qmp_pcie_configure(pcs_misc, tbls->pcs_misc, tbls->pcs_misc_num); 3437 + qmp_configure(pcs, tbls->pcs, tbls->pcs_num); 3438 + qmp_configure(pcs_misc, tbls->pcs_misc, tbls->pcs_misc_num); 3391 3439 3392 3440 if (cfg->lanes >= 4 && qmp->tcsr_4ln_config) { 3393 - qmp_pcie_configure(serdes, cfg->serdes_4ln_tbl, cfg->serdes_4ln_num); 3441 + qmp_configure(serdes, cfg->serdes_4ln_tbl, cfg->serdes_4ln_num); 3394 3442 qmp_pcie_init_port_b(qmp, tbls); 3395 3443 } 3396 3444 3397 - qmp_pcie_configure(ln_shrd, tbls->ln_shrd, tbls->ln_shrd_num); 3445 + qmp_configure(ln_shrd, tbls->ln_shrd, tbls->ln_shrd_num); 3398 3446 } 3399 3447 3400 3448 static int qmp_pcie_init(struct phy *phy)
+9 -56
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
··· 20 20 #include <linux/slab.h> 21 21 22 22 #include <ufs/unipro.h> 23 + 24 + #include "phy-qcom-qmp-common.h" 25 + 23 26 #include "phy-qcom-qmp.h" 24 27 #include "phy-qcom-qmp-pcs-ufs-v2.h" 25 28 #include "phy-qcom-qmp-pcs-ufs-v3.h" ··· 45 42 #define PHY_INIT_COMPLETE_TIMEOUT 10000 46 43 47 44 #define NUM_OVERLAY 2 48 - 49 - struct qmp_phy_init_tbl { 50 - unsigned int offset; 51 - unsigned int val; 52 - /* 53 - * mask of lanes for which this register is written 54 - * for cases when second lane needs different values 55 - */ 56 - u8 lane_mask; 57 - }; 58 - 59 - #define QMP_PHY_INIT_CFG(o, v) \ 60 - { \ 61 - .offset = o, \ 62 - .val = v, \ 63 - .lane_mask = 0xff, \ 64 - } 65 - 66 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 67 - { \ 68 - .offset = o, \ 69 - .val = v, \ 70 - .lane_mask = l, \ 71 - } 72 45 73 46 /* set of registers with offsets different per-PHY */ 74 47 enum qphy_reg_layout { ··· 1462 1483 .regs = ufsphy_v6_regs_layout, 1463 1484 }; 1464 1485 1465 - static void qmp_ufs_configure_lane(void __iomem *base, 1466 - const struct qmp_phy_init_tbl tbl[], 1467 - int num, 1468 - u8 lane_mask) 1469 - { 1470 - int i; 1471 - const struct qmp_phy_init_tbl *t = tbl; 1472 - 1473 - if (!t) 1474 - return; 1475 - 1476 - for (i = 0; i < num; i++, t++) { 1477 - if (!(t->lane_mask & lane_mask)) 1478 - continue; 1479 - 1480 - writel(t->val, base + t->offset); 1481 - } 1482 - } 1483 - 1484 - static void qmp_ufs_configure(void __iomem *base, 1485 - const struct qmp_phy_init_tbl tbl[], 1486 - int num) 1487 - { 1488 - qmp_ufs_configure_lane(base, tbl, num, 0xff); 1489 - } 1490 - 1491 1486 static void qmp_ufs_serdes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) 1492 1487 { 1493 1488 void __iomem *serdes = qmp->serdes; 1494 1489 1495 - qmp_ufs_configure(serdes, tbls->serdes, tbls->serdes_num); 1490 + qmp_configure(serdes, tbls->serdes, tbls->serdes_num); 1496 1491 } 1497 1492 1498 1493 static void qmp_ufs_lanes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) ··· 1475 1522 void __iomem *tx = qmp->tx; 1476 1523 void __iomem *rx = qmp->rx; 1477 1524 1478 - qmp_ufs_configure_lane(tx, tbls->tx, tbls->tx_num, 1); 1479 - qmp_ufs_configure_lane(rx, tbls->rx, tbls->rx_num, 1); 1525 + qmp_configure_lane(tx, tbls->tx, tbls->tx_num, 1); 1526 + qmp_configure_lane(rx, tbls->rx, tbls->rx_num, 1); 1480 1527 1481 1528 if (cfg->lanes >= 2) { 1482 - qmp_ufs_configure_lane(qmp->tx2, tbls->tx, tbls->tx_num, 2); 1483 - qmp_ufs_configure_lane(qmp->rx2, tbls->rx, tbls->rx_num, 2); 1529 + qmp_configure_lane(qmp->tx2, tbls->tx, tbls->tx_num, 2); 1530 + qmp_configure_lane(qmp->rx2, tbls->rx, tbls->rx_num, 2); 1484 1531 } 1485 1532 } 1486 1533 ··· 1488 1535 { 1489 1536 void __iomem *pcs = qmp->pcs; 1490 1537 1491 - qmp_ufs_configure(pcs, tbls->pcs, tbls->pcs_num); 1538 + qmp_configure(pcs, tbls->pcs, tbls->pcs_num); 1492 1539 } 1493 1540 1494 1541 static int qmp_ufs_get_gear_overlay(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg)
+7 -55
drivers/phy/qualcomm/phy-qcom-qmp-usb.c
··· 19 19 #include <linux/reset.h> 20 20 #include <linux/slab.h> 21 21 22 + #include "phy-qcom-qmp-common.h" 23 + 22 24 #include "phy-qcom-qmp.h" 23 25 #include "phy-qcom-qmp-pcs-misc-v3.h" 24 26 #include "phy-qcom-qmp-pcs-misc-v4.h" ··· 65 63 #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ 66 64 67 65 #define PHY_INIT_COMPLETE_TIMEOUT 10000 68 - 69 - struct qmp_phy_init_tbl { 70 - unsigned int offset; 71 - unsigned int val; 72 - /* 73 - * mask of lanes for which this register is written 74 - * for cases when second lane needs different values 75 - */ 76 - u8 lane_mask; 77 - }; 78 - 79 - #define QMP_PHY_INIT_CFG(o, v) \ 80 - { \ 81 - .offset = o, \ 82 - .val = v, \ 83 - .lane_mask = 0xff, \ 84 - } 85 - 86 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 87 - { \ 88 - .offset = o, \ 89 - .val = v, \ 90 - .lane_mask = l, \ 91 - } 92 66 93 67 /* set of registers with offsets different per-PHY */ 94 68 enum qphy_reg_layout { ··· 1609 1631 .regs = qmp_v7_usb3phy_regs_layout, 1610 1632 }; 1611 1633 1612 - static void qmp_usb_configure_lane(void __iomem *base, 1613 - const struct qmp_phy_init_tbl tbl[], 1614 - int num, 1615 - u8 lane_mask) 1616 - { 1617 - int i; 1618 - const struct qmp_phy_init_tbl *t = tbl; 1619 - 1620 - if (!t) 1621 - return; 1622 - 1623 - for (i = 0; i < num; i++, t++) { 1624 - if (!(t->lane_mask & lane_mask)) 1625 - continue; 1626 - 1627 - writel(t->val, base + t->offset); 1628 - } 1629 - } 1630 - 1631 - static void qmp_usb_configure(void __iomem *base, 1632 - const struct qmp_phy_init_tbl tbl[], 1633 - int num) 1634 - { 1635 - qmp_usb_configure_lane(base, tbl, num, 0xff); 1636 - } 1637 - 1638 1634 static int qmp_usb_serdes_init(struct qmp_usb *qmp) 1639 1635 { 1640 1636 const struct qmp_phy_cfg *cfg = qmp->cfg; ··· 1616 1664 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 1617 1665 int serdes_tbl_num = cfg->serdes_tbl_num; 1618 1666 1619 - qmp_usb_configure(serdes, serdes_tbl, serdes_tbl_num); 1667 + qmp_configure(serdes, serdes_tbl, serdes_tbl_num); 1620 1668 1621 1669 return 0; 1622 1670 } ··· 1697 1745 } 1698 1746 1699 1747 /* Tx, Rx, and PCS configurations */ 1700 - qmp_usb_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 1701 - qmp_usb_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 1748 + qmp_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 1749 + qmp_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 1702 1750 1703 - qmp_usb_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 1751 + qmp_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 1704 1752 1705 1753 if (pcs_usb) 1706 - qmp_usb_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); 1754 + qmp_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); 1707 1755 1708 1756 if (cfg->has_pwrdn_delay) 1709 1757 usleep_range(10, 20);
+8 -56
drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
··· 23 23 #include <linux/usb/typec.h> 24 24 #include <linux/usb/typec_mux.h> 25 25 26 + #include "phy-qcom-qmp-common.h" 27 + 26 28 #include "phy-qcom-qmp.h" 27 29 #include "phy-qcom-qmp-pcs-misc-v3.h" 28 30 ··· 61 59 #define IRQ_CLEAR BIT(0) 62 60 63 61 #define PHY_INIT_COMPLETE_TIMEOUT 10000 64 - 65 - struct qmp_phy_init_tbl { 66 - unsigned int offset; 67 - unsigned int val; 68 - /* 69 - * mask of lanes for which this register is written 70 - * for cases when second lane needs different values 71 - */ 72 - u8 lane_mask; 73 - }; 74 - 75 - #define QMP_PHY_INIT_CFG(o, v) \ 76 - { \ 77 - .offset = o, \ 78 - .val = v, \ 79 - .lane_mask = 0xff, \ 80 - } 81 - 82 - #define QMP_PHY_INIT_CFG_LANE(o, v, l) \ 83 - { \ 84 - .offset = o, \ 85 - .val = v, \ 86 - .lane_mask = l, \ 87 - } 88 62 89 63 /* set of registers with offsets different per-PHY */ 90 64 enum qphy_reg_layout { ··· 489 511 .regs = qmp_v3_usb3phy_regs_layout_qcm2290, 490 512 }; 491 513 492 - static void qmp_usbc_configure_lane(void __iomem *base, 493 - const struct qmp_phy_init_tbl tbl[], 494 - int num, 495 - u8 lane_mask) 496 - { 497 - int i; 498 - const struct qmp_phy_init_tbl *t = tbl; 499 - 500 - if (!t) 501 - return; 502 - 503 - for (i = 0; i < num; i++, t++) { 504 - if (!(t->lane_mask & lane_mask)) 505 - continue; 506 - 507 - writel(t->val, base + t->offset); 508 - } 509 - } 510 - 511 - static void qmp_usbc_configure(void __iomem *base, 512 - const struct qmp_phy_init_tbl tbl[], 513 - int num) 514 - { 515 - qmp_usbc_configure_lane(base, tbl, num, 0xff); 516 - } 517 - 518 514 static int qmp_usbc_init(struct phy *phy) 519 515 { 520 516 struct qmp_usbc *qmp = phy_get_drvdata(phy); ··· 561 609 unsigned int val; 562 610 int ret; 563 611 564 - qmp_usbc_configure(qmp->serdes, cfg->serdes_tbl, cfg->serdes_tbl_num); 612 + qmp_configure(qmp->serdes, cfg->serdes_tbl, cfg->serdes_tbl_num); 565 613 566 614 ret = clk_prepare_enable(qmp->pipe_clk); 567 615 if (ret) { ··· 570 618 } 571 619 572 620 /* Tx, Rx, and PCS configurations */ 573 - qmp_usbc_configure_lane(qmp->tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 574 - qmp_usbc_configure_lane(qmp->rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 621 + qmp_configure_lane(qmp->tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); 622 + qmp_configure_lane(qmp->rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); 575 623 576 - qmp_usbc_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); 577 - qmp_usbc_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); 624 + qmp_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); 625 + qmp_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); 578 626 579 - qmp_usbc_configure(qmp->pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 627 + qmp_configure(qmp->pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); 580 628 581 629 if (cfg->has_pwrdn_delay) 582 630 usleep_range(10, 20);