.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * scan.c - support for transforming the ACPI namespace into individual objects |
---|
3 | 4 | */ |
---|
.. | .. |
---|
12 | 13 | #include <linux/kthread.h> |
---|
13 | 14 | #include <linux/dmi.h> |
---|
14 | 15 | #include <linux/nls.h> |
---|
15 | | -#include <linux/dma-mapping.h> |
---|
| 16 | +#include <linux/dma-map-ops.h> |
---|
16 | 17 | #include <linux/platform_data/x86/apple.h> |
---|
17 | | - |
---|
18 | | -#include <asm/pgtable.h> |
---|
| 18 | +#include <linux/pgtable.h> |
---|
19 | 19 | |
---|
20 | 20 | #include "internal.h" |
---|
21 | 21 | |
---|
.. | .. |
---|
797 | 797 | } |
---|
798 | 798 | EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); |
---|
799 | 799 | |
---|
800 | | -static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle, |
---|
801 | | - struct acpi_device_wakeup *wakeup) |
---|
| 800 | +static int acpi_bus_extract_wakeup_device_power_package(struct acpi_device *dev) |
---|
802 | 801 | { |
---|
| 802 | + acpi_handle handle = dev->handle; |
---|
| 803 | + struct acpi_device_wakeup *wakeup = &dev->wakeup; |
---|
803 | 804 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
---|
804 | 805 | union acpi_object *package = NULL; |
---|
805 | 806 | union acpi_object *element = NULL; |
---|
806 | 807 | acpi_status status; |
---|
807 | 808 | int err = -ENODATA; |
---|
808 | | - |
---|
809 | | - if (!wakeup) |
---|
810 | | - return -EINVAL; |
---|
811 | 809 | |
---|
812 | 810 | INIT_LIST_HEAD(&wakeup->resources); |
---|
813 | 811 | |
---|
.. | .. |
---|
882 | 880 | static bool acpi_wakeup_gpe_init(struct acpi_device *device) |
---|
883 | 881 | { |
---|
884 | 882 | static const struct acpi_device_id button_device_ids[] = { |
---|
885 | | - {"PNP0C0C", 0}, |
---|
886 | | - {"PNP0C0D", 0}, |
---|
887 | | - {"PNP0C0E", 0}, |
---|
| 883 | + {"PNP0C0C", 0}, /* Power button */ |
---|
| 884 | + {"PNP0C0D", 0}, /* Lid */ |
---|
| 885 | + {"PNP0C0E", 0}, /* Sleep button */ |
---|
888 | 886 | {"", 0}, |
---|
889 | 887 | }; |
---|
890 | 888 | struct acpi_device_wakeup *wakeup = &device->wakeup; |
---|
.. | .. |
---|
917 | 915 | if (!acpi_has_method(device->handle, "_PRW")) |
---|
918 | 916 | return; |
---|
919 | 917 | |
---|
920 | | - err = acpi_bus_extract_wakeup_device_power_package(device->handle, |
---|
921 | | - &device->wakeup); |
---|
| 918 | + err = acpi_bus_extract_wakeup_device_power_package(device); |
---|
922 | 919 | if (err) { |
---|
923 | 920 | dev_err(&device->dev, "_PRW evaluation error: %d\n", err); |
---|
924 | 921 | return; |
---|
.. | .. |
---|
929 | 926 | /* |
---|
930 | 927 | * Call _PSW/_DSW object to disable its ability to wake the sleeping |
---|
931 | 928 | * system for the ACPI device with the _PRW object. |
---|
932 | | - * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW. |
---|
| 929 | + * The _PSW object is deprecated in ACPI 3.0 and is replaced by _DSW. |
---|
933 | 930 | * So it is necessary to call _DSW object first. Only when it is not |
---|
934 | 931 | * present will the _PSW object used. |
---|
935 | 932 | */ |
---|
936 | 933 | err = acpi_device_sleep_wake(device, 0, 0, 0); |
---|
937 | 934 | if (err) |
---|
938 | | - ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
---|
939 | | - "error in _DSW or _PSW evaluation\n")); |
---|
| 935 | + pr_debug("error in _DSW or _PSW evaluation\n"); |
---|
940 | 936 | } |
---|
941 | 937 | |
---|
942 | 938 | static void acpi_bus_init_power_state(struct acpi_device *device, int state) |
---|
.. | .. |
---|
1491 | 1487 | } |
---|
1492 | 1488 | |
---|
1493 | 1489 | /** |
---|
1494 | | - * acpi_dma_configure - Set-up DMA configuration for the device. |
---|
| 1490 | + * acpi_dma_configure_id - Set-up DMA configuration for the device. |
---|
1495 | 1491 | * @dev: The pointer to the device |
---|
1496 | 1492 | * @attr: device dma attributes |
---|
| 1493 | + * @input_id: input device id const value pointer |
---|
1497 | 1494 | */ |
---|
1498 | | -int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr) |
---|
| 1495 | +int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr, |
---|
| 1496 | + const u32 *input_id) |
---|
1499 | 1497 | { |
---|
1500 | 1498 | const struct iommu_ops *iommu; |
---|
1501 | 1499 | u64 dma_addr = 0, size = 0; |
---|
1502 | 1500 | |
---|
| 1501 | + if (attr == DEV_DMA_NOT_SUPPORTED) { |
---|
| 1502 | + set_dma_ops(dev, &dma_dummy_ops); |
---|
| 1503 | + return 0; |
---|
| 1504 | + } |
---|
| 1505 | + |
---|
1503 | 1506 | iort_dma_setup(dev, &dma_addr, &size); |
---|
1504 | 1507 | |
---|
1505 | | - iommu = iort_iommu_configure(dev); |
---|
1506 | | - if (IS_ERR(iommu) && PTR_ERR(iommu) == -EPROBE_DEFER) |
---|
| 1508 | + iommu = iort_iommu_configure_id(dev, input_id); |
---|
| 1509 | + if (PTR_ERR(iommu) == -EPROBE_DEFER) |
---|
1507 | 1510 | return -EPROBE_DEFER; |
---|
1508 | 1511 | |
---|
1509 | 1512 | arch_setup_dma_ops(dev, dma_addr, size, |
---|
.. | .. |
---|
1511 | 1514 | |
---|
1512 | 1515 | return 0; |
---|
1513 | 1516 | } |
---|
1514 | | -EXPORT_SYMBOL_GPL(acpi_dma_configure); |
---|
1515 | | - |
---|
1516 | | -/** |
---|
1517 | | - * acpi_dma_deconfigure - Tear-down DMA configuration for the device. |
---|
1518 | | - * @dev: The pointer to the device |
---|
1519 | | - */ |
---|
1520 | | -void acpi_dma_deconfigure(struct device *dev) |
---|
1521 | | -{ |
---|
1522 | | - arch_teardown_dma_ops(dev); |
---|
1523 | | -} |
---|
1524 | | -EXPORT_SYMBOL_GPL(acpi_dma_deconfigure); |
---|
| 1517 | +EXPORT_SYMBOL_GPL(acpi_dma_configure_id); |
---|
1525 | 1518 | |
---|
1526 | 1519 | static void acpi_init_coherency(struct acpi_device *adev) |
---|
1527 | 1520 | { |
---|
.. | .. |
---|
1584 | 1577 | { |
---|
1585 | 1578 | struct list_head resource_list; |
---|
1586 | 1579 | bool is_serial_bus_slave = false; |
---|
| 1580 | + static const struct acpi_device_id ignore_serial_bus_ids[] = { |
---|
1587 | 1581 | /* |
---|
1588 | 1582 | * These devices have multiple I2cSerialBus resources and an i2c-client |
---|
1589 | 1583 | * must be instantiated for each, each with its own i2c_device_id. |
---|
.. | .. |
---|
1592 | 1586 | * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows |
---|
1593 | 1587 | * which i2c_device_id to use for each resource. |
---|
1594 | 1588 | */ |
---|
1595 | | - static const struct acpi_device_id i2c_multi_instantiate_ids[] = { |
---|
1596 | 1589 | {"BSG1160", }, |
---|
| 1590 | + {"BSG2150", }, |
---|
1597 | 1591 | {"INT33FE", }, |
---|
| 1592 | + {"INT3515", }, |
---|
| 1593 | + /* |
---|
| 1594 | + * HIDs of device with an UartSerialBusV2 resource for which userspace |
---|
| 1595 | + * expects a regular tty cdev to be created (instead of the in kernel |
---|
| 1596 | + * serdev) and which have a kernel driver which expects a platform_dev |
---|
| 1597 | + * such as the rfkill-gpio driver. |
---|
| 1598 | + */ |
---|
| 1599 | + {"BCM4752", }, |
---|
| 1600 | + {"LNV4752", }, |
---|
1598 | 1601 | {} |
---|
1599 | 1602 | }; |
---|
1600 | 1603 | |
---|
.. | .. |
---|
1608 | 1611 | fwnode_property_present(&device->fwnode, "baud"))) |
---|
1609 | 1612 | return true; |
---|
1610 | 1613 | |
---|
1611 | | - /* Instantiate a pdev for the i2c-multi-instantiate drv to bind to */ |
---|
1612 | | - if (!acpi_match_device_ids(device, i2c_multi_instantiate_ids)) |
---|
| 1614 | + if (!acpi_match_device_ids(device, ignore_serial_bus_ids)) |
---|
1613 | 1615 | return false; |
---|
1614 | 1616 | |
---|
1615 | 1617 | INIT_LIST_HEAD(&resource_list); |
---|
.. | .. |
---|
1628 | 1630 | device->device_type = type; |
---|
1629 | 1631 | device->handle = handle; |
---|
1630 | 1632 | device->parent = acpi_bus_get_parent(handle); |
---|
1631 | | - device->fwnode.ops = &acpi_device_fwnode_ops; |
---|
| 1633 | + fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); |
---|
1632 | 1634 | acpi_set_device_status(device, sta); |
---|
1633 | 1635 | acpi_device_get_busid(device); |
---|
1634 | 1636 | acpi_set_pnp_ids(handle, &device->pnp, type); |
---|
.. | .. |
---|
2206 | 2208 | |
---|
2207 | 2209 | status = acpi_get_table(ACPI_SIG_SPCR, 0, |
---|
2208 | 2210 | (struct acpi_table_header **)&spcr_ptr); |
---|
2209 | | - if (ACPI_SUCCESS(status)) |
---|
2210 | | - spcr_uart_addr = spcr_ptr->serial_port.address; |
---|
2211 | | - else |
---|
2212 | | - printk(KERN_WARNING PREFIX "STAO table present, but SPCR is missing\n"); |
---|
| 2211 | + if (ACPI_FAILURE(status)) { |
---|
| 2212 | + pr_warn(PREFIX "STAO table present, but SPCR is missing\n"); |
---|
| 2213 | + return; |
---|
| 2214 | + } |
---|
| 2215 | + |
---|
| 2216 | + spcr_uart_addr = spcr_ptr->serial_port.address; |
---|
| 2217 | + acpi_put_table((struct acpi_table_header *)spcr_ptr); |
---|
2213 | 2218 | } |
---|
2214 | 2219 | |
---|
2215 | 2220 | static bool acpi_scan_initialized; |
---|
.. | .. |
---|
2223 | 2228 | acpi_pci_root_init(); |
---|
2224 | 2229 | acpi_pci_link_init(); |
---|
2225 | 2230 | acpi_processor_init(); |
---|
| 2231 | + acpi_platform_init(); |
---|
2226 | 2232 | acpi_lpss_init(); |
---|
2227 | 2233 | acpi_apd_init(); |
---|
2228 | 2234 | acpi_cmos_rtc_init(); |
---|
.. | .. |
---|
2244 | 2250 | (struct acpi_table_header **)&stao_ptr); |
---|
2245 | 2251 | if (ACPI_SUCCESS(status)) { |
---|
2246 | 2252 | if (stao_ptr->header.length > sizeof(struct acpi_table_stao)) |
---|
2247 | | - printk(KERN_INFO PREFIX "STAO Name List not yet supported."); |
---|
| 2253 | + pr_info(PREFIX "STAO Name List not yet supported.\n"); |
---|
2248 | 2254 | |
---|
2249 | 2255 | if (stao_ptr->ignore_uart) |
---|
2250 | 2256 | acpi_get_spcr_uart_addr(); |
---|
| 2257 | + |
---|
| 2258 | + acpi_put_table((struct acpi_table_header *)stao_ptr); |
---|
2251 | 2259 | } |
---|
2252 | 2260 | |
---|
2253 | 2261 | acpi_gpe_apply_masked_gpes(); |
---|
2254 | 2262 | acpi_update_all_gpes(); |
---|
2255 | 2263 | |
---|
| 2264 | + /* |
---|
| 2265 | + * Although we call __add_memory() that is documented to require the |
---|
| 2266 | + * device_hotplug_lock, it is not necessary here because this is an |
---|
| 2267 | + * early code when userspace or any other code path cannot trigger |
---|
| 2268 | + * hotplug/hotunplug operations. |
---|
| 2269 | + */ |
---|
2256 | 2270 | mutex_lock(&acpi_scan_lock); |
---|
2257 | 2271 | /* |
---|
2258 | 2272 | * Enumerate devices in the ACPI namespace. |
---|
.. | .. |
---|
2288 | 2302 | static int acpi_probe_count; |
---|
2289 | 2303 | static DEFINE_MUTEX(acpi_probe_mutex); |
---|
2290 | 2304 | |
---|
2291 | | -static int __init acpi_match_madt(struct acpi_subtable_header *header, |
---|
| 2305 | +static int __init acpi_match_madt(union acpi_subtable_headers *header, |
---|
2292 | 2306 | const unsigned long end) |
---|
2293 | 2307 | { |
---|
2294 | | - if (!ape->subtable_valid || ape->subtable_valid(header, ape)) |
---|
| 2308 | + if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape)) |
---|
2295 | 2309 | if (!ape->probe_subtbl(header, end)) |
---|
2296 | 2310 | acpi_probe_count++; |
---|
2297 | 2311 | |
---|
.. | .. |
---|
2307 | 2321 | |
---|
2308 | 2322 | mutex_lock(&acpi_probe_mutex); |
---|
2309 | 2323 | for (ape = ap_head; nr; ape++, nr--) { |
---|
2310 | | - if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) { |
---|
| 2324 | + if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) { |
---|
2311 | 2325 | acpi_probe_count = 0; |
---|
2312 | 2326 | acpi_table_parse_madt(ape->type, acpi_match_madt, 0); |
---|
2313 | 2327 | count += acpi_probe_count; |
---|