Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4632799imu; Tue, 8 Jan 2019 03:42:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN5RXeq/m3KP8QBZwyahoNUcss6Hc0vJowWgs25l6Ixhat9YDUU/Bf5tCDGlh1g/h0va/r1b X-Received: by 2002:a17:902:2ec1:: with SMTP id r59mr1461173plb.254.1546947770989; Tue, 08 Jan 2019 03:42:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546947770; cv=none; d=google.com; s=arc-20160816; b=0anDr9hWlVP7qlrzTaYNbq51+X7cVHFCM4JA7kksgiJl7YnNgMUzptCtzrXUekYIg/ lno36fD3goV5uhDJXN1r6WCyR4eamwInZs6wzY4SVuylGeErWzeM7NyR5gTxUaoAF1VI 8/2e9mBumjFqsJXHH2SWwIOHRoW2rFllKS8FiK31vWgYhgTl2nS9iRzgoEC6nOT4E+xn sUOi2s/4agOtCwjkWnmEyvZZ/WnTGNLR/ar+fRoOX3KHH3eckLFTqKOYNYxLvV2AQpow FsyMHGU3emByhjXS2A1l4Bmutr9EJrJiRC7dsEvm9+VI3rW42P6kA7Qpd4A8OCvtl6JS BQlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=IfxZpYv8EEBezOIvGU2H3Nvan1BGsI2AgsqwypbvGI8=; b=pkRFCZSYscRGyvODOcwFsjpiK+yUuNgm0YFM35NwE1RhqBYPd3N5NdrA3k6ncnj776 EAqDhSxWvRupwI8QRyD7puW0R1k2D31AC7mR8Z6EszcOQYoUIg4xuZggcidLk9vNxLhV Smqt6qftdb+3ZhRX258+xpPJxTTS/9pSfzWAjdctp2crce1KKGP6fjh4WjRrJ0hMIy8z 0mFyVb7w+IjG2LYMAs1MPTxwtLfYLss7s1kKsgJ3JG2TdTS12UBg7WCNcz8Xz9O64nYZ cB4gTBcw9b3585MKRZwbl01hmR80JaNXh3Y4yYVJbq5nk4G9YuqaJjlCTxtfSofTr1dx z3uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=KBnDGUCj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si14026643plp.114.2019.01.08.03.42.35; Tue, 08 Jan 2019 03:42:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=KBnDGUCj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728389AbfAHLlQ (ORCPT + 99 others); Tue, 8 Jan 2019 06:41:16 -0500 Received: from mout01.posteo.de ([185.67.36.65]:51080 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727484AbfAHLlP (ORCPT ); Tue, 8 Jan 2019 06:41:15 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 57DAB16005D for ; Tue, 8 Jan 2019 12:41:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1546947670; bh=eQPpMGvi7omKgnWy0rNFHP8rsFSo64eAIoWlDT63yO4=; h=Subject:To:Cc:From:Openpgp:Autocrypt:Date:From; b=KBnDGUCjXzazPlkDUB9rVS/jW7dD0mNw7Qt0QUvRubp4UIJZcqmpXlQdd+x+InBTb RSciriqWQzIk1c36LjoYIPSKjG2pEpqqIpEN8udnNRt7MtWiYbO5f5Z/B4w3zUWlWG /65wLDIKEM4nabnbTu6HD75jda5L6zoWn9aWQJKfwmK0EQAILJfpU/uafgufEsDVxi +MNqvkJ/ToM3y315oy5WshDQ+Vo1nAt30zl+foCybQ4v6nsy8K6gWVXVEjxXqHG0KP sxRgqTRRlxMGhrWJCBb9rtmfkE7rsHTOHF6jASGYkZXw51yaExHpxJgojpqhEwW++s fLunKT5l9pwkg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43Yr1X5TZJz6tmN; Tue, 8 Jan 2019 12:41:04 +0100 (CET) Subject: Re: [PATCH V7 2/2] iio: accell: mma8452: add vdd/vddio regulator operation support To: Anson Huang , "jic23@kernel.org" , "knaack.h@gmx.de" , "lars@metafoo.de" , "pmeerw@pmeerw.net" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "gustavo@embeddedor.com" , "gregkh@linuxfoundation.org" , Leonard Crestez , "rtresidd@electromag.com.au" , "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: dl-linux-imx References: <1546938556-26969-1-git-send-email-Anson.Huang@nxp.com> <1546938556-26969-2-git-send-email-Anson.Huang@nxp.com> From: Martin Kepplinger Openpgp: preference=signencrypt Autocrypt: addr=martink@posteo.de; keydata= mQINBFULfZABEADRxJqDOYAHfrp1w8Egcv88qoru37k1x0Ugy8S6qYtKLAAt7boZW+q5gPv3 Sj2KjfkWA7gotXpASN21OIfE/puKGwhDLAySY1DGNMQ0gIVakUO0ji5GJPjeB9JlmN5hbA87 Si9k3yKQQfv7Cf9Lr1iZaV4A4yjLP/JQMImaCVdC5KyqJ98Luwci1GbsLIGX3EEjfg1+MceO dnJTKZpBAKd1J7S2Ib3dRwvALdiD7zqMGqkw5xrtw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 Ej+QrsU3sq93D8gJNEVVV96tcGrJv4ytyRLmt5fi35xEvdxgf7FiS3bQqp9rS6jL/lhz7qNw mR8c4pgMAdURioI8QnPlgSEfneH8KVCWoCc09kysjG1rmVh2dXpIQo3Shri/zhbWtVQepTLI D+VjnhdFPVXTixI1b4NW6h4aSkrip6ccyH/8WjsGqPQVX5yNSAJnoqjlpb3buVEU+EP9uvg/ RvNj6qFRbc+nfOBBgrUvhEr0aEOvFotExGvNjR5T9MewbGVnL4s0IlMYwZBD88ygm77CmQRg MbBzOP6HyiLOUmLBbfDXmHP0ChP3Oi34bm7OSPq9PyxcuMhr1hzWXQYsjqH6CtU0cNRjeIz/ bEt7TFPkP0uzJ4zLjX2BAJ9WJC2JGDWEMhtzg2kZaAS9jwCEAf7m8mP+RT64rSMztjKtmIQN vZicCb2MBQaC7vS7thkGhyQIlzN32iWeCHeydZnDPMEU9PP3PMsQHDAnZdXjc5Jfa2q9WOzG nCFhEis48yoFOobYJHR0viwuY4DIprx3Dq6I4+WVwuf6U6y579i+qDvOxiuFcClGgBmsmehF YSKzZPSgZYhCVZhzSpg4D+AVQEhxhGTSCXDSBIMpnW4GgdJdZGmBBobKqvHmgI95tw== Message-ID: <84c2971b-29d5-a0d0-c830-11504c381dd2@posteo.de> Date: Tue, 8 Jan 2019 12:41:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1546938556-26969-2-git-send-email-Anson.Huang@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.01.19 10:14, Anson Huang wrote: > The accelerometer's power supply could be controllable on some > platforms, such as i.MX6Q-SABRESD board, the mma8451's power supplies > are controlled by a GPIO fixed regulator, need to make sure the > regulators are enabled before any communication with mma8451, this > patch adds vdd/vddio regulator operation support. > > Signed-off-by: Anson Huang > Acked-by: Martin Kepplinger > --- > ChangeLog Since V6: > - separate the error handling of regulators get to make code easy to read. > --- > drivers/iio/accel/mma8452.c | 105 ++++++++++++++++++++++++++++++++++---------- > 1 file changed, 83 insertions(+), 22 deletions(-) > > diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c > index 421a0a8..3027811 100644 > --- a/drivers/iio/accel/mma8452.c > +++ b/drivers/iio/accel/mma8452.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > > #define MMA8452_STATUS 0x00 > #define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0)) > @@ -107,6 +108,8 @@ struct mma8452_data { > u8 data_cfg; > const struct mma_chip_info *chip_info; > int sleep_val; > + struct regulator *vdd_reg; > + struct regulator *vddio_reg; > }; > > /** > @@ -1534,9 +1537,39 @@ static int mma8452_probe(struct i2c_client *client, > mutex_init(&data->lock); > data->chip_info = match->data; > > + data->vdd_reg = devm_regulator_get(&client->dev, "vdd"); > + if (IS_ERR(data->vdd_reg)) { > + if (PTR_ERR(data->vdd_reg) == -EPROBE_DEFER) > + return -EPROBE_DEFER; > + > + dev_err(&client->dev, "failed to get VDD regulator!\n"); > + return PTR_ERR(data->vdd_reg); > + } > + > + data->vddio_reg = devm_regulator_get(&client->dev, "vddio"); > + if (IS_ERR(data->vddio_reg)) { > + if (PTR_ERR(data->vddio_reg) == -EPROBE_DEFER) > + return -EPROBE_DEFER; > + > + dev_err(&client->dev, "failed to get VDDIO regulator!\n"); > + return PTR_ERR(data->vddio_reg); > + } > + > + ret = regulator_enable(data->vdd_reg); > + if (ret) { > + dev_err(&client->dev, "failed to enable VDD regulator!\n"); > + return ret; > + } > + > + ret = regulator_enable(data->vddio_reg); > + if (ret) { > + dev_err(&client->dev, "failed to enable VDDIO regulator!\n"); > + goto disable_regulator_vdd; > + } > + > ret = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I); > if (ret < 0) > - return ret; > + goto disable_regulators; > > switch (ret) { > case MMA8451_DEVICE_ID: > @@ -1549,7 +1582,8 @@ static int mma8452_probe(struct i2c_client *client, > break; > /* else: fall through */ > default: > - return -ENODEV; > + ret = -ENODEV; > + goto disable_regulators; > } > > dev_info(&client->dev, "registering %s accelerometer; ID 0x%x\n", > @@ -1566,13 +1600,13 @@ static int mma8452_probe(struct i2c_client *client, > > ret = mma8452_reset(client); > if (ret < 0) > - return ret; > + goto disable_regulators; > > data->data_cfg = MMA8452_DATA_CFG_FS_2G; > ret = i2c_smbus_write_byte_data(client, MMA8452_DATA_CFG, > data->data_cfg); > if (ret < 0) > - return ret; > + goto disable_regulators; > > /* > * By default set transient threshold to max to avoid events if > @@ -1581,7 +1615,7 @@ static int mma8452_probe(struct i2c_client *client, > ret = i2c_smbus_write_byte_data(client, MMA8452_TRANSIENT_THS, > MMA8452_TRANSIENT_THS_MASK); > if (ret < 0) > - return ret; > + goto disable_regulators; > > if (client->irq) { > int irq2; > @@ -1595,7 +1629,7 @@ static int mma8452_probe(struct i2c_client *client, > MMA8452_CTRL_REG5, > data->chip_info->all_events); > if (ret < 0) > - return ret; > + goto disable_regulators; > > dev_dbg(&client->dev, "using interrupt line INT1\n"); > } > @@ -1604,11 +1638,11 @@ static int mma8452_probe(struct i2c_client *client, > MMA8452_CTRL_REG4, > data->chip_info->enabled_events); > if (ret < 0) > - return ret; > + goto disable_regulators; > > ret = mma8452_trigger_setup(indio_dev); > if (ret < 0) > - return ret; > + goto disable_regulators; > } > > data->ctrl_reg1 = MMA8452_CTRL_ACTIVE | > @@ -1661,12 +1695,19 @@ static int mma8452_probe(struct i2c_client *client, > trigger_cleanup: > mma8452_trigger_cleanup(indio_dev); > > +disable_regulators: > + regulator_disable(data->vddio_reg); > + > +disable_regulator_vdd: > + regulator_disable(data->vdd_reg); > + > return ret; > } > > static int mma8452_remove(struct i2c_client *client) > { > struct iio_dev *indio_dev = i2c_get_clientdata(client); > + struct mma8452_data *data = iio_priv(indio_dev); > > iio_device_unregister(indio_dev); > > @@ -1678,6 +1719,9 @@ static int mma8452_remove(struct i2c_client *client) > mma8452_trigger_cleanup(indio_dev); > mma8452_standby(iio_priv(indio_dev)); > > + regulator_disable(data->vddio_reg); > + regulator_disable(data->vdd_reg); > + > return 0; > } > > @@ -1696,6 +1740,18 @@ static int mma8452_runtime_suspend(struct device *dev) > return -EAGAIN; > } > > + ret = regulator_disable(data->vddio_reg); > + if (ret) { > + dev_err(dev, "failed to disable VDDIO regulator\n"); > + return ret; > + } > + > + ret = regulator_disable(data->vdd_reg); > + if (ret) { > + dev_err(dev, "failed to disable VDD regulator\n"); > + return ret; > + } > + > return 0; > } > > @@ -1705,9 +1761,22 @@ static int mma8452_runtime_resume(struct device *dev) > struct mma8452_data *data = iio_priv(indio_dev); > int ret, sleep_val; > > + ret = regulator_enable(data->vdd_reg); > + if (ret) { > + dev_err(dev, "failed to enable VDD regulator\n"); > + return ret; > + } > + > + ret = regulator_enable(data->vddio_reg); > + if (ret) { > + dev_err(dev, "failed to enable VDDIO regulator\n"); > + regulator_disable(data->vdd_reg); > + return ret; > + } > + > ret = mma8452_active(data); > if (ret < 0) > - return ret; > + goto runtime_resume_failed; > > ret = mma8452_get_odr_index(data); > sleep_val = 1000 / mma8452_samp_freq[ret][0]; > @@ -1717,25 +1786,17 @@ static int mma8452_runtime_resume(struct device *dev) > msleep_interruptible(sleep_val); > > return 0; > -} > -#endif > > -#ifdef CONFIG_PM_SLEEP > -static int mma8452_suspend(struct device *dev) > -{ > - return mma8452_standby(iio_priv(i2c_get_clientdata( > - to_i2c_client(dev)))); > -} > +runtime_resume_failed: > + regulator_disable(data->vddio_reg); > + regulator_disable(data->vdd_reg); > > -static int mma8452_resume(struct device *dev) > -{ > - return mma8452_active(iio_priv(i2c_get_clientdata( > - to_i2c_client(dev)))); > + return ret; > } > #endif > > static const struct dev_pm_ops mma8452_pm_ops = { > - SET_SYSTEM_SLEEP_PM_OPS(mma8452_suspend, mma8452_resume) > + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) Just a quesion: Isn't it semantically a different change to replace mma8452_suspend() and mma8452_resume()? If not, why is it needed here? other than that, lgtm. > SET_RUNTIME_PM_OPS(mma8452_runtime_suspend, > mma8452_runtime_resume, NULL) > }; >