diff options
author | Alistair Popple <alistair@popple.id.au> | 2017-06-01 13:46:05 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-06-06 17:59:45 +1000 |
commit | d35084ef2b94d6ad293bc02fcdf1a30b78b02930 (patch) | |
tree | dc4f4e16e6f3212ce82bdf8fa6179b921e48858b /hw/npu2-hw-procedures.c | |
parent | b5d85370f669ab4e64f63cdd73c35f16e9d68794 (diff) | |
download | skiboot-d35084ef2b94d6ad293bc02fcdf1a30b78b02930.zip skiboot-d35084ef2b94d6ad293bc02fcdf1a30b78b02930.tar.gz skiboot-d35084ef2b94d6ad293bc02fcdf1a30b78b02930.tar.bz2 |
hw/npu2-hw-procedures.c: Fix running of zcal procedure
The zcal procedure should only be run once per obus (ie. once per group of 3
links). Clean up the code and fix the potential buffer overflow due to a typo.
Also updates the zcal settings to their proper values.
Fixes coverity 143248.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/npu2-hw-procedures.c')
-rw-r--r-- | hw/npu2-hw-procedures.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/hw/npu2-hw-procedures.c b/hw/npu2-hw-procedures.c index ade898e..ee1ade6 100644 --- a/hw/npu2-hw-procedures.c +++ b/hw/npu2-hw-procedures.c @@ -297,9 +297,8 @@ DEFINE_PROCEDURE(phy_reset, phy_reset_wait, phy_reset_complete); static uint32_t phy_tx_zcal(struct npu2_dev *ndev) { - if (ndev->npu->tx_zcal_complete[ndev->index % 3]) + if (ndev->npu->tx_zcal_complete[ndev->index > 2]) return PROCEDURE_COMPLETE; - ndev->npu->tx_zcal_complete[ndev->index % 3] = 1; /* Turn off SW enable and enable zcal state machine */ phy_write(ndev, &NPU2_PHY_TX_ZCAL_SWO_EN, 0); @@ -330,10 +329,9 @@ static uint32_t phy_tx_zcal_wait(struct npu2_dev *ndev) return PROCEDURE_NEXT; } -/* FIXME: What are the right values? I just chose the middle ones... */ -#define MARGIN_RATIO (32) -#define FFE_PRE_COEFF (7) -#define FFE_POST_COEFF (12) +#define MARGIN_RATIO (0) +#define FFE_PRE_COEFF (0) +#define FFE_POST_COEFF (0) #define PRE_WIDTH (5) #define POST_WIDTH (7) @@ -382,14 +380,6 @@ static uint32_t phy_tx_zcal_calculate(struct npu2_dev *ndev) uint32_t margin_pd_select; uint32_t margin_select; - if (ndev->index < 3) { - if (ndev->npu->tx_zcal_complete[0]) - return PROCEDURE_COMPLETE; - } else { - if (ndev->npu->tx_zcal_complete[1]) - return PROCEDURE_COMPLETE; - } - /* Convert the value from 8R to 2R by / 4 */ zcal_n = phy_read(ndev, &NPU2_PHY_TX_ZCAL_N) / 4; zcal_p = phy_read(ndev, &NPU2_PHY_TX_ZCAL_P) / 4; @@ -470,11 +460,7 @@ static uint32_t phy_tx_zcal_calculate(struct npu2_dev *ndev) phy_write(ndev, &NPU2_PHY_TX_MARGINPU_SELECT, therm(margin_select + 1)/2); phy_write(ndev, &NPU2_PHY_TX_MARGINPD_SELECT, therm(margin_select + 1)/2); - if (ndev->index < 3) - ndev->npu->tx_zcal_complete[0] = true; - else - ndev->npu->tx_zcal_complete[1] = true; - + ndev->npu->tx_zcal_complete[ndev->index > 2] = 1; return PROCEDURE_COMPLETE; } DEFINE_PROCEDURE(phy_tx_zcal, phy_tx_zcal_wait, phy_tx_zcal_calculate); |