bus.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  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. #include <linux/workqueue.h>
  33. #include <linux/reboot.h>
  34. #include <linux/delay.h>
  35. #ifdef CONFIG_X86
  36. #include <asm/mpspec.h>
  37. #endif
  38. #include <linux/acpi_iort.h>
  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. if (acpi_device_always_present(device)) {
  106. acpi_set_device_status(device, ACPI_STA_DEFAULT);
  107. return 0;
  108. }
  109. status = acpi_bus_get_status_handle(device->handle, &sta);
  110. if (ACPI_FAILURE(status))
  111. return -ENODEV;
  112. acpi_set_device_status(device, sta);
  113. if (device->status.functional && !device->status.present) {
  114. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
  115. "functional but not present;\n",
  116. device->pnp.bus_id, (u32)sta));
  117. }
  118. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
  119. device->pnp.bus_id, (u32)sta));
  120. return 0;
  121. }
  122. EXPORT_SYMBOL(acpi_bus_get_status);
  123. void acpi_bus_private_data_handler(acpi_handle handle,
  124. void *context)
  125. {
  126. return;
  127. }
  128. EXPORT_SYMBOL(acpi_bus_private_data_handler);
  129. int acpi_bus_attach_private_data(acpi_handle handle, void *data)
  130. {
  131. acpi_status status;
  132. status = acpi_attach_data(handle,
  133. acpi_bus_private_data_handler, data);
  134. if (ACPI_FAILURE(status)) {
  135. acpi_handle_debug(handle, "Error attaching device data\n");
  136. return -ENODEV;
  137. }
  138. return 0;
  139. }
  140. EXPORT_SYMBOL_GPL(acpi_bus_attach_private_data);
  141. int acpi_bus_get_private_data(acpi_handle handle, void **data)
  142. {
  143. acpi_status status;
  144. if (!*data)
  145. return -EINVAL;
  146. status = acpi_get_data(handle, acpi_bus_private_data_handler, data);
  147. if (ACPI_FAILURE(status)) {
  148. acpi_handle_debug(handle, "No context for object\n");
  149. return -ENODEV;
  150. }
  151. return 0;
  152. }
  153. EXPORT_SYMBOL_GPL(acpi_bus_get_private_data);
  154. void acpi_bus_detach_private_data(acpi_handle handle)
  155. {
  156. acpi_detach_data(handle, acpi_bus_private_data_handler);
  157. }
  158. EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data);
  159. static void acpi_print_osc_error(acpi_handle handle,
  160. struct acpi_osc_context *context, char *error)
  161. {
  162. int i;
  163. acpi_handle_debug(handle, "(%s): %s\n", context->uuid_str, error);
  164. pr_debug("_OSC request data:");
  165. for (i = 0; i < context->cap.length; i += sizeof(u32))
  166. pr_debug(" %x", *((u32 *)(context->cap.pointer + i)));
  167. pr_debug("\n");
  168. }
  169. acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
  170. {
  171. int i;
  172. static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
  173. 24, 26, 28, 30, 32, 34};
  174. if (strlen(str) != 36)
  175. return AE_BAD_PARAMETER;
  176. for (i = 0; i < 36; i++) {
  177. if (i == 8 || i == 13 || i == 18 || i == 23) {
  178. if (str[i] != '-')
  179. return AE_BAD_PARAMETER;
  180. } else if (!isxdigit(str[i]))
  181. return AE_BAD_PARAMETER;
  182. }
  183. for (i = 0; i < 16; i++) {
  184. uuid[i] = hex_to_bin(str[opc_map_to_uuid[i]]) << 4;
  185. uuid[i] |= hex_to_bin(str[opc_map_to_uuid[i] + 1]);
  186. }
  187. return AE_OK;
  188. }
  189. EXPORT_SYMBOL_GPL(acpi_str_to_uuid);
  190. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
  191. {
  192. acpi_status status;
  193. struct acpi_object_list input;
  194. union acpi_object in_params[4];
  195. union acpi_object *out_obj;
  196. u8 uuid[16];
  197. u32 errors;
  198. struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
  199. if (!context)
  200. return AE_ERROR;
  201. if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
  202. return AE_ERROR;
  203. context->ret.length = ACPI_ALLOCATE_BUFFER;
  204. context->ret.pointer = NULL;
  205. /* Setting up input parameters */
  206. input.count = 4;
  207. input.pointer = in_params;
  208. in_params[0].type = ACPI_TYPE_BUFFER;
  209. in_params[0].buffer.length = 16;
  210. in_params[0].buffer.pointer = uuid;
  211. in_params[1].type = ACPI_TYPE_INTEGER;
  212. in_params[1].integer.value = context->rev;
  213. in_params[2].type = ACPI_TYPE_INTEGER;
  214. in_params[2].integer.value = context->cap.length/sizeof(u32);
  215. in_params[3].type = ACPI_TYPE_BUFFER;
  216. in_params[3].buffer.length = context->cap.length;
  217. in_params[3].buffer.pointer = context->cap.pointer;
  218. status = acpi_evaluate_object(handle, "_OSC", &input, &output);
  219. if (ACPI_FAILURE(status))
  220. return status;
  221. if (!output.length)
  222. return AE_NULL_OBJECT;
  223. out_obj = output.pointer;
  224. if (out_obj->type != ACPI_TYPE_BUFFER
  225. || out_obj->buffer.length != context->cap.length) {
  226. acpi_print_osc_error(handle, context,
  227. "_OSC evaluation returned wrong type");
  228. status = AE_TYPE;
  229. goto out_kfree;
  230. }
  231. /* Need to ignore the bit0 in result code */
  232. errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
  233. if (errors) {
  234. if (errors & OSC_REQUEST_ERROR)
  235. acpi_print_osc_error(handle, context,
  236. "_OSC request failed");
  237. if (errors & OSC_INVALID_UUID_ERROR)
  238. acpi_print_osc_error(handle, context,
  239. "_OSC invalid UUID");
  240. if (errors & OSC_INVALID_REVISION_ERROR)
  241. acpi_print_osc_error(handle, context,
  242. "_OSC invalid revision");
  243. if (errors & OSC_CAPABILITIES_MASK_ERROR) {
  244. if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD]
  245. & OSC_QUERY_ENABLE)
  246. goto out_success;
  247. status = AE_SUPPORT;
  248. goto out_kfree;
  249. }
  250. status = AE_ERROR;
  251. goto out_kfree;
  252. }
  253. out_success:
  254. context->ret.length = out_obj->buffer.length;
  255. context->ret.pointer = kmemdup(out_obj->buffer.pointer,
  256. context->ret.length, GFP_KERNEL);
  257. if (!context->ret.pointer) {
  258. status = AE_NO_MEMORY;
  259. goto out_kfree;
  260. }
  261. status = AE_OK;
  262. out_kfree:
  263. kfree(output.pointer);
  264. if (status != AE_OK)
  265. context->ret.pointer = NULL;
  266. return status;
  267. }
  268. EXPORT_SYMBOL(acpi_run_osc);
  269. bool osc_sb_apei_support_acked;
  270. /*
  271. * ACPI 6.0 Section 8.4.4.2 Idle State Coordination
  272. * OSPM supports platform coordinated low power idle(LPI) states
  273. */
  274. bool osc_pc_lpi_support_confirmed;
  275. EXPORT_SYMBOL_GPL(osc_pc_lpi_support_confirmed);
  276. static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
  277. static void acpi_bus_osc_support(void)
  278. {
  279. u32 capbuf[2];
  280. struct acpi_osc_context context = {
  281. .uuid_str = sb_uuid_str,
  282. .rev = 1,
  283. .cap.length = 8,
  284. .cap.pointer = capbuf,
  285. };
  286. acpi_handle handle;
  287. capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
  288. capbuf[OSC_SUPPORT_DWORD] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
  289. if (IS_ENABLED(CONFIG_ACPI_PROCESSOR_AGGREGATOR))
  290. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PAD_SUPPORT;
  291. if (IS_ENABLED(CONFIG_ACPI_PROCESSOR))
  292. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT;
  293. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT;
  294. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PCLPI_SUPPORT;
  295. #ifdef CONFIG_X86
  296. if (boot_cpu_has(X86_FEATURE_HWP)) {
  297. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_SUPPORT;
  298. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPCV2_SUPPORT;
  299. }
  300. #endif
  301. if (IS_ENABLED(CONFIG_SCHED_MC_PRIO))
  302. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT;
  303. if (!ghes_disable)
  304. capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT;
  305. if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
  306. return;
  307. if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) {
  308. u32 *capbuf_ret = context.ret.pointer;
  309. if (context.ret.length > OSC_SUPPORT_DWORD) {
  310. osc_sb_apei_support_acked =
  311. capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
  312. osc_pc_lpi_support_confirmed =
  313. capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
  314. }
  315. kfree(context.ret.pointer);
  316. }
  317. /* do we need to check other returned cap? Sounds no */
  318. }
  319. /* --------------------------------------------------------------------------
  320. Notification Handling
  321. -------------------------------------------------------------------------- */
  322. /**
  323. * acpi_bus_notify
  324. * ---------------
  325. * Callback for all 'system-level' device notifications (values 0x00-0x7F).
  326. */
  327. static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
  328. {
  329. struct acpi_device *adev;
  330. struct acpi_driver *driver;
  331. u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
  332. bool hotplug_event = false;
  333. switch (type) {
  334. case ACPI_NOTIFY_BUS_CHECK:
  335. acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n");
  336. hotplug_event = true;
  337. break;
  338. case ACPI_NOTIFY_DEVICE_CHECK:
  339. acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
  340. hotplug_event = true;
  341. break;
  342. case ACPI_NOTIFY_DEVICE_WAKE:
  343. acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_WAKE event\n");
  344. break;
  345. case ACPI_NOTIFY_EJECT_REQUEST:
  346. acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
  347. hotplug_event = true;
  348. break;
  349. case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
  350. acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK_LIGHT event\n");
  351. /* TBD: Exactly what does 'light' mean? */
  352. break;
  353. case ACPI_NOTIFY_FREQUENCY_MISMATCH:
  354. acpi_handle_err(handle, "Device cannot be configured due "
  355. "to a frequency mismatch\n");
  356. break;
  357. case ACPI_NOTIFY_BUS_MODE_MISMATCH:
  358. acpi_handle_err(handle, "Device cannot be configured due "
  359. "to a bus mode mismatch\n");
  360. break;
  361. case ACPI_NOTIFY_POWER_FAULT:
  362. acpi_handle_err(handle, "Device has suffered a power fault\n");
  363. break;
  364. default:
  365. acpi_handle_debug(handle, "Unknown event type 0x%x\n", type);
  366. break;
  367. }
  368. adev = acpi_bus_get_acpi_device(handle);
  369. if (!adev)
  370. goto err;
  371. driver = adev->driver;
  372. if (driver && driver->ops.notify &&
  373. (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
  374. driver->ops.notify(adev, type);
  375. if (hotplug_event && ACPI_SUCCESS(acpi_hotplug_schedule(adev, type)))
  376. return;
  377. acpi_bus_put_acpi_device(adev);
  378. return;
  379. err:
  380. acpi_evaluate_ost(handle, type, ost_code, NULL);
  381. }
  382. static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
  383. {
  384. struct acpi_device *device = data;
  385. device->driver->ops.notify(device, event);
  386. }
  387. static void acpi_device_notify_fixed(void *data)
  388. {
  389. struct acpi_device *device = data;
  390. /* Fixed hardware devices have no handles */
  391. acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
  392. }
  393. static u32 acpi_device_fixed_event(void *data)
  394. {
  395. acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
  396. return ACPI_INTERRUPT_HANDLED;
  397. }
  398. static int acpi_device_install_notify_handler(struct acpi_device *device)
  399. {
  400. acpi_status status;
  401. if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
  402. status =
  403. acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
  404. acpi_device_fixed_event,
  405. device);
  406. else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
  407. status =
  408. acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
  409. acpi_device_fixed_event,
  410. device);
  411. else
  412. status = acpi_install_notify_handler(device->handle,
  413. ACPI_DEVICE_NOTIFY,
  414. acpi_device_notify,
  415. device);
  416. if (ACPI_FAILURE(status))
  417. return -EINVAL;
  418. return 0;
  419. }
  420. static void acpi_device_remove_notify_handler(struct acpi_device *device)
  421. {
  422. if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
  423. acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
  424. acpi_device_fixed_event);
  425. else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
  426. acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
  427. acpi_device_fixed_event);
  428. else
  429. acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
  430. acpi_device_notify);
  431. }
  432. /* Handle events targeting \_SB device (at present only graceful shutdown) */
  433. #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
  434. #define ACPI_SB_INDICATE_INTERVAL 10000
  435. static void sb_notify_work(struct work_struct *dummy)
  436. {
  437. acpi_handle sb_handle;
  438. orderly_poweroff(true);
  439. /*
  440. * After initiating graceful shutdown, the ACPI spec requires OSPM
  441. * to evaluate _OST method once every 10seconds to indicate that
  442. * the shutdown is in progress
  443. */
  444. acpi_get_handle(NULL, "\\_SB", &sb_handle);
  445. while (1) {
  446. pr_info("Graceful shutdown in progress.\n");
  447. acpi_evaluate_ost(sb_handle, ACPI_OST_EC_OSPM_SHUTDOWN,
  448. ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS, NULL);
  449. msleep(ACPI_SB_INDICATE_INTERVAL);
  450. }
  451. }
  452. static void acpi_sb_notify(acpi_handle handle, u32 event, void *data)
  453. {
  454. static DECLARE_WORK(acpi_sb_work, sb_notify_work);
  455. if (event == ACPI_SB_NOTIFY_SHUTDOWN_REQUEST) {
  456. if (!work_busy(&acpi_sb_work))
  457. schedule_work(&acpi_sb_work);
  458. } else
  459. pr_warn("event %x is not supported by \\_SB device\n", event);
  460. }
  461. static int __init acpi_setup_sb_notify_handler(void)
  462. {
  463. acpi_handle sb_handle;
  464. if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &sb_handle)))
  465. return -ENXIO;
  466. if (ACPI_FAILURE(acpi_install_notify_handler(sb_handle, ACPI_DEVICE_NOTIFY,
  467. acpi_sb_notify, NULL)))
  468. return -EINVAL;
  469. return 0;
  470. }
  471. /* --------------------------------------------------------------------------
  472. Device Matching
  473. -------------------------------------------------------------------------- */
  474. /**
  475. * acpi_get_first_physical_node - Get first physical node of an ACPI device
  476. * @adev: ACPI device in question
  477. *
  478. * Return: First physical node of ACPI device @adev
  479. */
  480. struct device *acpi_get_first_physical_node(struct acpi_device *adev)
  481. {
  482. struct mutex *physical_node_lock = &adev->physical_node_lock;
  483. struct device *phys_dev;
  484. mutex_lock(physical_node_lock);
  485. if (list_empty(&adev->physical_node_list)) {
  486. phys_dev = NULL;
  487. } else {
  488. const struct acpi_device_physical_node *node;
  489. node = list_first_entry(&adev->physical_node_list,
  490. struct acpi_device_physical_node, node);
  491. phys_dev = node->dev;
  492. }
  493. mutex_unlock(physical_node_lock);
  494. return phys_dev;
  495. }
  496. static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev,
  497. const struct device *dev)
  498. {
  499. const struct device *phys_dev = acpi_get_first_physical_node(adev);
  500. return phys_dev && phys_dev == dev ? adev : NULL;
  501. }
  502. /**
  503. * acpi_device_is_first_physical_node - Is given dev first physical node
  504. * @adev: ACPI companion device
  505. * @dev: Physical device to check
  506. *
  507. * Function checks if given @dev is the first physical devices attached to
  508. * the ACPI companion device. This distinction is needed in some cases
  509. * where the same companion device is shared between many physical devices.
  510. *
  511. * Note that the caller have to provide valid @adev pointer.
  512. */
  513. bool acpi_device_is_first_physical_node(struct acpi_device *adev,
  514. const struct device *dev)
  515. {
  516. return !!acpi_primary_dev_companion(adev, dev);
  517. }
  518. /*
  519. * acpi_companion_match() - Can we match via ACPI companion device
  520. * @dev: Device in question
  521. *
  522. * Check if the given device has an ACPI companion and if that companion has
  523. * a valid list of PNP IDs, and if the device is the first (primary) physical
  524. * device associated with it. Return the companion pointer if that's the case
  525. * or NULL otherwise.
  526. *
  527. * If multiple physical devices are attached to a single ACPI companion, we need
  528. * to be careful. The usage scenario for this kind of relationship is that all
  529. * of the physical devices in question use resources provided by the ACPI
  530. * companion. A typical case is an MFD device where all the sub-devices share
  531. * the parent's ACPI companion. In such cases we can only allow the primary
  532. * (first) physical device to be matched with the help of the companion's PNP
  533. * IDs.
  534. *
  535. * Additional physical devices sharing the ACPI companion can still use
  536. * resources available from it but they will be matched normally using functions
  537. * provided by their bus types (and analogously for their modalias).
  538. */
  539. struct acpi_device *acpi_companion_match(const struct device *dev)
  540. {
  541. struct acpi_device *adev;
  542. adev = ACPI_COMPANION(dev);
  543. if (!adev)
  544. return NULL;
  545. if (list_empty(&adev->pnp.ids))
  546. return NULL;
  547. return acpi_primary_dev_companion(adev, dev);
  548. }
  549. /**
  550. * acpi_of_match_device - Match device object using the "compatible" property.
  551. * @adev: ACPI device object to match.
  552. * @of_match_table: List of device IDs to match against.
  553. *
  554. * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of
  555. * identifiers and a _DSD object with the "compatible" property, use that
  556. * property to match against the given list of identifiers.
  557. */
  558. static bool acpi_of_match_device(struct acpi_device *adev,
  559. const struct of_device_id *of_match_table)
  560. {
  561. const union acpi_object *of_compatible, *obj;
  562. int i, nval;
  563. if (!adev)
  564. return false;
  565. of_compatible = adev->data.of_compatible;
  566. if (!of_match_table || !of_compatible)
  567. return false;
  568. if (of_compatible->type == ACPI_TYPE_PACKAGE) {
  569. nval = of_compatible->package.count;
  570. obj = of_compatible->package.elements;
  571. } else { /* Must be ACPI_TYPE_STRING. */
  572. nval = 1;
  573. obj = of_compatible;
  574. }
  575. /* Now we can look for the driver DT compatible strings */
  576. for (i = 0; i < nval; i++, obj++) {
  577. const struct of_device_id *id;
  578. for (id = of_match_table; id->compatible[0]; id++)
  579. if (!strcasecmp(obj->string.pointer, id->compatible))
  580. return true;
  581. }
  582. return false;
  583. }
  584. static bool acpi_of_modalias(struct acpi_device *adev,
  585. char *modalias, size_t len)
  586. {
  587. const union acpi_object *of_compatible;
  588. const union acpi_object *obj;
  589. const char *str, *chr;
  590. of_compatible = adev->data.of_compatible;
  591. if (!of_compatible)
  592. return false;
  593. if (of_compatible->type == ACPI_TYPE_PACKAGE)
  594. obj = of_compatible->package.elements;
  595. else /* Must be ACPI_TYPE_STRING. */
  596. obj = of_compatible;
  597. str = obj->string.pointer;
  598. chr = strchr(str, ',');
  599. strlcpy(modalias, chr ? chr + 1 : str, len);
  600. return true;
  601. }
  602. /**
  603. * acpi_set_modalias - Set modalias using "compatible" property or supplied ID
  604. * @adev: ACPI device object to match
  605. * @default_id: ID string to use as default if no compatible string found
  606. * @modalias: Pointer to buffer that modalias value will be copied into
  607. * @len: Length of modalias buffer
  608. *
  609. * This is a counterpart of of_modalias_node() for struct acpi_device objects.
  610. * If there is a compatible string for @adev, it will be copied to @modalias
  611. * with the vendor prefix stripped; otherwise, @default_id will be used.
  612. */
  613. void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
  614. char *modalias, size_t len)
  615. {
  616. if (!acpi_of_modalias(adev, modalias, len))
  617. strlcpy(modalias, default_id, len);
  618. }
  619. EXPORT_SYMBOL_GPL(acpi_set_modalias);
  620. static bool __acpi_match_device_cls(const struct acpi_device_id *id,
  621. struct acpi_hardware_id *hwid)
  622. {
  623. int i, msk, byte_shift;
  624. char buf[3];
  625. if (!id->cls)
  626. return false;
  627. /* Apply class-code bitmask, before checking each class-code byte */
  628. for (i = 1; i <= 3; i++) {
  629. byte_shift = 8 * (3 - i);
  630. msk = (id->cls_msk >> byte_shift) & 0xFF;
  631. if (!msk)
  632. continue;
  633. sprintf(buf, "%02x", (id->cls >> byte_shift) & msk);
  634. if (strncmp(buf, &hwid->id[(i - 1) * 2], 2))
  635. return false;
  636. }
  637. return true;
  638. }
  639. static const struct acpi_device_id *__acpi_match_device(
  640. struct acpi_device *device,
  641. const struct acpi_device_id *ids,
  642. const struct of_device_id *of_ids)
  643. {
  644. const struct acpi_device_id *id;
  645. struct acpi_hardware_id *hwid;
  646. /*
  647. * If the device is not present, it is unnecessary to load device
  648. * driver for it.
  649. */
  650. if (!device || !device->status.present)
  651. return NULL;
  652. list_for_each_entry(hwid, &device->pnp.ids, list) {
  653. /* First, check the ACPI/PNP IDs provided by the caller. */
  654. for (id = ids; id->id[0] || id->cls; id++) {
  655. if (id->id[0] && !strcmp((char *) id->id, hwid->id))
  656. return id;
  657. else if (id->cls && __acpi_match_device_cls(id, hwid))
  658. return id;
  659. }
  660. /*
  661. * Next, check ACPI_DT_NAMESPACE_HID and try to match the
  662. * "compatible" property if found.
  663. *
  664. * The id returned by the below is not valid, but the only
  665. * caller passing non-NULL of_ids here is only interested in
  666. * whether or not the return value is NULL.
  667. */
  668. if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id)
  669. && acpi_of_match_device(device, of_ids))
  670. return id;
  671. }
  672. return NULL;
  673. }
  674. /**
  675. * acpi_match_device - Match a struct device against a given list of ACPI IDs
  676. * @ids: Array of struct acpi_device_id object to match against.
  677. * @dev: The device structure to match.
  678. *
  679. * Check if @dev has a valid ACPI handle and if there is a struct acpi_device
  680. * object for that handle and use that object to match against a given list of
  681. * device IDs.
  682. *
  683. * Return a pointer to the first matching ID on success or %NULL on failure.
  684. */
  685. const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
  686. const struct device *dev)
  687. {
  688. return __acpi_match_device(acpi_companion_match(dev), ids, NULL);
  689. }
  690. EXPORT_SYMBOL_GPL(acpi_match_device);
  691. int acpi_match_device_ids(struct acpi_device *device,
  692. const struct acpi_device_id *ids)
  693. {
  694. return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
  695. }
  696. EXPORT_SYMBOL(acpi_match_device_ids);
  697. bool acpi_driver_match_device(struct device *dev,
  698. const struct device_driver *drv)
  699. {
  700. if (!drv->acpi_match_table)
  701. return acpi_of_match_device(ACPI_COMPANION(dev),
  702. drv->of_match_table);
  703. return !!__acpi_match_device(acpi_companion_match(dev),
  704. drv->acpi_match_table, drv->of_match_table);
  705. }
  706. EXPORT_SYMBOL_GPL(acpi_driver_match_device);
  707. /* --------------------------------------------------------------------------
  708. ACPI Driver Management
  709. -------------------------------------------------------------------------- */
  710. /**
  711. * acpi_bus_register_driver - register a driver with the ACPI bus
  712. * @driver: driver being registered
  713. *
  714. * Registers a driver with the ACPI bus. Searches the namespace for all
  715. * devices that match the driver's criteria and binds. Returns zero for
  716. * success or a negative error status for failure.
  717. */
  718. int acpi_bus_register_driver(struct acpi_driver *driver)
  719. {
  720. int ret;
  721. if (acpi_disabled)
  722. return -ENODEV;
  723. driver->drv.name = driver->name;
  724. driver->drv.bus = &acpi_bus_type;
  725. driver->drv.owner = driver->owner;
  726. ret = driver_register(&driver->drv);
  727. return ret;
  728. }
  729. EXPORT_SYMBOL(acpi_bus_register_driver);
  730. /**
  731. * acpi_bus_unregister_driver - unregisters a driver with the ACPI bus
  732. * @driver: driver to unregister
  733. *
  734. * Unregisters a driver with the ACPI bus. Searches the namespace for all
  735. * devices that match the driver's criteria and unbinds.
  736. */
  737. void acpi_bus_unregister_driver(struct acpi_driver *driver)
  738. {
  739. driver_unregister(&driver->drv);
  740. }
  741. EXPORT_SYMBOL(acpi_bus_unregister_driver);
  742. /* --------------------------------------------------------------------------
  743. ACPI Bus operations
  744. -------------------------------------------------------------------------- */
  745. static int acpi_bus_match(struct device *dev, struct device_driver *drv)
  746. {
  747. struct acpi_device *acpi_dev = to_acpi_device(dev);
  748. struct acpi_driver *acpi_drv = to_acpi_driver(drv);
  749. return acpi_dev->flags.match_driver
  750. && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
  751. }
  752. static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
  753. {
  754. return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
  755. }
  756. static int acpi_device_probe(struct device *dev)
  757. {
  758. struct acpi_device *acpi_dev = to_acpi_device(dev);
  759. struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
  760. int ret;
  761. if (acpi_dev->handler && !acpi_is_pnp_device(acpi_dev))
  762. return -EINVAL;
  763. if (!acpi_drv->ops.add)
  764. return -ENOSYS;
  765. ret = acpi_drv->ops.add(acpi_dev);
  766. if (ret)
  767. return ret;
  768. acpi_dev->driver = acpi_drv;
  769. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  770. "Driver [%s] successfully bound to device [%s]\n",
  771. acpi_drv->name, acpi_dev->pnp.bus_id));
  772. if (acpi_drv->ops.notify) {
  773. ret = acpi_device_install_notify_handler(acpi_dev);
  774. if (ret) {
  775. if (acpi_drv->ops.remove)
  776. acpi_drv->ops.remove(acpi_dev);
  777. acpi_dev->driver = NULL;
  778. acpi_dev->driver_data = NULL;
  779. return ret;
  780. }
  781. }
  782. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
  783. acpi_drv->name, acpi_dev->pnp.bus_id));
  784. get_device(dev);
  785. return 0;
  786. }
  787. static int acpi_device_remove(struct device * dev)
  788. {
  789. struct acpi_device *acpi_dev = to_acpi_device(dev);
  790. struct acpi_driver *acpi_drv = acpi_dev->driver;
  791. if (acpi_drv) {
  792. if (acpi_drv->ops.notify)
  793. acpi_device_remove_notify_handler(acpi_dev);
  794. if (acpi_drv->ops.remove)
  795. acpi_drv->ops.remove(acpi_dev);
  796. }
  797. acpi_dev->driver = NULL;
  798. acpi_dev->driver_data = NULL;
  799. put_device(dev);
  800. return 0;
  801. }
  802. struct bus_type acpi_bus_type = {
  803. .name = "acpi",
  804. .match = acpi_bus_match,
  805. .probe = acpi_device_probe,
  806. .remove = acpi_device_remove,
  807. .uevent = acpi_device_uevent,
  808. };
  809. /* --------------------------------------------------------------------------
  810. Initialization/Cleanup
  811. -------------------------------------------------------------------------- */
  812. static int __init acpi_bus_init_irq(void)
  813. {
  814. acpi_status status;
  815. char *message = NULL;
  816. /*
  817. * Let the system know what interrupt model we are using by
  818. * evaluating the \_PIC object, if exists.
  819. */
  820. switch (acpi_irq_model) {
  821. case ACPI_IRQ_MODEL_PIC:
  822. message = "PIC";
  823. break;
  824. case ACPI_IRQ_MODEL_IOAPIC:
  825. message = "IOAPIC";
  826. break;
  827. case ACPI_IRQ_MODEL_IOSAPIC:
  828. message = "IOSAPIC";
  829. break;
  830. case ACPI_IRQ_MODEL_GIC:
  831. message = "GIC";
  832. break;
  833. case ACPI_IRQ_MODEL_PLATFORM:
  834. message = "platform specific model";
  835. break;
  836. default:
  837. printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
  838. return -ENODEV;
  839. }
  840. printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
  841. status = acpi_execute_simple_method(NULL, "\\_PIC", acpi_irq_model);
  842. if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
  843. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
  844. return -ENODEV;
  845. }
  846. return 0;
  847. }
  848. /**
  849. * acpi_early_init - Initialize ACPICA and populate the ACPI namespace.
  850. *
  851. * The ACPI tables are accessible after this, but the handling of events has not
  852. * been initialized and the global lock is not available yet, so AML should not
  853. * be executed at this point.
  854. *
  855. * Doing this before switching the EFI runtime services to virtual mode allows
  856. * the EfiBootServices memory to be freed slightly earlier on boot.
  857. */
  858. void __init acpi_early_init(void)
  859. {
  860. acpi_status status;
  861. if (acpi_disabled)
  862. return;
  863. printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
  864. /* It's safe to verify table checksums during late stage */
  865. acpi_gbl_verify_table_checksum = TRUE;
  866. /* enable workarounds, unless strict ACPI spec. compliance */
  867. if (!acpi_strict)
  868. acpi_gbl_enable_interpreter_slack = TRUE;
  869. acpi_permanent_mmap = true;
  870. /*
  871. * If the machine falls into the DMI check table,
  872. * DSDT will be copied to memory
  873. */
  874. dmi_check_system(dsdt_dmi_table);
  875. status = acpi_reallocate_root_table();
  876. if (ACPI_FAILURE(status)) {
  877. printk(KERN_ERR PREFIX
  878. "Unable to reallocate ACPI tables\n");
  879. goto error0;
  880. }
  881. status = acpi_initialize_subsystem();
  882. if (ACPI_FAILURE(status)) {
  883. printk(KERN_ERR PREFIX
  884. "Unable to initialize the ACPI Interpreter\n");
  885. goto error0;
  886. }
  887. if (!acpi_gbl_parse_table_as_term_list &&
  888. acpi_gbl_group_module_level_code) {
  889. status = acpi_load_tables();
  890. if (ACPI_FAILURE(status)) {
  891. printk(KERN_ERR PREFIX
  892. "Unable to load the System Description Tables\n");
  893. goto error0;
  894. }
  895. }
  896. #ifdef CONFIG_X86
  897. if (!acpi_ioapic) {
  898. /* compatible (0) means level (3) */
  899. if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) {
  900. acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK;
  901. acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL;
  902. }
  903. /* Set PIC-mode SCI trigger type */
  904. acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt,
  905. (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  906. } else {
  907. /*
  908. * now that acpi_gbl_FADT is initialized,
  909. * update it with result from INT_SRC_OVR parsing
  910. */
  911. acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi;
  912. }
  913. #endif
  914. return;
  915. error0:
  916. disable_acpi();
  917. }
  918. /**
  919. * acpi_subsystem_init - Finalize the early initialization of ACPI.
  920. *
  921. * Switch over the platform to the ACPI mode (if possible).
  922. *
  923. * Doing this too early is generally unsafe, but at the same time it needs to be
  924. * done before all things that really depend on ACPI. The right spot appears to
  925. * be before finalizing the EFI initialization.
  926. */
  927. void __init acpi_subsystem_init(void)
  928. {
  929. acpi_status status;
  930. if (acpi_disabled)
  931. return;
  932. status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE);
  933. if (ACPI_FAILURE(status)) {
  934. printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
  935. disable_acpi();
  936. } else {
  937. /*
  938. * If the system is using ACPI then we can be reasonably
  939. * confident that any regulators are managed by the firmware
  940. * so tell the regulator core it has everything it needs to
  941. * know.
  942. */
  943. regulator_has_full_constraints();
  944. }
  945. }
  946. static acpi_status acpi_bus_table_handler(u32 event, void *table, void *context)
  947. {
  948. acpi_scan_table_handler(event, table, context);
  949. return acpi_sysfs_table_handler(event, table, context);
  950. }
  951. static int __init acpi_bus_init(void)
  952. {
  953. int result;
  954. acpi_status status;
  955. acpi_os_initialize1();
  956. /*
  957. * ACPI 2.0 requires the EC driver to be loaded and work before
  958. * the EC device is found in the namespace (i.e. before
  959. * acpi_load_tables() is called).
  960. *
  961. * This is accomplished by looking for the ECDT table, and getting
  962. * the EC parameters out of that.
  963. */
  964. status = acpi_ec_ecdt_probe();
  965. /* Ignore result. Not having an ECDT is not fatal. */
  966. if (acpi_gbl_parse_table_as_term_list ||
  967. !acpi_gbl_group_module_level_code) {
  968. status = acpi_load_tables();
  969. if (ACPI_FAILURE(status)) {
  970. printk(KERN_ERR PREFIX
  971. "Unable to load the System Description Tables\n");
  972. goto error1;
  973. }
  974. }
  975. status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
  976. if (ACPI_FAILURE(status)) {
  977. printk(KERN_ERR PREFIX
  978. "Unable to start the ACPI Interpreter\n");
  979. goto error1;
  980. }
  981. status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
  982. if (ACPI_FAILURE(status)) {
  983. printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
  984. goto error1;
  985. }
  986. /* Set capability bits for _OSC under processor scope */
  987. acpi_early_processor_osc();
  988. /*
  989. * _OSC method may exist in module level code,
  990. * so it must be run after ACPI_FULL_INITIALIZATION
  991. */
  992. acpi_bus_osc_support();
  993. /*
  994. * _PDC control method may load dynamic SSDT tables,
  995. * and we need to install the table handler before that.
  996. */
  997. status = acpi_install_table_handler(acpi_bus_table_handler, NULL);
  998. acpi_sysfs_init();
  999. acpi_early_processor_set_pdc();
  1000. /*
  1001. * Maybe EC region is required at bus_scan/acpi_get_devices. So it
  1002. * is necessary to enable it as early as possible.
  1003. */
  1004. acpi_ec_dsdt_probe();
  1005. printk(KERN_INFO PREFIX "Interpreter enabled\n");
  1006. /* Initialize sleep structures */
  1007. acpi_sleep_init();
  1008. /*
  1009. * Get the system interrupt model and evaluate \_PIC.
  1010. */
  1011. result = acpi_bus_init_irq();
  1012. if (result)
  1013. goto error1;
  1014. /*
  1015. * Register the for all standard device notifications.
  1016. */
  1017. status =
  1018. acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
  1019. &acpi_bus_notify, NULL);
  1020. if (ACPI_FAILURE(status)) {
  1021. printk(KERN_ERR PREFIX
  1022. "Unable to register for device notifications\n");
  1023. goto error1;
  1024. }
  1025. /*
  1026. * Create the top ACPI proc directory
  1027. */
  1028. acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
  1029. result = bus_register(&acpi_bus_type);
  1030. if (!result)
  1031. return 0;
  1032. /* Mimic structured exception handling */
  1033. error1:
  1034. acpi_terminate();
  1035. return -ENODEV;
  1036. }
  1037. struct kobject *acpi_kobj;
  1038. EXPORT_SYMBOL_GPL(acpi_kobj);
  1039. static int __init acpi_init(void)
  1040. {
  1041. int result;
  1042. if (acpi_disabled) {
  1043. printk(KERN_INFO PREFIX "Interpreter disabled.\n");
  1044. return -ENODEV;
  1045. }
  1046. acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
  1047. if (!acpi_kobj) {
  1048. printk(KERN_WARNING "%s: kset create error\n", __func__);
  1049. acpi_kobj = NULL;
  1050. }
  1051. init_acpi_device_notify();
  1052. result = acpi_bus_init();
  1053. if (result) {
  1054. disable_acpi();
  1055. return result;
  1056. }
  1057. pci_mmcfg_late_init();
  1058. acpi_iort_init();
  1059. acpi_scan_init();
  1060. acpi_ec_init();
  1061. acpi_debugfs_init();
  1062. acpi_sleep_proc_init();
  1063. acpi_wakeup_device_init();
  1064. acpi_debugger_init();
  1065. acpi_setup_sb_notify_handler();
  1066. return 0;
  1067. }
  1068. subsys_initcall(acpi_init);