bus.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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/device.h>
  32. #include <linux/proc_fs.h>
  33. #include <linux/acpi.h>
  34. #include <linux/slab.h>
  35. #ifdef CONFIG_X86
  36. #include <asm/mpspec.h>
  37. #endif
  38. #include <linux/pci.h>
  39. #include <acpi/acpi_bus.h>
  40. #include <acpi/acpi_drivers.h>
  41. #include <acpi/apei.h>
  42. #include <linux/dmi.h>
  43. #include <linux/suspend.h>
  44. #include "internal.h"
  45. #define _COMPONENT ACPI_BUS_COMPONENT
  46. ACPI_MODULE_NAME("bus");
  47. struct acpi_device *acpi_root;
  48. struct proc_dir_entry *acpi_root_dir;
  49. EXPORT_SYMBOL(acpi_root_dir);
  50. #define STRUCT_TO_INT(s) (*((int*)&s))
  51. #ifdef CONFIG_X86
  52. static int set_copy_dsdt(const struct dmi_system_id *id)
  53. {
  54. printk(KERN_NOTICE "%s detected - "
  55. "force copy of DSDT to local memory\n", id->ident);
  56. acpi_gbl_copy_dsdt_locally = 1;
  57. return 0;
  58. }
  59. static struct dmi_system_id dsdt_dmi_table[] __initdata = {
  60. /*
  61. * Invoke DSDT corruption work-around on all Toshiba Satellite.
  62. * https://bugzilla.kernel.org/show_bug.cgi?id=14679
  63. */
  64. {
  65. .callback = set_copy_dsdt,
  66. .ident = "TOSHIBA Satellite",
  67. .matches = {
  68. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  69. DMI_MATCH(DMI_PRODUCT_NAME, "Satellite"),
  70. },
  71. },
  72. {}
  73. };
  74. #else
  75. static struct dmi_system_id dsdt_dmi_table[] __initdata = {
  76. {}
  77. };
  78. #endif
  79. /* --------------------------------------------------------------------------
  80. Device Management
  81. -------------------------------------------------------------------------- */
  82. acpi_status acpi_bus_get_status_handle(acpi_handle handle,
  83. unsigned long long *sta)
  84. {
  85. acpi_status status;
  86. status = acpi_evaluate_integer(handle, "_STA", NULL, sta);
  87. if (ACPI_SUCCESS(status))
  88. return AE_OK;
  89. if (status == AE_NOT_FOUND) {
  90. *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
  91. ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
  92. return AE_OK;
  93. }
  94. return status;
  95. }
  96. int acpi_bus_get_status(struct acpi_device *device)
  97. {
  98. acpi_status status;
  99. unsigned long long sta;
  100. status = acpi_bus_get_status_handle(device->handle, &sta);
  101. if (ACPI_FAILURE(status))
  102. return -ENODEV;
  103. STRUCT_TO_INT(device->status) = (int) sta;
  104. if (device->status.functional && !device->status.present) {
  105. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
  106. "functional but not present;\n",
  107. device->pnp.bus_id,
  108. (u32) STRUCT_TO_INT(device->status)));
  109. }
  110. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
  111. device->pnp.bus_id,
  112. (u32) STRUCT_TO_INT(device->status)));
  113. return 0;
  114. }
  115. EXPORT_SYMBOL(acpi_bus_get_status);
  116. void acpi_bus_private_data_handler(acpi_handle handle,
  117. void *context)
  118. {
  119. return;
  120. }
  121. EXPORT_SYMBOL(acpi_bus_private_data_handler);
  122. int acpi_bus_get_private_data(acpi_handle handle, void **data)
  123. {
  124. acpi_status status;
  125. if (!*data)
  126. return -EINVAL;
  127. status = acpi_get_data(handle, acpi_bus_private_data_handler, data);
  128. if (ACPI_FAILURE(status) || !*data) {
  129. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
  130. handle));
  131. return -ENODEV;
  132. }
  133. return 0;
  134. }
  135. EXPORT_SYMBOL(acpi_bus_get_private_data);
  136. static void acpi_print_osc_error(acpi_handle handle,
  137. struct acpi_osc_context *context, char *error)
  138. {
  139. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER};
  140. int i;
  141. if (ACPI_FAILURE(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer)))
  142. printk(KERN_DEBUG "%s\n", error);
  143. else {
  144. printk(KERN_DEBUG "%s:%s\n", (char *)buffer.pointer, error);
  145. kfree(buffer.pointer);
  146. }
  147. printk(KERN_DEBUG"_OSC request data:");
  148. for (i = 0; i < context->cap.length; i += sizeof(u32))
  149. printk("%x ", *((u32 *)(context->cap.pointer + i)));
  150. printk("\n");
  151. }
  152. static acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
  153. {
  154. int i;
  155. static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
  156. 24, 26, 28, 30, 32, 34};
  157. if (strlen(str) != 36)
  158. return AE_BAD_PARAMETER;
  159. for (i = 0; i < 36; i++) {
  160. if (i == 8 || i == 13 || i == 18 || i == 23) {
  161. if (str[i] != '-')
  162. return AE_BAD_PARAMETER;
  163. } else if (!isxdigit(str[i]))
  164. return AE_BAD_PARAMETER;
  165. }
  166. for (i = 0; i < 16; i++) {
  167. uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4;
  168. uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]);
  169. }
  170. return AE_OK;
  171. }
  172. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
  173. {
  174. acpi_status status;
  175. struct acpi_object_list input;
  176. union acpi_object in_params[4];
  177. union acpi_object *out_obj;
  178. u8 uuid[16];
  179. u32 errors;
  180. struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
  181. if (!context)
  182. return AE_ERROR;
  183. if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
  184. return AE_ERROR;
  185. context->ret.length = ACPI_ALLOCATE_BUFFER;
  186. context->ret.pointer = NULL;
  187. /* Setting up input parameters */
  188. input.count = 4;
  189. input.pointer = in_params;
  190. in_params[0].type = ACPI_TYPE_BUFFER;
  191. in_params[0].buffer.length = 16;
  192. in_params[0].buffer.pointer = uuid;
  193. in_params[1].type = ACPI_TYPE_INTEGER;
  194. in_params[1].integer.value = context->rev;
  195. in_params[2].type = ACPI_TYPE_INTEGER;
  196. in_params[2].integer.value = context->cap.length/sizeof(u32);
  197. in_params[3].type = ACPI_TYPE_BUFFER;
  198. in_params[3].buffer.length = context->cap.length;
  199. in_params[3].buffer.pointer = context->cap.pointer;
  200. status = acpi_evaluate_object(handle, "_OSC", &input, &output);
  201. if (ACPI_FAILURE(status))
  202. return status;
  203. if (!output.length)
  204. return AE_NULL_OBJECT;
  205. out_obj = output.pointer;
  206. if (out_obj->type != ACPI_TYPE_BUFFER
  207. || out_obj->buffer.length != context->cap.length) {
  208. acpi_print_osc_error(handle, context,
  209. "_OSC evaluation returned wrong type");
  210. status = AE_TYPE;
  211. goto out_kfree;
  212. }
  213. /* Need to ignore the bit0 in result code */
  214. errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
  215. if (errors) {
  216. if (errors & OSC_REQUEST_ERROR)
  217. acpi_print_osc_error(handle, context,
  218. "_OSC request failed");
  219. if (errors & OSC_INVALID_UUID_ERROR)
  220. acpi_print_osc_error(handle, context,
  221. "_OSC invalid UUID");
  222. if (errors & OSC_INVALID_REVISION_ERROR)
  223. acpi_print_osc_error(handle, context,
  224. "_OSC invalid revision");
  225. if (errors & OSC_CAPABILITIES_MASK_ERROR) {
  226. if (((u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
  227. & OSC_QUERY_ENABLE)
  228. goto out_success;
  229. status = AE_SUPPORT;
  230. goto out_kfree;
  231. }
  232. status = AE_ERROR;
  233. goto out_kfree;
  234. }
  235. out_success:
  236. context->ret.length = out_obj->buffer.length;
  237. context->ret.pointer = kmemdup(out_obj->buffer.pointer,
  238. context->ret.length, GFP_KERNEL);
  239. if (!context->ret.pointer) {
  240. status = AE_NO_MEMORY;
  241. goto out_kfree;
  242. }
  243. status = AE_OK;
  244. out_kfree:
  245. kfree(output.pointer);
  246. if (status != AE_OK)
  247. context->ret.pointer = NULL;
  248. return status;
  249. }
  250. EXPORT_SYMBOL(acpi_run_osc);
  251. bool osc_sb_apei_support_acked;
  252. static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
  253. static void acpi_bus_osc_support(void)
  254. {
  255. u32 capbuf[2];
  256. struct acpi_osc_context context = {
  257. .uuid_str = sb_uuid_str,
  258. .rev = 1,
  259. .cap.length = 8,
  260. .cap.pointer = capbuf,
  261. };
  262. acpi_handle handle;
  263. capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
  264. capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
  265. #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
  266. defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
  267. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
  268. #endif
  269. #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
  270. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
  271. #endif
  272. #ifdef ACPI_HOTPLUG_OST
  273. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_HOTPLUG_OST_SUPPORT;
  274. #endif
  275. if (!ghes_disable)
  276. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT;
  277. if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
  278. return;
  279. if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) {
  280. u32 *capbuf_ret = context.ret.pointer;
  281. if (context.ret.length > OSC_SUPPORT_TYPE)
  282. osc_sb_apei_support_acked =
  283. capbuf_ret[OSC_SUPPORT_TYPE] & OSC_SB_APEI_SUPPORT;
  284. kfree(context.ret.pointer);
  285. }
  286. /* do we need to check other returned cap? Sounds no */
  287. }
  288. /* --------------------------------------------------------------------------
  289. Notification Handling
  290. -------------------------------------------------------------------------- */
  291. static void acpi_bus_check_device(acpi_handle handle)
  292. {
  293. struct acpi_device *device;
  294. acpi_status status;
  295. struct acpi_device_status old_status;
  296. if (acpi_bus_get_device(handle, &device))
  297. return;
  298. if (!device)
  299. return;
  300. old_status = device->status;
  301. /*
  302. * Make sure this device's parent is present before we go about
  303. * messing with the device.
  304. */
  305. if (device->parent && !device->parent->status.present) {
  306. device->status = device->parent->status;
  307. return;
  308. }
  309. status = acpi_bus_get_status(device);
  310. if (ACPI_FAILURE(status))
  311. return;
  312. if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
  313. return;
  314. /*
  315. * Device Insertion/Removal
  316. */
  317. if ((device->status.present) && !(old_status.present)) {
  318. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
  319. /* TBD: Handle device insertion */
  320. } else if (!(device->status.present) && (old_status.present)) {
  321. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
  322. /* TBD: Handle device removal */
  323. }
  324. }
  325. static void acpi_bus_check_scope(acpi_handle handle)
  326. {
  327. /* Status Change? */
  328. acpi_bus_check_device(handle);
  329. /*
  330. * TBD: Enumerate child devices within this device's scope and
  331. * run acpi_bus_check_device()'s on them.
  332. */
  333. }
  334. /**
  335. * acpi_bus_notify
  336. * ---------------
  337. * Callback for all 'system-level' device notifications (values 0x00-0x7F).
  338. */
  339. static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
  340. {
  341. struct acpi_device *device = NULL;
  342. struct acpi_driver *driver;
  343. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n",
  344. type, handle));
  345. switch (type) {
  346. case ACPI_NOTIFY_BUS_CHECK:
  347. acpi_bus_check_scope(handle);
  348. /*
  349. * TBD: We'll need to outsource certain events to non-ACPI
  350. * drivers via the device manager (device.c).
  351. */
  352. break;
  353. case ACPI_NOTIFY_DEVICE_CHECK:
  354. acpi_bus_check_device(handle);
  355. /*
  356. * TBD: We'll need to outsource certain events to non-ACPI
  357. * drivers via the device manager (device.c).
  358. */
  359. break;
  360. case ACPI_NOTIFY_DEVICE_WAKE:
  361. /* TBD */
  362. break;
  363. case ACPI_NOTIFY_EJECT_REQUEST:
  364. /* TBD */
  365. break;
  366. case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
  367. /* TBD: Exactly what does 'light' mean? */
  368. break;
  369. case ACPI_NOTIFY_FREQUENCY_MISMATCH:
  370. /* TBD */
  371. break;
  372. case ACPI_NOTIFY_BUS_MODE_MISMATCH:
  373. /* TBD */
  374. break;
  375. case ACPI_NOTIFY_POWER_FAULT:
  376. /* TBD */
  377. break;
  378. default:
  379. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  380. "Received unknown/unsupported notification [%08x]\n",
  381. type));
  382. break;
  383. }
  384. acpi_bus_get_device(handle, &device);
  385. if (device) {
  386. driver = device->driver;
  387. if (driver && driver->ops.notify &&
  388. (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
  389. driver->ops.notify(device, type);
  390. }
  391. }
  392. /* --------------------------------------------------------------------------
  393. Initialization/Cleanup
  394. -------------------------------------------------------------------------- */
  395. static int __init acpi_bus_init_irq(void)
  396. {
  397. acpi_status status;
  398. char *message = NULL;
  399. /*
  400. * Let the system know what interrupt model we are using by
  401. * evaluating the \_PIC object, if exists.
  402. */
  403. switch (acpi_irq_model) {
  404. case ACPI_IRQ_MODEL_PIC:
  405. message = "PIC";
  406. break;
  407. case ACPI_IRQ_MODEL_IOAPIC:
  408. message = "IOAPIC";
  409. break;
  410. case ACPI_IRQ_MODEL_IOSAPIC:
  411. message = "IOSAPIC";
  412. break;
  413. case ACPI_IRQ_MODEL_PLATFORM:
  414. message = "platform specific model";
  415. break;
  416. default:
  417. printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
  418. return -ENODEV;
  419. }
  420. printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
  421. status = acpi_execute_simple_method(NULL, "\\_PIC", acpi_irq_model);
  422. if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
  423. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
  424. return -ENODEV;
  425. }
  426. return 0;
  427. }
  428. u8 acpi_gbl_permanent_mmap;
  429. void __init acpi_early_init(void)
  430. {
  431. acpi_status status;
  432. if (acpi_disabled)
  433. return;
  434. printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
  435. /* enable workarounds, unless strict ACPI spec. compliance */
  436. if (!acpi_strict)
  437. acpi_gbl_enable_interpreter_slack = TRUE;
  438. acpi_gbl_permanent_mmap = 1;
  439. /*
  440. * If the machine falls into the DMI check table,
  441. * DSDT will be copied to memory
  442. */
  443. dmi_check_system(dsdt_dmi_table);
  444. status = acpi_reallocate_root_table();
  445. if (ACPI_FAILURE(status)) {
  446. printk(KERN_ERR PREFIX
  447. "Unable to reallocate ACPI tables\n");
  448. goto error0;
  449. }
  450. status = acpi_initialize_subsystem();
  451. if (ACPI_FAILURE(status)) {
  452. printk(KERN_ERR PREFIX
  453. "Unable to initialize the ACPI Interpreter\n");
  454. goto error0;
  455. }
  456. status = acpi_load_tables();
  457. if (ACPI_FAILURE(status)) {
  458. printk(KERN_ERR PREFIX
  459. "Unable to load the System Description Tables\n");
  460. goto error0;
  461. }
  462. #ifdef CONFIG_X86
  463. if (!acpi_ioapic) {
  464. /* compatible (0) means level (3) */
  465. if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) {
  466. acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK;
  467. acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL;
  468. }
  469. /* Set PIC-mode SCI trigger type */
  470. acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt,
  471. (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  472. } else {
  473. /*
  474. * now that acpi_gbl_FADT is initialized,
  475. * update it with result from INT_SRC_OVR parsing
  476. */
  477. acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi;
  478. }
  479. #endif
  480. status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE);
  481. if (ACPI_FAILURE(status)) {
  482. printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
  483. goto error0;
  484. }
  485. return;
  486. error0:
  487. disable_acpi();
  488. return;
  489. }
  490. static int __init acpi_bus_init(void)
  491. {
  492. int result;
  493. acpi_status status;
  494. acpi_os_initialize1();
  495. status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
  496. if (ACPI_FAILURE(status)) {
  497. printk(KERN_ERR PREFIX
  498. "Unable to start the ACPI Interpreter\n");
  499. goto error1;
  500. }
  501. /*
  502. * ACPI 2.0 requires the EC driver to be loaded and work before
  503. * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
  504. * is called).
  505. *
  506. * This is accomplished by looking for the ECDT table, and getting
  507. * the EC parameters out of that.
  508. */
  509. status = acpi_ec_ecdt_probe();
  510. /* Ignore result. Not having an ECDT is not fatal. */
  511. status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
  512. if (ACPI_FAILURE(status)) {
  513. printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
  514. goto error1;
  515. }
  516. /*
  517. * _OSC method may exist in module level code,
  518. * so it must be run after ACPI_FULL_INITIALIZATION
  519. */
  520. acpi_bus_osc_support();
  521. /*
  522. * _PDC control method may load dynamic SSDT tables,
  523. * and we need to install the table handler before that.
  524. */
  525. acpi_sysfs_init();
  526. acpi_early_processor_set_pdc();
  527. /*
  528. * Maybe EC region is required at bus_scan/acpi_get_devices. So it
  529. * is necessary to enable it as early as possible.
  530. */
  531. acpi_boot_ec_enable();
  532. printk(KERN_INFO PREFIX "Interpreter enabled\n");
  533. /* Initialize sleep structures */
  534. acpi_sleep_init();
  535. /*
  536. * Get the system interrupt model and evaluate \_PIC.
  537. */
  538. result = acpi_bus_init_irq();
  539. if (result)
  540. goto error1;
  541. /*
  542. * Register the for all standard device notifications.
  543. */
  544. status =
  545. acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
  546. &acpi_bus_notify, NULL);
  547. if (ACPI_FAILURE(status)) {
  548. printk(KERN_ERR PREFIX
  549. "Unable to register for device notifications\n");
  550. goto error1;
  551. }
  552. /*
  553. * Create the top ACPI proc directory
  554. */
  555. acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
  556. return 0;
  557. /* Mimic structured exception handling */
  558. error1:
  559. acpi_terminate();
  560. return -ENODEV;
  561. }
  562. struct kobject *acpi_kobj;
  563. EXPORT_SYMBOL_GPL(acpi_kobj);
  564. static int __init acpi_init(void)
  565. {
  566. int result;
  567. if (acpi_disabled) {
  568. printk(KERN_INFO PREFIX "Interpreter disabled.\n");
  569. return -ENODEV;
  570. }
  571. acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
  572. if (!acpi_kobj) {
  573. printk(KERN_WARNING "%s: kset create error\n", __func__);
  574. acpi_kobj = NULL;
  575. }
  576. init_acpi_device_notify();
  577. result = acpi_bus_init();
  578. if (result) {
  579. disable_acpi();
  580. return result;
  581. }
  582. pci_mmcfg_late_init();
  583. acpi_scan_init();
  584. acpi_ec_init();
  585. acpi_debugfs_init();
  586. acpi_sleep_proc_init();
  587. acpi_wakeup_device_init();
  588. return 0;
  589. }
  590. subsys_initcall(acpi_init);