Skip to content

Commit daa2e3b

Browse files
Evan Wanghtejun
authored andcommitted
ata: ahci: mvebu: override ahci_stop_engine for mvebu AHCI
There is an issue(Errata Ref#226) that the SATA can not be detected via SATA Port-MultiPlayer(PMP) with following error log: ata1.15: PMP product ID mismatch ata1.15: SATA link up 6.0 Gbps (SStatus 133 SControl 300) ata1.15: Port Multiplier vendor mismatch '0x1b4b'!='0x0' ata1.15: PMP revalidation failed (errno=-19) After debugging, the reason is found that the value Port-x FIS-based Switching Control(PxFBS@0x40) become wrong. According to design, the bits[11:8, 0] of register PxFBS are cleared when Port Command and Status (0x18) bit[0] changes its value from 1 to 0, i.e. falling edge of Port Command and Status bit[0] sends PULSE that resets PxFBS bits[11:8; 0]. So it needs a mvebu SATA WA to save the port PxFBS register before PxCMD ST write and restore it afterwards. This patch implements the WA in a separate function of ahci_mvebu_stop_engine to override ahci_stop_gngine. Signed-off-by: Evan Wang <xswang@marvell.com> Cc: Ofer Heifetz <oferh@marvell.com> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent fa89f53 commit daa2e3b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

drivers/ata/ahci_mvebu.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,60 @@ static void ahci_mvebu_regret_option(struct ahci_host_priv *hpriv)
6262
writel(0x80, hpriv->mmio + AHCI_VENDOR_SPECIFIC_0_DATA);
6363
}
6464

65+
/**
66+
* ahci_mvebu_stop_engine
67+
*
68+
* @ap: Target ata port
69+
*
70+
* Errata Ref#226 - SATA Disk HOT swap issue when connected through
71+
* Port Multiplier in FIS-based Switching mode.
72+
*
73+
* To avoid the issue, according to design, the bits[11:8, 0] of
74+
* register PxFBS are cleared when Port Command and Status (0x18) bit[0]
75+
* changes its value from 1 to 0, i.e. falling edge of Port
76+
* Command and Status bit[0] sends PULSE that resets PxFBS
77+
* bits[11:8; 0].
78+
*
79+
* This function is used to override function of "ahci_stop_engine"
80+
* from libahci.c by adding the mvebu work around(WA) to save PxFBS
81+
* value before the PxCMD ST write of 0, then restore PxFBS value.
82+
*
83+
* Return: 0 on success; Error code otherwise.
84+
*/
85+
int ahci_mvebu_stop_engine(struct ata_port *ap)
86+
{
87+
void __iomem *port_mmio = ahci_port_base(ap);
88+
u32 tmp, port_fbs;
89+
90+
tmp = readl(port_mmio + PORT_CMD);
91+
92+
/* check if the HBA is idle */
93+
if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
94+
return 0;
95+
96+
/* save the port PxFBS register for later restore */
97+
port_fbs = readl(port_mmio + PORT_FBS);
98+
99+
/* setting HBA to idle */
100+
tmp &= ~PORT_CMD_START;
101+
writel(tmp, port_mmio + PORT_CMD);
102+
103+
/*
104+
* bit #15 PxCMD signal doesn't clear PxFBS,
105+
* restore the PxFBS register right after clearing the PxCMD ST,
106+
* no need to wait for the PxCMD bit #15.
107+
*/
108+
writel(port_fbs, port_mmio + PORT_FBS);
109+
110+
/* wait for engine to stop. This could be as long as 500 msec */
111+
tmp = ata_wait_register(ap, port_mmio + PORT_CMD,
112+
PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
113+
if (tmp & PORT_CMD_LIST_ON)
114+
return -EIO;
115+
116+
return 0;
117+
}
118+
65119
#ifdef CONFIG_PM_SLEEP
66120
static int ahci_mvebu_suspend(struct platform_device *pdev, pm_message_t state)
67121
{
@@ -112,6 +166,8 @@ static int ahci_mvebu_probe(struct platform_device *pdev)
112166
if (rc)
113167
return rc;
114168

169+
hpriv->stop_engine = ahci_mvebu_stop_engine;
170+
115171
if (of_device_is_compatible(pdev->dev.of_node,
116172
"marvell,armada-380-ahci")) {
117173
dram = mv_mbus_dram_info();

0 commit comments

Comments
 (0)