| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dsk.c,v 1.13 2012/01/22 13:08:16 phx Exp $ */ | | 1 | /* $NetBSD: dsk.c,v 1.14 2012/01/22 13:16:54 phx Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Tohru Nishimura. | | 8 | * by Tohru Nishimura. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -169,39 +169,34 @@ spinwait_unbusy(struct dkdev_ata *l, int | | | @@ -169,39 +169,34 @@ spinwait_unbusy(struct dkdev_ata *l, int |
169 | msg = "remains BUSY"; | | 169 | msg = "remains BUSY"; |
170 | else if ((sts & ATA_STS_DRDY) == 0) | | 170 | else if ((sts & ATA_STS_DRDY) == 0) |
171 | msg = "no DRDY"; | | 171 | msg = "no DRDY"; |
172 | | | 172 | |
173 | if (err != NULL) | | 173 | if (err != NULL) |
174 | *err = msg; | | 174 | *err = msg; |
175 | return msg == NULL; | | 175 | return msg == NULL; |
176 | } | | 176 | } |
177 | | | 177 | |
178 | int | | 178 | int |
179 | perform_atareset(struct dkdev_ata *l, int n) | | 179 | perform_atareset(struct dkdev_ata *l, int n) |
180 | { | | 180 | { |
181 | struct dvata_chan *chan = &l->chan[n]; | | 181 | struct dvata_chan *chan = &l->chan[n]; |
182 | // int retries; | | | |
183 | | | 182 | |
184 | // for (retries = 0; retries < 10; retries++) { | | 183 | CSR_WRITE_1(chan->ctl, ATA_DREQ); |
185 | CSR_WRITE_1(chan->ctl, ATA_DREQ); | | 184 | delay(10); |
186 | delay(10); | | 185 | CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ); |
187 | CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ); | | 186 | delay(10); |
188 | delay(10); | | 187 | CSR_WRITE_1(chan->ctl, ATA_DREQ); |
189 | CSR_WRITE_1(chan->ctl, ATA_DREQ); | | 188 | |
190 | // if (spinwait_unbusy(l, n, 1000/*250*/, NULL) != 0) | | 189 | return spinwait_unbusy(l, n, 1000, NULL); |
191 | // return 1; | | | |
192 | // delay(1000 * 1000); | | | |
193 | // } | | | |
194 | return spinwait_unbusy(l, n, 1000/*250*/, NULL); | | | |
195 | } | | 190 | } |
196 | | | 191 | |
197 | /* clear idle and standby timers to spin up the drive */ | | 192 | /* clear idle and standby timers to spin up the drive */ |
198 | void | | 193 | void |
199 | wakeup_drive(struct dkdev_ata *l, int n) | | 194 | wakeup_drive(struct dkdev_ata *l, int n) |
200 | { | | 195 | { |
201 | struct dvata_chan *chan = &l->chan[n]; | | 196 | struct dvata_chan *chan = &l->chan[n]; |
202 | | | 197 | |
203 | CSR_WRITE_1(chan->cmd + _NSECT, 0); | | 198 | CSR_WRITE_1(chan->cmd + _NSECT, 0); |
204 | CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_IDLE); | | 199 | CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_IDLE); |
205 | (void)CSR_READ_1(chan->alt); | | 200 | (void)CSR_READ_1(chan->alt); |
206 | delay(10 * 1000); | | 201 | delay(10 * 1000); |
207 | CSR_WRITE_1(chan->cmd + _NSECT, 0); | | 202 | CSR_WRITE_1(chan->cmd + _NSECT, 0); |