bus.c 33 KB

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