ide-acpi.c 16 KB

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