12 #include <linux/device.h>
13 #include <linux/errno.h>
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
18 #include <linux/pci.h>
20 #include <linux/module.h>
24 #define REGS_PER_GTF 7
50 #define DEBPRINT(fmt, args...) \
51 printk(KERN_DEBUG "%s: " fmt, __func__, ## args)
53 #define DEBPRINT(fmt, args...) do {} while (0)
56 static bool ide_noacpi;
60 static bool ide_acpigtf;
64 static bool ide_acpionboot;
68 static bool ide_noacpi_psx;
71 ide_noacpi_psx =
true;
80 .callback = no_acpi_psx,
99 return ide_noacpi == 0 && hwif->acpidata;
123 bus = pdev->
bus->number;
127 addr = (
u64)(devnum << 16 | func);
129 DEBPRINT(
"ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
131 dev_handle = DEVICE_ACPI_HANDLE(dev);
133 DEBPRINT(
"no acpi handle for device\n");
139 DEBPRINT(
"get_object_info for device failed\n");
147 DEBPRINT(
"get_object_info for device has wrong "
148 " address: %llu, should be %u\n",
149 dinfo ? (
unsigned long long)dinfo->
address : -1ULL,
154 DEBPRINT(
"for dev=0x%x.%x, addr=0x%llx, *handle=0x%p\n",
155 devnum, func, (
unsigned long long)addr, *handle);
185 err = ide_get_dev_handle(dev, &dev_handle, &pcidevfn);
187 DEBPRINT(
"ide_get_dev_handle failed (%d)\n", err);
195 DEBPRINT(
"chan adr=%d: handle=0x%p\n",
217 unsigned int *gtf_length,
unsigned long *gtf_address,
218 unsigned long *obj_loc)
229 if (!drive->acpidata->obj_handle) {
244 "%s: Run _GTF error: status = 0x%x\n",
251 "length or ptr is NULL (0x%llx, 0x%p)\n",
252 (
unsigned long long)
output.length,
260 "expected object type of ACPI_TYPE_BUFFER, "
261 "got 0x%x\n", out_obj->
type);
267 if (!out_obj->
buffer.length || !out_obj->
buffer.pointer ||
270 "%s: unexpected GTF length (%d) or addr (0x%p)\n",
271 __func__, out_obj->
buffer.length,
278 *gtf_length = out_obj->
buffer.length;
279 *gtf_address = (
unsigned long)out_obj->
buffer.pointer;
280 *obj_loc = (
unsigned long)out_obj;
281 DEBPRINT(
"returning gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n",
282 *gtf_length, *gtf_address, *obj_loc);
297 static int do_drive_set_taskfiles(
ide_drive_t *drive,
298 unsigned int gtf_length,
299 unsigned long gtf_address)
305 DEBPRINT(
"total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
306 gtf_length, gtf_length, gtf_count, gtf_address);
309 for (ix = 0; ix < gtf_count; ix++) {
314 "hex: %02x %02x %02x %02x %02x %02x %02x\n",
315 gtf[0], gtf[1], gtf[2],
316 gtf[3], gtf[4], gtf[5], gtf[6]);
319 DEBPRINT(
"_GTF execution disabled\n");
325 memcpy(&
cmd.tf.feature, gtf, REGS_PER_GTF);
355 unsigned int gtf_length;
356 unsigned long gtf_address;
357 unsigned long obj_loc;
359 DEBPRINT(
"call get_GTF, drive=%s port=%d\n", drive->
name, drive->
dn);
361 ret = do_drive_get_GTF(drive, >f_length, >f_address, &obj_loc);
363 DEBPRINT(
"get_GTF error (%d)\n", ret);
367 DEBPRINT(
"call set_taskfiles, drive=%s\n", drive->
name);
369 ret = do_drive_set_taskfiles(drive, gtf_length, gtf_address);
370 kfree((
void *)obj_loc);
372 DEBPRINT(
"set_taskfiles error (%d)\n", ret);
401 DEBPRINT(
"_GTM status: %d, outptr: 0x%p, outlen: 0x%llx\n",
403 (
unsigned long long)output.
length);
406 DEBPRINT(
"Run _GTM error: status = 0x%x\n", status);
411 DEBPRINT(
"Run _GTM: length or ptr is NULL (0x%llx, 0x%p)\n",
412 (
unsigned long long)output.
length,
421 "expected object type of ACPI_TYPE_BUFFER, "
422 "got 0x%x\n", out_obj->
type);
427 if (!out_obj->
buffer.length || !out_obj->
buffer.pointer ||
430 "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or "
432 __func__, out_obj->
buffer.length,
441 DEBPRINT(
"_GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%Zx\n",
445 DEBPRINT(
"_GTM fields: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
446 hwif->acpidata->gtm.PIO_speed0,
447 hwif->acpidata->gtm.DMA_speed0,
448 hwif->acpidata->gtm.PIO_speed1,
449 hwif->acpidata->gtm.DMA_speed1,
450 hwif->acpidata->gtm.GTM_flags);
480 in_params[0].
buffer.pointer = (
u8 *)&hwif->acpidata->gtm;
493 DEBPRINT(
"Run _STM error: status = 0x%x\n", status);
495 DEBPRINT(
"_STM status: %d\n", status);
521 if (drive->acpidata->obj_handle)
547 hwif->acpidata->obj_handle = ide_acpi_hwif_get_handle(hwif);
548 if (!hwif->acpidata->obj_handle) {
550 kfree(hwif->acpidata);
551 hwif->acpidata =
NULL;
560 if (hwif->acpidata ==
NULL)
568 hwif->
devices[0]->acpidata = &hwif->acpidata->master;
569 hwif->
devices[1]->acpidata = &hwif->acpidata->slave;
575 DEBPRINT(
"ENTER: %s at channel#: %d port#: %d\n",
582 DEBPRINT(
"drive %s handle 0x%p\n", drive->
name, dev_handle);
591 DEBPRINT(
"identify device %s failed (%d)\n",
595 if (ide_noacpi || ide_acpionboot == 0) {
596 DEBPRINT(
"ACPI methods disabled on boot\n");