bus.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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. static 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. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
  173. {
  174. acpi_status status;
  175. struct acpi_object_list input;
  176. union acpi_object in_params[4];
  177. union acpi_object *out_obj;
  178. u8 uuid[16];
  179. u32 errors;
  180. struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
  181. if (!context)
  182. return AE_ERROR;
  183. if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
  184. return AE_ERROR;
  185. context->ret.length = ACPI_ALLOCATE_BUFFER;
  186. context->ret.pointer = NULL;
  187. /* Setting up input parameters */
  188. input.count = 4;
  189. input.pointer = in_params;
  190. in_params[0].type = ACPI_TYPE_BUFFER;
  191. in_params[0].buffer.length = 16;
  192. in_params[0].buffer.pointer = uuid;
  193. in_params[1].type = ACPI_TYPE_INTEGER;
  194. in_params[1].integer.value = context->rev;
  195. in_params[2].type = ACPI_TYPE_INTEGER;
  196. in_params[2].integer.value = context->cap.length/sizeof(u32);
  197. in_params[3].type = ACPI_TYPE_BUFFER;
  198. in_params[3].buffer.length = context->cap.length;
  199. in_params[3].buffer.pointer = context->cap.pointer;
  200. status = acpi_evaluate_object(handle, "_OSC", &input, &output);
  201. if (ACPI_FAILURE(status))
  202. return status;
  203. if (!output.length)
  204. return AE_NULL_OBJECT;
  205. out_obj = output.pointer;
  206. if (out_obj->type != ACPI_TYPE_BUFFER
  207. || out_obj->buffer.length != context->cap.length) {
  208. acpi_print_osc_error(handle, context,
  209. "_OSC evaluation returned wrong type");
  210. status = AE_TYPE;
  211. goto out_kfree;
  212. }
  213. /* Need to ignore the bit0 in result code */
  214. errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
  215. if (errors) {
  216. if (errors & OSC_REQUEST_ERROR)
  217. acpi_print_osc_error(handle, context,
  218. "_OSC request failed");
  219. if (errors & OSC_INVALID_UUID_ERROR)
  220. acpi_print_osc_error(handle, context,
  221. "_OSC invalid UUID");
  222. if (errors & OSC_INVALID_REVISION_ERROR)
  223. acpi_print_osc_error(handle, context,
  224. "_OSC invalid revision");
  225. if (errors & OSC_CAPABILITIES_MASK_ERROR) {
  226. if (((u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
  227. & OSC_QUERY_ENABLE)
  228. goto out_success;
  229. status = AE_SUPPORT;
  230. goto out_kfree;
  231. }
  232. status = AE_ERROR;
  233. goto out_kfree;
  234. }
  235. out_success:
  236. context->ret.length = out_obj->buffer.length;
  237. context->ret.pointer = kmemdup(out_obj->buffer.pointer,
  238. context->ret.length, GFP_KERNEL);
  239. if (!context->ret.pointer) {
  240. status = AE_NO_MEMORY;
  241. goto out_kfree;
  242. }
  243. status = AE_OK;
  244. out_kfree:
  245. kfree(output.pointer);
  246. if (status != AE_OK)
  247. context->ret.pointer = NULL;
  248. return status;
  249. }
  250. EXPORT_SYMBOL(acpi_run_osc);
  251. bool osc_sb_apei_support_acked;
  252. static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
  253. static void acpi_bus_osc_support(void)
  254. {
  255. u32 capbuf[2];
  256. struct acpi_osc_context context = {
  257. .uuid_str = sb_uuid_str,
  258. .rev = 1,
  259. .cap.length = 8,
  260. .cap.pointer = capbuf,
  261. };
  262. acpi_handle handle;
  263. capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
  264. capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
  265. #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
  266. defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
  267. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
  268. #endif
  269. #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
  270. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
  271. #endif
  272. #ifdef ACPI_HOTPLUG_OST
  273. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_HOTPLUG_OST_SUPPORT;
  274. #endif
  275. if (!ghes_disable)
  276. capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT;
  277. if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
  278. return;
  279. if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) {
  280. u32 *capbuf_ret = context.ret.pointer;
  281. if (context.ret.length > OSC_SUPPORT_TYPE)
  282. osc_sb_apei_support_acked =
  283. capbuf_ret[OSC_SUPPORT_TYPE] & OSC_SB_APEI_SUPPORT;
  284. kfree(context.ret.pointer);
  285. }
  286. /* do we need to check other returned cap? Sounds no */
  287. }
  288. /* --------------------------------------------------------------------------
  289. Notification Handling
  290. -------------------------------------------------------------------------- */
  291. static void acpi_bus_check_device(acpi_handle handle)
  292. {
  293. struct acpi_device *device;
  294. acpi_status status;
  295. struct acpi_device_status old_status;
  296. if (acpi_bus_get_device(handle, &device))
  297. return;
  298. if (!device)
  299. return;
  300. old_status = device->status;
  301. /*
  302. * Make sure this device's parent is present before we go about
  303. * messing with the device.
  304. */
  305. if (device->parent && !device->parent->status.present) {
  306. device->status = device->parent->status;
  307. return;
  308. }
  309. status = acpi_bus_get_status(device);
  310. if (ACPI_FAILURE(status))
  311. return;
  312. if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
  313. return;
  314. /*
  315. * Device Insertion/Removal
  316. */
  317. if ((device->status.present) && !(old_status.present)) {
  318. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
  319. /* TBD: Handle device insertion */
  320. } else if (!(device->status.present) && (old_status.present)) {
  321. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
  322. /* TBD: Handle device removal */
  323. }
  324. }
  325. static void acpi_bus_check_scope(acpi_handle handle)
  326. {
  327. /* Status Change? */
  328. acpi_bus_check_device(handle);
  329. /*
  330. * TBD: Enumerate child devices within this device's scope and
  331. * run acpi_bus_check_device()'s on them.
  332. */
  333. }
  334. static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
  335. int register_acpi_bus_notifier(struct notifier_block *nb)
  336. {
  337. return blocking_notifier_chain_register(&acpi_bus_notify_list, nb);
  338. }
  339. EXPORT_SYMBOL_GPL(register_acpi_bus_notifier);
  340. void unregister_acpi_bus_notifier(struct notifier_block *nb)
  341. {
  342. blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb);
  343. }
  344. EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
  345. /**
  346. * acpi_bus_notify
  347. * ---------------
  348. * Callback for all 'system-level' device notifications (values 0x00-0x7F).
  349. */
  350. static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
  351. {
  352. struct acpi_device *device = NULL;
  353. struct acpi_driver *driver;
  354. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n",
  355. type, handle));
  356. blocking_notifier_call_chain(&acpi_bus_notify_list,
  357. type, (void *)handle);
  358. switch (type) {
  359. case ACPI_NOTIFY_BUS_CHECK:
  360. acpi_bus_check_scope(handle);
  361. /*
  362. * TBD: We'll need to outsource certain events to non-ACPI
  363. * drivers via the device manager (device.c).
  364. */
  365. break;
  366. case ACPI_NOTIFY_DEVICE_CHECK:
  367. acpi_bus_check_device(handle);
  368. /*
  369. * TBD: We'll need to outsource certain events to non-ACPI
  370. * drivers via the device manager (device.c).
  371. */
  372. break;
  373. case ACPI_NOTIFY_DEVICE_WAKE:
  374. /* TBD */
  375. break;
  376. case ACPI_NOTIFY_EJECT_REQUEST:
  377. /* TBD */
  378. break;
  379. case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
  380. /* TBD: Exactly what does 'light' mean? */
  381. break;
  382. case ACPI_NOTIFY_FREQUENCY_MISMATCH:
  383. /* TBD */
  384. break;
  385. case ACPI_NOTIFY_BUS_MODE_MISMATCH:
  386. /* TBD */
  387. break;
  388. case ACPI_NOTIFY_POWER_FAULT:
  389. /* TBD */
  390. break;
  391. default:
  392. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  393. "Received unknown/unsupported notification [%08x]\n",
  394. type));
  395. break;
  396. }
  397. acpi_bus_get_device(handle, &device);
  398. if (device) {
  399. driver = device->driver;
  400. if (driver && driver->ops.notify &&
  401. (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
  402. driver->ops.notify(device, type);
  403. }
  404. }
  405. /* --------------------------------------------------------------------------
  406. Initialization/Cleanup
  407. -------------------------------------------------------------------------- */
  408. static int __init acpi_bus_init_irq(void)
  409. {
  410. acpi_status status;
  411. union acpi_object arg = { ACPI_TYPE_INTEGER };
  412. struct acpi_object_list arg_list = { 1, &arg };
  413. char *message = NULL;
  414. /*
  415. * Let the system know what interrupt model we are using by
  416. * evaluating the \_PIC object, if exists.
  417. */
  418. switch (acpi_irq_model) {
  419. case ACPI_IRQ_MODEL_PIC:
  420. message = "PIC";
  421. break;
  422. case ACPI_IRQ_MODEL_IOAPIC:
  423. message = "IOAPIC";
  424. break;
  425. case ACPI_IRQ_MODEL_IOSAPIC:
  426. message = "IOSAPIC";
  427. break;
  428. case ACPI_IRQ_MODEL_PLATFORM:
  429. message = "platform specific model";
  430. break;
  431. default:
  432. printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
  433. return -ENODEV;
  434. }
  435. printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
  436. arg.integer.value = acpi_irq_model;
  437. status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
  438. if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
  439. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
  440. return -ENODEV;
  441. }
  442. return 0;
  443. }
  444. u8 acpi_gbl_permanent_mmap;
  445. void __init acpi_early_init(void)
  446. {
  447. acpi_status status;
  448. if (acpi_disabled)
  449. return;
  450. printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
  451. /* enable workarounds, unless strict ACPI spec. compliance */
  452. if (!acpi_strict)
  453. acpi_gbl_enable_interpreter_slack = TRUE;
  454. acpi_gbl_permanent_mmap = 1;
  455. /*
  456. * If the machine falls into the DMI check table,
  457. * DSDT will be copied to memory
  458. */
  459. dmi_check_system(dsdt_dmi_table);
  460. status = acpi_reallocate_root_table();
  461. if (ACPI_FAILURE(status)) {
  462. printk(KERN_ERR PREFIX
  463. "Unable to reallocate ACPI tables\n");
  464. goto error0;
  465. }
  466. status = acpi_initialize_subsystem();
  467. if (ACPI_FAILURE(status)) {
  468. printk(KERN_ERR PREFIX
  469. "Unable to initialize the ACPI Interpreter\n");
  470. goto error0;
  471. }
  472. status = acpi_load_tables();
  473. if (ACPI_FAILURE(status)) {
  474. printk(KERN_ERR PREFIX
  475. "Unable to load the System Description Tables\n");
  476. goto error0;
  477. }
  478. #ifdef CONFIG_X86
  479. if (!acpi_ioapic) {
  480. /* compatible (0) means level (3) */
  481. if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) {
  482. acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK;
  483. acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL;
  484. }
  485. /* Set PIC-mode SCI trigger type */
  486. acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt,
  487. (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
  488. } else {
  489. /*
  490. * now that acpi_gbl_FADT is initialized,
  491. * update it with result from INT_SRC_OVR parsing
  492. */
  493. acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi;
  494. }
  495. #endif
  496. status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE);
  497. if (ACPI_FAILURE(status)) {
  498. printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
  499. goto error0;
  500. }
  501. return;
  502. error0:
  503. disable_acpi();
  504. return;
  505. }
  506. static int __init acpi_bus_init(void)
  507. {
  508. int result;
  509. acpi_status status;
  510. acpi_os_initialize1();
  511. status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
  512. if (ACPI_FAILURE(status)) {
  513. printk(KERN_ERR PREFIX
  514. "Unable to start the ACPI Interpreter\n");
  515. goto error1;
  516. }
  517. /*
  518. * ACPI 2.0 requires the EC driver to be loaded and work before
  519. * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
  520. * is called).
  521. *
  522. * This is accomplished by looking for the ECDT table, and getting
  523. * the EC parameters out of that.
  524. */
  525. status = acpi_ec_ecdt_probe();
  526. /* Ignore result. Not having an ECDT is not fatal. */
  527. status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
  528. if (ACPI_FAILURE(status)) {
  529. printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
  530. goto error1;
  531. }
  532. /*
  533. * _OSC method may exist in module level code,
  534. * so it must be run after ACPI_FULL_INITIALIZATION
  535. */
  536. acpi_bus_osc_support();
  537. /*
  538. * _PDC control method may load dynamic SSDT tables,
  539. * and we need to install the table handler before that.
  540. */
  541. acpi_sysfs_init();
  542. acpi_early_processor_set_pdc();
  543. /*
  544. * Maybe EC region is required at bus_scan/acpi_get_devices. So it
  545. * is necessary to enable it as early as possible.
  546. */
  547. acpi_boot_ec_enable();
  548. printk(KERN_INFO PREFIX "Interpreter enabled\n");
  549. /* Initialize sleep structures */
  550. acpi_sleep_init();
  551. /*
  552. * Get the system interrupt model and evaluate \_PIC.
  553. */
  554. result = acpi_bus_init_irq();
  555. if (result)
  556. goto error1;
  557. /*
  558. * Register the for all standard device notifications.
  559. */
  560. status =
  561. acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
  562. &acpi_bus_notify, NULL);
  563. if (ACPI_FAILURE(status)) {
  564. printk(KERN_ERR PREFIX
  565. "Unable to register for device notifications\n");
  566. goto error1;
  567. }
  568. /*
  569. * Create the top ACPI proc directory
  570. */
  571. acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
  572. return 0;
  573. /* Mimic structured exception handling */
  574. error1:
  575. acpi_terminate();
  576. return -ENODEV;
  577. }
  578. struct kobject *acpi_kobj;
  579. EXPORT_SYMBOL_GPL(acpi_kobj);
  580. static int __init acpi_init(void)
  581. {
  582. int result;
  583. if (acpi_disabled) {
  584. printk(KERN_INFO PREFIX "Interpreter disabled.\n");
  585. return -ENODEV;
  586. }
  587. acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
  588. if (!acpi_kobj) {
  589. printk(KERN_WARNING "%s: kset create error\n", __func__);
  590. acpi_kobj = NULL;
  591. }
  592. init_acpi_device_notify();
  593. result = acpi_bus_init();
  594. if (result) {
  595. disable_acpi();
  596. return result;
  597. }
  598. pci_mmcfg_late_init();
  599. acpi_scan_init();
  600. acpi_ec_init();
  601. acpi_debugfs_init();
  602. acpi_sleep_proc_init();
  603. acpi_wakeup_device_init();
  604. return 0;
  605. }
  606. subsys_initcall(acpi_init);