Pull more ACPI updates from Rafael Wysocki: "These add support for a new ACPI device configuration object called _DSC, fix some issues including one recent regression, add two new items to quirk lists and clean up assorted pieces of code. Specifics: - Add support for new ACPI device configuration object called _DSC ("Deepest State for Configuration") to allow certain devices to be probed without changing their power states, document it and make two drivers use it (Sakari Ailus, Rajmohan Mani). - Fix device wakeup power reference counting broken recently by mistake (Rafael Wysocki). - Drop unused symbol and macros depending on it from acgcc.h (Rafael Wysocki). - Add HP ZHAN 66 Pro to the "no EC wakeup" quirk list (Binbin Zhou). - Add Xiaomi Mi Pad 2 to the backlight quirk list and drop an unused piece of data from all of the list entries (Hans de Goede). - Fix register read accesses handling in the Intel PMIC operation region driver (Hans de Goede). - Clean up static variables initialization in the EC driver (wangzhitong)" * tag 'acpi-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: Documentation: ACPI: Fix non-D0 probe _DSC object example ACPI: Drop ACPI_USE_BUILTIN_STDARG ifdef from acgcc.h ACPI: PM: Fix device wakeup power reference counting error ACPI: video: use platform backlight driver on Xiaomi Mi Pad 2 ACPI: video: Drop dmi_system_id.ident settings from video_detect_dmi_table[] ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses ACPI: EC: Remove initialization of static variables to false ACPI: EC: Use ec_no_wakeup on HP ZHAN 66 Pro at24: Support probing while in non-zero ACPI D state media: i2c: imx319: Support device probe in non-zero ACPI D state ACPI: Add a convenience function to tell a device is in D0 state Documentation: ACPI: Document _DSC object usage for enum power state i2c: Allow an ACPI driver to manage the device's power state during probe ACPI: scan: Obtain device's desired enumeration power state
Unified · Split
| @@ -26,5 +26,6 @@ ACPI Support · 25 unmodified lines | ||
| 26 | 26 | acpi-lid |
| 27 | 27 | lpit |
| 28 | 28 | video_extension |
| 29 | + non-d0-probe | |
| 29 | 30 | extcon-intel-int3496 |
| 30 | 31 | intel-pmc-mux |
| @@ -0,0 +1,78 @@ | ||
| 1 | +.. SPDX-License-Identifier: GPL-2.0 | |
| 2 | + | |
| 3 | +======================================== | |
| 4 | +Probing devices in other D states than 0 | |
| 5 | +======================================== | |
| 6 | + | |
| 7 | +Introduction | |
| 8 | +============ | |
| 9 | + | |
| 10 | +In some cases it may be preferred to leave certain devices powered off for the | |
| 11 | +entire system bootup if powering on these devices has adverse side effects, | |
| 12 | +beyond just powering on the said device. | |
| 13 | + | |
| 14 | +How it works | |
| 15 | +============ | |
| 16 | + | |
| 17 | +The _DSC (Device State for Configuration) object that evaluates to an integer | |
| 18 | +may be used to tell Linux the highest allowed D state for a device during | |
| 19 | +probe. The support for _DSC requires support from the kernel bus type if the | |
| 20 | +bus driver normally sets the device in D0 state for probe. | |
| 21 | + | |
| 22 | +The downside of using _DSC is that as the device is not powered on, even if | |
| 23 | +there's a problem with the device, the driver likely probes just fine but the | |
| 24 | +first user will find out the device doesn't work, instead of a failure at probe | |
| 25 | +time. This feature should thus be used sparingly. | |
| 26 | + | |
| 27 | +I²C | |
| 28 | +--- | |
| 29 | + | |
| 30 | +If an I²C driver indicates its support for this by setting the | |
| 31 | +I2C_DRV_ACPI_WAIVE_D0_PROBE flag in struct i2c_driver.flags field and the | |
| 32 | +_DSC object evaluates to integer higher than the D state of the device, | |
| 33 | +the device will not be powered on (put in D0 state) for probe. | |
| 34 | + | |
| 35 | +D states | |
| 36 | +-------- | |
| 37 | + | |
| 38 | +The D states and thus also the allowed values for _DSC are listed below. Refer | |
| 39 | +to [1] for more information on device power states. | |
| 40 | + | |
| 41 | +.. code-block:: text | |
| 42 | + | |
| 43 | + Number State Description | |
| 44 | + 0 D0 Device fully powered on | |
| 45 | + 1 D1 | |
| 46 | + 2 D2 | |
| 47 | + 3 D3hot | |
| 48 | + 4 D3cold Off | |
| 49 | + | |
| 50 | +References | |
| 51 | +========== | |
| 52 | + | |
| 53 | +[1] https://uefi.org/specifications/ACPI/6.4/02_Definition_of_Terms/Definition_of_Terms.html#device-power-state-definitions | |
| 54 | + | |
| 55 | +Example | |
| 56 | +======= | |
| 57 | + | |
| 58 | +An ASL example describing an ACPI device using _DSC object to tell Operating | |
| 59 | +System the device should remain powered off during probe looks like this. Some | |
| 60 | +objects not relevant from the example point of view have been omitted. | |
| 61 | + | |
| 62 | +.. code-block:: text | |
| 63 | + | |
| 64 | + Device (CAM0) | |
| 65 | + { | |
| 66 | + Name (_HID, "SONY319A") | |
| 67 | + Name (_UID, Zero) | |
| 68 | + Name (_CRS, ResourceTemplate () | |
| 69 | + { | |
| 70 | + I2cSerialBus(0x0020, ControllerInitiated, 0x00061A80, | |
| 71 | + AddressingMode7Bit, "\\_SB.PCI0.I2C0", | |
| 72 | + 0x00, ResourceConsumer) | |
| 73 | + }) | |
| 74 | + Method (_DSC, 0, NotSerialized) | |
| 75 | + { | |
| 76 | + Return (0x4) | |
| 77 | + } | |
| 78 | + } | |
| @@ -1400,4 +1400,30 @@ bool acpi_storage_d3(struct device *dev) · 1399 unmodified lines | ||
| 1400 | 1400 | } |
| 1401 | 1401 | EXPORT_SYMBOL_GPL(acpi_storage_d3); |
| 1402 | 1402 | |
| 1403 | +/** | |
| 1404 | + * acpi_dev_state_d0 - Tell if the device is in D0 power state | |
| 1405 | + * @dev: Physical device the ACPI power state of which to check | |
| 1406 | + * | |
| 1407 | + * On a system without ACPI, return true. On a system with ACPI, return true if | |
| 1408 | + * the current ACPI power state of the device is D0, or false otherwise. | |
| 1409 | + * | |
| 1410 | + * Note that the power state of a device is not well-defined after it has been | |
| 1411 | + * passed to acpi_device_set_power() and before that function returns, so it is | |
| 1412 | + * not valid to ask for the ACPI power state of the device in that time frame. | |
| 1413 | + * | |
| 1414 | + * This function is intended to be used in a driver's probe or remove | |
| 1415 | + * function. See Documentation/firmware-guide/acpi/low-power-probe.rst for | |
| 1416 | + * more information. | |
| 1417 | + */ | |
| 1418 | +bool acpi_dev_state_d0(struct device *dev) | |
| 1419 | +{ | |
| 1420 | + struct acpi_device *adev = ACPI_COMPANION(dev); | |
| 1421 | + | |
| 1422 | + if (!adev) | |
| 1423 | + return true; | |
| 1424 | + | |
| 1425 | + return adev->power.state == ACPI_STATE_D0; | |
| 1426 | +} | |
| 1427 | +EXPORT_SYMBOL_GPL(acpi_dev_state_d0); | |
| 1428 | + | |
| 1403 | 1429 | #endif /* CONFIG_PM */ |
| @@ -133,7 +133,7 @@ static unsigned int ec_storm_threshold __read_mostly = 8; · 132 unmodified lines | ||
| 133 | 133 | module_param(ec_storm_threshold, uint, 0644); |
| 134 | 134 | MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); |
| 135 | 135 | |
| 136 | −static bool ec_freeze_events __read_mostly = false; | |
| 136 | +static bool ec_freeze_events __read_mostly; | |
| 137 | 137 | module_param(ec_freeze_events, bool, 0644); |
| 138 | 138 | MODULE_PARM_DESC(ec_freeze_events, "Disabling event handling during suspend/resume"); |
| 139 | 139 | |
| @@ -177,7 +177,7 @@ struct acpi_ec *first_ec; · 37 unmodified lines | ||
| 177 | 177 | EXPORT_SYMBOL(first_ec); |
| 178 | 178 | |
| 179 | 179 | static struct acpi_ec *boot_ec; |
| 180 | −static bool boot_ec_is_ecdt = false; | |
| 180 | +static bool boot_ec_is_ecdt; | |
| 181 | 181 | static struct workqueue_struct *ec_wq; |
| 182 | 182 | static struct workqueue_struct *ec_query_wq; |
| 183 | 183 | |
| @@ -2152,6 +2152,13 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = { · 1968 unmodified lines | ||
| 2152 | 2152 | DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Yoga 3rd"), |
| 2153 | 2153 | }, |
| 2154 | 2154 | }, |
| 2155 | + { | |
| 2156 | + .ident = "HP ZHAN 66 Pro", | |
| 2157 | + .matches = { | |
| 2158 | + DMI_MATCH(DMI_SYS_VENDOR, "HP"), | |
| 2159 | + DMI_MATCH(DMI_PRODUCT_FAMILY, "103C_5336AN HP ZHAN 66 Pro"), | |
| 2160 | + }, | |
| 2161 | + }, | |
| 2155 | 2162 | { }, |
| 2156 | 2163 | }; |
| 2157 | 2164 | |
| @@ -211,31 +211,36 @@ static acpi_status intel_pmic_regs_handler(u32 function, · 210 unmodified lines | ||
| 211 | 211 | void *handler_context, void *region_context) |
| 212 | 212 | { |
| 213 | 213 | struct intel_pmic_opregion *opregion = region_context; |
| 214 | − int result = 0; | |
| 214 | + int result = -EINVAL; | |
| 215 | + | |
| 216 | + if (function == ACPI_WRITE) { | |
| 217 | + switch (address) { | |
| 218 | + case 0: | |
| 219 | + return AE_OK; | |
| 220 | + case 1: | |
| 221 | + opregion->ctx.addr |= (*value64 & 0xff) << 8; | |
| 222 | + return AE_OK; | |
| 223 | + case 2: | |
| 224 | + opregion->ctx.addr |= *value64 & 0xff; | |
| 225 | + return AE_OK; | |
| 226 | + case 3: | |
| 227 | + opregion->ctx.val = *value64 & 0xff; | |
| 228 | + return AE_OK; | |
| 229 | + case 4: | |
| 230 | + if (*value64) { | |
| 231 | + result = regmap_write(opregion->regmap, opregion->ctx.addr, | |
| 232 | + opregion->ctx.val); | |
| 233 | + } else { | |
| 234 | + result = regmap_read(opregion->regmap, opregion->ctx.addr, | |
| 235 | + &opregion->ctx.val); | |
| 236 | + } | |
| 237 | + opregion->ctx.addr = 0; | |
| 238 | + } | |
| 239 | + } | |
| 215 | 240 | |
| 216 | − switch (address) { | |
| 217 | − case 0: | |
| 218 | − return AE_OK; | |
| 219 | − case 1: | |
| 220 | − opregion->ctx.addr |= (*value64 & 0xff) << 8; | |
| 221 | − return AE_OK; | |
| 222 | − case 2: | |
| 223 | − opregion->ctx.addr |= *value64 & 0xff; | |
| 241 | + if (function == ACPI_READ && address == 3) { | |
| 242 | + *value64 = opregion->ctx.val; | |
| 224 | 243 | return AE_OK; |
| 225 | − case 3: | |
| 226 | − opregion->ctx.val = *value64 & 0xff; | |
| 227 | − return AE_OK; | |
| 228 | − case 4: | |
| 229 | − if (*value64) { | |
| 230 | − result = regmap_write(opregion->regmap, opregion->ctx.addr, | |
| 231 | − opregion->ctx.val); | |
| 232 | − } else { | |
| 233 | − result = regmap_read(opregion->regmap, opregion->ctx.addr, | |
| 234 | − &opregion->ctx.val); | |
| 235 | − if (result == 0) | |
| 236 | − *value64 = opregion->ctx.val; | |
| 237 | − } | |
| 238 | − memset(&opregion->ctx, 0x00, sizeof(opregion->ctx)); | |
| 239 | 244 | } |
| 240 | 245 | |
| 241 | 246 | if (result < 0) { |
| @@ -757,13 +757,11 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev) · 756 unmodified lines | ||
| 757 | 757 | |
| 758 | 758 | mutex_lock(&acpi_device_lock); |
| 759 | 759 | |
| 760 | − if (dev->wakeup.prepare_count > 1) { | |
| 761 | − dev->wakeup.prepare_count--; | |
| 760 | + /* Do nothing if wakeup power has not been enabled for this device. */ | |
| 761 | + if (dev->wakeup.prepare_count <= 0) | |
| 762 | 762 | goto out; |
| 763 | − } | |
| 764 | 763 | |
| 765 | − /* Do nothing if wakeup power has not been enabled for this device. */ | |
| 766 | − if (!dev->wakeup.prepare_count) | |
| 764 | + if (--dev->wakeup.prepare_count > 0) | |
| 767 | 765 | goto out; |
| 768 | 766 | |
| 769 | 767 | err = acpi_device_sleep_wake(dev, 0, 0, 0); |
| @@ -1017,6 +1017,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) · 1016 unmodified lines | ||
| 1017 | 1017 | |
| 1018 | 1018 | static void acpi_bus_get_power_flags(struct acpi_device *device) |
| 1019 | 1019 | { |
| 1020 | + unsigned long long dsc = ACPI_STATE_D0; | |
| 1020 | 1021 | u32 i; |
| 1021 | 1022 | |
| 1022 | 1023 | /* Presence of _PS0|_PR0 indicates 'power manageable' */ |
| @@ -1038,6 +1039,9 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) · 15 unmodified lines | ||
| 1038 | 1039 | if (acpi_has_method(device->handle, "_DSW")) |
| 1039 | 1040 | device->power.flags.dsw_present = 1; |
| 1040 | 1041 | |
| 1042 | + acpi_evaluate_integer(device->handle, "_DSC", NULL, &dsc); | |
| 1043 | + device->power.state_for_enumeration = dsc; | |
| 1044 | + | |
| 1041 | 1045 | /* |
| 1042 | 1046 | * Enumerate supported power management states |
| 1043 | 1047 | */ |
| @@ -115,7 +115,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 114 unmodified lines | ||
| 115 | 115 | */ |
| 116 | 116 | { |
| 117 | 117 | .callback = video_detect_force_vendor, |
| 118 | − .ident = "X360", | |
| 118 | + /* X360 */ | |
| 119 | 119 | .matches = { |
| 120 | 120 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 121 | 121 | DMI_MATCH(DMI_PRODUCT_NAME, "X360"), |
| @@ -124,7 +124,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 124 | 124 | }, |
| 125 | 125 | { |
| 126 | 126 | .callback = video_detect_force_vendor, |
| 127 | − .ident = "Asus UL30VT", | |
| 127 | + /* Asus UL30VT */ | |
| 128 | 128 | .matches = { |
| 129 | 129 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), |
| 130 | 130 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"), |
| @@ -132,7 +132,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 132 | 132 | }, |
| 133 | 133 | { |
| 134 | 134 | .callback = video_detect_force_vendor, |
| 135 | − .ident = "Asus UL30A", | |
| 135 | + /* Asus UL30A */ | |
| 136 | 136 | .matches = { |
| 137 | 137 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), |
| 138 | 138 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), |
| @@ -140,7 +140,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 140 | 140 | }, |
| 141 | 141 | { |
| 142 | 142 | .callback = video_detect_force_vendor, |
| 143 | − .ident = "GIGABYTE GB-BXBT-2807", | |
| 143 | + /* GIGABYTE GB-BXBT-2807 */ | |
| 144 | 144 | .matches = { |
| 145 | 145 | DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), |
| 146 | 146 | DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"), |
| @@ -148,12 +148,20 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 148 | 148 | }, |
| 149 | 149 | { |
| 150 | 150 | .callback = video_detect_force_vendor, |
| 151 | − .ident = "Sony VPCEH3U1E", | |
| 151 | + /* Sony VPCEH3U1E */ | |
| 152 | 152 | .matches = { |
| 153 | 153 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 154 | 154 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"), |
| 155 | 155 | }, |
| 156 | 156 | }, |
| 157 | + { | |
| 158 | + .callback = video_detect_force_vendor, | |
| 159 | + /* Xiaomi Mi Pad 2 */ | |
| 160 | + .matches = { | |
| 161 | + DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"), | |
| 162 | + DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), | |
| 163 | + }, | |
| 164 | + }, | |
| 157 | 165 | |
| 158 | 166 | /* |
| 159 | 167 | * These models have a working acpi_video backlight control, and using |
| @@ -164,7 +172,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 4 unmodified lines | ||
| 164 | 172 | */ |
| 165 | 173 | { |
| 166 | 174 | .callback = video_detect_force_video, |
| 167 | − .ident = "ThinkPad T420", | |
| 175 | + /* ThinkPad T420 */ | |
| 168 | 176 | .matches = { |
| 169 | 177 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 170 | 178 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"), |
| @@ -172,7 +180,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 172 | 180 | }, |
| 173 | 181 | { |
| 174 | 182 | .callback = video_detect_force_video, |
| 175 | − .ident = "ThinkPad T520", | |
| 183 | + /* ThinkPad T520 */ | |
| 176 | 184 | .matches = { |
| 177 | 185 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 178 | 186 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"), |
| @@ -180,7 +188,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 180 | 188 | }, |
| 181 | 189 | { |
| 182 | 190 | .callback = video_detect_force_video, |
| 183 | − .ident = "ThinkPad X201s", | |
| 191 | + /* ThinkPad X201s */ | |
| 184 | 192 | .matches = { |
| 185 | 193 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 186 | 194 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"), |
| @@ -188,7 +196,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 188 | 196 | }, |
| 189 | 197 | { |
| 190 | 198 | .callback = video_detect_force_video, |
| 191 | − .ident = "ThinkPad X201T", | |
| 199 | + /* ThinkPad X201T */ | |
| 192 | 200 | .matches = { |
| 193 | 201 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 194 | 202 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"), |
| @@ -199,7 +207,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 4 unmodified lines | ||
| 199 | 207 | { |
| 200 | 208 | /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */ |
| 201 | 209 | .callback = video_detect_force_video, |
| 202 | − .ident = "HP ENVY 15 Notebook", | |
| 210 | + /* HP ENVY 15 Notebook */ | |
| 203 | 211 | .matches = { |
| 204 | 212 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 205 | 213 | DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"), |
| @@ -207,7 +215,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 207 | 215 | }, |
| 208 | 216 | { |
| 209 | 217 | .callback = video_detect_force_video, |
| 210 | − .ident = "SAMSUNG 870Z5E/880Z5E/680Z5E", | |
| 218 | + /* SAMSUNG 870Z5E/880Z5E/680Z5E */ | |
| 211 | 219 | .matches = { |
| 212 | 220 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 213 | 221 | DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"), |
| @@ -215,7 +223,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 215 | 223 | }, |
| 216 | 224 | { |
| 217 | 225 | .callback = video_detect_force_video, |
| 218 | − .ident = "SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V", | |
| 226 | + /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */ | |
| 219 | 227 | .matches = { |
| 220 | 228 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 221 | 229 | DMI_MATCH(DMI_PRODUCT_NAME, |
| @@ -225,7 +233,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines | ||
| 225 | 233 | { |
| 226 | 234 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */ |
| 227 | 235 | .callback = video_detect_force_video, |
| 228 | − .ident = "SAMSUNG 3570R/370R/470R/450R/510R/4450RV", | |
| 236 | + /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */ | |
| 229 | 237 | .matches = { |
| 230 | 238 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 231 | 239 | DMI_MATCH(DMI_PRODUCT_NAME, |
| @@ -235,7 +243,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines | ||
| 235 | 243 | { |
| 236 | 244 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */ |
| 237 | 245 | .callback = video_detect_force_video, |
| 238 | − .ident = "SAMSUNG 670Z5E", | |
| 246 | + /* SAMSUNG 670Z5E */ | |
| 239 | 247 | .matches = { |
| 240 | 248 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 241 | 249 | DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"), |
| @@ -244,7 +252,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 244 | 252 | { |
| 245 | 253 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */ |
| 246 | 254 | .callback = video_detect_force_video, |
| 247 | − .ident = "SAMSUNG 730U3E/740U3E", | |
| 255 | + /* SAMSUNG 730U3E/740U3E */ | |
| 248 | 256 | .matches = { |
| 249 | 257 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 250 | 258 | DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"), |
| @@ -253,7 +261,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 253 | 261 | { |
| 254 | 262 | /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */ |
| 255 | 263 | .callback = video_detect_force_video, |
| 256 | − .ident = "SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D", | |
| 264 | + /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */ | |
| 257 | 265 | .matches = { |
| 258 | 266 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 259 | 267 | DMI_MATCH(DMI_PRODUCT_NAME, |
| @@ -263,7 +271,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines | ||
| 263 | 271 | { |
| 264 | 272 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */ |
| 265 | 273 | .callback = video_detect_force_video, |
| 266 | − .ident = "Dell XPS14 L421X", | |
| 274 | + /* Dell XPS14 L421X */ | |
| 267 | 275 | .matches = { |
| 268 | 276 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 269 | 277 | DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"), |
| @@ -272,7 +280,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 272 | 280 | { |
| 273 | 281 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */ |
| 274 | 282 | .callback = video_detect_force_video, |
| 275 | − .ident = "Dell XPS15 L521X", | |
| 283 | + /* Dell XPS15 L521X */ | |
| 276 | 284 | .matches = { |
| 277 | 285 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 278 | 286 | DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"), |
| @@ -281,7 +289,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 281 | 289 | { |
| 282 | 290 | /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */ |
| 283 | 291 | .callback = video_detect_force_video, |
| 284 | − .ident = "SAMSUNG 530U4E/540U4E", | |
| 292 | + /* SAMSUNG 530U4E/540U4E */ | |
| 285 | 293 | .matches = { |
| 286 | 294 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 287 | 295 | DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"), |
| @@ -290,7 +298,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 290 | 298 | /* https://bugs.launchpad.net/bugs/1894667 */ |
| 291 | 299 | { |
| 292 | 300 | .callback = video_detect_force_video, |
| 293 | − .ident = "HP 635 Notebook", | |
| 301 | + /* HP 635 Notebook */ | |
| 294 | 302 | .matches = { |
| 295 | 303 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 296 | 304 | DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"), |
| @@ -301,7 +309,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 4 unmodified lines | ||
| 301 | 309 | { |
| 302 | 310 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */ |
| 303 | 311 | .callback = video_detect_force_native, |
| 304 | − .ident = "Lenovo Ideapad S405", | |
| 312 | + /* Lenovo Ideapad S405 */ | |
| 305 | 313 | .matches = { |
| 306 | 314 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 307 | 315 | DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"), |
| @@ -310,7 +318,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 310 | 318 | { |
| 311 | 319 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */ |
| 312 | 320 | .callback = video_detect_force_native, |
| 313 | − .ident = "Lenovo Ideapad Z570", | |
| 321 | + /* Lenovo Ideapad Z570 */ | |
| 314 | 322 | .matches = { |
| 315 | 323 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 316 | 324 | DMI_MATCH(DMI_PRODUCT_NAME, "102434U"), |
| @@ -318,7 +326,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 318 | 326 | }, |
| 319 | 327 | { |
| 320 | 328 | .callback = video_detect_force_native, |
| 321 | − .ident = "Lenovo E41-25", | |
| 329 | + /* Lenovo E41-25 */ | |
| 322 | 330 | .matches = { |
| 323 | 331 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 324 | 332 | DMI_MATCH(DMI_PRODUCT_NAME, "81FS"), |
| @@ -326,7 +334,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 326 | 334 | }, |
| 327 | 335 | { |
| 328 | 336 | .callback = video_detect_force_native, |
| 329 | − .ident = "Lenovo E41-45", | |
| 337 | + /* Lenovo E41-45 */ | |
| 330 | 338 | .matches = { |
| 331 | 339 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 332 | 340 | DMI_MATCH(DMI_PRODUCT_NAME, "82BK"), |
| @@ -335,7 +343,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 335 | 343 | { |
| 336 | 344 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */ |
| 337 | 345 | .callback = video_detect_force_native, |
| 338 | − .ident = "Apple MacBook Pro 12,1", | |
| 346 | + /* Apple MacBook Pro 12,1 */ | |
| 339 | 347 | .matches = { |
| 340 | 348 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), |
| 341 | 349 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"), |
| @@ -343,7 +351,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 343 | 351 | }, |
| 344 | 352 | { |
| 345 | 353 | .callback = video_detect_force_native, |
| 346 | − .ident = "Dell Vostro V131", | |
| 354 | + /* Dell Vostro V131 */ | |
| 347 | 355 | .matches = { |
| 348 | 356 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 349 | 357 | DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"), |
| @@ -352,7 +360,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 352 | 360 | { |
| 353 | 361 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */ |
| 354 | 362 | .callback = video_detect_force_native, |
| 355 | − .ident = "Dell XPS 17 L702X", | |
| 363 | + /* Dell XPS 17 L702X */ | |
| 356 | 364 | .matches = { |
| 357 | 365 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 358 | 366 | DMI_MATCH(DMI_PRODUCT_NAME, "Dell System XPS L702X"), |
| @@ -360,7 +368,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 360 | 368 | }, |
| 361 | 369 | { |
| 362 | 370 | .callback = video_detect_force_native, |
| 363 | − .ident = "Dell Precision 7510", | |
| 371 | + /* Dell Precision 7510 */ | |
| 364 | 372 | .matches = { |
| 365 | 373 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 366 | 374 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), |
| @@ -368,7 +376,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 368 | 376 | }, |
| 369 | 377 | { |
| 370 | 378 | .callback = video_detect_force_native, |
| 371 | − .ident = "Acer Aspire 5738z", | |
| 379 | + /* Acer Aspire 5738z */ | |
| 372 | 380 | .matches = { |
| 373 | 381 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 374 | 382 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"), |
| @@ -378,7 +386,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines | ||
| 378 | 386 | { |
| 379 | 387 | /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */ |
| 380 | 388 | .callback = video_detect_force_native, |
| 381 | − .ident = "Acer TravelMate 5735Z", | |
| 389 | + /* Acer TravelMate 5735Z */ | |
| 382 | 390 | .matches = { |
| 383 | 391 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 384 | 392 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"), |
| @@ -387,7 +395,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines | ||
| 387 | 395 | }, |
| 388 | 396 | { |
| 389 | 397 | .callback = video_detect_force_native, |
| 390 | − .ident = "ASUSTeK COMPUTER INC. GA401", | |
| 398 | + /* ASUSTeK COMPUTER INC. GA401 */ | |
| 391 | 399 | .matches = { |
| 392 | 400 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 393 | 401 | DMI_MATCH(DMI_PRODUCT_NAME, "GA401"), |
| @@ -395,7 +403,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 395 | 403 | }, |
| 396 | 404 | { |
| 397 | 405 | .callback = video_detect_force_native, |
| 398 | − .ident = "ASUSTeK COMPUTER INC. GA502", | |
| 406 | + /* ASUSTeK COMPUTER INC. GA502 */ | |
| 399 | 407 | .matches = { |
| 400 | 408 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 401 | 409 | DMI_MATCH(DMI_PRODUCT_NAME, "GA502"), |
| @@ -403,7 +411,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 403 | 411 | }, |
| 404 | 412 | { |
| 405 | 413 | .callback = video_detect_force_native, |
| 406 | − .ident = "ASUSTeK COMPUTER INC. GA503", | |
| 414 | + /* ASUSTeK COMPUTER INC. GA503 */ | |
| 407 | 415 | .matches = { |
| 408 | 416 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 409 | 417 | DMI_MATCH(DMI_PRODUCT_NAME, "GA503"), |
| @@ -416,7 +424,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 6 unmodified lines | ||
| 416 | 424 | */ |
| 417 | 425 | { |
| 418 | 426 | .callback = video_detect_force_none, |
| 419 | − .ident = "Dell OptiPlex 9020M", | |
| 427 | + /* Dell OptiPlex 9020M */ | |
| 420 | 428 | .matches = { |
| 421 | 429 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 422 | 430 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), |
| @@ -424,7 +432,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line | ||
| 424 | 432 | }, |
| 425 | 433 | { |
| 426 | 434 | .callback = video_detect_force_none, |
| 427 | − .ident = "MSI MS-7721", | |
| 435 | + /* MSI MS-7721 */ | |
| 428 | 436 | .matches = { |
| 429 | 437 | DMI_MATCH(DMI_SYS_VENDOR, "MSI"), |
| 430 | 438 | DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"), |
| @@ -522,6 +522,16 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, · 521 unmodified lines | ||
| 522 | 522 | } |
| 523 | 523 | EXPORT_SYMBOL_GPL(i2c_acpi_new_device); |
| 524 | 524 | |
| 525 | +bool i2c_acpi_waive_d0_probe(struct device *dev) | |
| 526 | +{ | |
| 527 | + struct i2c_driver *driver = to_i2c_driver(dev->driver); | |
| 528 | + struct acpi_device *adev = ACPI_COMPANION(dev); | |
| 529 | + | |
| 530 | + return driver->flags & I2C_DRV_ACPI_WAIVE_D0_PROBE && | |
| 531 | + adev && adev->power.state_for_enumeration >= adev->power.state; | |
| 532 | +} | |
| 533 | +EXPORT_SYMBOL_GPL(i2c_acpi_waive_d0_probe); | |
| 534 | + | |
| 525 | 535 | #ifdef CONFIG_ACPI_I2C_OPREGION |
| 526 | 536 | static int acpi_gsb_i2c_read_bytes(struct i2c_client *client, |
| 527 | 537 | u8 cmd, u8 *data, u8 data_len) |
| @@ -551,7 +551,8 @@ static int i2c_device_probe(struct device *dev) · 550 unmodified lines | ||
| 551 | 551 | if (status < 0) |
| 552 | 552 | goto err_clear_wakeup_irq; |
| 553 | 553 | |
| 554 | − status = dev_pm_domain_attach(&client->dev, true); | |
| 554 | + status = dev_pm_domain_attach(&client->dev, | |
| 555 | + !i2c_acpi_waive_d0_probe(dev)); | |
| 555 | 556 | if (status) |
| 556 | 557 | goto err_clear_wakeup_irq; |
| 557 | 558 | |
| @@ -590,7 +591,7 @@ static int i2c_device_probe(struct device *dev) · 32 unmodified lines | ||
| 590 | 591 | err_release_driver_resources: |
| 591 | 592 | devres_release_group(&client->dev, client->devres_group_id); |
| 592 | 593 | err_detach_pm_domain: |
| 593 | − dev_pm_domain_detach(&client->dev, true); | |
| 594 | + dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev)); | |
| 594 | 595 | err_clear_wakeup_irq: |
| 595 | 596 | dev_pm_clear_wake_irq(&client->dev); |
| 596 | 597 | device_init_wakeup(&client->dev, false); |
| @@ -621,7 +622,7 @@ static void i2c_device_remove(struct device *dev) · 24 unmodified lines | ||
| 621 | 622 | |
| 622 | 623 | devres_release_group(&client->dev, client->devres_group_id); |
| 623 | 624 | |
| 624 | − dev_pm_domain_detach(&client->dev, true); | |
| 625 | + dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev)); | |
| 625 | 626 | if (!pm_runtime_status_suspended(&client->dev) && adap->bus_regulator) |
| 626 | 627 | regulator_disable(adap->bus_regulator); |
| 627 | 628 | |
| @@ -140,6 +140,8 @@ struct imx319 { · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | /* Streaming on/off */ |
| 142 | 142 | bool streaming; |
| 143 | + /* True if the device has been identified */ | |
| 144 | + bool identified; | |
| 143 | 145 | }; |
| 144 | 146 | |
| 145 | 147 | static const struct imx319_reg imx319_global_regs[] = { |
| @@ -2084,6 +2086,31 @@ imx319_set_pad_format(struct v4l2_subdev *sd, · 1938 unmodified lines | ||
| 2084 | 2086 | return 0; |
| 2085 | 2087 | } |
| 2086 | 2088 | |
| 2089 | +/* Verify chip ID */ | |
| 2090 | +static int imx319_identify_module(struct imx319 *imx319) | |
| 2091 | +{ | |
| 2092 | + struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); | |
| 2093 | + int ret; | |
| 2094 | + u32 val; | |
| 2095 | + | |
| 2096 | + if (imx319->identified) | |
| 2097 | + return 0; | |
| 2098 | + | |
| 2099 | + ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val); | |
| 2100 | + if (ret) | |
| 2101 | + return ret; | |
| 2102 | + | |
| 2103 | + if (val != IMX319_CHIP_ID) { | |
| 2104 | + dev_err(&client->dev, "chip id mismatch: %x!=%x", | |
| 2105 | + IMX319_CHIP_ID, val); | |
| 2106 | + return -EIO; | |
| 2107 | + } | |
| 2108 | + | |
| 2109 | + imx319->identified = true; | |
| 2110 | + | |
| 2111 | + return 0; | |
| 2112 | +} | |
| 2113 | + | |
| 2087 | 2114 | /* Start streaming */ |
| 2088 | 2115 | static int imx319_start_streaming(struct imx319 *imx319) |
| 2089 | 2116 | { |
| @@ -2091,6 +2118,10 @@ static int imx319_start_streaming(struct imx319 *imx319) · 1 unmodified line | ||
| 2091 | 2118 | const struct imx319_reg_list *reg_list; |
| 2092 | 2119 | int ret; |
| 2093 | 2120 | |
| 2121 | + ret = imx319_identify_module(imx319); | |
| 2122 | + if (ret) | |
| 2123 | + return ret; | |
| 2124 | + | |
| 2094 | 2125 | /* Global Setting */ |
| 2095 | 2126 | reg_list = &imx319_global_setting; |
| 2096 | 2127 | ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs); |
| @@ -2206,26 +2237,6 @@ error: · 109 unmodified lines | ||
| 2206 | 2237 | return ret; |
| 2207 | 2238 | } |
| 2208 | 2239 | |
| 2209 | −/* Verify chip ID */ | |
| 2210 | −static int imx319_identify_module(struct imx319 *imx319) | |
| 2211 | −{ | |
| 2212 | − struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); | |
| 2213 | − int ret; | |
| 2214 | − u32 val; | |
| 2215 | − | |
| 2216 | − ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val); | |
| 2217 | − if (ret) | |
| 2218 | − return ret; | |
| 2219 | − | |
| 2220 | − if (val != IMX319_CHIP_ID) { | |
| 2221 | − dev_err(&client->dev, "chip id mismatch: %x!=%x", | |
| 2222 | − IMX319_CHIP_ID, val); | |
| 2223 | − return -EIO; | |
| 2224 | − } | |
| 2225 | − | |
| 2226 | − return 0; | |
| 2227 | −} | |
| 2228 | − | |
| 2229 | 2240 | static const struct v4l2_subdev_core_ops imx319_subdev_core_ops = { |
| 2230 | 2241 | .subscribe_event = v4l2_ctrl_subdev_subscribe_event, |
| 2231 | 2242 | .unsubscribe_event = v4l2_event_subdev_unsubscribe, |
| @@ -2420,6 +2431,7 @@ out_err: · 188 unmodified lines | ||
| 2420 | 2431 | static int imx319_probe(struct i2c_client *client) |
| 2421 | 2432 | { |
| 2422 | 2433 | struct imx319 *imx319; |
| 2434 | + bool full_power; | |
| 2423 | 2435 | int ret; |
| 2424 | 2436 | u32 i; |
| 2425 | 2437 | |
| @@ -2432,11 +2444,14 @@ static int imx319_probe(struct i2c_client *client) · 6 unmodified lines | ||
| 2432 | 2444 | /* Initialize subdev */ |
| 2433 | 2445 | v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops); |
| 2434 | 2446 | |
| 2435 | − /* Check module identity */ | |
| 2436 | − ret = imx319_identify_module(imx319); | |
| 2437 | − if (ret) { | |
| 2438 | − dev_err(&client->dev, "failed to find sensor: %d", ret); | |
| 2439 | − goto error_probe; | |
| 2447 | + full_power = acpi_dev_state_d0(&client->dev); | |
| 2448 | + if (full_power) { | |
| 2449 | + /* Check module identity */ | |
| 2450 | + ret = imx319_identify_module(imx319); | |
| 2451 | + if (ret) { | |
| 2452 | + dev_err(&client->dev, "failed to find sensor: %d", ret); | |
| 2453 | + goto error_probe; | |
| 2454 | + } | |
| 2440 | 2455 | } |
| 2441 | 2456 | |
| 2442 | 2457 | imx319->hwcfg = imx319_get_hwcfg(&client->dev); |
| @@ -2488,11 +2503,9 @@ static int imx319_probe(struct i2c_client *client) · 45 unmodified lines | ||
| 2488 | 2503 | if (ret < 0) |
| 2489 | 2504 | goto error_media_entity; |
| 2490 | 2505 | |
| 2491 | − /* | |
| 2492 | − * Device is already turned on by i2c-core with ACPI domain PM. | |
| 2493 | − * Enable runtime PM and turn off the device. | |
| 2494 | − */ | |
| 2495 | − pm_runtime_set_active(&client->dev); | |
| 2506 | + /* Set the device's state to active if it's in D0 state. */ | |
| 2507 | + if (full_power) | |
| 2508 | + pm_runtime_set_active(&client->dev); | |
| 2496 | 2509 | pm_runtime_enable(&client->dev); |
| 2497 | 2510 | pm_runtime_idle(&client->dev); |
| 2498 | 2511 | |
| @@ -2545,6 +2558,7 @@ static struct i2c_driver imx319_i2c_driver = { · 46 unmodified lines | ||
| 2545 | 2558 | }, |
| 2546 | 2559 | .probe_new = imx319_probe, |
| 2547 | 2560 | .remove = imx319_remove, |
| 2561 | + .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE, | |
| 2548 | 2562 | }; |
| 2549 | 2563 | module_i2c_driver(imx319_i2c_driver); |
| 2550 | 2564 | |
| @@ -595,6 +595,7 @@ static int at24_probe(struct i2c_client *client) · 594 unmodified lines | ||
| 595 | 595 | bool i2c_fn_i2c, i2c_fn_block; |
| 596 | 596 | unsigned int i, num_addresses; |
| 597 | 597 | struct at24_data *at24; |
| 598 | + bool full_power; | |
| 598 | 599 | struct regmap *regmap; |
| 599 | 600 | bool writable; |
| 600 | 601 | u8 test_byte; |
| @@ -747,14 +748,16 @@ static int at24_probe(struct i2c_client *client) · 146 unmodified lines | ||
| 747 | 748 | |
| 748 | 749 | i2c_set_clientdata(client, at24); |
| 749 | 750 | |
| 750 | − err = regulator_enable(at24->vcc_reg); | |
| 751 | − if (err) { | |
| 752 | − dev_err(dev, "Failed to enable vcc regulator\n"); | |
| 753 | − return err; | |
| 754 | − } | |
| 751 | + full_power = acpi_dev_state_d0(&client->dev); | |
| 752 | + if (full_power) { | |
| 753 | + err = regulator_enable(at24->vcc_reg); | |
| 754 | + if (err) { | |
| 755 | + dev_err(dev, "Failed to enable vcc regulator\n"); | |
| 756 | + return err; | |
| 757 | + } | |
| 755 | 758 | |
| 756 | − /* enable runtime pm */ | |
| 757 | − pm_runtime_set_active(dev); | |
| 759 | + pm_runtime_set_active(dev); | |
| 760 | + } | |
| 758 | 761 | pm_runtime_enable(dev); |
| 759 | 762 | |
| 760 | 763 | at24->nvmem = devm_nvmem_register(dev, &nvmem_config); |
| @@ -766,15 +769,18 @@ static int at24_probe(struct i2c_client *client) · 5 unmodified lines | ||
| 766 | 769 | } |
| 767 | 770 | |
| 768 | 771 | /* |
| 769 | − * Perform a one-byte test read to verify that the | |
| 770 | − * chip is functional. | |
| 772 | + * Perform a one-byte test read to verify that the chip is functional, | |
| 773 | + * unless powering on the device is to be avoided during probe (i.e. | |
| 774 | + * it's powered off right now). | |
| 771 | 775 | */ |
| 772 | − err = at24_read(at24, 0, &test_byte, 1); | |
| 773 | − if (err) { | |
| 774 | − pm_runtime_disable(dev); | |
| 775 | − if (!pm_runtime_status_suspended(dev)) | |
| 776 | − regulator_disable(at24->vcc_reg); | |
| 777 | − return -ENODEV; | |
| 776 | + if (full_power) { | |
| 777 | + err = at24_read(at24, 0, &test_byte, 1); | |
| 778 | + if (err) { | |
| 779 | + pm_runtime_disable(dev); | |
| 780 | + if (!pm_runtime_status_suspended(dev)) | |
| 781 | + regulator_disable(at24->vcc_reg); | |
| 782 | + return -ENODEV; | |
| 783 | + } | |
| 778 | 784 | } |
| 779 | 785 | |
| 780 | 786 | pm_runtime_idle(dev); |
| @@ -794,9 +800,11 @@ static int at24_remove(struct i2c_client *client) · 13 unmodified lines | ||
| 794 | 800 | struct at24_data *at24 = i2c_get_clientdata(client); |
| 795 | 801 | |
| 796 | 802 | pm_runtime_disable(&client->dev); |
| 797 | − if (!pm_runtime_status_suspended(&client->dev)) | |
| 798 | − regulator_disable(at24->vcc_reg); | |
| 799 | − pm_runtime_set_suspended(&client->dev); | |
| 803 | + if (acpi_dev_state_d0(&client->dev)) { | |
| 804 | + if (!pm_runtime_status_suspended(&client->dev)) | |
| 805 | + regulator_disable(at24->vcc_reg); | |
| 806 | + pm_runtime_set_suspended(&client->dev); | |
| 807 | + } | |
| 800 | 808 | |
| 801 | 809 | return 0; |
| 802 | 810 | } |
| @@ -833,6 +841,7 @@ static struct i2c_driver at24_driver = { · 30 unmodified lines | ||
| 833 | 841 | .probe_new = at24_probe, |
| 834 | 842 | .remove = at24_remove, |
| 835 | 843 | .id_table = at24_ids, |
| 844 | + .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE, | |
| 836 | 845 | }; |
| 837 | 846 | |
| 838 | 847 | static int __init at24_init(void) |
| @@ -278,6 +278,7 @@ struct acpi_device_power { · 277 unmodified lines | ||
| 278 | 278 | int state; /* Current state */ |
| 279 | 279 | struct acpi_device_power_flags flags; |
| 280 | 280 | struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */ |
| 281 | + u8 state_for_enumeration; /* Deepest power state for enumeration */ | |
| 281 | 282 | }; |
| 282 | 283 | |
| 283 | 284 | struct acpi_dep_data { |
| @@ -10,25 +10,12 @@ · 9 unmodified lines | ||
| 10 | 10 | #ifndef __ACGCC_H__ |
| 11 | 11 | #define __ACGCC_H__ |
| 12 | 12 | |
| 13 | −/* | |
| 14 | − * Use compiler specific <stdarg.h> is a good practice for even when | |
| 15 | − * -nostdinc is specified (i.e., ACPI_USE_STANDARD_HEADERS undefined. | |
| 16 | − */ | |
| 17 | 13 | #ifndef va_arg |
| 18 | −#ifdef ACPI_USE_BUILTIN_STDARG | |
| 19 | −typedef __builtin_va_list va_list; | |
| 20 | −#define va_start(v, l) __builtin_va_start(v, l) | |
| 21 | −#define va_end(v) __builtin_va_end(v) | |
| 22 | −#define va_arg(v, l) __builtin_va_arg(v, l) | |
| 23 | −#define va_copy(d, s) __builtin_va_copy(d, s) | |
| 24 | −#else | |
| 25 | 14 | #ifdef __KERNEL__ |
| 26 | 15 | #include <linux/stdarg.h> |
| 27 | 16 | #else |
| 28 | −/* Used to build acpi tools */ | |
| 29 | 17 | #include <stdarg.h> |
| 30 | 18 | #endif /* __KERNEL__ */ |
| 31 | −#endif /* ACPI_USE_BUILTIN_STDARG */ | |
| 32 | 19 | #endif /* ! va_arg */ |
| 33 | 20 | |
| 34 | 21 | #define ACPI_INLINE __inline__ |
| @@ -1014,6 +1014,7 @@ int acpi_subsys_runtime_suspend(struct device *dev); · 1013 unmodified lines | ||
| 1014 | 1014 | int acpi_subsys_runtime_resume(struct device *dev); |
| 1015 | 1015 | int acpi_dev_pm_attach(struct device *dev, bool power_on); |
| 1016 | 1016 | bool acpi_storage_d3(struct device *dev); |
| 1017 | +bool acpi_dev_state_d0(struct device *dev); | |
| 1017 | 1018 | #else |
| 1018 | 1019 | static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; } |
| 1019 | 1020 | static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; } |
| @@ -1025,6 +1026,10 @@ static inline bool acpi_storage_d3(struct device *dev) · 5 unmodified lines | ||
| 1025 | 1026 | { |
| 1026 | 1027 | return false; |
| 1027 | 1028 | } |
| 1029 | +static inline bool acpi_dev_state_d0(struct device *dev) | |
| 1030 | +{ | |
| 1031 | + return true; | |
| 1032 | +} | |
| 1028 | 1033 | #endif |
| 1029 | 1034 | |
| 1030 | 1035 | #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #define _LINUX_I2C_H |
| 12 | 12 | |
| 13 | 13 | #include <linux/acpi.h> /* for acpi_handle */ |
| 14 | +#include <linux/bits.h> | |
| 14 | 15 | #include <linux/mod_devicetable.h> |
| 15 | 16 | #include <linux/device.h> /* for struct device */ |
| 16 | 17 | #include <linux/sched.h> /* for completion */ |
| @@ -222,6 +223,15 @@ enum i2c_alert_protocol { · 205 unmodified lines | ||
| 222 | 223 | I2C_PROTOCOL_SMBUS_HOST_NOTIFY, |
| 223 | 224 | }; |
| 224 | 225 | |
| 226 | +/** | |
| 227 | + * enum i2c_driver_flags - Flags for an I2C device driver | |
| 228 | + * | |
| 229 | + * @I2C_DRV_ACPI_WAIVE_D0_PROBE: Don't put the device in D0 state for probe | |
| 230 | + */ | |
| 231 | +enum i2c_driver_flags { | |
| 232 | + I2C_DRV_ACPI_WAIVE_D0_PROBE = BIT(0), | |
| 233 | +}; | |
| 234 | + | |
| 225 | 235 | /** |
| 226 | 236 | * struct i2c_driver - represent an I2C device driver |
| 227 | 237 | * @class: What kind of i2c device we instantiate (for detect) |
| @@ -236,6 +246,7 @@ enum i2c_alert_protocol { · 8 unmodified lines | ||
| 236 | 246 | * @detect: Callback for device detection |
| 237 | 247 | * @address_list: The I2C addresses to probe (for detect) |
| 238 | 248 | * @clients: List of detected clients we created (for i2c-core use only) |
| 249 | + * @flags: A bitmask of flags defined in &enum i2c_driver_flags | |
| 239 | 250 | * |
| 240 | 251 | * The driver.owner field should be set to the module owner of this driver. |
| 241 | 252 | * The driver.name field should be set to the name of this driver. |
| @@ -294,6 +305,8 @@ struct i2c_driver { · 52 unmodified lines | ||
| 294 | 305 | int (*detect)(struct i2c_client *client, struct i2c_board_info *info); |
| 295 | 306 | const unsigned short *address_list; |
| 296 | 307 | struct list_head clients; |
| 308 | + | |
| 309 | + u32 flags; | |
| 297 | 310 | }; |
| 298 | 311 | #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) |
| 299 | 312 | |
| @@ -1015,6 +1028,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev); · 715 unmodified lines | ||
| 1015 | 1028 | struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, |
| 1016 | 1029 | struct i2c_board_info *info); |
| 1017 | 1030 | struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle); |
| 1031 | +bool i2c_acpi_waive_d0_probe(struct device *dev); | |
| 1018 | 1032 | #else |
| 1019 | 1033 | static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, |
| 1020 | 1034 | struct acpi_resource_i2c_serialbus **i2c) |
| @@ -1038,6 +1052,10 @@ static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle ha · 17 unmodified lines | ||
| 1038 | 1052 | { |
| 1039 | 1053 | return NULL; |
| 1040 | 1054 | } |
| 1055 | +static inline bool i2c_acpi_waive_d0_probe(struct device *dev) | |
| 1056 | +{ | |
| 1057 | + return false; | |
| 1058 | +} | |
| 1041 | 1059 | #endif /* CONFIG_ACPI */ |
| 1042 | 1060 | |
| 1043 | 1061 | #endif /* _LINUX_I2C_H */ |