bus.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. * acpi_bus.c - ACPI Bus Driver ($Revision: 80 $)
  3. *
  4. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. *
  6. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  21. *
  22. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. */
  24. #include <linux/module.h>
  25. #include <linux/init.h>
  26. #include <linux/ioport.h>
  27. #include <linux/kernel.h>
  28. #include <linux/list.h>
  29. #include <linux/sched.h>
  30. #include <linux/pm.h>
  31. #include <linux/pm_legacy.h>
  32. #include <linux/device.h>
  33. #include <linux/proc_fs.h>
  34. #ifdef CONFIG_X86
  35. #include <asm/mpspec.h>
  36. #endif
  37. #include <acpi/acpi_bus.h>
  38. #include <acpi/acpi_drivers.h>
  39. #define _COMPONENT ACPI_BUS_COMPONENT
  40. ACPI_MODULE_NAME("acpi_bus")
  41. #ifdef CONFIG_X86
  42. extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger);
  43. #endif
  44. struct fadt_descriptor acpi_fadt;
  45. EXPORT_SYMBOL(acpi_fadt);
  46. struct acpi_device *acpi_root;
  47. struct proc_dir_entry *acpi_root_dir;
  48. EXPORT_SYMBOL(acpi_root_dir);
  49. #define STRUCT_TO_INT(s) (*((int*)&s))
  50. /* --------------------------------------------------------------------------
  51. Device Management
  52. -------------------------------------------------------------------------- */
  53. int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
  54. {
  55. acpi_status status = AE_OK;
  56. if (!device)
  57. return -EINVAL;
  58. /* TBD: Support fixed-feature devices */
  59. status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
  60. if (ACPI_FAILURE(status) || !*device) {
  61. ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle));
  62. return -ENODEV;
  63. }
  64. return 0;
  65. }
  66. EXPORT_SYMBOL(acpi_bus_get_device);
  67. int acpi_bus_get_status(struct acpi_device *device)
  68. {
  69. acpi_status status = AE_OK;
  70. unsigned long sta = 0;
  71. if (!device)
  72. return -EINVAL;
  73. /*
  74. * Evaluate _STA if present.
  75. */
  76. if (device->flags.dynamic_status) {
  77. status =
  78. acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
  79. if (ACPI_FAILURE(status))
  80. return -ENODEV;
  81. STRUCT_TO_INT(device->status) = (int)sta;
  82. }
  83. /*
  84. * Otherwise we assume the status of our parent (unless we don't
  85. * have one, in which case status is implied).
  86. */
  87. else if (device->parent)
  88. device->status = device->parent->status;
  89. else
  90. STRUCT_TO_INT(device->status) = 0x0F;
  91. if (device->status.functional && !device->status.present) {
  92. printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: "
  93. "functional but not present; setting present\n",
  94. device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status));
  95. device->status.present = 1;
  96. }
  97. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
  98. device->pnp.bus_id,
  99. (u32) STRUCT_TO_INT(device->status)));
  100. return 0;
  101. }
  102. EXPORT_SYMBOL(acpi_bus_get_status);
  103. /* --------------------------------------------------------------------------
  104. Power Management
  105. -------------------------------------------------------------------------- */
  106. int acpi_bus_get_power(acpi_handle handle, int *state)
  107. {
  108. int result = 0;
  109. acpi_status status = 0;
  110. struct acpi_device *device = NULL;
  111. unsigned long psc = 0;
  112. result = acpi_bus_get_device(handle, &device);
  113. if (result)
  114. return result;
  115. *state = ACPI_STATE_UNKNOWN;
  116. if (!device->flags.power_manageable) {
  117. /* TBD: Non-recursive algorithm for walking up hierarchy */
  118. if (device->parent)
  119. *state = device->parent->power.state;
  120. else
  121. *state = ACPI_STATE_D0;
  122. } else {
  123. /*
  124. * Get the device's power state either directly (via _PSC) or
  125. * indirectly (via power resources).
  126. */
  127. if (device->power.flags.explicit_get) {
  128. status = acpi_evaluate_integer(device->handle, "_PSC",
  129. NULL, &psc);
  130. if (ACPI_FAILURE(status))
  131. return -ENODEV;
  132. device->power.state = (int)psc;
  133. } else if (device->power.flags.power_resources) {
  134. result = acpi_power_get_inferred_state(device);
  135. if (result)
  136. return result;
  137. }
  138. *state = device->power.state;
  139. }
  140. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
  141. device->pnp.bus_id, device->power.state));
  142. return 0;
  143. }
  144. EXPORT_SYMBOL(acpi_bus_get_power);
  145. int acpi_bus_set_power(acpi_handle handle, int state)
  146. {
  147. int result = 0;
  148. acpi_status status = AE_OK;
  149. struct acpi_device *device = NULL;
  150. char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
  151. result = acpi_bus_get_device(handle, &device);
  152. if (result)
  153. return result;
  154. if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
  155. return -EINVAL;
  156. /* Make sure this is a valid target state */
  157. if (!device->flags.power_manageable) {
  158. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable",
  159. device->kobj.name));
  160. return -ENODEV;
  161. }
  162. /*
  163. * Get device's current power state if it's unknown
  164. * This means device power state isn't initialized or previous setting failed
  165. */
  166. if (!device->flags.force_power_state) {
  167. if (device->power.state == ACPI_STATE_UNKNOWN)
  168. acpi_bus_get_power(device->handle, &device->power.state);
  169. if (state == device->power.state) {
  170. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
  171. state));
  172. return 0;
  173. }
  174. }
  175. if (!device->power.states[state].flags.valid) {
  176. printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
  177. return -ENODEV;
  178. }
  179. if (device->parent && (state < device->parent->power.state)) {
  180. printk(KERN_WARNING PREFIX
  181. "Cannot set device to a higher-powered"
  182. " state than parent\n");
  183. return -ENODEV;
  184. }
  185. /*
  186. * Transition Power
  187. * ----------------
  188. * On transitions to a high-powered state we first apply power (via
  189. * power resources) then evalute _PSx. Conversly for transitions to
  190. * a lower-powered state.
  191. */
  192. if (state < device->power.state) {
  193. if (device->power.flags.power_resources) {
  194. result = acpi_power_transition(device, state);
  195. if (result)
  196. goto end;
  197. }
  198. if (device->power.states[state].flags.explicit_set) {
  199. status = acpi_evaluate_object(device->handle,
  200. object_name, NULL, NULL);
  201. if (ACPI_FAILURE(status)) {
  202. result = -ENODEV;
  203. goto end;
  204. }
  205. }
  206. } else {
  207. if (device->power.states[state].flags.explicit_set) {
  208. status = acpi_evaluate_object(device->handle,
  209. object_name, NULL, NULL);
  210. if (ACPI_FAILURE(status)) {
  211. result = -ENODEV;
  212. goto end;
  213. }
  214. }
  215. if (device->power.flags.power_resources) {
  216. result = acpi_power_transition(device, state);
  217. if (result)
  218. goto end;
  219. }
  220. }
  221. end:
  222. if (result)
  223. printk(KERN_WARNING PREFIX
  224. "Transitioning device [%s] to D%d\n",
  225. device->pnp.bus_id, state);
  226. else
  227. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  228. "Device [%s] transitioned to D%d\n",
  229. device->pnp.bus_id, state));
  230. return result;
  231. }
  232. EXPORT_SYMBOL(acpi_bus_set_power);
  233. /* --------------------------------------------------------------------------
  234. Event Management
  235. -------------------------------------------------------------------------- */
  236. static DEFINE_SPINLOCK(acpi_bus_event_lock);
  237. LIST_HEAD(acpi_bus_event_list);
  238. DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
  239. extern int event_is_open;
  240. int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
  241. {
  242. struct acpi_bus_event *event = NULL;
  243. unsigned long flags = 0;
  244. if (!device)
  245. return -EINVAL;
  246. /* drop event on the floor if no one's listening */
  247. if (!event_is_open)
  248. return 0;
  249. event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
  250. if (!event)
  251. return -ENOMEM;
  252. strcpy(event->device_class, device->pnp.device_class);
  253. strcpy(event->bus_id, device->pnp.bus_id);
  254. event->type = type;
  255. event->data = data;
  256. spin_lock_irqsave(&acpi_bus_event_lock, flags);
  257. list_add_tail(&event->node, &acpi_bus_event_list);
  258. spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
  259. wake_up_interruptible(&acpi_bus_event_queue);
  260. return 0;
  261. }
  262. EXPORT_SYMBOL(acpi_bus_generate_event);
  263. int acpi_bus_receive_event(struct acpi_bus_event *event)
  264. {
  265. unsigned long flags = 0;
  266. struct acpi_bus_event *entry = NULL;
  267. DECLARE_WAITQUEUE(wait, current);
  268. if (!event)
  269. return -EINVAL;
  270. if (list_empty(&acpi_bus_event_list)) {
  271. set_current_state(TASK_INTERRUPTIBLE);
  272. add_wait_queue(&acpi_bus_event_queue, &wait);
  273. if (list_empty(&acpi_bus_event_list))
  274. schedule();
  275. remove_wait_queue(&acpi_bus_event_queue, &wait);
  276. set_current_state(TASK_RUNNING);
  277. if (signal_pending(current))
  278. return -ERESTARTSYS;
  279. }
  280. spin_lock_irqsave(&acpi_bus_event_lock, flags);
  281. entry =
  282. list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
  283. if (entry)
  284. list_del(&entry->node);
  285. spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
  286. if (!entry)
  287. return -ENODEV;
  288. memcpy(event, entry, sizeof(struct acpi_bus_event));
  289. kfree(entry);
  290. return 0;
  291. }
  292. EXPORT_SYMBOL(acpi_bus_receive_event);
  293. /* --------------------------------------------------------------------------
  294. Notification Handling
  295. -------------------------------------------------------------------------- */
  296. static int
  297. acpi_bus_check_device(struct acpi_device *device, int *status_changed)
  298. {
  299. acpi_status status = 0;
  300. struct acpi_device_status old_status;
  301. if (!device)
  302. return -EINVAL;
  303. if (status_changed)
  304. *status_changed = 0;
  305. old_status = device->status;
  306. /*
  307. * Make sure this device's parent is present before we go about
  308. * messing with the device.
  309. */
  310. if (device->parent && !device->parent->status.present) {
  311. device->status = device->parent->status;
  312. if (STRUCT_TO_INT(old_status) != STRUCT_TO_INT(device->status)) {
  313. if (status_changed)
  314. *status_changed = 1;
  315. }
  316. return 0;
  317. }
  318. status = acpi_bus_get_status(device);
  319. if (ACPI_FAILURE(status))
  320. return -ENODEV;
  321. if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
  322. return 0;
  323. if (status_changed)
  324. *status_changed = 1;
  325. /*
  326. * Device Insertion/Removal
  327. */
  328. if ((device->status.present) && !(old_status.present)) {
  329. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
  330. /* TBD: Handle device insertion */
  331. } else if (!(device->status.present) && (old_status.present)) {
  332. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
  333. /* TBD: Handle device removal */
  334. }
  335. return 0;
  336. }
  337. static int acpi_bus_check_scope(struct acpi_device *device)
  338. {
  339. int result = 0;
  340. int status_changed = 0;
  341. if (!device)
  342. return -EINVAL;
  343. /* Status Change? */
  344. result = acpi_bus_check_device(device, &status_changed);
  345. if (result)
  346. return result;
  347. if (!status_changed)
  348. return 0;
  349. /*
  350. * TBD: Enumerate child devices within this device's scope and
  351. * run acpi_bus_check_device()'s on them.
  352. */
  353. return 0;
  354. }
  355. /**
  356. * acpi_bus_notify
  357. * ---------------
  358. * Callback for all 'system-level' device notifications (values 0x00-0x7F).
  359. */
  360. static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
  361. {
  362. int result = 0;
  363. struct acpi_device *device = NULL;
  364. if (acpi_bus_get_device(handle, &device))
  365. return;
  366. switch (type) {
  367. case ACPI_NOTIFY_BUS_CHECK:
  368. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  369. "Received BUS CHECK notification for device [%s]\n",
  370. device->pnp.bus_id));
  371. result = acpi_bus_check_scope(device);
  372. /*
  373. * TBD: We'll need to outsource certain events to non-ACPI
  374. * drivers via the device manager (device.c).
  375. */
  376. break;
  377. case ACPI_NOTIFY_DEVICE_CHECK:
  378. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  379. "Received DEVICE CHECK notification for device [%s]\n",
  380. device->pnp.bus_id));
  381. result = acpi_bus_check_device(device, NULL);
  382. /*
  383. * TBD: We'll need to outsource certain events to non-ACPI
  384. * drivers via the device manager (device.c).
  385. */
  386. break;
  387. case ACPI_NOTIFY_DEVICE_WAKE:
  388. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  389. "Received DEVICE WAKE notification for device [%s]\n",
  390. device->pnp.bus_id));
  391. /* TBD */
  392. break;
  393. case ACPI_NOTIFY_EJECT_REQUEST:
  394. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  395. "Received EJECT REQUEST notification for device [%s]\n",
  396. device->pnp.bus_id));
  397. /* TBD */
  398. break;
  399. case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
  400. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  401. "Received DEVICE CHECK LIGHT notification for device [%s]\n",
  402. device->pnp.bus_id));
  403. /* TBD: Exactly what does 'light' mean? */
  404. break;
  405. case ACPI_NOTIFY_FREQUENCY_MISMATCH:
  406. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  407. "Received FREQUENCY MISMATCH notification for device [%s]\n",
  408. device->pnp.bus_id));
  409. /* TBD */
  410. break;
  411. case ACPI_NOTIFY_BUS_MODE_MISMATCH:
  412. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  413. "Received BUS MODE MISMATCH notification for device [%s]\n",
  414. device->pnp.bus_id));
  415. /* TBD */
  416. break;
  417. case ACPI_NOTIFY_POWER_FAULT:
  418. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  419. "Received POWER FAULT notification for device [%s]\n",
  420. device->pnp.bus_id));
  421. /* TBD */
  422. break;
  423. default:
  424. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  425. "Received unknown/unsupported notification [%08x]\n",
  426. type));
  427. break;
  428. }
  429. return;
  430. }
  431. /* --------------------------------------------------------------------------
  432. Initialization/Cleanup
  433. -------------------------------------------------------------------------- */
  434. static int __init acpi_bus_init_irq(void)
  435. {
  436. acpi_status status = AE_OK;
  437. union acpi_object arg = { ACPI_TYPE_INTEGER };
  438. struct acpi_object_list arg_list = { 1, &arg };
  439. char *message = NULL;
  440. /*
  441. * Let the system know what interrupt model we are using by
  442. * evaluating the \_PIC object, if exists.
  443. */
  444. switch (acpi_irq_model) {
  445. case ACPI_IRQ_MODEL_PIC:
  446. message = "PIC";
  447. break;
  448. case ACPI_IRQ_MODEL_IOAPIC:
  449. message = "IOAPIC";
  450. break;
  451. case ACPI_IRQ_MODEL_IOSAPIC:
  452. message = "IOSAPIC";
  453. break;
  454. default:
  455. printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
  456. return -ENODEV;
  457. }
  458. printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
  459. arg.integer.value = acpi_irq_model;
  460. status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
  461. if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
  462. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
  463. return -ENODEV;
  464. }
  465. return 0;
  466. }
  467. void __init acpi_early_init(void)
  468. {
  469. acpi_status status = AE_OK;
  470. struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
  471. if (acpi_disabled)
  472. return;
  473. printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
  474. /* enable workarounds, unless strict ACPI spec. compliance */
  475. if (!acpi_strict)
  476. acpi_gbl_enable_interpreter_slack = TRUE;
  477. status = acpi_initialize_subsystem();
  478. if (ACPI_FAILURE(status)) {
  479. printk(KERN_ERR PREFIX
  480. "Unable to initialize the ACPI Interpreter\n");
  481. goto error0;
  482. }
  483. status = acpi_load_tables();
  484. if (ACPI_FAILURE(status)) {
  485. printk(KERN_ERR PREFIX
  486. "Unable to load the System Description Tables\n");
  487. goto error0;
  488. }
  489. /*
  490. * Get a separate copy of the FADT for use by other drivers.
  491. */
  492. status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &buffer);
  493. if (ACPI_FAILURE(status)) {
  494. printk(KERN_ERR PREFIX "Unable to get the FADT\n");
  495. goto error0;
  496. }
  497. #ifdef CONFIG_X86
  498. if (!acpi_ioapic) {
  499. extern acpi_interrupt_flags acpi_sci_flags;
  500. /* compatible (0) means level (3) */
  501. if (acpi_sci_flags.trigger == 0)
  502. acpi_sci_flags.trigger = 3;
  503. /* Set PIC-mode SCI trigger type */
  504. acpi_pic_sci_set_trigger(acpi_fadt.sci_int,
  505. acpi_sci_flags.trigger);
  506. } else {
  507. extern int acpi_sci_override_gsi;
  508. /*
  509. * now that acpi_fadt is initialized,
  510. * update it with result from INT_SRC_OVR parsing
  511. */
  512. acpi_fadt.sci_int = acpi_sci_override_gsi;
  513. }
  514. #endif
  515. status =
  516. acpi_enable_subsystem(~
  517. (ACPI_NO_HARDWARE_INIT |
  518. ACPI_NO_ACPI_ENABLE));
  519. if (ACPI_FAILURE(status)) {
  520. printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
  521. goto error0;
  522. }
  523. return;
  524. error0:
  525. disable_acpi();
  526. return;
  527. }
  528. static int __init acpi_bus_init(void)
  529. {
  530. int result = 0;
  531. acpi_status status = AE_OK;
  532. extern acpi_status acpi_os_initialize1(void);
  533. status = acpi_os_initialize1();
  534. status =
  535. acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
  536. if (ACPI_FAILURE(status)) {
  537. printk(KERN_ERR PREFIX
  538. "Unable to start the ACPI Interpreter\n");
  539. goto error1;
  540. }
  541. if (ACPI_FAILURE(status)) {
  542. printk(KERN_ERR PREFIX
  543. "Unable to initialize ACPI OS objects\n");
  544. goto error1;
  545. }
  546. #ifdef CONFIG_ACPI_EC
  547. /*
  548. * ACPI 2.0 requires the EC driver to be loaded and work before
  549. * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
  550. * is called).
  551. *
  552. * This is accomplished by looking for the ECDT table, and getting
  553. * the EC parameters out of that.
  554. */
  555. status = acpi_ec_ecdt_probe();
  556. /* Ignore result. Not having an ECDT is not fatal. */
  557. #endif
  558. status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
  559. if (ACPI_FAILURE(status)) {
  560. printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
  561. goto error1;
  562. }
  563. printk(KERN_INFO PREFIX "Interpreter enabled\n");
  564. /*
  565. * Get the system interrupt model and evaluate \_PIC.
  566. */
  567. result = acpi_bus_init_irq();
  568. if (result)
  569. goto error1;
  570. /*
  571. * Register the for all standard device notifications.
  572. */
  573. status =
  574. acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
  575. &acpi_bus_notify, NULL);
  576. if (ACPI_FAILURE(status)) {
  577. printk(KERN_ERR PREFIX
  578. "Unable to register for device notifications\n");
  579. goto error1;
  580. }
  581. /*
  582. * Create the top ACPI proc directory
  583. */
  584. acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
  585. return 0;
  586. /* Mimic structured exception handling */
  587. error1:
  588. acpi_terminate();
  589. return -ENODEV;
  590. }
  591. decl_subsys(acpi, NULL, NULL);
  592. static int __init acpi_init(void)
  593. {
  594. int result = 0;
  595. if (acpi_disabled) {
  596. printk(KERN_INFO PREFIX "Interpreter disabled.\n");
  597. return -ENODEV;
  598. }
  599. result = firmware_register(&acpi_subsys);
  600. if (result < 0)
  601. printk(KERN_WARNING "%s: firmware_register error: %d\n",
  602. __FUNCTION__, result);
  603. result = acpi_bus_init();
  604. if (!result) {
  605. #ifdef CONFIG_PM_LEGACY
  606. if (!PM_IS_ACTIVE())
  607. pm_active = 1;
  608. else {
  609. printk(KERN_INFO PREFIX
  610. "APM is already active, exiting\n");
  611. disable_acpi();
  612. result = -ENODEV;
  613. }
  614. #endif
  615. } else
  616. disable_acpi();
  617. return result;
  618. }
  619. subsys_initcall(acpi_init);