History

Merge tag 'acpi-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

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

Linus Torvalds committed 5 years ago

Commit 285fc3d2 parents e68a7d3 314c6e216 files · +301 −129Browse files

Unified · Split

16 files
  1. Documentation/firmware-guide/acpi/index.rst +1 −0
  2. Documentation/firmware-guide/acpi/non-d0-probe.rst +78 −0
  3. drivers/acpi/device_pm.c +26 −0
  4. drivers/acpi/ec.c +9 −2
  5. drivers/acpi/pmic/intel_pmic.c +28 −23
  6. drivers/acpi/power.c +3 −5
  7. drivers/acpi/scan.c +4 −0
  8. drivers/acpi/video_detect.c +43 −35
  9. drivers/i2c/i2c-core-acpi.c +10 −0
  10. drivers/i2c/i2c-core-base.c +4 −3
  11. drivers/media/i2c/imx319.c +44 −30
  12. drivers/misc/eeprom/at24.c +27 −18
  13. include/acpi/acpi_bus.h +1 −0
  14. include/acpi/platform/acgcc.h +0 −13
  15. include/linux/acpi.h +5 −0
  16. include/linux/i2c.h +18 −0
Documentation/firmware-guide/acpi/index.rst+1−0
@@ -26,5 +26,6 @@ ACPI Support · 25 unmodified lines
2626 acpi-lid
2727 lpit
2828 video_extension
29+ non-d0-probe
2930 extcon-intel-int3496
3031 intel-pmc-mux
Documentation/firmware-guide/acpi/non-d0-probe.rst+78−0
@@ -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+ }
drivers/acpi/device_pm.c+26−0
@@ -1400,4 +1400,30 @@ bool acpi_storage_d3(struct device *dev) · 1399 unmodified lines
14001400 }
14011401 EXPORT_SYMBOL_GPL(acpi_storage_d3);
14021402
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+
14031429 #endif /* CONFIG_PM */
drivers/acpi/ec.c+9−2
@@ -133,7 +133,7 @@ static unsigned int ec_storm_threshold __read_mostly = 8; · 132 unmodified lines
133133 module_param(ec_storm_threshold, uint, 0644);
134134 MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm");
135135
136−static bool ec_freeze_events __read_mostly = false;
136+static bool ec_freeze_events __read_mostly;
137137 module_param(ec_freeze_events, bool, 0644);
138138 MODULE_PARM_DESC(ec_freeze_events, "Disabling event handling during suspend/resume");
139139
@@ -177,7 +177,7 @@ struct acpi_ec *first_ec; · 37 unmodified lines
177177 EXPORT_SYMBOL(first_ec);
178178
179179 static struct acpi_ec *boot_ec;
180−static bool boot_ec_is_ecdt = false;
180+static bool boot_ec_is_ecdt;
181181 static struct workqueue_struct *ec_wq;
182182 static struct workqueue_struct *ec_query_wq;
183183
@@ -2152,6 +2152,13 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = { · 1968 unmodified lines
21522152 DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Yoga 3rd"),
21532153 },
21542154 },
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+ },
21552162 { },
21562163 };
21572164
drivers/acpi/pmic/intel_pmic.c+28−23
@@ -211,31 +211,36 @@ static acpi_status intel_pmic_regs_handler(u32 function, · 210 unmodified lines
211211 void *handler_context, void *region_context)
212212 {
213213 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+ }
215240
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;
224243 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));
239244 }
240245
241246 if (result < 0) {
drivers/acpi/power.c+3−5
@@ -757,13 +757,11 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev) · 756 unmodified lines
757757
758758 mutex_lock(&acpi_device_lock);
759759
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)
762762 goto out;
763− }
764763
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)
767765 goto out;
768766
769767 err = acpi_device_sleep_wake(dev, 0, 0, 0);
drivers/acpi/scan.c+4−0
@@ -1017,6 +1017,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) · 1016 unmodified lines
10171017
10181018 static void acpi_bus_get_power_flags(struct acpi_device *device)
10191019 {
1020+ unsigned long long dsc = ACPI_STATE_D0;
10201021 u32 i;
10211022
10221023 /* 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
10381039 if (acpi_has_method(device->handle, "_DSW"))
10391040 device->power.flags.dsw_present = 1;
10401041
1042+ acpi_evaluate_integer(device->handle, "_DSC", NULL, &dsc);
1043+ device->power.state_for_enumeration = dsc;
1044+
10411045 /*
10421046 * Enumerate supported power management states
10431047 */
drivers/acpi/video_detect.c+43−35
@@ -115,7 +115,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 114 unmodified lines
115115 */
116116 {
117117 .callback = video_detect_force_vendor,
118− .ident = "X360",
118+ /* X360 */
119119 .matches = {
120120 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
121121 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
@@ -124,7 +124,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
124124 },
125125 {
126126 .callback = video_detect_force_vendor,
127− .ident = "Asus UL30VT",
127+ /* Asus UL30VT */
128128 .matches = {
129129 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
130130 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"),
@@ -132,7 +132,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
132132 },
133133 {
134134 .callback = video_detect_force_vendor,
135− .ident = "Asus UL30A",
135+ /* Asus UL30A */
136136 .matches = {
137137 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
138138 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
@@ -140,7 +140,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
140140 },
141141 {
142142 .callback = video_detect_force_vendor,
143− .ident = "GIGABYTE GB-BXBT-2807",
143+ /* GIGABYTE GB-BXBT-2807 */
144144 .matches = {
145145 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
146146 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
148148 },
149149 {
150150 .callback = video_detect_force_vendor,
151− .ident = "Sony VPCEH3U1E",
151+ /* Sony VPCEH3U1E */
152152 .matches = {
153153 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
154154 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
155155 },
156156 },
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+ },
157165
158166 /*
159167 * 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
164172 */
165173 {
166174 .callback = video_detect_force_video,
167− .ident = "ThinkPad T420",
175+ /* ThinkPad T420 */
168176 .matches = {
169177 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
170178 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T420"),
@@ -172,7 +180,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
172180 },
173181 {
174182 .callback = video_detect_force_video,
175− .ident = "ThinkPad T520",
183+ /* ThinkPad T520 */
176184 .matches = {
177185 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
178186 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"),
@@ -180,7 +188,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
180188 },
181189 {
182190 .callback = video_detect_force_video,
183− .ident = "ThinkPad X201s",
191+ /* ThinkPad X201s */
184192 .matches = {
185193 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
186194 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
@@ -188,7 +196,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
188196 },
189197 {
190198 .callback = video_detect_force_video,
191− .ident = "ThinkPad X201T",
199+ /* ThinkPad X201T */
192200 .matches = {
193201 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
194202 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201T"),
@@ -199,7 +207,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 4 unmodified lines
199207 {
200208 /* https://bugs.freedesktop.org/show_bug.cgi?id=81515 */
201209 .callback = video_detect_force_video,
202− .ident = "HP ENVY 15 Notebook",
210+ /* HP ENVY 15 Notebook */
203211 .matches = {
204212 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
205213 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
207215 },
208216 {
209217 .callback = video_detect_force_video,
210− .ident = "SAMSUNG 870Z5E/880Z5E/680Z5E",
218+ /* SAMSUNG 870Z5E/880Z5E/680Z5E */
211219 .matches = {
212220 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
213221 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
215223 },
216224 {
217225 .callback = video_detect_force_video,
218− .ident = "SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V",
226+ /* SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V */
219227 .matches = {
220228 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
221229 DMI_MATCH(DMI_PRODUCT_NAME,
@@ -225,7 +233,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines
225233 {
226234 /* https://bugzilla.redhat.com/show_bug.cgi?id=1186097 */
227235 .callback = video_detect_force_video,
228− .ident = "SAMSUNG 3570R/370R/470R/450R/510R/4450RV",
236+ /* SAMSUNG 3570R/370R/470R/450R/510R/4450RV */
229237 .matches = {
230238 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
231239 DMI_MATCH(DMI_PRODUCT_NAME,
@@ -235,7 +243,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines
235243 {
236244 /* https://bugzilla.redhat.com/show_bug.cgi?id=1557060 */
237245 .callback = video_detect_force_video,
238− .ident = "SAMSUNG 670Z5E",
246+ /* SAMSUNG 670Z5E */
239247 .matches = {
240248 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
241249 DMI_MATCH(DMI_PRODUCT_NAME, "670Z5E"),
@@ -244,7 +252,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
244252 {
245253 /* https://bugzilla.redhat.com/show_bug.cgi?id=1094948 */
246254 .callback = video_detect_force_video,
247− .ident = "SAMSUNG 730U3E/740U3E",
255+ /* SAMSUNG 730U3E/740U3E */
248256 .matches = {
249257 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
250258 DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"),
@@ -253,7 +261,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
253261 {
254262 /* https://bugs.freedesktop.org/show_bug.cgi?id=87286 */
255263 .callback = video_detect_force_video,
256− .ident = "SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D",
264+ /* SAMSUNG 900X3C/900X3D/900X3E/900X4C/900X4D */
257265 .matches = {
258266 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
259267 DMI_MATCH(DMI_PRODUCT_NAME,
@@ -263,7 +271,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines
263271 {
264272 /* https://bugzilla.redhat.com/show_bug.cgi?id=1272633 */
265273 .callback = video_detect_force_video,
266− .ident = "Dell XPS14 L421X",
274+ /* Dell XPS14 L421X */
267275 .matches = {
268276 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
269277 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
@@ -272,7 +280,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
272280 {
273281 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */
274282 .callback = video_detect_force_video,
275− .ident = "Dell XPS15 L521X",
283+ /* Dell XPS15 L521X */
276284 .matches = {
277285 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
278286 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
@@ -281,7 +289,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
281289 {
282290 /* https://bugzilla.kernel.org/show_bug.cgi?id=108971 */
283291 .callback = video_detect_force_video,
284− .ident = "SAMSUNG 530U4E/540U4E",
292+ /* SAMSUNG 530U4E/540U4E */
285293 .matches = {
286294 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
287295 DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
@@ -290,7 +298,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
290298 /* https://bugs.launchpad.net/bugs/1894667 */
291299 {
292300 .callback = video_detect_force_video,
293− .ident = "HP 635 Notebook",
301+ /* HP 635 Notebook */
294302 .matches = {
295303 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
296304 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
301309 {
302310 /* https://bugzilla.redhat.com/show_bug.cgi?id=1201530 */
303311 .callback = video_detect_force_native,
304− .ident = "Lenovo Ideapad S405",
312+ /* Lenovo Ideapad S405 */
305313 .matches = {
306314 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
307315 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
310318 {
311319 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
312320 .callback = video_detect_force_native,
313− .ident = "Lenovo Ideapad Z570",
321+ /* Lenovo Ideapad Z570 */
314322 .matches = {
315323 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
316324 DMI_MATCH(DMI_PRODUCT_NAME, "102434U"),
@@ -318,7 +326,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
318326 },
319327 {
320328 .callback = video_detect_force_native,
321− .ident = "Lenovo E41-25",
329+ /* Lenovo E41-25 */
322330 .matches = {
323331 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
324332 DMI_MATCH(DMI_PRODUCT_NAME, "81FS"),
@@ -326,7 +334,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
326334 },
327335 {
328336 .callback = video_detect_force_native,
329− .ident = "Lenovo E41-45",
337+ /* Lenovo E41-45 */
330338 .matches = {
331339 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
332340 DMI_MATCH(DMI_PRODUCT_NAME, "82BK"),
@@ -335,7 +343,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
335343 {
336344 /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */
337345 .callback = video_detect_force_native,
338− .ident = "Apple MacBook Pro 12,1",
346+ /* Apple MacBook Pro 12,1 */
339347 .matches = {
340348 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
341349 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro12,1"),
@@ -343,7 +351,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
343351 },
344352 {
345353 .callback = video_detect_force_native,
346− .ident = "Dell Vostro V131",
354+ /* Dell Vostro V131 */
347355 .matches = {
348356 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
349357 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V131"),
@@ -352,7 +360,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
352360 {
353361 /* https://bugzilla.redhat.com/show_bug.cgi?id=1123661 */
354362 .callback = video_detect_force_native,
355− .ident = "Dell XPS 17 L702X",
363+ /* Dell XPS 17 L702X */
356364 .matches = {
357365 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
358366 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
360368 },
361369 {
362370 .callback = video_detect_force_native,
363− .ident = "Dell Precision 7510",
371+ /* Dell Precision 7510 */
364372 .matches = {
365373 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
366374 DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"),
@@ -368,7 +376,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
368376 },
369377 {
370378 .callback = video_detect_force_native,
371− .ident = "Acer Aspire 5738z",
379+ /* Acer Aspire 5738z */
372380 .matches = {
373381 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
374382 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
@@ -378,7 +386,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 3 unmodified lines
378386 {
379387 /* https://bugzilla.kernel.org/show_bug.cgi?id=207835 */
380388 .callback = video_detect_force_native,
381− .ident = "Acer TravelMate 5735Z",
389+ /* Acer TravelMate 5735Z */
382390 .matches = {
383391 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
384392 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5735Z"),
@@ -387,7 +395,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 2 unmodified lines
387395 },
388396 {
389397 .callback = video_detect_force_native,
390− .ident = "ASUSTeK COMPUTER INC. GA401",
398+ /* ASUSTeK COMPUTER INC. GA401 */
391399 .matches = {
392400 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
393401 DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
@@ -395,7 +403,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
395403 },
396404 {
397405 .callback = video_detect_force_native,
398− .ident = "ASUSTeK COMPUTER INC. GA502",
406+ /* ASUSTeK COMPUTER INC. GA502 */
399407 .matches = {
400408 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
401409 DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
@@ -403,7 +411,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
403411 },
404412 {
405413 .callback = video_detect_force_native,
406− .ident = "ASUSTeK COMPUTER INC. GA503",
414+ /* ASUSTeK COMPUTER INC. GA503 */
407415 .matches = {
408416 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
409417 DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
@@ -416,7 +424,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 6 unmodified lines
416424 */
417425 {
418426 .callback = video_detect_force_none,
419− .ident = "Dell OptiPlex 9020M",
427+ /* Dell OptiPlex 9020M */
420428 .matches = {
421429 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
422430 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"),
@@ -424,7 +432,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 1 unmodified line
424432 },
425433 {
426434 .callback = video_detect_force_none,
427− .ident = "MSI MS-7721",
435+ /* MSI MS-7721 */
428436 .matches = {
429437 DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
430438 DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"),
drivers/i2c/i2c-core-acpi.c+10−0
@@ -522,6 +522,16 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, · 521 unmodified lines
522522 }
523523 EXPORT_SYMBOL_GPL(i2c_acpi_new_device);
524524
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+
525535 #ifdef CONFIG_ACPI_I2C_OPREGION
526536 static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
527537 u8 cmd, u8 *data, u8 data_len)
drivers/i2c/i2c-core-base.c+4−3
@@ -551,7 +551,8 @@ static int i2c_device_probe(struct device *dev) · 550 unmodified lines
551551 if (status < 0)
552552 goto err_clear_wakeup_irq;
553553
554− status = dev_pm_domain_attach(&client->dev, true);
554+ status = dev_pm_domain_attach(&client->dev,
555+ !i2c_acpi_waive_d0_probe(dev));
555556 if (status)
556557 goto err_clear_wakeup_irq;
557558
@@ -590,7 +591,7 @@ static int i2c_device_probe(struct device *dev) · 32 unmodified lines
590591 err_release_driver_resources:
591592 devres_release_group(&client->dev, client->devres_group_id);
592593 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));
594595 err_clear_wakeup_irq:
595596 dev_pm_clear_wake_irq(&client->dev);
596597 device_init_wakeup(&client->dev, false);
@@ -621,7 +622,7 @@ static void i2c_device_remove(struct device *dev) · 24 unmodified lines
621622
622623 devres_release_group(&client->dev, client->devres_group_id);
623624
624− dev_pm_domain_detach(&client->dev, true);
625+ dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev));
625626 if (!pm_runtime_status_suspended(&client->dev) && adap->bus_regulator)
626627 regulator_disable(adap->bus_regulator);
627628
drivers/media/i2c/imx319.c+44−30
@@ -140,6 +140,8 @@ struct imx319 { · 139 unmodified lines
140140
141141 /* Streaming on/off */
142142 bool streaming;
143+ /* True if the device has been identified */
144+ bool identified;
143145 };
144146
145147 static const struct imx319_reg imx319_global_regs[] = {
@@ -2084,6 +2086,31 @@ imx319_set_pad_format(struct v4l2_subdev *sd, · 1938 unmodified lines
20842086 return 0;
20852087 }
20862088
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+
20872114 /* Start streaming */
20882115 static int imx319_start_streaming(struct imx319 *imx319)
20892116 {
@@ -2091,6 +2118,10 @@ static int imx319_start_streaming(struct imx319 *imx319) · 1 unmodified line
20912118 const struct imx319_reg_list *reg_list;
20922119 int ret;
20932120
2121+ ret = imx319_identify_module(imx319);
2122+ if (ret)
2123+ return ret;
2124+
20942125 /* Global Setting */
20952126 reg_list = &imx319_global_setting;
20962127 ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs);
@@ -2206,26 +2237,6 @@ error: · 109 unmodified lines
22062237 return ret;
22072238 }
22082239
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−
22292240 static const struct v4l2_subdev_core_ops imx319_subdev_core_ops = {
22302241 .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
22312242 .unsubscribe_event = v4l2_event_subdev_unsubscribe,
@@ -2420,6 +2431,7 @@ out_err: · 188 unmodified lines
24202431 static int imx319_probe(struct i2c_client *client)
24212432 {
24222433 struct imx319 *imx319;
2434+ bool full_power;
24232435 int ret;
24242436 u32 i;
24252437
@@ -2432,11 +2444,14 @@ static int imx319_probe(struct i2c_client *client) · 6 unmodified lines
24322444 /* Initialize subdev */
24332445 v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops);
24342446
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+ }
24402455 }
24412456
24422457 imx319->hwcfg = imx319_get_hwcfg(&client->dev);
@@ -2488,11 +2503,9 @@ static int imx319_probe(struct i2c_client *client) · 45 unmodified lines
24882503 if (ret < 0)
24892504 goto error_media_entity;
24902505
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);
24962509 pm_runtime_enable(&client->dev);
24972510 pm_runtime_idle(&client->dev);
24982511
@@ -2545,6 +2558,7 @@ static struct i2c_driver imx319_i2c_driver = { · 46 unmodified lines
25452558 },
25462559 .probe_new = imx319_probe,
25472560 .remove = imx319_remove,
2561+ .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE,
25482562 };
25492563 module_i2c_driver(imx319_i2c_driver);
25502564
drivers/misc/eeprom/at24.c+27−18
@@ -595,6 +595,7 @@ static int at24_probe(struct i2c_client *client) · 594 unmodified lines
595595 bool i2c_fn_i2c, i2c_fn_block;
596596 unsigned int i, num_addresses;
597597 struct at24_data *at24;
598+ bool full_power;
598599 struct regmap *regmap;
599600 bool writable;
600601 u8 test_byte;
@@ -747,14 +748,16 @@ static int at24_probe(struct i2c_client *client) · 146 unmodified lines
747748
748749 i2c_set_clientdata(client, at24);
749750
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+ }
755758
756− /* enable runtime pm */
757− pm_runtime_set_active(dev);
759+ pm_runtime_set_active(dev);
760+ }
758761 pm_runtime_enable(dev);
759762
760763 at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
@@ -766,15 +769,18 @@ static int at24_probe(struct i2c_client *client) · 5 unmodified lines
766769 }
767770
768771 /*
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).
771775 */
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+ }
778784 }
779785
780786 pm_runtime_idle(dev);
@@ -794,9 +800,11 @@ static int at24_remove(struct i2c_client *client) · 13 unmodified lines
794800 struct at24_data *at24 = i2c_get_clientdata(client);
795801
796802 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+ }
800808
801809 return 0;
802810 }
@@ -833,6 +841,7 @@ static struct i2c_driver at24_driver = { · 30 unmodified lines
833841 .probe_new = at24_probe,
834842 .remove = at24_remove,
835843 .id_table = at24_ids,
844+ .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE,
836845 };
837846
838847 static int __init at24_init(void)
include/acpi/acpi_bus.h+1−0
@@ -278,6 +278,7 @@ struct acpi_device_power { · 277 unmodified lines
278278 int state; /* Current state */
279279 struct acpi_device_power_flags flags;
280280 struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */
281+ u8 state_for_enumeration; /* Deepest power state for enumeration */
281282 };
282283
283284 struct acpi_dep_data {
include/acpi/platform/acgcc.h+0−13
@@ -10,25 +10,12 @@ · 9 unmodified lines
1010 #ifndef __ACGCC_H__
1111 #define __ACGCC_H__
1212
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− */
1713 #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
2514 #ifdef __KERNEL__
2615 #include <linux/stdarg.h>
2716 #else
28−/* Used to build acpi tools */
2917 #include <stdarg.h>
3018 #endif /* __KERNEL__ */
31−#endif /* ACPI_USE_BUILTIN_STDARG */
3219 #endif /* ! va_arg */
3320
3421 #define ACPI_INLINE __inline__
include/linux/acpi.h+5−0
@@ -1014,6 +1014,7 @@ int acpi_subsys_runtime_suspend(struct device *dev); · 1013 unmodified lines
10141014 int acpi_subsys_runtime_resume(struct device *dev);
10151015 int acpi_dev_pm_attach(struct device *dev, bool power_on);
10161016 bool acpi_storage_d3(struct device *dev);
1017+bool acpi_dev_state_d0(struct device *dev);
10171018 #else
10181019 static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
10191020 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
10251026 {
10261027 return false;
10271028 }
1029+static inline bool acpi_dev_state_d0(struct device *dev)
1030+{
1031+ return true;
1032+}
10281033 #endif
10291034
10301035 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
include/linux/i2c.h+18−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #define _LINUX_I2C_H
1212
1313 #include <linux/acpi.h> /* for acpi_handle */
14+#include <linux/bits.h>
1415 #include <linux/mod_devicetable.h>
1516 #include <linux/device.h> /* for struct device */
1617 #include <linux/sched.h> /* for completion */
@@ -222,6 +223,15 @@ enum i2c_alert_protocol { · 205 unmodified lines
222223 I2C_PROTOCOL_SMBUS_HOST_NOTIFY,
223224 };
224225
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+
225235 /**
226236 * struct i2c_driver - represent an I2C device driver
227237 * @class: What kind of i2c device we instantiate (for detect)
@@ -236,6 +246,7 @@ enum i2c_alert_protocol { · 8 unmodified lines
236246 * @detect: Callback for device detection
237247 * @address_list: The I2C addresses to probe (for detect)
238248 * @clients: List of detected clients we created (for i2c-core use only)
249+ * @flags: A bitmask of flags defined in &enum i2c_driver_flags
239250 *
240251 * The driver.owner field should be set to the module owner of this driver.
241252 * The driver.name field should be set to the name of this driver.
@@ -294,6 +305,8 @@ struct i2c_driver { · 52 unmodified lines
294305 int (*detect)(struct i2c_client *client, struct i2c_board_info *info);
295306 const unsigned short *address_list;
296307 struct list_head clients;
308+
309+ u32 flags;
297310 };
298311 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
299312
@@ -1015,6 +1028,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev); · 715 unmodified lines
10151028 struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
10161029 struct i2c_board_info *info);
10171030 struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle);
1031+bool i2c_acpi_waive_d0_probe(struct device *dev);
10181032 #else
10191033 static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
10201034 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
10381052 {
10391053 return NULL;
10401054 }
1055+static inline bool i2c_acpi_waive_d0_probe(struct device *dev)
1056+{
1057+ return false;
1058+}
10411059 #endif /* CONFIG_ACPI */
10421060
10431061 #endif /* _LINUX_I2C_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t