bus.c 17 KB

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