bus.c 34 KB

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