bus.c 17 KB

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