ide-acpi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * Provides ACPI support for IDE drives.
  3. *
  4. * Copyright (C) 2005 Intel Corp.
  5. * Copyright (C) 2005 Randy Dunlap
  6. * Copyright (C) 2006 SUSE Linux Products GmbH
  7. * Copyright (C) 2006 Hannes Reinecke
  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 <linux/ide.h>
  16. #include <linux/pci.h>
  17. #include <linux/dmi.h>
  18. #include <acpi/acpi_bus.h>
  19. #define REGS_PER_GTF 7
  20. struct GTM_buffer {
  21. u32 PIO_speed0;
  22. u32 DMA_speed0;
  23. u32 PIO_speed1;
  24. u32 DMA_speed1;
  25. u32 GTM_flags;
  26. };
  27. struct ide_acpi_drive_link {
  28. acpi_handle obj_handle;
  29. u8 idbuff[512];
  30. };
  31. struct ide_acpi_hwif_link {
  32. ide_hwif_t *hwif;
  33. acpi_handle obj_handle;
  34. struct GTM_buffer gtm;
  35. struct ide_acpi_drive_link master;
  36. struct ide_acpi_drive_link slave;
  37. };
  38. #undef DEBUGGING
  39. /* note: adds function name and KERN_DEBUG */
  40. #ifdef DEBUGGING
  41. #define DEBPRINT(fmt, args...) \
  42. printk(KERN_DEBUG "%s: " fmt, __func__, ## args)
  43. #else
  44. #define DEBPRINT(fmt, args...) do {} while (0)
  45. #endif /* DEBUGGING */
  46. static int ide_noacpi;
  47. module_param_named(noacpi, ide_noacpi, bool, 0);
  48. MODULE_PARM_DESC(noacpi, "disable IDE ACPI support");
  49. static int ide_acpigtf;
  50. module_param_named(acpigtf, ide_acpigtf, bool, 0);
  51. MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support");
  52. static int ide_acpionboot;
  53. module_param_named(acpionboot, ide_acpionboot, bool, 0);
  54. MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot");
  55. static bool ide_noacpi_psx;
  56. static int no_acpi_psx(const struct dmi_system_id *id)
  57. {
  58. ide_noacpi_psx = true;
  59. printk(KERN_NOTICE"%s detected - disable ACPI _PSx.\n", id->ident);
  60. return 0;
  61. }
  62. static const struct dmi_system_id ide_acpi_dmi_table[] = {
  63. /* Bug 9673. */
  64. /* We should check if this is because ACPI NVS isn't save/restored. */
  65. {
  66. .callback = no_acpi_psx,
  67. .ident = "HP nx9005",
  68. .matches = {
  69. DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies Ltd."),
  70. DMI_MATCH(DMI_BIOS_VERSION, "KAM1.60")
  71. },
  72. },
  73. { } /* terminate list */
  74. };
  75. int ide_acpi_init(void)
  76. {
  77. dmi_check_system(ide_acpi_dmi_table);
  78. return 0;
  79. }
  80. /**
  81. * ide_get_dev_handle - finds acpi_handle and PCI device.function
  82. * @dev: device to locate
  83. * @handle: returned acpi_handle for @dev
  84. * @pcidevfn: return PCI device.func for @dev
  85. *
  86. * Returns the ACPI object handle to the corresponding PCI device.
  87. *
  88. * Returns 0 on success, <0 on error.
  89. */
  90. static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
  91. acpi_integer *pcidevfn)
  92. {
  93. struct pci_dev *pdev = to_pci_dev(dev);
  94. unsigned int bus, devnum, func;
  95. acpi_integer addr;
  96. acpi_handle dev_handle;
  97. struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER,
  98. .pointer = NULL};
  99. acpi_status status;
  100. struct acpi_device_info *dinfo = NULL;
  101. int ret = -ENODEV;
  102. bus = pdev->bus->number;
  103. devnum = PCI_SLOT(pdev->devfn);
  104. func = PCI_FUNC(pdev->devfn);
  105. /* ACPI _ADR encoding for PCI bus: */
  106. addr = (acpi_integer)(devnum << 16 | func);
  107. DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
  108. dev_handle = DEVICE_ACPI_HANDLE(dev);
  109. if (!dev_handle) {
  110. DEBPRINT("no acpi handle for device\n");
  111. goto err;
  112. }
  113. status = acpi_get_object_info(dev_handle, &buffer);
  114. if (ACPI_FAILURE(status)) {
  115. DEBPRINT("get_object_info for device failed\n");
  116. goto err;
  117. }
  118. dinfo = buffer.pointer;
  119. if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
  120. dinfo->address == addr) {
  121. *pcidevfn = addr;
  122. *handle = dev_handle;
  123. } else {
  124. DEBPRINT("get_object_info for device has wrong "
  125. " address: %llu, should be %u\n",
  126. dinfo ? (unsigned long long)dinfo->address : -1ULL,
  127. (unsigned int)addr);
  128. goto err;
  129. }
  130. DEBPRINT("for dev=0x%x.%x, addr=0x%llx, *handle=0x%p\n",
  131. devnum, func, (unsigned long long)addr, *handle);
  132. ret = 0;
  133. err:
  134. kfree(dinfo);
  135. return ret;
  136. }
  137. /**
  138. * ide_acpi_hwif_get_handle - Get ACPI object handle for a given hwif
  139. * @hwif: device to locate
  140. *
  141. * Retrieves the object handle for a given hwif.
  142. *
  143. * Returns handle on success, 0 on error.
  144. */
  145. static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif)
  146. {
  147. struct device *dev = hwif->gendev.parent;
  148. acpi_handle uninitialized_var(dev_handle);
  149. acpi_integer pcidevfn;
  150. acpi_handle chan_handle;
  151. int err;
  152. DEBPRINT("ENTER: device %s\n", hwif->name);
  153. if (!dev) {
  154. DEBPRINT("no PCI device for %s\n", hwif->name);
  155. return NULL;
  156. }
  157. err = ide_get_dev_handle(dev, &dev_handle, &pcidevfn);
  158. if (err < 0) {
  159. DEBPRINT("ide_get_dev_handle failed (%d)\n", err);
  160. return NULL;
  161. }
  162. /* get child objects of dev_handle == channel objects,
  163. * + _their_ children == drive objects */
  164. /* channel is hwif->channel */
  165. chan_handle = acpi_get_child(dev_handle, hwif->channel);
  166. DEBPRINT("chan adr=%d: handle=0x%p\n",
  167. hwif->channel, chan_handle);
  168. return chan_handle;
  169. }
  170. /**
  171. * do_drive_get_GTF - get the drive bootup default taskfile settings
  172. * @drive: the drive for which the taskfile settings should be retrieved
  173. * @gtf_length: number of bytes of _GTF data returned at @gtf_address
  174. * @gtf_address: buffer containing _GTF taskfile arrays
  175. *
  176. * The _GTF method has no input parameters.
  177. * It returns a variable number of register set values (registers
  178. * hex 1F1..1F7, taskfiles).
  179. * The <variable number> is not known in advance, so have ACPI-CA
  180. * allocate the buffer as needed and return it, then free it later.
  181. *
  182. * The returned @gtf_length and @gtf_address are only valid if the
  183. * function return value is 0.
  184. */
  185. static int do_drive_get_GTF(ide_drive_t *drive,
  186. unsigned int *gtf_length, unsigned long *gtf_address,
  187. unsigned long *obj_loc)
  188. {
  189. acpi_status status;
  190. struct acpi_buffer output;
  191. union acpi_object *out_obj;
  192. int err = -ENODEV;
  193. *gtf_length = 0;
  194. *gtf_address = 0UL;
  195. *obj_loc = 0UL;
  196. if (!drive->acpidata->obj_handle) {
  197. DEBPRINT("No ACPI object found for %s\n", drive->name);
  198. goto out;
  199. }
  200. /* Setting up output buffer */
  201. output.length = ACPI_ALLOCATE_BUFFER;
  202. output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
  203. /* _GTF has no input parameters */
  204. err = -EIO;
  205. status = acpi_evaluate_object(drive->acpidata->obj_handle, "_GTF",
  206. NULL, &output);
  207. if (ACPI_FAILURE(status)) {
  208. printk(KERN_DEBUG
  209. "%s: Run _GTF error: status = 0x%x\n",
  210. __func__, status);
  211. goto out;
  212. }
  213. if (!output.length || !output.pointer) {
  214. DEBPRINT("Run _GTF: "
  215. "length or ptr is NULL (0x%llx, 0x%p)\n",
  216. (unsigned long long)output.length,
  217. output.pointer);
  218. goto out;
  219. }
  220. out_obj = output.pointer;
  221. if (out_obj->type != ACPI_TYPE_BUFFER) {
  222. DEBPRINT("Run _GTF: error: "
  223. "expected object type of ACPI_TYPE_BUFFER, "
  224. "got 0x%x\n", out_obj->type);
  225. err = -ENOENT;
  226. kfree(output.pointer);
  227. goto out;
  228. }
  229. if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
  230. out_obj->buffer.length % REGS_PER_GTF) {
  231. printk(KERN_ERR
  232. "%s: unexpected GTF length (%d) or addr (0x%p)\n",
  233. __func__, out_obj->buffer.length,
  234. out_obj->buffer.pointer);
  235. err = -ENOENT;
  236. kfree(output.pointer);
  237. goto out;
  238. }
  239. *gtf_length = out_obj->buffer.length;
  240. *gtf_address = (unsigned long)out_obj->buffer.pointer;
  241. *obj_loc = (unsigned long)out_obj;
  242. DEBPRINT("returning gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n",
  243. *gtf_length, *gtf_address, *obj_loc);
  244. err = 0;
  245. out:
  246. return err;
  247. }
  248. /**
  249. * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
  250. * @drive: the drive to which the taskfile command should be sent
  251. * @gtf_length: total number of bytes of _GTF taskfiles
  252. * @gtf_address: location of _GTF taskfile arrays
  253. *
  254. * Write {gtf_address, length gtf_length} in groups of
  255. * REGS_PER_GTF bytes.
  256. */
  257. static int do_drive_set_taskfiles(ide_drive_t *drive,
  258. unsigned int gtf_length,
  259. unsigned long gtf_address)
  260. {
  261. int rc = 0, err;
  262. int gtf_count = gtf_length / REGS_PER_GTF;
  263. int ix;
  264. DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
  265. gtf_length, gtf_length, gtf_count, gtf_address);
  266. /* send all taskfile registers (0x1f1-0x1f7) *in*that*order* */
  267. for (ix = 0; ix < gtf_count; ix++) {
  268. u8 *gtf = (u8 *)(gtf_address + ix * REGS_PER_GTF);
  269. struct ide_cmd cmd;
  270. DEBPRINT("(0x1f1-1f7): "
  271. "hex: %02x %02x %02x %02x %02x %02x %02x\n",
  272. gtf[0], gtf[1], gtf[2],
  273. gtf[3], gtf[4], gtf[5], gtf[6]);
  274. if (!ide_acpigtf) {
  275. DEBPRINT("_GTF execution disabled\n");
  276. continue;
  277. }
  278. /* convert GTF to taskfile */
  279. memset(&cmd, 0, sizeof(cmd));
  280. memcpy(&cmd.tf.feature, gtf, REGS_PER_GTF);
  281. cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
  282. cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
  283. err = ide_no_data_taskfile(drive, &cmd);
  284. if (err) {
  285. printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
  286. __func__, err);
  287. rc = err;
  288. }
  289. }
  290. return rc;
  291. }
  292. /**
  293. * ide_acpi_exec_tfs - get then write drive taskfile settings
  294. * @drive: the drive for which the taskfile settings should be
  295. * written.
  296. *
  297. * According to the ACPI spec this should be called after _STM
  298. * has been evaluated for the interface. Some ACPI vendors interpret
  299. * that as a hard requirement and modify the taskfile according
  300. * to the Identify Drive information passed down with _STM.
  301. * So one should really make sure to call this only after _STM has
  302. * been executed.
  303. */
  304. int ide_acpi_exec_tfs(ide_drive_t *drive)
  305. {
  306. int ret;
  307. unsigned int gtf_length;
  308. unsigned long gtf_address;
  309. unsigned long obj_loc;
  310. if (ide_noacpi)
  311. return 0;
  312. DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn);
  313. ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc);
  314. if (ret < 0) {
  315. DEBPRINT("get_GTF error (%d)\n", ret);
  316. return ret;
  317. }
  318. DEBPRINT("call set_taskfiles, drive=%s\n", drive->name);
  319. ret = do_drive_set_taskfiles(drive, gtf_length, gtf_address);
  320. kfree((void *)obj_loc);
  321. if (ret < 0) {
  322. DEBPRINT("set_taskfiles error (%d)\n", ret);
  323. }
  324. DEBPRINT("ret=%d\n", ret);
  325. return ret;
  326. }
  327. /**
  328. * ide_acpi_get_timing - get the channel (controller) timings
  329. * @hwif: target IDE interface (channel)
  330. *
  331. * This function executes the _GTM ACPI method for the target channel.
  332. *
  333. */
  334. void ide_acpi_get_timing(ide_hwif_t *hwif)
  335. {
  336. acpi_status status;
  337. struct acpi_buffer output;
  338. union acpi_object *out_obj;
  339. if (ide_noacpi)
  340. return;
  341. DEBPRINT("ENTER:\n");
  342. if (!hwif->acpidata) {
  343. DEBPRINT("no ACPI data for %s\n", hwif->name);
  344. return;
  345. }
  346. /* Setting up output buffer for _GTM */
  347. output.length = ACPI_ALLOCATE_BUFFER;
  348. output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
  349. /* _GTM has no input parameters */
  350. status = acpi_evaluate_object(hwif->acpidata->obj_handle, "_GTM",
  351. NULL, &output);
  352. DEBPRINT("_GTM status: %d, outptr: 0x%p, outlen: 0x%llx\n",
  353. status, output.pointer,
  354. (unsigned long long)output.length);
  355. if (ACPI_FAILURE(status)) {
  356. DEBPRINT("Run _GTM error: status = 0x%x\n", status);
  357. return;
  358. }
  359. if (!output.length || !output.pointer) {
  360. DEBPRINT("Run _GTM: length or ptr is NULL (0x%llx, 0x%p)\n",
  361. (unsigned long long)output.length,
  362. output.pointer);
  363. kfree(output.pointer);
  364. return;
  365. }
  366. out_obj = output.pointer;
  367. if (out_obj->type != ACPI_TYPE_BUFFER) {
  368. kfree(output.pointer);
  369. DEBPRINT("Run _GTM: error: "
  370. "expected object type of ACPI_TYPE_BUFFER, "
  371. "got 0x%x\n", out_obj->type);
  372. return;
  373. }
  374. if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
  375. out_obj->buffer.length != sizeof(struct GTM_buffer)) {
  376. kfree(output.pointer);
  377. printk(KERN_ERR
  378. "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or "
  379. "addr (0x%p)\n",
  380. __func__, out_obj->buffer.length,
  381. sizeof(struct GTM_buffer), out_obj->buffer.pointer);
  382. return;
  383. }
  384. memcpy(&hwif->acpidata->gtm, out_obj->buffer.pointer,
  385. sizeof(struct GTM_buffer));
  386. DEBPRINT("_GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%Zx\n",
  387. out_obj->buffer.pointer, out_obj->buffer.length,
  388. sizeof(struct GTM_buffer));
  389. DEBPRINT("_GTM fields: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
  390. hwif->acpidata->gtm.PIO_speed0,
  391. hwif->acpidata->gtm.DMA_speed0,
  392. hwif->acpidata->gtm.PIO_speed1,
  393. hwif->acpidata->gtm.DMA_speed1,
  394. hwif->acpidata->gtm.GTM_flags);
  395. kfree(output.pointer);
  396. }
  397. /**
  398. * ide_acpi_push_timing - set the channel (controller) timings
  399. * @hwif: target IDE interface (channel)
  400. *
  401. * This function executes the _STM ACPI method for the target channel.
  402. *
  403. * _STM requires Identify Drive data, which has to passed as an argument.
  404. * Unfortunately drive->id is a mangled version which we can't readily
  405. * use; hence we'll get the information afresh.
  406. */
  407. void ide_acpi_push_timing(ide_hwif_t *hwif)
  408. {
  409. acpi_status status;
  410. struct acpi_object_list input;
  411. union acpi_object in_params[3];
  412. struct ide_acpi_drive_link *master = &hwif->acpidata->master;
  413. struct ide_acpi_drive_link *slave = &hwif->acpidata->slave;
  414. if (ide_noacpi)
  415. return;
  416. DEBPRINT("ENTER:\n");
  417. if (!hwif->acpidata) {
  418. DEBPRINT("no ACPI data for %s\n", hwif->name);
  419. return;
  420. }
  421. /* Give the GTM buffer + drive Identify data to the channel via the
  422. * _STM method: */
  423. /* setup input parameters buffer for _STM */
  424. input.count = 3;
  425. input.pointer = in_params;
  426. in_params[0].type = ACPI_TYPE_BUFFER;
  427. in_params[0].buffer.length = sizeof(struct GTM_buffer);
  428. in_params[0].buffer.pointer = (u8 *)&hwif->acpidata->gtm;
  429. in_params[1].type = ACPI_TYPE_BUFFER;
  430. in_params[1].buffer.length = ATA_ID_WORDS * 2;
  431. in_params[1].buffer.pointer = (u8 *)&master->idbuff;
  432. in_params[2].type = ACPI_TYPE_BUFFER;
  433. in_params[2].buffer.length = ATA_ID_WORDS * 2;
  434. in_params[2].buffer.pointer = (u8 *)&slave->idbuff;
  435. /* Output buffer: _STM has no output */
  436. status = acpi_evaluate_object(hwif->acpidata->obj_handle, "_STM",
  437. &input, NULL);
  438. if (ACPI_FAILURE(status)) {
  439. DEBPRINT("Run _STM error: status = 0x%x\n", status);
  440. }
  441. DEBPRINT("_STM status: %d\n", status);
  442. }
  443. /**
  444. * ide_acpi_set_state - set the channel power state
  445. * @hwif: target IDE interface
  446. * @on: state, on/off
  447. *
  448. * This function executes the _PS0/_PS3 ACPI method to set the power state.
  449. * ACPI spec requires _PS0 when IDE power on and _PS3 when power off
  450. */
  451. void ide_acpi_set_state(ide_hwif_t *hwif, int on)
  452. {
  453. ide_drive_t *drive;
  454. int i;
  455. if (ide_noacpi || ide_noacpi_psx)
  456. return;
  457. DEBPRINT("ENTER:\n");
  458. if (!hwif->acpidata) {
  459. DEBPRINT("no ACPI data for %s\n", hwif->name);
  460. return;
  461. }
  462. /* channel first and then drives for power on and verse versa for power off */
  463. if (on)
  464. acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
  465. ide_port_for_each_present_dev(i, drive, hwif) {
  466. if (drive->acpidata->obj_handle)
  467. acpi_bus_set_power(drive->acpidata->obj_handle,
  468. on ? ACPI_STATE_D0 : ACPI_STATE_D3);
  469. }
  470. if (!on)
  471. acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
  472. }
  473. /**
  474. * ide_acpi_init_port - initialize the ACPI link for an IDE interface
  475. * @hwif: target IDE interface (channel)
  476. *
  477. * The ACPI spec is not quite clear when the drive identify buffer
  478. * should be obtained. Calling IDENTIFY DEVICE during shutdown
  479. * is not the best of ideas as the drive might already being put to
  480. * sleep. And obviously we can't call it during resume.
  481. * So we get the information during startup; but this means that
  482. * any changes during run-time will be lost after resume.
  483. */
  484. void ide_acpi_init_port(ide_hwif_t *hwif)
  485. {
  486. hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
  487. if (!hwif->acpidata)
  488. return;
  489. hwif->acpidata->obj_handle = ide_acpi_hwif_get_handle(hwif);
  490. if (!hwif->acpidata->obj_handle) {
  491. DEBPRINT("no ACPI object for %s found\n", hwif->name);
  492. kfree(hwif->acpidata);
  493. hwif->acpidata = NULL;
  494. }
  495. }
  496. void ide_acpi_port_init_devices(ide_hwif_t *hwif)
  497. {
  498. ide_drive_t *drive;
  499. int i, err;
  500. if (hwif->acpidata == NULL)
  501. return;
  502. /*
  503. * The ACPI spec mandates that we send information
  504. * for both drives, regardless whether they are connected
  505. * or not.
  506. */
  507. hwif->devices[0]->acpidata = &hwif->acpidata->master;
  508. hwif->devices[1]->acpidata = &hwif->acpidata->slave;
  509. /* get _ADR info for each device */
  510. ide_port_for_each_present_dev(i, drive, hwif) {
  511. acpi_handle dev_handle;
  512. DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
  513. drive->name, hwif->channel, drive->dn & 1);
  514. /* TBD: could also check ACPI object VALID bits */
  515. dev_handle = acpi_get_child(hwif->acpidata->obj_handle,
  516. drive->dn & 1);
  517. DEBPRINT("drive %s handle 0x%p\n", drive->name, dev_handle);
  518. drive->acpidata->obj_handle = dev_handle;
  519. }
  520. /* send IDENTIFY for each device */
  521. ide_port_for_each_present_dev(i, drive, hwif) {
  522. err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
  523. if (err)
  524. DEBPRINT("identify device %s failed (%d)\n",
  525. drive->name, err);
  526. }
  527. if (!ide_acpionboot) {
  528. DEBPRINT("ACPI methods disabled on boot\n");
  529. return;
  530. }
  531. /* ACPI _PS0 before _STM */
  532. ide_acpi_set_state(hwif, 1);
  533. /*
  534. * ACPI requires us to call _STM on startup
  535. */
  536. ide_acpi_get_timing(hwif);
  537. ide_acpi_push_timing(hwif);
  538. ide_port_for_each_present_dev(i, drive, hwif) {
  539. ide_acpi_exec_tfs(drive);
  540. }
  541. }