Skip to content

Commit

Permalink
npu2: hw-procedures: Manipulate IOVALID during training
Browse files Browse the repository at this point in the history
Ensure that the IOVALID bit for this brick is raised at the start of
link training, in the reset_ntl procedure.

Then, to protect us from a glitch when the PHY clock turns off or gets
chopped, lower IOVALID for the duration of the phy_reset and
phy_rx_dccal procedures.

Signed-off-by: Reza Arbab <[email protected]>
Acked-By: Alistair Popple <[email protected]>
Signed-off-by: Stewart Smith <[email protected]>
(cherry picked from commit 4e04c83)
Signed-off-by: Stewart Smith <[email protected]>
  • Loading branch information
rarbab authored and stewartsmith committed Nov 28, 2017
1 parent 36402ae commit f52024f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions hw/npu2-hw-procedures.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ static int obus_brick_index(struct npu2_dev *ndev)
return index;
}

static void set_iovalid(struct npu2_dev *ndev, bool raise)
{
uint64_t addr, val, mask;
int rc;

addr = (ndev->pl_xscom_base & 0x3F000000) | 0x9;
mask = PPC_BIT(6 + obus_brick_index(ndev));
val = raise ? mask : 0;

rc = xscom_write_mask(ndev->npu->chip_id, addr, val, mask);
if (rc)
NPU2DEVERR(ndev, "error %d writing scom 0x%llx\n", rc, addr);
}

static bool poll_fence_status(struct npu2_dev *ndev, uint64_t val)
{
uint64_t fs;
Expand All @@ -223,6 +237,8 @@ static uint32_t reset_ntl(struct npu2_dev *ndev)
{
uint64_t val;

set_iovalid(ndev, true);

/* Write PRI */
val = SETFIELD(PPC_BITMASK(0,1), 0ull, obus_brick_index(ndev));
npu2_write_mask(ndev->npu, NPU2_NTL_PRI_CFG(ndev), val, -1ULL);
Expand Down Expand Up @@ -304,6 +320,8 @@ static uint32_t phy_reset(struct npu2_dev *ndev)
{
int lane;

set_iovalid(ndev, false);

/* Power on clocks */
phy_write(ndev, &NPU2_PHY_RX_CLKDIST_PDWN, 0);
phy_write(ndev, &NPU2_PHY_RX_IREF_PDWN, 1);
Expand Down Expand Up @@ -360,6 +378,8 @@ static uint32_t phy_reset_complete(struct npu2_dev *ndev)
phy_write_lane(ndev, &NPU2_PHY_RX_E_INTEG_COARSE_GAIN, lane, 11);
}

set_iovalid(ndev, true);

return PROCEDURE_COMPLETE;
}
DEFINE_PROCEDURE(phy_reset, phy_reset_wait, phy_reset_complete);
Expand Down Expand Up @@ -572,6 +592,8 @@ static uint32_t phy_rx_dccal(struct npu2_dev *ndev)
{
int lane;

set_iovalid(ndev, false);

FOR_EACH_LANE(ndev, lane)
phy_write_lane(ndev, &NPU2_PHY_RX_PR_FW_OFF, lane, 1);

Expand All @@ -598,6 +620,8 @@ static uint32_t phy_rx_dccal_complete(struct npu2_dev *ndev)
phy_write_lane(ndev, &NPU2_PHY_RX_PR_FW_OFF, lane, 0);
}

set_iovalid(ndev, true);

return PROCEDURE_NEXT;
}

Expand Down

0 comments on commit f52024f

Please sign in to comment.