|
Line 0
Link Here
|
|
|
1 |
/* |
| 2 |
* libata-acpi.c |
| 3 |
* Provides ACPI support for PATA/SATA. |
| 4 |
* |
| 5 |
* Copyright (C) 2005 Intel Corp. |
| 6 |
* Copyright (C) 2005 Randy Dunlap |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <linux/ata.h> |
| 10 |
#include <linux/delay.h> |
| 11 |
#include <linux/device.h> |
| 12 |
#include <linux/errno.h> |
| 13 |
#include <linux/kernel.h> |
| 14 |
#include <acpi/acpi.h> |
| 15 |
#include "scsi.h" |
| 16 |
#include <linux/libata.h> |
| 17 |
#include <linux/pci.h> |
| 18 |
#include "libata.h" |
| 19 |
|
| 20 |
#include <acpi/acpi_bus.h> |
| 21 |
#include <acpi/acnames.h> |
| 22 |
#include <acpi/acnamesp.h> |
| 23 |
#include <acpi/acparser.h> |
| 24 |
#include <acpi/acexcep.h> |
| 25 |
#include <acpi/acmacros.h> |
| 26 |
#include <acpi/actypes.h> |
| 27 |
|
| 28 |
#define SATA_ROOT_PORT(x) (((x) >> 16) & 0xffff) |
| 29 |
#define SATA_PORT_NUMBER(x) ((x) & 0xffff) /* or NO_PORT_MULT */ |
| 30 |
#define NO_PORT_MULT 0xffff |
| 31 |
#define SATA_ADR_RSVD 0xffffffff |
| 32 |
|
| 33 |
#define REGS_PER_GTF 7 |
| 34 |
struct taskfile_array { |
| 35 |
u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */ |
| 36 |
}; |
| 37 |
|
| 38 |
struct GTM_buffer { |
| 39 |
__u32 PIO_speed0; |
| 40 |
__u32 DMA_speed0; |
| 41 |
__u32 PIO_speed1; |
| 42 |
__u32 DMA_speed1; |
| 43 |
__u32 GTM_flags; |
| 44 |
}; |
| 45 |
|
| 46 |
#define DEBUGGING 1 |
| 47 |
/* note: adds function name and KERN_DEBUG */ |
| 48 |
#ifdef DEBUGGING |
| 49 |
#define DEBPRINT(fmt, args...) \ |
| 50 |
printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ## args) |
| 51 |
#else |
| 52 |
#define DEBPRINT(fmt, args...) do {} while (0) |
| 53 |
#endif /* DEBUGGING */ |
| 54 |
|
| 55 |
/** |
| 56 |
* sata_get_dev_handle - finds acpi_handle and PCI device.function |
| 57 |
* @dev: device to locate |
| 58 |
* @handle: returned acpi_handle for @dev |
| 59 |
* @pcidevfn: return PCI device.func for @dev |
| 60 |
* |
| 61 |
* This function is somewhat SATA-specific. Or at least the |
| 62 |
* IDE and SCSI versions of this function are different, |
| 63 |
* so it's not entirely generic code. |
| 64 |
* |
| 65 |
* Returns 0 on success, <0 on error. |
| 66 |
*/ |
| 67 |
static int sata_get_dev_handle(struct device *dev, acpi_handle *handle, |
| 68 |
acpi_integer *pcidevfn) |
| 69 |
{ |
| 70 |
struct pci_dev *pci_dev; |
| 71 |
acpi_integer addr; |
| 72 |
|
| 73 |
pci_dev = to_pci_dev(dev); /* NOTE: PCI-specific */ |
| 74 |
/* Please refer to the ACPI spec for the syntax of _ADR. */ |
| 75 |
addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); |
| 76 |
*pcidevfn = addr; |
| 77 |
*handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr); |
| 78 |
printk(KERN_DEBUG "%s: SATA dev addr=0x%llx, handle=0x%p\n", |
| 79 |
__FUNCTION__, (unsigned long long)addr, *handle); |
| 80 |
if (!*handle) |
| 81 |
return -ENODEV; |
| 82 |
return 0; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* pata_get_dev_handle - finds acpi_handle and PCI device.function |
| 87 |
* @dev: device to locate |
| 88 |
* @handle: returned acpi_handle for @dev |
| 89 |
* @pcidevfn: return PCI device.func for @dev |
| 90 |
* |
| 91 |
* The PATA and SATA versions of this function are different. |
| 92 |
* |
| 93 |
* Returns 0 on success, <0 on error. |
| 94 |
*/ |
| 95 |
static int pata_get_dev_handle(struct device *dev, acpi_handle *handle, |
| 96 |
acpi_integer *pcidevfn) |
| 97 |
{ |
| 98 |
unsigned int domain, bus, devnum, func; |
| 99 |
acpi_integer addr; |
| 100 |
acpi_handle dev_handle, parent_handle; |
| 101 |
int scanned; |
| 102 |
struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER, |
| 103 |
.pointer = NULL}; |
| 104 |
acpi_status status; |
| 105 |
struct acpi_device_info *dinfo = NULL; |
| 106 |
int ret = -ENODEV; |
| 107 |
|
| 108 |
printk(KERN_DEBUG "%s: enter: dev->bus_id='%s'\n", |
| 109 |
__FUNCTION__, dev->bus_id); |
| 110 |
if ((scanned = sscanf(dev->bus_id, "%x:%x:%x.%x", |
| 111 |
&domain, &bus, &devnum, &func)) != 4) { |
| 112 |
printk(KERN_DEBUG "%s: sscanf ret. %d\n", |
| 113 |
__FUNCTION__, scanned); |
| 114 |
goto err; |
| 115 |
} |
| 116 |
|
| 117 |
dev_handle = DEVICE_ACPI_HANDLE(dev); |
| 118 |
parent_handle = DEVICE_ACPI_HANDLE(dev->parent); |
| 119 |
|
| 120 |
status = acpi_get_object_info(parent_handle, &buffer); |
| 121 |
if (ACPI_FAILURE(status)) { |
| 122 |
printk(KERN_DEBUG "%s: get_object_info for parent failed\n", |
| 123 |
__FUNCTION__); |
| 124 |
goto err; |
| 125 |
} |
| 126 |
dinfo = buffer.pointer; |
| 127 |
if (dinfo && (dinfo->valid & ACPI_VALID_ADR) && |
| 128 |
dinfo->address == bus) { |
| 129 |
/* ACPI spec for _ADR for PCI bus: */ |
| 130 |
addr = (acpi_integer)(devnum << 16 | func); |
| 131 |
*pcidevfn = addr; |
| 132 |
*handle = dev_handle; |
| 133 |
} else { |
| 134 |
printk(KERN_DEBUG "%s: get_object_info for parent has wrong " |
| 135 |
" bus: %llu, should be %d\n", |
| 136 |
__FUNCTION__, |
| 137 |
dinfo ? (unsigned long long)dinfo->address : -1ULL, |
| 138 |
bus); |
| 139 |
goto err; |
| 140 |
} |
| 141 |
|
| 142 |
printk(KERN_DEBUG "%s: dev_handle: 0x%p, parent_handle: 0x%p\n", |
| 143 |
__FUNCTION__, dev_handle, parent_handle); |
| 144 |
printk(KERN_DEBUG |
| 145 |
"%s: for dev=0x%x.%x, addr=0x%llx, parent=0x%p, *handle=0x%p\n", |
| 146 |
__FUNCTION__, devnum, func, (unsigned long long)addr, |
| 147 |
dev->parent, *handle); |
| 148 |
if (!*handle) |
| 149 |
goto err; |
| 150 |
ret = 0; |
| 151 |
err: |
| 152 |
acpi_os_free(dinfo); |
| 153 |
return ret; |
| 154 |
} |
| 155 |
|
| 156 |
struct walk_info { /* can be trimmed some */ |
| 157 |
struct device *dev; |
| 158 |
struct acpi_device *adev; |
| 159 |
acpi_handle handle; |
| 160 |
acpi_integer pcidevfn; |
| 161 |
unsigned int drivenum; |
| 162 |
acpi_handle obj_handle; |
| 163 |
struct ata_port *ataport; |
| 164 |
struct ata_device *atadev; |
| 165 |
u32 sata_adr; |
| 166 |
int status; |
| 167 |
char basepath[ACPI_PATHNAME_MAX]; |
| 168 |
int basepath_len; |
| 169 |
}; |
| 170 |
|
| 171 |
static acpi_status get_devices(acpi_handle handle, |
| 172 |
u32 level, void *context, void **return_value) |
| 173 |
{ |
| 174 |
acpi_status status; |
| 175 |
struct walk_info *winfo = context; |
| 176 |
struct acpi_buffer namebuf = {ACPI_ALLOCATE_BUFFER, NULL}; |
| 177 |
char *pathname; |
| 178 |
struct acpi_buffer buffer; |
| 179 |
struct acpi_device_info *dinfo; |
| 180 |
|
| 181 |
status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &namebuf); |
| 182 |
if (status) |
| 183 |
goto ret; |
| 184 |
pathname = namebuf.pointer; |
| 185 |
|
| 186 |
buffer.length = ACPI_ALLOCATE_BUFFER; |
| 187 |
buffer.pointer = NULL; |
| 188 |
status = acpi_get_object_info(handle, &buffer); |
| 189 |
|
| 190 |
if (ACPI_SUCCESS(status)) { |
| 191 |
dinfo = buffer.pointer; |
| 192 |
|
| 193 |
/* find full device path name for pcidevfn */ |
| 194 |
if (dinfo && (dinfo->valid & ACPI_VALID_ADR) && |
| 195 |
dinfo->address == winfo->pcidevfn) { |
| 196 |
if (ata_msg_probe(winfo->ataport)) |
| 197 |
printk(KERN_DEBUG |
| 198 |
":%s: matches pcidevfn (0x%llx)\n", |
| 199 |
pathname, winfo->pcidevfn); |
| 200 |
strlcpy(winfo->basepath, pathname, |
| 201 |
sizeof(winfo->basepath)); |
| 202 |
winfo->basepath_len = strlen(pathname); |
| 203 |
goto out; |
| 204 |
} |
| 205 |
|
| 206 |
/* if basepath is not yet known, ignore this object */ |
| 207 |
if (!winfo->basepath_len) |
| 208 |
goto out; |
| 209 |
|
| 210 |
/* if this object is in scope of basepath, maybe use it */ |
| 211 |
if (strncmp(pathname, winfo->basepath, |
| 212 |
winfo->basepath_len) == 0) { |
| 213 |
if (!(dinfo->valid & ACPI_VALID_ADR)) |
| 214 |
goto out; |
| 215 |
if (ata_msg_probe(winfo->ataport)) |
| 216 |
printk(KERN_DEBUG "GOT ONE: (%s) " |
| 217 |
"root_port = 0x%llx, port_num = 0x%llx\n", |
| 218 |
pathname, |
| 219 |
SATA_ROOT_PORT(dinfo->address), |
| 220 |
SATA_PORT_NUMBER(dinfo->address)); |
| 221 |
/* heuristics: */ |
| 222 |
if (SATA_PORT_NUMBER(dinfo->address) != NO_PORT_MULT) |
| 223 |
if (ata_msg_probe(winfo->ataport)) |
| 224 |
printk(KERN_DEBUG |
| 225 |
"warning: don't know how to handle SATA port multiplier\n"); |
| 226 |
if (SATA_ROOT_PORT(dinfo->address) == |
| 227 |
winfo->ataport->port_no && |
| 228 |
SATA_PORT_NUMBER(dinfo->address) == NO_PORT_MULT) { |
| 229 |
if (ata_msg_probe(winfo->ataport)) |
| 230 |
printk(KERN_DEBUG |
| 231 |
"THIS ^^^^^ is the requested SATA drive (handle = 0x%p)\n", |
| 232 |
handle); |
| 233 |
winfo->sata_adr = dinfo->address; |
| 234 |
winfo->obj_handle = handle; |
| 235 |
} |
| 236 |
} |
| 237 |
out: |
| 238 |
acpi_os_free(dinfo); |
| 239 |
} |
| 240 |
acpi_os_free(pathname); |
| 241 |
|
| 242 |
ret: |
| 243 |
return status; |
| 244 |
} |
| 245 |
|
| 246 |
/* Get the SATA drive _ADR object. */ |
| 247 |
static int get_sata_adr(struct device *dev, acpi_handle handle, |
| 248 |
acpi_integer pcidevfn, unsigned int drive, |
| 249 |
struct ata_port *ap, |
| 250 |
struct ata_device *atadev, u32 *dev_adr) |
| 251 |
{ |
| 252 |
acpi_status status; |
| 253 |
struct walk_info *winfo; |
| 254 |
int err = -ENOMEM; |
| 255 |
|
| 256 |
winfo = kmalloc(sizeof(struct walk_info), GFP_KERNEL); |
| 257 |
if (!winfo) |
| 258 |
goto out; |
| 259 |
|
| 260 |
memset(winfo, 0, sizeof(struct walk_info)); |
| 261 |
|
| 262 |
winfo->dev = dev; |
| 263 |
winfo->atadev = atadev; |
| 264 |
winfo->ataport = ap; |
| 265 |
if (acpi_bus_get_device(handle, &winfo->adev) < 0) |
| 266 |
if (ata_msg_probe(ap)) |
| 267 |
printk(KERN_DEBUG "acpi_bus_get_device failed\n"); |
| 268 |
winfo->handle = handle; |
| 269 |
winfo->pcidevfn = pcidevfn; |
| 270 |
winfo->drivenum = drive; |
| 271 |
|
| 272 |
status = acpi_get_devices(NULL, get_devices, winfo, NULL); |
| 273 |
if (ACPI_FAILURE(status)) { |
| 274 |
if (ata_msg_probe(ap)) |
| 275 |
printk(KERN_DEBUG "%s: acpi_get_devices failed\n", |
| 276 |
__FUNCTION__); |
| 277 |
err = -ENODEV; |
| 278 |
} else { |
| 279 |
*dev_adr = winfo->sata_adr; |
| 280 |
atadev->obj_handle = winfo->obj_handle; |
| 281 |
err = 0; |
| 282 |
} |
| 283 |
kfree(winfo); |
| 284 |
out: |
| 285 |
return err; |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* ata_acpi_push_id - send Identify data to a drive |
| 290 |
* @ap: the ata_port for the drive |
| 291 |
* @ix: drive index |
| 292 |
* |
| 293 |
* _SDD ACPI object: for SATA mode only. |
| 294 |
* Must be after Identify (Packet) Device -- uses its data. |
| 295 |
*/ |
| 296 |
int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) |
| 297 |
{ |
| 298 |
acpi_handle handle; |
| 299 |
acpi_integer pcidevfn; |
| 300 |
int err = -ENODEV; |
| 301 |
struct device *dev = ap->host_set->dev; |
| 302 |
struct ata_device *atadev = &ap->device[ix]; |
| 303 |
u32 dev_adr; |
| 304 |
acpi_status status; |
| 305 |
struct acpi_object_list input; |
| 306 |
union acpi_object in_params[1]; |
| 307 |
|
| 308 |
if (ap->legacy_mode) { |
| 309 |
printk(KERN_DEBUG "%s: should not be here for PATA mode\n", |
| 310 |
__FUNCTION__); |
| 311 |
return 0; |
| 312 |
} |
| 313 |
if (noacpi) |
| 314 |
return 0; |
| 315 |
|
| 316 |
if (ata_msg_probe(ap)) |
| 317 |
printk(KERN_DEBUG |
| 318 |
"%s: ap->id: %d, ix = %d, port#: %d, hard_port#: %d\n", |
| 319 |
__FUNCTION__, ap->id, ix, |
| 320 |
ap->port_no, ap->hard_port_no); |
| 321 |
|
| 322 |
/* Don't continue if not a SATA device. */ |
| 323 |
if (!ata_id_is_sata(atadev->id)) { |
| 324 |
if (ata_msg_probe(ap)) |
| 325 |
printk(KERN_DEBUG "%s: ata_id_is_sata is False\n", |
| 326 |
__FUNCTION__); |
| 327 |
goto out; |
| 328 |
} |
| 329 |
|
| 330 |
/* Don't continue if device has no _ADR method. |
| 331 |
* _SDD is intended for known motherboard devices. */ |
| 332 |
err = sata_get_dev_handle(dev, &handle, &pcidevfn); |
| 333 |
if (err < 0) { |
| 334 |
if (ata_msg_probe(ap)) |
| 335 |
printk(KERN_DEBUG |
| 336 |
"%s: sata_get_dev_handle failed (%d\n", |
| 337 |
__FUNCTION__, err); |
| 338 |
goto out; |
| 339 |
} |
| 340 |
|
| 341 |
/* Get this drive's _ADR info. if not already known. */ |
| 342 |
if (!atadev->obj_handle) { |
| 343 |
dev_adr = SATA_ADR_RSVD; |
| 344 |
err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, |
| 345 |
&dev_adr); |
| 346 |
if (err < 0 || dev_adr == SATA_ADR_RSVD || |
| 347 |
!atadev->obj_handle) { |
| 348 |
if (ata_msg_probe(ap)) |
| 349 |
printk(KERN_DEBUG "%s: get_sata_adr failed: " |
| 350 |
"err=%d, dev_adr=%u, obj_handle=0x%p\n", |
| 351 |
__FUNCTION__, err, dev_adr, |
| 352 |
atadev->obj_handle); |
| 353 |
goto out; |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
/* Give the drive Identify data to the drive via the _SDD method */ |
| 358 |
/* _SDD: set up input parameters */ |
| 359 |
input.count = 1; |
| 360 |
input.pointer = in_params; |
| 361 |
in_params[0].type = ACPI_TYPE_BUFFER; |
| 362 |
in_params[0].buffer.length = sizeof(atadev->id); |
| 363 |
in_params[0].buffer.pointer = (u8 *)atadev->id; |
| 364 |
/* Output buffer: _SDD has no output */ |
| 365 |
|
| 366 |
/* It's OK for _SDD to be missing too. */ |
| 367 |
swap_buf_le16(atadev->id, ATA_ID_WORDS); |
| 368 |
status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); |
| 369 |
swap_buf_le16(atadev->id, ATA_ID_WORDS); |
| 370 |
|
| 371 |
err = ACPI_FAILURE(status) ? -EIO : 0; |
| 372 |
if (err < 0) { |
| 373 |
if (ata_msg_probe(ap)) |
| 374 |
printk(KERN_DEBUG |
| 375 |
"ata%u(%u): %s _SDD error: status = 0x%x\n", |
| 376 |
ap->id, ap->device->devno, |
| 377 |
__FUNCTION__, status); |
| 378 |
} |
| 379 |
out: |
| 380 |
return err; |
| 381 |
} |
| 382 |
EXPORT_SYMBOL_GPL(ata_acpi_push_id); |
| 383 |
|
| 384 |
/** |
| 385 |
* do_drive_get_GTF - get the drive bootup default taskfile settings |
| 386 |
* @ap: the ata_port for the drive |
| 387 |
* @atadev: target ata_device |
| 388 |
* @gtf_length: number of bytes of _GTF data returned at @gtf_address |
| 389 |
* @gtf_address: buffer containing _GTF taskfile arrays |
| 390 |
* |
| 391 |
* This applies to both PATA and SATA drives. |
| 392 |
* |
| 393 |
* The _GTF method has no input parameters. |
| 394 |
* It returns a variable number of register set values (registers |
| 395 |
* hex 1F1..1F7, taskfiles). |
| 396 |
* The <variable number> is not known in advance, so have ACPI-CA |
| 397 |
* allocate the buffer as needed and return it, then free it later. |
| 398 |
* |
| 399 |
* The returned @gtf_length and @gtf_address are only valid if the |
| 400 |
* function return value is 0. |
| 401 |
*/ |
| 402 |
int do_drive_get_GTF(struct ata_port *ap, struct ata_device *atadev, |
| 403 |
unsigned int *gtf_length, unsigned long *gtf_address, |
| 404 |
unsigned long *obj_loc) |
| 405 |
{ |
| 406 |
acpi_status status; |
| 407 |
acpi_handle handle; |
| 408 |
acpi_integer pcidevfn; |
| 409 |
u32 dev_adr; |
| 410 |
struct acpi_buffer output; |
| 411 |
union acpi_object *out_obj; |
| 412 |
struct device *dev = ap->host_set->dev; |
| 413 |
int err = -ENODEV; |
| 414 |
|
| 415 |
if (ata_msg_probe(ap)) |
| 416 |
printk(KERN_DEBUG |
| 417 |
"%s: ENTER: ap->id: %d, port#: %d, hard_port#: %d\n", |
| 418 |
__FUNCTION__, ap->id, |
| 419 |
ap->port_no, ap->hard_port_no); |
| 420 |
|
| 421 |
*gtf_length = 0; |
| 422 |
*gtf_address = 0UL; |
| 423 |
*obj_loc = 0UL; |
| 424 |
|
| 425 |
if (noacpi) |
| 426 |
return 0; |
| 427 |
|
| 428 |
if (!ata_dev_present(atadev) || |
| 429 |
(ap->flags & ATA_FLAG_PORT_DISABLED)) { |
| 430 |
if (ata_msg_probe(ap)) |
| 431 |
printk(KERN_DEBUG "%s: ERR: " |
| 432 |
"ata_dev_present: %d, PORT_DISABLED: %lu\n", |
| 433 |
__FUNCTION__, ata_dev_present(atadev), |
| 434 |
ap->flags & ATA_FLAG_PORT_DISABLED); |
| 435 |
goto out; |
| 436 |
} |
| 437 |
|
| 438 |
/* Don't continue if device has no _ADR method. |
| 439 |
* _GTF is intended for known motherboard devices. */ |
| 440 |
if (!ata_id_is_sata(atadev->id)) { |
| 441 |
err = pata_get_dev_handle(dev, &handle, &pcidevfn); |
| 442 |
if (err < 0) { |
| 443 |
if (ata_msg_probe(ap)) |
| 444 |
printk(KERN_DEBUG |
| 445 |
"%s: pata_get_dev_handle failed (%d)\n", |
| 446 |
__FUNCTION__, err); |
| 447 |
goto out; |
| 448 |
} |
| 449 |
} else { |
| 450 |
err = sata_get_dev_handle(dev, &handle, &pcidevfn); |
| 451 |
if (err < 0) { |
| 452 |
if (ata_msg_probe(ap)) |
| 453 |
printk(KERN_DEBUG |
| 454 |
"%s: sata_get_dev_handle failed (%d\n", |
| 455 |
__FUNCTION__, err); |
| 456 |
goto out; |
| 457 |
} |
| 458 |
} |
| 459 |
|
| 460 |
/* Get this drive's _ADR info. if not already known. */ |
| 461 |
if (!atadev->obj_handle) { |
| 462 |
dev_adr = SATA_ADR_RSVD; |
| 463 |
err = get_sata_adr(dev, handle, pcidevfn, 0, ap, atadev, |
| 464 |
&dev_adr); |
| 465 |
if (!ata_id_is_sata(atadev->id)) { |
| 466 |
printk(KERN_DEBUG "%s: early exit\n", __FUNCTION__); |
| 467 |
err = -1; |
| 468 |
goto out; |
| 469 |
} |
| 470 |
if (err < 0 || dev_adr == SATA_ADR_RSVD || |
| 471 |
!atadev->obj_handle) { |
| 472 |
if (ata_msg_probe(ap)) |
| 473 |
printk(KERN_DEBUG "%s: get_sata_adr failed: " |
| 474 |
"err=%d, dev_adr=%u, obj_handle=0x%p\n", |
| 475 |
__FUNCTION__, err, dev_adr, |
| 476 |
atadev->obj_handle); |
| 477 |
goto out; |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
/* Setting up output buffer */ |
| 482 |
output.length = ACPI_ALLOCATE_BUFFER; |
| 483 |
output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ |
| 484 |
|
| 485 |
/* _GTF has no input parameters */ |
| 486 |
err = -EIO; |
| 487 |
status = acpi_evaluate_object(atadev->obj_handle, "_GTF", |
| 488 |
NULL, &output); |
| 489 |
if (ACPI_FAILURE(status)) { |
| 490 |
if (ata_msg_probe(ap)) |
| 491 |
printk(KERN_DEBUG |
| 492 |
"%s: Run _GTF error: status = 0x%x\n", |
| 493 |
__FUNCTION__, status); |
| 494 |
goto out; |
| 495 |
} |
| 496 |
|
| 497 |
if (!output.length || !output.pointer) { |
| 498 |
if (ata_msg_probe(ap)) |
| 499 |
printk(KERN_DEBUG "%s: Run _GTF: " |
| 500 |
"length or ptr is NULL (0x%llx, 0x%p)\n", |
| 501 |
__FUNCTION__, |
| 502 |
(unsigned long long)output.length, |
| 503 |
output.pointer); |
| 504 |
acpi_os_free(output.pointer); |
| 505 |
goto out; |
| 506 |
} |
| 507 |
|
| 508 |
out_obj = output.pointer; |
| 509 |
if (out_obj->type != ACPI_TYPE_BUFFER) { |
| 510 |
acpi_os_free(output.pointer); |
| 511 |
if (ata_msg_probe(ap)) |
| 512 |
printk(KERN_DEBUG "%s: Run _GTF: error: " |
| 513 |
"expected object type of ACPI_TYPE_BUFFER, " |
| 514 |
"got 0x%x\n", |
| 515 |
__FUNCTION__, out_obj->type); |
| 516 |
err = -ENOENT; |
| 517 |
goto out; |
| 518 |
} |
| 519 |
|
| 520 |
if (!out_obj->buffer.length || !out_obj->buffer.pointer || |
| 521 |
out_obj->buffer.length % REGS_PER_GTF) { |
| 522 |
if (ata_msg_drv(ap)) |
| 523 |
printk(KERN_ERR |
| 524 |
"%s: unexpected GTF length (%d) or addr (0x%p)\n", |
| 525 |
__FUNCTION__, out_obj->buffer.length, |
| 526 |
out_obj->buffer.pointer); |
| 527 |
err = -ENOENT; |
| 528 |
goto out; |
| 529 |
} |
| 530 |
|
| 531 |
*gtf_length = out_obj->buffer.length; |
| 532 |
*gtf_address = (unsigned long)out_obj->buffer.pointer; |
| 533 |
*obj_loc = (unsigned long)out_obj; |
| 534 |
if (ata_msg_probe(ap)) |
| 535 |
printk(KERN_DEBUG "%s: returning " |
| 536 |
"gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", |
| 537 |
__FUNCTION__, *gtf_length, *gtf_address, *obj_loc); |
| 538 |
err = 0; |
| 539 |
out: |
| 540 |
return err; |
| 541 |
} |
| 542 |
EXPORT_SYMBOL_GPL(do_drive_get_GTF); |
| 543 |
|
| 544 |
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) |
| 545 |
{ |
| 546 |
return 0; |
| 547 |
} |
| 548 |
|
| 549 |
/** |
| 550 |
* taskfile_load_raw - send taskfile registers to host controller |
| 551 |
* @ap: Port to which output is sent |
| 552 |
* @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) |
| 553 |
* |
| 554 |
* Outputs ATA taskfile to standard ATA host controller using MMIO |
| 555 |
* or PIO as indicated by the ATA_FLAG_MMIO flag. |
| 556 |
* Writes the control, feature, nsect, lbal, lbam, and lbah registers. |
| 557 |
* Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, |
| 558 |
* hob_lbal, hob_lbam, and hob_lbah. |
| 559 |
* |
| 560 |
* This function waits for idle (!BUSY and !DRQ) after writing |
| 561 |
* registers. If the control register has a new value, this |
| 562 |
* function also waits for idle after writing control and before |
| 563 |
* writing the remaining registers. |
| 564 |
* |
| 565 |
* LOCKING: TBD: |
| 566 |
* Inherited from caller. |
| 567 |
*/ |
| 568 |
static void taskfile_load_raw(struct ata_port *ap, |
| 569 |
struct ata_device *atadev, |
| 570 |
const struct taskfile_array *gtf) |
| 571 |
{ |
| 572 |
unsigned long timeout = HZ * 5; |
| 573 |
|
| 574 |
if (ata_msg_probe(ap)) |
| 575 |
printk(KERN_DEBUG "%s: (0x1f1-1f7): hex: " |
| 576 |
"%02x %02x %02x %02x %02x %02x %02x\n", |
| 577 |
__FUNCTION__, |
| 578 |
gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], |
| 579 |
gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]); |
| 580 |
|
| 581 |
if (ap->ops->qc_issue) { |
| 582 |
DECLARE_COMPLETION(wait); |
| 583 |
struct ata_queued_cmd *qc; |
| 584 |
int rc; |
| 585 |
unsigned long flags; |
| 586 |
|
| 587 |
qc = ata_qc_new_init(ap, atadev); |
| 588 |
BUG_ON(qc == NULL); |
| 589 |
|
| 590 |
/* convert gtf to tf */ |
| 591 |
qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ |
| 592 |
qc->tf.protocol = atadev->class == ATA_DEV_ATAPI ? |
| 593 |
ATA_PROT_ATAPI_NODATA : ATA_PROT_NODATA; |
| 594 |
qc->tf.feature = gtf->tfa[0]; /* 0x1f1 */ |
| 595 |
qc->tf.nsect = gtf->tfa[1]; /* 0x1f2 */ |
| 596 |
qc->tf.lbal = gtf->tfa[2]; /* 0x1f3 */ |
| 597 |
qc->tf.lbam = gtf->tfa[3]; /* 0x1f4 */ |
| 598 |
qc->tf.lbah = gtf->tfa[4]; /* 0x1f5 */ |
| 599 |
qc->tf.device = gtf->tfa[5]; /* 0x1f6 */ |
| 600 |
qc->tf.command = gtf->tfa[6]; /* 0x1f7 */ |
| 601 |
|
| 602 |
if (ata_msg_probe(ap)) |
| 603 |
printk(KERN_DEBUG "call ata_qc_issue:\n"); |
| 604 |
|
| 605 |
qc->waiting = &wait; |
| 606 |
qc->complete_fn = ata_qc_complete_noop; |
| 607 |
|
| 608 |
spin_lock_irqsave(&ap->host_set->lock, flags); |
| 609 |
rc = ata_qc_issue(qc); |
| 610 |
spin_unlock_irqrestore(&ap->host_set->lock, flags); |
| 611 |
if (rc) { |
| 612 |
if (ata_msg_probe(ap)) |
| 613 |
printk(KERN_ERR "%s: ata_qc_issue failed: %u\n", |
| 614 |
__FUNCTION__, rc); |
| 615 |
} else { |
| 616 |
if (!wait_for_completion_timeout(&wait, timeout)) { |
| 617 |
if (ata_msg_probe(ap)) |
| 618 |
printk(KERN_ERR "%s: ata_qc_issue timeout\n", __FUNCTION__); |
| 619 |
qc->flags &= ~ATA_QCFLAG_ACTIVE; |
| 620 |
} |
| 621 |
} |
| 622 |
} else |
| 623 |
if (ata_msg_warn(ap)) |
| 624 |
printk(KERN_WARNING |
| 625 |
"%s: SATA driver is missing qc_issue function entry points\n", |
| 626 |
__FUNCTION__); |
| 627 |
} |
| 628 |
|
| 629 |
/** |
| 630 |
* do_drive_set_taskfiles - write the drive taskfile settings from _GTF |
| 631 |
* @ap: the ata_port for the drive |
| 632 |
* @atadev: target ata_device |
| 633 |
* @gtf_length: total number of bytes of _GTF taskfiles |
| 634 |
* @gtf_address: location of _GTF taskfile arrays |
| 635 |
* |
| 636 |
* This applies to both PATA and SATA drives. |
| 637 |
* |
| 638 |
* Write {gtf_address, length gtf_length} in groups of |
| 639 |
* REGS_PER_GTF bytes. |
| 640 |
*/ |
| 641 |
int do_drive_set_taskfiles(struct ata_port *ap, struct ata_device *atadev, |
| 642 |
unsigned int gtf_length, unsigned long gtf_address) |
| 643 |
{ |
| 644 |
int err = -ENODEV; |
| 645 |
int gtf_count = gtf_length / REGS_PER_GTF; |
| 646 |
int ix; |
| 647 |
struct taskfile_array *gtf; |
| 648 |
|
| 649 |
if (ata_msg_probe(ap)) |
| 650 |
printk(KERN_DEBUG |
| 651 |
"%s: ENTER: ap->id: %d, port#: %d, hard_port#: %d\n", |
| 652 |
__FUNCTION__, ap->id, |
| 653 |
ap->port_no, ap->hard_port_no); |
| 654 |
|
| 655 |
if (noacpi) |
| 656 |
return 0; |
| 657 |
if (!ata_id_is_sata(atadev->id)) { |
| 658 |
printk(KERN_DEBUG "%s: skipping non-SATA drive\n", |
| 659 |
__FUNCTION__); |
| 660 |
return 0; |
| 661 |
} |
| 662 |
|
| 663 |
if (!ata_dev_present(atadev) || |
| 664 |
(ap->flags & ATA_FLAG_PORT_DISABLED)) |
| 665 |
goto out; |
| 666 |
if (!gtf_count) /* shouldn't be here */ |
| 667 |
goto out; |
| 668 |
|
| 669 |
if (ata_msg_probe(ap)) |
| 670 |
printk(KERN_DEBUG |
| 671 |
"%s: total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n", |
| 672 |
__FUNCTION__, gtf_length, gtf_length, gtf_count, |
| 673 |
gtf_address); |
| 674 |
if (gtf_length % REGS_PER_GTF) { |
| 675 |
if (ata_msg_drv(ap)) |
| 676 |
printk(KERN_ERR "%s: unexpected GTF length (%d)\n", |
| 677 |
__FUNCTION__, gtf_length); |
| 678 |
goto out; |
| 679 |
} |
| 680 |
|
| 681 |
for (ix = 0; ix < gtf_count; ix++) { |
| 682 |
gtf = (struct taskfile_array *) |
| 683 |
(gtf_address + ix * REGS_PER_GTF); |
| 684 |
|
| 685 |
/* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ |
| 686 |
taskfile_load_raw(ap, atadev, gtf); |
| 687 |
} |
| 688 |
|
| 689 |
err = 0; |
| 690 |
out: |
| 691 |
return err; |
| 692 |
} |
| 693 |
EXPORT_SYMBOL_GPL(do_drive_set_taskfiles); |
| 694 |
|
| 695 |
/** |
| 696 |
* ata_acpi_exec_tfs - get then write drive taskfile settings |
| 697 |
* @ap: the ata_port for the drive |
| 698 |
* |
| 699 |
* This applies to both PATA and SATA drives. |
| 700 |
*/ |
| 701 |
int ata_acpi_exec_tfs(struct ata_port *ap) |
| 702 |
{ |
| 703 |
int ix; |
| 704 |
int ret; |
| 705 |
unsigned int gtf_length; |
| 706 |
unsigned long gtf_address; |
| 707 |
unsigned long obj_loc; |
| 708 |
|
| 709 |
if (ata_msg_probe(ap)) |
| 710 |
printk(KERN_DEBUG "%s: ENTER:\n", __FUNCTION__); |
| 711 |
|
| 712 |
if (noacpi) |
| 713 |
return 0; |
| 714 |
|
| 715 |
for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { |
| 716 |
if (ata_msg_probe(ap)) |
| 717 |
printk(KERN_DEBUG "%s: call get_GTF, ix=%d\n", |
| 718 |
__FUNCTION__, ix); |
| 719 |
ret = do_drive_get_GTF(ap, &ap->device[ix], |
| 720 |
>f_length, >f_address, &obj_loc); |
| 721 |
if (ret < 0) { |
| 722 |
if (ata_msg_probe(ap)) |
| 723 |
printk(KERN_DEBUG "%s: get_GTF error (%d)\n", |
| 724 |
__FUNCTION__, ret); |
| 725 |
break; |
| 726 |
} |
| 727 |
|
| 728 |
if (ata_msg_probe(ap)) |
| 729 |
printk(KERN_DEBUG "%s: call set_taskfiles, ix=%d\n", |
| 730 |
__FUNCTION__, ix); |
| 731 |
ret = do_drive_set_taskfiles(ap, &ap->device[ix], |
| 732 |
gtf_length, gtf_address); |
| 733 |
acpi_os_free((void *)obj_loc); |
| 734 |
if (ret < 0) { |
| 735 |
if (ata_msg_probe(ap)) |
| 736 |
printk(KERN_DEBUG |
| 737 |
"%s: set_taskfiles error (%d)\n", |
| 738 |
__FUNCTION__, ret); |
| 739 |
break; |
| 740 |
} |
| 741 |
} |
| 742 |
|
| 743 |
if (ata_msg_probe(ap)) |
| 744 |
printk(KERN_DEBUG "%s: ret=%d\n", __FUNCTION__, ret); |
| 745 |
|
| 746 |
return ret; |
| 747 |
} |
| 748 |
EXPORT_SYMBOL_GPL(ata_acpi_exec_tfs); |
| 749 |
|
| 750 |
/** |
| 751 |
* ata_acpi_get_timing - get the channel (controller) timings |
| 752 |
* @ap: target ata_port (channel) |
| 753 |
* |
| 754 |
* For PATA ACPI, this function executes the _GTM ACPI method for the |
| 755 |
* target channel. |
| 756 |
* |
| 757 |
* _GTM only applies to ATA controllers in PATA (legacy) mode, not to SATA. |
| 758 |
* In legacy mode, ap->hard_port_no is channel (controller) number. |
| 759 |
*/ |
| 760 |
void ata_acpi_get_timing(struct ata_port *ap) |
| 761 |
{ |
| 762 |
struct device *dev = ap->dev; |
| 763 |
int err; |
| 764 |
acpi_handle dev_handle; |
| 765 |
acpi_integer pcidevfn; |
| 766 |
acpi_handle chan_handle; |
| 767 |
acpi_status status; |
| 768 |
struct acpi_buffer output; |
| 769 |
union acpi_object *out_obj; |
| 770 |
struct GTM_buffer *gtm; |
| 771 |
|
| 772 |
if (noacpi) |
| 773 |
goto out; |
| 774 |
|
| 775 |
if (!ap->legacy_mode) { |
| 776 |
if (ata_msg_probe(ap)) |
| 777 |
printk(KERN_DEBUG |
| 778 |
"%s: channel/controller not in legacy mode (%s)\n", |
| 779 |
__FUNCTION__, dev->bus_id); |
| 780 |
goto out; |
| 781 |
} |
| 782 |
|
| 783 |
err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); |
| 784 |
if (err < 0) { |
| 785 |
if (ata_msg_probe(ap)) |
| 786 |
printk(KERN_DEBUG |
| 787 |
"%s: pata_get_dev_handle failed (%d)\n", |
| 788 |
__FUNCTION__, err); |
| 789 |
goto out; |
| 790 |
} |
| 791 |
|
| 792 |
/* get child objects of dev_handle == channel objects, |
| 793 |
* + _their_ children == drive objects */ |
| 794 |
/* channel is ap->hard_port_no */ |
| 795 |
chan_handle = acpi_get_child(dev_handle, ap->hard_port_no); |
| 796 |
if (ata_msg_probe(ap)) |
| 797 |
printk(KERN_DEBUG "%s: chan adr=%d: handle=0x%p\n", |
| 798 |
__FUNCTION__, ap->hard_port_no, chan_handle); |
| 799 |
if (!chan_handle) |
| 800 |
goto out; |
| 801 |
|
| 802 |
#if 0 |
| 803 |
/* TBD: also check ACPI object VALID bits */ |
| 804 |
drive_handle = acpi_get_child(chan_handle, 0); |
| 805 |
printk(KERN_DEBUG "%s: drive w/ adr=0: %c: 0x%p\n", |
| 806 |
__FUNCTION__, |
| 807 |
ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v', |
| 808 |
drive_handle); |
| 809 |
drive_handle = acpi_get_child(chan_handle, 1); |
| 810 |
printk(KERN_DEBUG "%s: drive w/ adr=1: %c: 0x%p\n", |
| 811 |
__FUNCTION__, |
| 812 |
ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v', |
| 813 |
drive_handle); |
| 814 |
#endif |
| 815 |
|
| 816 |
/* Setting up output buffer for _GTM */ |
| 817 |
output.length = ACPI_ALLOCATE_BUFFER; |
| 818 |
output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ |
| 819 |
|
| 820 |
/* _GTM has no input parameters */ |
| 821 |
status = acpi_evaluate_object(chan_handle, "_GTM", |
| 822 |
NULL, &output); |
| 823 |
if (ata_msg_probe(ap)) |
| 824 |
printk(KERN_DEBUG "%s: _GTM status: %d, outptr: 0x%p, outlen: 0x%llx\n", |
| 825 |
__FUNCTION__, status, output.pointer, |
| 826 |
(unsigned long long)output.length); |
| 827 |
if (ACPI_FAILURE(status)) { |
| 828 |
if (ata_msg_probe(ap)) |
| 829 |
printk(KERN_DEBUG |
| 830 |
"%s: Run _GTM error: status = 0x%x\n", |
| 831 |
__FUNCTION__, status); |
| 832 |
goto out; |
| 833 |
} |
| 834 |
|
| 835 |
if (!output.length || !output.pointer) { |
| 836 |
if (ata_msg_probe(ap)) |
| 837 |
printk(KERN_DEBUG "%s: Run _GTM: " |
| 838 |
"length or ptr is NULL (0x%llx, 0x%p)\n", |
| 839 |
__FUNCTION__, |
| 840 |
(unsigned long long)output.length, |
| 841 |
output.pointer); |
| 842 |
acpi_os_free(output.pointer); |
| 843 |
goto out; |
| 844 |
} |
| 845 |
|
| 846 |
out_obj = output.pointer; |
| 847 |
if (out_obj->type != ACPI_TYPE_BUFFER) { |
| 848 |
acpi_os_free(output.pointer); |
| 849 |
if (ata_msg_probe(ap)) |
| 850 |
printk(KERN_DEBUG "%s: Run _GTM: error: " |
| 851 |
"expected object type of ACPI_TYPE_BUFFER, " |
| 852 |
"got 0x%x\n", |
| 853 |
__FUNCTION__, out_obj->type); |
| 854 |
goto out; |
| 855 |
} |
| 856 |
|
| 857 |
if (!out_obj->buffer.length || !out_obj->buffer.pointer || |
| 858 |
out_obj->buffer.length != sizeof(struct GTM_buffer)) { |
| 859 |
acpi_os_free(output.pointer); |
| 860 |
if (ata_msg_drv(ap)) |
| 861 |
printk(KERN_ERR |
| 862 |
"%s: unexpected _GTM length (0x%x)[should be 0x%x] or addr (0x%p)\n", |
| 863 |
__FUNCTION__, out_obj->buffer.length, |
| 864 |
sizeof(struct GTM_buffer), out_obj->buffer.pointer); |
| 865 |
goto out; |
| 866 |
} |
| 867 |
|
| 868 |
gtm = (struct GTM_buffer *)out_obj->buffer.pointer; |
| 869 |
if (ata_msg_probe(ap)) { |
| 870 |
printk(KERN_DEBUG "%s: _GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%Zx\n", |
| 871 |
__FUNCTION__, out_obj->buffer.pointer, |
| 872 |
out_obj->buffer.length, sizeof(struct GTM_buffer)); |
| 873 |
printk(KERN_DEBUG "%s: _GTM fields: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", |
| 874 |
__FUNCTION__, gtm->PIO_speed0, gtm->DMA_speed0, |
| 875 |
gtm->PIO_speed1, gtm->DMA_speed1, gtm->GTM_flags); |
| 876 |
} |
| 877 |
|
| 878 |
/* TBD: when to free gtm */ |
| 879 |
ap->gtm = gtm; |
| 880 |
kfree(ap->gtm_object_area); /* free previous then store new one */ |
| 881 |
ap->gtm_object_area = out_obj; |
| 882 |
out:; |
| 883 |
} |
| 884 |
EXPORT_SYMBOL_GPL(ata_acpi_get_timing); |
| 885 |
|
| 886 |
/** |
| 887 |
* platform_set_timing - set the channel (controller) timings |
| 888 |
* @ap: target ata_port (channel) |
| 889 |
* |
| 890 |
* For PATA ACPI, this function executes the _STM ACPI method for the |
| 891 |
* target channel. |
| 892 |
* |
| 893 |
* _STM only applies to ATA controllers in PATA (legacy) mode, not to SATA. |
| 894 |
* In legacy mode, ap->hard_port_no is channel (controller) number. |
| 895 |
* |
| 896 |
* _STM requires Identify Drive data, which must already be present in |
| 897 |
* ata_device->id[] (i.e., it's not fetched here). |
| 898 |
*/ |
| 899 |
void ata_acpi_push_timing(struct ata_port *ap) |
| 900 |
{ |
| 901 |
struct device *dev = ap->dev; |
| 902 |
int err; |
| 903 |
acpi_handle dev_handle; |
| 904 |
acpi_integer pcidevfn; |
| 905 |
acpi_handle chan_handle; |
| 906 |
acpi_status status; |
| 907 |
struct acpi_object_list input; |
| 908 |
union acpi_object in_params[1]; |
| 909 |
|
| 910 |
if (noacpi) |
| 911 |
goto out; |
| 912 |
|
| 913 |
if (!ap->legacy_mode) { |
| 914 |
if (ata_msg_probe(ap)) |
| 915 |
printk(KERN_DEBUG |
| 916 |
"%s: channel/controller not in legacy mode (%s)\n", |
| 917 |
__FUNCTION__, dev->bus_id); |
| 918 |
goto out; |
| 919 |
} |
| 920 |
|
| 921 |
if (ap->device[0].id[49] || ap->device[1].id[49]) { |
| 922 |
if (ata_msg_probe(ap)) |
| 923 |
printk(KERN_DEBUG "%s: drive(s) on channel %d: missing Identify data\n", |
| 924 |
__FUNCTION__, ap->hard_port_no); |
| 925 |
goto out; |
| 926 |
} |
| 927 |
|
| 928 |
err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); |
| 929 |
if (err < 0) { |
| 930 |
if (ata_msg_probe(ap)) |
| 931 |
printk(KERN_DEBUG |
| 932 |
"%s: pata_get_dev_handle failed (%d)\n", |
| 933 |
__FUNCTION__, err); |
| 934 |
goto out; |
| 935 |
} |
| 936 |
|
| 937 |
/* get child objects of dev_handle == channel objects, |
| 938 |
* + _their_ children == drive objects */ |
| 939 |
/* channel is ap->hard_port_no */ |
| 940 |
chan_handle = acpi_get_child(dev_handle, ap->hard_port_no); |
| 941 |
if (ata_msg_probe(ap)) |
| 942 |
printk(KERN_DEBUG "%s: chan adr=%d: handle=0x%p\n", |
| 943 |
__FUNCTION__, ap->hard_port_no, chan_handle); |
| 944 |
if (!chan_handle) |
| 945 |
goto out; |
| 946 |
|
| 947 |
#if 0 |
| 948 |
/* TBD: also check ACPI object VALID bits */ |
| 949 |
drive_handle = acpi_get_child(chan_handle, 0); |
| 950 |
printk(KERN_DEBUG "%s: drive w/ adr=0: %c: 0x%p\n", |
| 951 |
__FUNCTION__, |
| 952 |
ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v', |
| 953 |
drive_handle); |
| 954 |
drive_handle = acpi_get_child(chan_handle, 1); |
| 955 |
printk(KERN_DEBUG "%s: drive w/ adr=1: %c: 0x%p\n", |
| 956 |
__FUNCTION__, |
| 957 |
ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v', |
| 958 |
drive_handle); |
| 959 |
#endif |
| 960 |
|
| 961 |
/* Give the GTM buffer + drive Identify data to the channel via the |
| 962 |
* _STM method: */ |
| 963 |
/* setup input parameters buffer for _STM */ |
| 964 |
input.count = 3; |
| 965 |
input.pointer = in_params; |
| 966 |
in_params[0].type = ACPI_TYPE_BUFFER; |
| 967 |
in_params[0].buffer.length = sizeof(struct GTM_buffer); |
| 968 |
in_params[0].buffer.pointer = (u8 *)ap->gtm; |
| 969 |
in_params[1].type = ACPI_TYPE_BUFFER; |
| 970 |
in_params[1].buffer.length = sizeof(ap->device[0].id); |
| 971 |
in_params[1].buffer.pointer = (u8 *)ap->device[0].id; |
| 972 |
in_params[2].type = ACPI_TYPE_BUFFER; |
| 973 |
in_params[2].buffer.length = sizeof(ap->device[1].id); |
| 974 |
in_params[2].buffer.pointer = (u8 *)ap->device[1].id; |
| 975 |
/* Output buffer: _STM has no output */ |
| 976 |
|
| 977 |
swap_buf_le16(ap->device[0].id, ATA_ID_WORDS); |
| 978 |
swap_buf_le16(ap->device[1].id, ATA_ID_WORDS); |
| 979 |
status = acpi_evaluate_object(chan_handle, "_STM", &input, NULL); |
| 980 |
swap_buf_le16(ap->device[0].id, ATA_ID_WORDS); |
| 981 |
swap_buf_le16(ap->device[1].id, ATA_ID_WORDS); |
| 982 |
if (ata_msg_probe(ap)) |
| 983 |
printk(KERN_DEBUG "%s: _STM status: %d\n", |
| 984 |
__FUNCTION__, status); |
| 985 |
if (ACPI_FAILURE(status)) { |
| 986 |
if (ata_msg_probe(ap)) |
| 987 |
printk(KERN_DEBUG |
| 988 |
"%s: Run _STM error: status = 0x%x\n", |
| 989 |
__FUNCTION__, status); |
| 990 |
goto out; |
| 991 |
} |
| 992 |
|
| 993 |
out:; |
| 994 |
} |
| 995 |
EXPORT_SYMBOL_GPL(ata_acpi_push_timing); |