bus.c 17 KB

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