sdiahci: fix staggered spinup wait loop, fix confusion
setting Asud in the cmd register is not needed, because Apwr is (Asud|Apod) already. the problem really was that the drive comes up with sstatus Spresent (001), so we never spun it up because (p->sstatus & Sphylink) == 0 was never met (Sphylink being a mask (011) overlaping Spresent bit). the spinup wait loop has to run only for the staggered spinup case (h->cap & Hss) and it should wait for the drive to be detected by the phy, not just cold presence detect.
This commit is contained in:
parent
a9206fa5ad
commit
50c9769bbd
1 changed files with 7 additions and 9 deletions
|
@ -612,16 +612,15 @@ ahciconfigdrive(Ahba *h, Aportc *c, int mode)
|
||||||
dprint("ahci: configdrive cmd=%lux sstatus=%lux\n", p->cmd, p->sstatus);
|
dprint("ahci: configdrive cmd=%lux sstatus=%lux\n", p->cmd, p->sstatus);
|
||||||
p->cmd |= Afre;
|
p->cmd |= Afre;
|
||||||
|
|
||||||
if((p->sstatus & Sbist) == 0 && (p->cmd & Apwr) != Apwr){
|
if((p->cmd & Apwr) != Apwr)
|
||||||
p->cmd |= Apwr;
|
p->cmd |= Apwr;
|
||||||
dprint("ahci: power up ... [%.3lux]\n", p->sstatus);
|
|
||||||
}
|
if((h->cap & Hss) != 0){
|
||||||
if((p->sstatus & Sphylink) == 0){
|
|
||||||
if(h->cap & Hss)
|
|
||||||
p->cmd |= Asud;
|
|
||||||
dprint("ahci: spin up ... [%.3lux]\n", p->sstatus);
|
dprint("ahci: spin up ... [%.3lux]\n", p->sstatus);
|
||||||
for(int i = 0; i < 1400; i += 50){
|
for(int i = 0; i < 1400; i += 50){
|
||||||
if(p->sstatus & (Sphylink | Sbist))
|
if((p->sstatus & Sbist) != 0)
|
||||||
|
break;
|
||||||
|
if((p->sstatus & Sphylink) == Sphylink)
|
||||||
break;
|
break;
|
||||||
asleep(50);
|
asleep(50);
|
||||||
}
|
}
|
||||||
|
@ -633,8 +632,7 @@ ahciconfigdrive(Ahba *h, Aportc *c, int mode)
|
||||||
|
|
||||||
/* disable power managment sequence from book. */
|
/* disable power managment sequence from book. */
|
||||||
p->sctl = 3*Aipm | mode*Aspd | 0*Adet;
|
p->sctl = 3*Aipm | mode*Aspd | 0*Adet;
|
||||||
if(h->cap & Halp)
|
p->cmd &= ~Aalpe;
|
||||||
p->cmd &= ~Aalpe;
|
|
||||||
|
|
||||||
p->cmd |= Ast;
|
p->cmd |= Ast;
|
||||||
p->ie = IEM;
|
p->ie = IEM;
|
||||||
|
|
Loading…
Reference in a new issue