Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp184211pxk; Wed, 9 Sep 2020 02:37:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEQd7gr/geOvmDKuwzLt5PN3nOTVgojpKvuK0hO6+kXIfQaY7Wp4iypo0+0fMrPSHs8mpt X-Received: by 2002:a17:906:354c:: with SMTP id s12mr2538095eja.370.1599644265756; Wed, 09 Sep 2020 02:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599644265; cv=none; d=google.com; s=arc-20160816; b=PH6DYINReMxuS4O1uScQGkfbwZx/Gx8RSB0ibh7fPhloZs+wgvbHkGT2YEmntyrzcb YTy72dd2pG6p5JnfczIvrppEKUwXsu91IFOXMHl17GvZyXA9movW1RQUB20YAXXbe7K/ HrtpOxUlHFqOv0kiXlqyEx1P+fDBbmrzE56mJnPKOvLhvoSvY2B/BAkpjceA+bau767E CdDpk8ScPaF8QFRwIzgn6GTCy5Qi3jZYybvvrbiQtlvBKCJIgy9pCl3Ouru5pOhBF0Hc uYUT2cH2dTayA/CjFlYXhSz3rBBWcuBRty0vR/PY62xN+QFP2Hfv+10LuaBw/v7qW34P 4oFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gEj+lZMiE2N3jtcmr4bdk2b4ihEa+T3DPwIHNq/FC0A=; b=sWg5RKR7sAQbQFoIu2wQhguZaVbAj6esVdC+1BtoThINBw7aBvNiufp1R24Q/+8wUe N0e8KodmiRPLHYItI5x4vj+6MgK01YlgUvOaffvMYAkKkfu2vbwkn99obo3+4whJ8vWT W0BSLAHV+xAh69zWEVGXGYQ7d3IvlgrKn93BsnL2iZ5Ayep9sF38FstS0msKnqWCxi5B yGNRakd06kQ1Sh7RPKZN7N5YMGiftb4PLV/rd/FPWOhJzd3l+VS28QIc9jdScRW1g+n5 Elq7wKrZczOutr9rzDaUmp8ZY31LnjbKaxr9NaQQqqdReOnNPvCkoelCGu/32Y8QBTqZ 5YAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=MnAYd8sc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn11si1079041ejb.303.2020.09.09.02.37.22; Wed, 09 Sep 2020 02:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=MnAYd8sc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730154AbgIIJgF (ORCPT + 99 others); Wed, 9 Sep 2020 05:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730131AbgIIJf6 (ORCPT ); Wed, 9 Sep 2020 05:35:58 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1252C061757 for ; Wed, 9 Sep 2020 02:35:57 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id b12so1924737edz.11 for ; Wed, 09 Sep 2020 02:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gEj+lZMiE2N3jtcmr4bdk2b4ihEa+T3DPwIHNq/FC0A=; b=MnAYd8sc0uAXa4xqRVnzLJOadO+X8KmqyIdvburVZXxUL900xJEyapW1Ct9zaawwd8 kdze07iRXbco8NxlLs0ExiS6gTmQetCxZiIOmR9Yg+M8EawfaFn1iWYEgpGI0s42KylK dgB2r/HBUaniUTEIOcju/3mYFv4TyrExxjQTEOV00ZCEmbREPRWjjF7D9qzN19ighwhP 0AsQKxChLAS+EvKvrfXgdsB0KUeINDtJ4IS3ZcAFQRpC/Muyg2qAxI6VwmuhLuXlBUFL 8Q/nrHAacTrDozB1be9KjpVvtf3rTEIi0Ockq4zC2UPya7XOiPu4h5bCZRpWpz52UZcQ zWPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gEj+lZMiE2N3jtcmr4bdk2b4ihEa+T3DPwIHNq/FC0A=; b=nHNzk8XNR0j+y9XoRZeyVQLQPKuGEm4cg+0zKc4H5uw+gtj3Sz6UzYDdlTnCGyH35W bXRloQ39hJ15uDaOMRKoR/S8SsZRmvyKAHXiUnYEXWlpI+7ukXWt3hp7l8sQUy41RQBe WUNBvB7oaB4z1zQYovwxSpOHafSyPueaJ2i6szwtQKZjP+KsIziqwnBuAMQqWIJLL0C4 LJEWyi7WNrIonvweqRMM6ySiDIEsRUQG7vq3LTmeoUSlNHqP0m+NxUR5Sw+5OcfE4vTM aQQ0N+errIK3cFzFN31NzxL+5fD7vAaosnkW/H/eZeFDKoGLc77rPzgYAsSsLmndP57Z NWRQ== X-Gm-Message-State: AOAM533rep6YTbVPooM+SJMD5V+D9sAjIqU6p5OJu9p1lz9EUW3z/tNR R50kP7EmwUUtkbN/QwqJquv9GUqBTVD3ngMQ7vxCmg== X-Received: by 2002:aa7:c9ce:: with SMTP id i14mr3328398edt.186.1599644156363; Wed, 09 Sep 2020 02:35:56 -0700 (PDT) MIME-Version: 1.0 References: <20200903081550.6012-1-sakari.ailus@linux.intel.com> <20200903081550.6012-7-sakari.ailus@linux.intel.com> In-Reply-To: <20200903081550.6012-7-sakari.ailus@linux.intel.com> From: Bartosz Golaszewski Date: Wed, 9 Sep 2020 11:35:45 +0200 Message-ID: Subject: Re: [PATCH v8 6/6] at24: Support probing while off To: Sakari Ailus Cc: linux-i2c , Wolfram Sang , "Rafael J. Wysocki" , ACPI Devel Maling List , LKML , Greg Kroah-Hartman , Rajmohan Mani , Tomasz Figa , Bingbu Cao , Chiranjeevi Rapolu , Hyungwoo Yang , linux-media Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 3, 2020 at 10:15 AM Sakari Ailus wrote: > > In certain use cases (where the chip is part of a camera module, and the > camera module is wired together with a camera privacy LED), powering on > the device during probe is undesirable. Add support for the at24 to > execute probe while being powered off. For this to happen, a hint in form > of a device property is required from the firmware. > > Signed-off-by: Sakari Ailus > --- > drivers/misc/eeprom/at24.c | 43 +++++++++++++++++++++++--------------- > 1 file changed, 26 insertions(+), 17 deletions(-) > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > index 8f5de5f10bbea..2d24e33788d7d 100644 > --- a/drivers/misc/eeprom/at24.c > +++ b/drivers/misc/eeprom/at24.c > @@ -595,6 +595,7 @@ static int at24_probe(struct i2c_client *client) > bool i2c_fn_i2c, i2c_fn_block; > unsigned int i, num_addresses; > struct at24_data *at24; > + bool low_power; > struct regmap *regmap; > bool writable; > u8 test_byte; > @@ -733,25 +734,30 @@ static int at24_probe(struct i2c_client *client) > > i2c_set_clientdata(client, at24); > > - err = regulator_enable(at24->vcc_reg); > - if (err) { > - dev_err(dev, "Failed to enable vcc regulator\n"); > - return err; > - } > + low_power = acpi_dev_state_low_power(&client->dev); > + if (!low_power) { > + err = regulator_enable(at24->vcc_reg); > + if (err) { > + dev_err(dev, "Failed to enable vcc regulator\n"); > + return err; > + } > > - /* enable runtime pm */ > - pm_runtime_set_active(dev); > + pm_runtime_set_active(dev); > + } > pm_runtime_enable(dev); > > /* > - * Perform a one-byte test read to verify that the > - * chip is functional. > + * Perform a one-byte test read to verify that the chip is functional, > + * unless powering on the device is to be avoided during probe (i.e. > + * it's powered off right now). > */ > - err = at24_read(at24, 0, &test_byte, 1); > - if (err) { > - pm_runtime_disable(dev); > - regulator_disable(at24->vcc_reg); > - return -ENODEV; > + if (!low_power) { > + err = at24_read(at24, 0, &test_byte, 1); > + if (err) { > + pm_runtime_disable(dev); > + regulator_disable(at24->vcc_reg); > + return -ENODEV; > + } > } > > pm_runtime_idle(dev); > @@ -771,9 +777,11 @@ static int at24_remove(struct i2c_client *client) > struct at24_data *at24 = i2c_get_clientdata(client); > > pm_runtime_disable(&client->dev); > - if (!pm_runtime_status_suspended(&client->dev)) > - regulator_disable(at24->vcc_reg); > - pm_runtime_set_suspended(&client->dev); > + if (!acpi_dev_state_low_power(&client->dev)) { > + if (!pm_runtime_status_suspended(&client->dev)) > + regulator_disable(at24->vcc_reg); > + pm_runtime_set_suspended(&client->dev); > + } > > return 0; > } > @@ -810,6 +818,7 @@ static struct i2c_driver at24_driver = { > .probe_new = at24_probe, > .remove = at24_remove, > .id_table = at24_ids, > + .flags = I2C_DRV_FL_ALLOW_LOW_POWER_PROBE, > }; > > static int __init at24_init(void) > -- > 2.20.1 > This currently conflicts with the fix I queued for at24 for v5.9. Which tree is going to take this series? Bartosz