ata-sata.c (874108aed99d76099ff9eb6c8d830479a504c1ad) ata-sata.c (066f913a94b134b6d5e32b6af88f297c7da9c031)
1/*-
2 * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 195 unchanged lines hidden (view full) ---

204 return (0);
205 if ((val & ATA_SC_DET_MASK) == 0)
206 return ata_sata_connect(ch, port);
207 }
208 }
209 return 0;
210}
211
1/*-
2 * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 195 unchanged lines hidden (view full) ---

204 return (0);
205 if ((val & ATA_SC_DET_MASK) == 0)
206 return ata_sata_connect(ch, port);
207 }
208 }
209 return 0;
210}
211
212void
213ata_sata_setmode(device_t dev, int mode)
212int
213ata_sata_setmode(device_t dev, int target, int mode)
214{
214{
215 struct ata_device *atadev = device_get_softc(dev);
216
215
217 /*
218 * if we detect that the device isn't a real SATA device we limit
219 * the transfer mode to UDMA5/ATA100.
220 * this works around the problems some devices has with the
221 * Marvell 88SX8030 SATA->PATA converters and UDMA6/ATA133.
222 */
223 if (atadev->param.satacapabilities != 0x0000 &&
224 atadev->param.satacapabilities != 0xffff) {
225 struct ata_channel *ch = device_get_softc(device_get_parent(dev));
216 return (min(mode, ATA_UDMA5));
217}
226
218
227 /* on some drives we need to set the transfer mode */
228 ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0,
229 ata_limit_mode(dev, mode, ATA_UDMA6));
219int
220ata_sata_getrev(device_t dev, int target)
221{
222 struct ata_channel *ch = device_get_softc(dev);
230
223
231 /* query SATA STATUS for the speed */
232 if (ch->r_io[ATA_SSTATUS].res &&
233 ((ATA_IDX_INL(ch, ATA_SSTATUS) & ATA_SS_CONWELL_MASK) ==
234 ATA_SS_CONWELL_GEN2))
235 atadev->mode = ATA_SA300;
236 else
237 atadev->mode = ATA_SA150;
238 }
239 else {
240 mode = ata_limit_mode(dev, mode, ATA_UDMA5);
241 if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode))
242 atadev->mode = mode;
243 }
224 if (ch->r_io[ATA_SSTATUS].res)
225 return ((ATA_IDX_INL(ch, ATA_SSTATUS) & 0x0f0) >> 4);
226 return (0);
244}
245
246int
247ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis)
248{
249
250 if (request->flags & ATA_R_ATAPI) {
251 fis[0] = 0x27; /* host to device */

--- 118 unchanged lines hidden ---
227}
228
229int
230ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis)
231{
232
233 if (request->flags & ATA_R_ATAPI) {
234 fis[0] = 0x27; /* host to device */

--- 118 unchanged lines hidden ---