bus.c 17 KB

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