diff options
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 179 |
1 files changed, 143 insertions, 36 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 03141aa4ea95..ec256352f423 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kthread.h> | 11 | #include <linux/kthread.h> |
12 | #include <linux/dmi.h> | 12 | #include <linux/dmi.h> |
13 | #include <linux/nls.h> | 13 | #include <linux/nls.h> |
14 | #include <linux/dma-mapping.h> | ||
14 | 15 | ||
15 | #include <asm/pgtable.h> | 16 | #include <asm/pgtable.h> |
16 | 17 | ||
@@ -135,12 +136,13 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
135 | struct acpi_hardware_id *id; | 136 | struct acpi_hardware_id *id; |
136 | 137 | ||
137 | /* | 138 | /* |
138 | * Since we skip PRP0001 from the modalias below, 0 should be returned | 139 | * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should |
139 | * if PRP0001 is the only ACPI/PNP ID in the device's list. | 140 | * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the |
141 | * device's list. | ||
140 | */ | 142 | */ |
141 | count = 0; | 143 | count = 0; |
142 | list_for_each_entry(id, &acpi_dev->pnp.ids, list) | 144 | list_for_each_entry(id, &acpi_dev->pnp.ids, list) |
143 | if (strcmp(id->id, "PRP0001")) | 145 | if (strcmp(id->id, ACPI_DT_NAMESPACE_HID)) |
144 | count++; | 146 | count++; |
145 | 147 | ||
146 | if (!count) | 148 | if (!count) |
@@ -153,7 +155,7 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
153 | size -= len; | 155 | size -= len; |
154 | 156 | ||
155 | list_for_each_entry(id, &acpi_dev->pnp.ids, list) { | 157 | list_for_each_entry(id, &acpi_dev->pnp.ids, list) { |
156 | if (!strcmp(id->id, "PRP0001")) | 158 | if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID)) |
157 | continue; | 159 | continue; |
158 | 160 | ||
159 | count = snprintf(&modalias[len], size, "%s:", id->id); | 161 | count = snprintf(&modalias[len], size, "%s:", id->id); |
@@ -177,7 +179,8 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
177 | * @size: Size of the buffer. | 179 | * @size: Size of the buffer. |
178 | * | 180 | * |
179 | * Expose DT compatible modalias as of:NnameTCcompatible. This function should | 181 | * Expose DT compatible modalias as of:NnameTCcompatible. This function should |
180 | * only be called for devices having PRP0001 in their list of ACPI/PNP IDs. | 182 | * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of |
183 | * ACPI/PNP IDs. | ||
181 | */ | 184 | */ |
182 | static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias, | 185 | static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias, |
183 | int size) | 186 | int size) |
@@ -980,9 +983,9 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
980 | * @adev: ACPI device object to match. | 983 | * @adev: ACPI device object to match. |
981 | * @of_match_table: List of device IDs to match against. | 984 | * @of_match_table: List of device IDs to match against. |
982 | * | 985 | * |
983 | * If @dev has an ACPI companion which has the special PRP0001 device ID in its | 986 | * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of |
984 | * list of identifiers and a _DSD object with the "compatible" property, use | 987 | * identifiers and a _DSD object with the "compatible" property, use that |
985 | * that property to match against the given list of identifiers. | 988 | * property to match against the given list of identifiers. |
986 | */ | 989 | */ |
987 | static bool acpi_of_match_device(struct acpi_device *adev, | 990 | static bool acpi_of_match_device(struct acpi_device *adev, |
988 | const struct of_device_id *of_match_table) | 991 | const struct of_device_id *of_match_table) |
@@ -1016,6 +1019,29 @@ static bool acpi_of_match_device(struct acpi_device *adev, | |||
1016 | return false; | 1019 | return false; |
1017 | } | 1020 | } |
1018 | 1021 | ||
1022 | static bool __acpi_match_device_cls(const struct acpi_device_id *id, | ||
1023 | struct acpi_hardware_id *hwid) | ||
1024 | { | ||
1025 | int i, msk, byte_shift; | ||
1026 | char buf[3]; | ||
1027 | |||
1028 | if (!id->cls) | ||
1029 | return false; | ||
1030 | |||
1031 | /* Apply class-code bitmask, before checking each class-code byte */ | ||
1032 | for (i = 1; i <= 3; i++) { | ||
1033 | byte_shift = 8 * (3 - i); | ||
1034 | msk = (id->cls_msk >> byte_shift) & 0xFF; | ||
1035 | if (!msk) | ||
1036 | continue; | ||
1037 | |||
1038 | sprintf(buf, "%02x", (id->cls >> byte_shift) & msk); | ||
1039 | if (strncmp(buf, &hwid->id[(i - 1) * 2], 2)) | ||
1040 | return false; | ||
1041 | } | ||
1042 | return true; | ||
1043 | } | ||
1044 | |||
1019 | static const struct acpi_device_id *__acpi_match_device( | 1045 | static const struct acpi_device_id *__acpi_match_device( |
1020 | struct acpi_device *device, | 1046 | struct acpi_device *device, |
1021 | const struct acpi_device_id *ids, | 1047 | const struct acpi_device_id *ids, |
@@ -1033,19 +1059,22 @@ static const struct acpi_device_id *__acpi_match_device( | |||
1033 | 1059 | ||
1034 | list_for_each_entry(hwid, &device->pnp.ids, list) { | 1060 | list_for_each_entry(hwid, &device->pnp.ids, list) { |
1035 | /* First, check the ACPI/PNP IDs provided by the caller. */ | 1061 | /* First, check the ACPI/PNP IDs provided by the caller. */ |
1036 | for (id = ids; id->id[0]; id++) | 1062 | for (id = ids; id->id[0] || id->cls; id++) { |
1037 | if (!strcmp((char *) id->id, hwid->id)) | 1063 | if (id->id[0] && !strcmp((char *) id->id, hwid->id)) |
1038 | return id; | 1064 | return id; |
1065 | else if (id->cls && __acpi_match_device_cls(id, hwid)) | ||
1066 | return id; | ||
1067 | } | ||
1039 | 1068 | ||
1040 | /* | 1069 | /* |
1041 | * Next, check the special "PRP0001" ID and try to match the | 1070 | * Next, check ACPI_DT_NAMESPACE_HID and try to match the |
1042 | * "compatible" property if found. | 1071 | * "compatible" property if found. |
1043 | * | 1072 | * |
1044 | * The id returned by the below is not valid, but the only | 1073 | * The id returned by the below is not valid, but the only |
1045 | * caller passing non-NULL of_ids here is only interested in | 1074 | * caller passing non-NULL of_ids here is only interested in |
1046 | * whether or not the return value is NULL. | 1075 | * whether or not the return value is NULL. |
1047 | */ | 1076 | */ |
1048 | if (!strcmp("PRP0001", hwid->id) | 1077 | if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id) |
1049 | && acpi_of_match_device(device, of_ids)) | 1078 | && acpi_of_match_device(device, of_ids)) |
1050 | return id; | 1079 | return id; |
1051 | } | 1080 | } |
@@ -1671,7 +1700,7 @@ static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle, | |||
1671 | 1700 | ||
1672 | static void acpi_wakeup_gpe_init(struct acpi_device *device) | 1701 | static void acpi_wakeup_gpe_init(struct acpi_device *device) |
1673 | { | 1702 | { |
1674 | struct acpi_device_id button_device_ids[] = { | 1703 | static const struct acpi_device_id button_device_ids[] = { |
1675 | {"PNP0C0C", 0}, | 1704 | {"PNP0C0C", 0}, |
1676 | {"PNP0C0D", 0}, | 1705 | {"PNP0C0D", 0}, |
1677 | {"PNP0C0E", 0}, | 1706 | {"PNP0C0E", 0}, |
@@ -1766,15 +1795,9 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) | |||
1766 | if (acpi_has_method(device->handle, pathname)) | 1795 | if (acpi_has_method(device->handle, pathname)) |
1767 | ps->flags.explicit_set = 1; | 1796 | ps->flags.explicit_set = 1; |
1768 | 1797 | ||
1769 | /* | 1798 | /* State is valid if there are means to put the device into it. */ |
1770 | * State is valid if there are means to put the device into it. | 1799 | if (!list_empty(&ps->resources) || ps->flags.explicit_set) |
1771 | * D3hot is only valid if _PR3 present. | ||
1772 | */ | ||
1773 | if (!list_empty(&ps->resources) | ||
1774 | || (ps->flags.explicit_set && state < ACPI_STATE_D3_HOT)) { | ||
1775 | ps->flags.valid = 1; | 1800 | ps->flags.valid = 1; |
1776 | ps->flags.os_accessible = 1; | ||
1777 | } | ||
1778 | 1801 | ||
1779 | ps->power = -1; /* Unknown - driver assigned */ | 1802 | ps->power = -1; /* Unknown - driver assigned */ |
1780 | ps->latency = -1; /* Unknown - driver assigned */ | 1803 | ps->latency = -1; /* Unknown - driver assigned */ |
@@ -1810,21 +1833,13 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) | |||
1810 | acpi_bus_init_power_state(device, i); | 1833 | acpi_bus_init_power_state(device, i); |
1811 | 1834 | ||
1812 | INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); | 1835 | INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); |
1836 | if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources)) | ||
1837 | device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; | ||
1813 | 1838 | ||
1814 | /* Set defaults for D0 and D3 states (always valid) */ | 1839 | /* Set defaults for D0 and D3hot states (always valid) */ |
1815 | device->power.states[ACPI_STATE_D0].flags.valid = 1; | 1840 | device->power.states[ACPI_STATE_D0].flags.valid = 1; |
1816 | device->power.states[ACPI_STATE_D0].power = 100; | 1841 | device->power.states[ACPI_STATE_D0].power = 100; |
1817 | device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; | 1842 | device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1; |
1818 | device->power.states[ACPI_STATE_D3_COLD].power = 0; | ||
1819 | |||
1820 | /* Set D3cold's explicit_set flag if _PS3 exists. */ | ||
1821 | if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) | ||
1822 | device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1; | ||
1823 | |||
1824 | /* Presence of _PS3 or _PRx means we can put the device into D3 cold */ | ||
1825 | if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set || | ||
1826 | device->power.flags.power_resources) | ||
1827 | device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1; | ||
1828 | 1843 | ||
1829 | if (acpi_bus_init_power(device)) | 1844 | if (acpi_bus_init_power(device)) |
1830 | device->flags.power_manageable = 0; | 1845 | device->flags.power_manageable = 0; |
@@ -1947,6 +1962,62 @@ bool acpi_dock_match(acpi_handle handle) | |||
1947 | return acpi_has_method(handle, "_DCK"); | 1962 | return acpi_has_method(handle, "_DCK"); |
1948 | } | 1963 | } |
1949 | 1964 | ||
1965 | static acpi_status | ||
1966 | acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | ||
1967 | void **return_value) | ||
1968 | { | ||
1969 | long *cap = context; | ||
1970 | |||
1971 | if (acpi_has_method(handle, "_BCM") && | ||
1972 | acpi_has_method(handle, "_BCL")) { | ||
1973 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " | ||
1974 | "support\n")); | ||
1975 | *cap |= ACPI_VIDEO_BACKLIGHT; | ||
1976 | if (!acpi_has_method(handle, "_BQC")) | ||
1977 | printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, " | ||
1978 | "cannot determine initial brightness\n"); | ||
1979 | /* We have backlight support, no need to scan further */ | ||
1980 | return AE_CTRL_TERMINATE; | ||
1981 | } | ||
1982 | return 0; | ||
1983 | } | ||
1984 | |||
1985 | /* Returns true if the ACPI object is a video device which can be | ||
1986 | * handled by video.ko. | ||
1987 | * The device will get a Linux specific CID added in scan.c to | ||
1988 | * identify the device as an ACPI graphics device | ||
1989 | * Be aware that the graphics device may not be physically present | ||
1990 | * Use acpi_video_get_capabilities() to detect general ACPI video | ||
1991 | * capabilities of present cards | ||
1992 | */ | ||
1993 | long acpi_is_video_device(acpi_handle handle) | ||
1994 | { | ||
1995 | long video_caps = 0; | ||
1996 | |||
1997 | /* Is this device able to support video switching ? */ | ||
1998 | if (acpi_has_method(handle, "_DOD") || acpi_has_method(handle, "_DOS")) | ||
1999 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; | ||
2000 | |||
2001 | /* Is this device able to retrieve a video ROM ? */ | ||
2002 | if (acpi_has_method(handle, "_ROM")) | ||
2003 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; | ||
2004 | |||
2005 | /* Is this device able to configure which video head to be POSTed ? */ | ||
2006 | if (acpi_has_method(handle, "_VPO") && | ||
2007 | acpi_has_method(handle, "_GPD") && | ||
2008 | acpi_has_method(handle, "_SPD")) | ||
2009 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; | ||
2010 | |||
2011 | /* Only check for backlight functionality if one of the above hit. */ | ||
2012 | if (video_caps) | ||
2013 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | ||
2014 | ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL, | ||
2015 | &video_caps, NULL); | ||
2016 | |||
2017 | return video_caps; | ||
2018 | } | ||
2019 | EXPORT_SYMBOL(acpi_is_video_device); | ||
2020 | |||
1950 | const char *acpi_device_hid(struct acpi_device *device) | 2021 | const char *acpi_device_hid(struct acpi_device *device) |
1951 | { | 2022 | { |
1952 | struct acpi_hardware_id *hid; | 2023 | struct acpi_hardware_id *hid; |
@@ -2056,6 +2127,8 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, | |||
2056 | if (info->valid & ACPI_VALID_UID) | 2127 | if (info->valid & ACPI_VALID_UID) |
2057 | pnp->unique_id = kstrdup(info->unique_id.string, | 2128 | pnp->unique_id = kstrdup(info->unique_id.string, |
2058 | GFP_KERNEL); | 2129 | GFP_KERNEL); |
2130 | if (info->valid & ACPI_VALID_CLS) | ||
2131 | acpi_add_id(pnp, info->class_code.string); | ||
2059 | 2132 | ||
2060 | kfree(info); | 2133 | kfree(info); |
2061 | 2134 | ||
@@ -2109,6 +2182,39 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) | |||
2109 | kfree(pnp->unique_id); | 2182 | kfree(pnp->unique_id); |
2110 | } | 2183 | } |
2111 | 2184 | ||
2185 | static void acpi_init_coherency(struct acpi_device *adev) | ||
2186 | { | ||
2187 | unsigned long long cca = 0; | ||
2188 | acpi_status status; | ||
2189 | struct acpi_device *parent = adev->parent; | ||
2190 | |||
2191 | if (parent && parent->flags.cca_seen) { | ||
2192 | /* | ||
2193 | * From ACPI spec, OSPM will ignore _CCA if an ancestor | ||
2194 | * already saw one. | ||
2195 | */ | ||
2196 | adev->flags.cca_seen = 1; | ||
2197 | cca = parent->flags.coherent_dma; | ||
2198 | } else { | ||
2199 | status = acpi_evaluate_integer(adev->handle, "_CCA", | ||
2200 | NULL, &cca); | ||
2201 | if (ACPI_SUCCESS(status)) | ||
2202 | adev->flags.cca_seen = 1; | ||
2203 | else if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED)) | ||
2204 | /* | ||
2205 | * If architecture does not specify that _CCA is | ||
2206 | * required for DMA-able devices (e.g. x86), | ||
2207 | * we default to _CCA=1. | ||
2208 | */ | ||
2209 | cca = 1; | ||
2210 | else | ||
2211 | acpi_handle_debug(adev->handle, | ||
2212 | "ACPI device is missing _CCA.\n"); | ||
2213 | } | ||
2214 | |||
2215 | adev->flags.coherent_dma = cca; | ||
2216 | } | ||
2217 | |||
2112 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | 2218 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, |
2113 | int type, unsigned long long sta) | 2219 | int type, unsigned long long sta) |
2114 | { | 2220 | { |
@@ -2127,6 +2233,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
2127 | device->flags.visited = false; | 2233 | device->flags.visited = false; |
2128 | device_initialize(&device->dev); | 2234 | device_initialize(&device->dev); |
2129 | dev_set_uevent_suppress(&device->dev, true); | 2235 | dev_set_uevent_suppress(&device->dev, true); |
2236 | acpi_init_coherency(device); | ||
2130 | } | 2237 | } |
2131 | 2238 | ||
2132 | void acpi_device_add_finalize(struct acpi_device *device) | 2239 | void acpi_device_add_finalize(struct acpi_device *device) |
@@ -2405,7 +2512,7 @@ static void acpi_default_enumeration(struct acpi_device *device) | |||
2405 | } | 2512 | } |
2406 | 2513 | ||
2407 | static const struct acpi_device_id generic_device_ids[] = { | 2514 | static const struct acpi_device_id generic_device_ids[] = { |
2408 | {"PRP0001", }, | 2515 | {ACPI_DT_NAMESPACE_HID, }, |
2409 | {"", }, | 2516 | {"", }, |
2410 | }; | 2517 | }; |
2411 | 2518 | ||
@@ -2413,8 +2520,8 @@ static int acpi_generic_device_attach(struct acpi_device *adev, | |||
2413 | const struct acpi_device_id *not_used) | 2520 | const struct acpi_device_id *not_used) |
2414 | { | 2521 | { |
2415 | /* | 2522 | /* |
2416 | * Since PRP0001 is the only ID handled here, the test below can be | 2523 | * Since ACPI_DT_NAMESPACE_HID is the only ID handled here, the test |
2417 | * unconditional. | 2524 | * below can be unconditional. |
2418 | */ | 2525 | */ |
2419 | if (adev->data.of_compatible) | 2526 | if (adev->data.of_compatible) |
2420 | acpi_default_enumeration(adev); | 2527 | acpi_default_enumeration(adev); |