Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: imx319: Support device probe in non-zero ACPI D state

Tell ACPI device PM code that the driver supports the device being in
non-zero ACPI D state when the driver's probe function is entered.

Signed-off-by: Rajmohan Mani <rajmohan.mani@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Rajmohan Mani and committed by
Rafael J. Wysocki
434aa74b b82a7df4

+44 -30
+44 -30
drivers/media/i2c/imx319.c
··· 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[] = { ··· 2086 2084 return 0; 2087 2085 } 2088 2086 2087 + /* Verify chip ID */ 2088 + static int imx319_identify_module(struct imx319 *imx319) 2089 + { 2090 + struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); 2091 + int ret; 2092 + u32 val; 2093 + 2094 + if (imx319->identified) 2095 + return 0; 2096 + 2097 + ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val); 2098 + if (ret) 2099 + return ret; 2100 + 2101 + if (val != IMX319_CHIP_ID) { 2102 + dev_err(&client->dev, "chip id mismatch: %x!=%x", 2103 + IMX319_CHIP_ID, val); 2104 + return -EIO; 2105 + } 2106 + 2107 + imx319->identified = true; 2108 + 2109 + return 0; 2110 + } 2111 + 2089 2112 /* Start streaming */ 2090 2113 static int imx319_start_streaming(struct imx319 *imx319) 2091 2114 { 2092 2115 struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); 2093 2116 const struct imx319_reg_list *reg_list; 2094 2117 int ret; 2118 + 2119 + ret = imx319_identify_module(imx319); 2120 + if (ret) 2121 + return ret; 2095 2122 2096 2123 /* Global Setting */ 2097 2124 reg_list = &imx319_global_setting; ··· 2235 2204 imx319_stop_streaming(imx319); 2236 2205 imx319->streaming = 0; 2237 2206 return ret; 2238 - } 2239 - 2240 - /* Verify chip ID */ 2241 - static int imx319_identify_module(struct imx319 *imx319) 2242 - { 2243 - struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); 2244 - int ret; 2245 - u32 val; 2246 - 2247 - ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val); 2248 - if (ret) 2249 - return ret; 2250 - 2251 - if (val != IMX319_CHIP_ID) { 2252 - dev_err(&client->dev, "chip id mismatch: %x!=%x", 2253 - IMX319_CHIP_ID, val); 2254 - return -EIO; 2255 - } 2256 - 2257 - return 0; 2258 2207 } 2259 2208 2260 2209 static const struct v4l2_subdev_core_ops imx319_subdev_core_ops = { ··· 2431 2420 static int imx319_probe(struct i2c_client *client) 2432 2421 { 2433 2422 struct imx319 *imx319; 2423 + bool full_power; 2434 2424 int ret; 2435 2425 u32 i; 2436 2426 ··· 2444 2432 /* Initialize subdev */ 2445 2433 v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops); 2446 2434 2447 - /* Check module identity */ 2448 - ret = imx319_identify_module(imx319); 2449 - if (ret) { 2450 - dev_err(&client->dev, "failed to find sensor: %d", ret); 2451 - goto error_probe; 2435 + full_power = acpi_dev_state_d0(&client->dev); 2436 + if (full_power) { 2437 + /* Check module identity */ 2438 + ret = imx319_identify_module(imx319); 2439 + if (ret) { 2440 + dev_err(&client->dev, "failed to find sensor: %d", ret); 2441 + goto error_probe; 2442 + } 2452 2443 } 2453 2444 2454 2445 imx319->hwcfg = imx319_get_hwcfg(&client->dev); ··· 2503 2488 if (ret < 0) 2504 2489 goto error_media_entity; 2505 2490 2506 - /* 2507 - * Device is already turned on by i2c-core with ACPI domain PM. 2508 - * Enable runtime PM and turn off the device. 2509 - */ 2510 - pm_runtime_set_active(&client->dev); 2491 + /* Set the device's state to active if it's in D0 state. */ 2492 + if (full_power) 2493 + pm_runtime_set_active(&client->dev); 2511 2494 pm_runtime_enable(&client->dev); 2512 2495 pm_runtime_idle(&client->dev); 2513 2496 ··· 2558 2545 }, 2559 2546 .probe_new = imx319_probe, 2560 2547 .remove = imx319_remove, 2548 + .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE, 2561 2549 }; 2562 2550 module_i2c_driver(imx319_i2c_driver); 2563 2551