bus.c 18 KB

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