Skip to content

Commit f6bc818

Browse files
Vladimir Kondratievstorulf
authored andcommitted
mmc: sdhci-cadence: fix PHY write
Accordingly to Cadence documentation, PHY write procedure is: 1. Software sets the PHY Register Address (HRS04[5:0]) and the PHY Write Data (HRS04[15:8]) fields. 2. Software sets the PHY Write Transaction Request (HRS04[24]) field to 1. 3. Software waits as the PHY Write Transaction Acknowledge (HRS04[26]) field is equal to 0. 4. Hardware performs the write transaction to PHY register where HRS04[15:8] is a data written to register under HRS04[5:0] address. 5. Hardware sets the PHY Transaction Acknowledge (HRS04[26]) to 1 when transaction is completed. 6. Software clears the PHY Write Transaction Request (HRS04[24]) to 1 after noticing that the PHY Write Transaction Acknowledge (HRS04[26]) field is equal to 1. 7. Software waits for the PHY Acknowledge Register (HRS04[26]) field is equal to 0. Add missing steps 3 and 7. Lack of these steps causes integrity errors detested by hardware. Signed-off-by: Vladimir Kondratiev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 798dd3c commit f6bc818

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/mmc/host/sdhci-cadence.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv,
9797
u32 tmp;
9898
int ret;
9999

100+
ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS04_ACK),
101+
0, 10);
102+
if (ret)
103+
return ret;
104+
100105
tmp = FIELD_PREP(SDHCI_CDNS_HRS04_WDATA, data) |
101106
FIELD_PREP(SDHCI_CDNS_HRS04_ADDR, addr);
102107
writel(tmp, reg);
@@ -111,7 +116,10 @@ static int sdhci_cdns_write_phy_reg(struct sdhci_cdns_priv *priv,
111116
tmp &= ~SDHCI_CDNS_HRS04_WR;
112117
writel(tmp, reg);
113118

114-
return 0;
119+
ret = readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS04_ACK),
120+
0, 10);
121+
122+
return ret;
115123
}
116124

117125
static unsigned int sdhci_cdns_phy_param_count(struct device_node *np)

0 commit comments

Comments
 (0)