bus.c 17 KB

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