From patchwork Mon Dec 10 07:11:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 10720681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B54E18A7 for ; Mon, 10 Dec 2018 07:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55D7929E65 for ; Mon, 10 Dec 2018 07:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A46B29E6C; Mon, 10 Dec 2018 07:11:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6FF29E65 for ; Mon, 10 Dec 2018 07:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbeLJHLZ (ORCPT ); Mon, 10 Dec 2018 02:11:25 -0500 Received: from mail-eopbgr130057.outbound.protection.outlook.com ([40.107.13.57]:52880 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726292AbeLJHLZ (ORCPT ); Mon, 10 Dec 2018 02:11:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kkw+VQ2kzCV/S0gzxRdHxDfYF103nbCPIOZ+DCj7Bec=; b=Wj2KSyeJFAXOYnHLgyUCaarYaU9aul3ifoypWmUuoJzrX6BRQ+t9pRqjiqYFETZA48Y4ge2MrisdfMpsVgOejz5MqOgGmiV0d+0UZcLph68c4y1rgGVWhyani/ETd0048UZU4IpMXvktgFcZe/IQ5LQJdF6klMX/31hoXvxeq5Q= Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com (52.134.72.18) by DB3PR0402MB3690.eurprd04.prod.outlook.com (52.134.70.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.19; Mon, 10 Dec 2018 07:11:19 +0000 Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::adf8:f49d:deb4:58fd]) by DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::adf8:f49d:deb4:58fd%3]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 07:11:19 +0000 From: Anson Huang To: "jic23@kernel.org" , "knaack.h@gmx.de" , "lars@metafoo.de" , "pmeerw@pmeerw.net" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: dl-linux-imx Subject: [PATCH V3 1/2] dt-bindings: iio: light: isl29018: update power supply name Thread-Topic: [PATCH V3 1/2] dt-bindings: iio: light: isl29018: update power supply name Thread-Index: AQHUkFeMq54w2saSI0m5D7dfdmdMWQ== Date: Mon, 10 Dec 2018 07:11:19 +0000 Message-ID: <1544425521-775-1-git-send-email-Anson.Huang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR0302CA0015.apcprd03.prod.outlook.com (2603:1096:202::25) To DB3PR0402MB3916.eurprd04.prod.outlook.com (2603:10a6:8:10::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB3PR0402MB3690;6:sG9vfzht60I8Knk4APMol/6LYrtJy1TIIwhZvUVpwbH479lJwOfx3G+gLLSehPgblYK/Mo+9VCywCtHMMiBLOrWtLUG+oiQa1ytoGlmWp2YWlbUZESYNgNQI4TwjB+/BiuZuWBOp06e3or5b0Tw5U55DI929J+o4WR0U+GsLsaLdogv2BUK04KGSq+kTkwb4c/VyNGK/u6ySN3lZAxSQXyvZ7H1ORnmLvyuZLU1pLWZarDpnyd93dvZPEacyJIEQ+Yv7tHoWy3Q91V17JrE45i0psuVrxQYflA2j6I2ZLAGHofzlupWjiQiPkrD3AWVmb0pcHpAkzfuykDIULBXdaiou7qOOIb59ApiS39cCApdJvh1Sa8ChNVoHg6uB+Xog3ufqDiAxijgtlSN0n4mGD+FDLtpAVcGn9KPw1Y7bLF4NebS3LyCkXJco2kM1GFK4WTBKOZW4B020uui0go3JCQ==;5:K15iGcFX3WwC9nP6xGRxTyl4IYkXIf66nvk6WqPXwlkGY9i7LI4c6j7FEIfd90oGELk23W2Tv7uLYVzFdcjTlOG0+GEuuuB9LmKT3VwAAbZwgcLc9uJ1AkPBOrbAy0GsuI3iOSUuOT1E0VMJ+DGPnz74CfR710pCCQY5Sbxzi+I=;7:9fZqxNYrckPdssXb6S6hndo4vL/JUMHbDqPo2fS9M6KpEfLeqkaPcYxKwi0zqyB2Eh0d7YIIPqy+EmwpERjeGBkF5hqWLQeomqhfOyaBYZJEv/nV8Iv4C837E4rpLsi68OUk/QInx+TTvA6D1jGxIw== x-ms-office365-filtering-correlation-id: b932492c-cd2b-433e-d5df-08d65e6eae89 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB3PR0402MB3690; x-ms-traffictypediagnostic: DB3PR0402MB3690: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(3230017)(999002)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231472)(944501520)(52105112)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:DB3PR0402MB3690;BCL:0;PCL:0;RULEID:;SRVR:DB3PR0402MB3690; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(376002)(39860400002)(346002)(136003)(396003)(199004)(189003)(25786009)(8676002)(386003)(66066001)(316002)(86362001)(486006)(102836004)(5660300001)(15650500001)(36756003)(52116002)(68736007)(256004)(14444005)(14454004)(6506007)(2201001)(110136005)(105586002)(305945005)(71200400001)(53936002)(71190400001)(2501003)(6116002)(476003)(81156014)(81166006)(6486002)(99286004)(7736002)(4326008)(50226002)(2616005)(186003)(6436002)(26005)(97736004)(478600001)(106356001)(3846002)(2906002)(6512007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR0402MB3690;H:DB3PR0402MB3916.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: PxcMWWFweTa9jKzKZLItM5jpvQPmxJvoWhFDpBs6cqMR7VBLYhx3diUx27iRE++BBpbcXn0IXeqALTQLDzZx8pt/cPlXDZx3uOsWkHvye7YOOTFcCAAL/3F4DfcEtIZg7rCjMVuUU4AQ9fQFGlv5WFppaQjmdBLrYu4C8oBuF0j4V7dehEbeZJt5V2ZC9yI4qmIr0WP7pt8cFT5T6mIz7N/sW1hBo69NXQdxu4XwRzlw0F5FQgEn2EKP2xDLiEu6S0sPo1d9oWGkim2Ng6AvfTB/002hbs0+xl0yfglkkJ33wC6FEuGwq0c1boXF5KNP spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b932492c-cd2b-433e-d5df-08d65e6eae89 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 07:11:19.2469 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3690 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to datasheet, the isl29018 has "vddd/vdda" power supply, and isl29023/isl29035 ONLY has "vdd" power supply, update the power supply name with "vdd" and "vdda" according to datasheet to cover all devices and avoid confusion. Signed-off-by: Anson Huang --- Documentation/devicetree/bindings/iio/light/isl29018.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.txt b/Documentation/devicetree/bindings/iio/light/isl29018.txt index b9bbde3..36f737d 100644 --- a/Documentation/devicetree/bindings/iio/light/isl29018.txt +++ b/Documentation/devicetree/bindings/iio/light/isl29018.txt @@ -15,7 +15,9 @@ Optional properties: Refer to interrupt-controller/interrupts.txt for generic interrupt client node bindings. - - vcc-supply: phandle to the regulator that provides power to the sensor. + - vdd-supply: phandle to the regulator that provides vdd power to the sensor. + + - vdda-supply: phandle to the regulator that provides vdda power to the sensor. Example: From patchwork Mon Dec 10 07:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 10720679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E47D415A6 for ; Mon, 10 Dec 2018 07:11:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D151F29E47 for ; Mon, 10 Dec 2018 07:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C515429E6D; Mon, 10 Dec 2018 07:11:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BDE329E5B for ; Mon, 10 Dec 2018 07:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbeLJHLa (ORCPT ); Mon, 10 Dec 2018 02:11:30 -0500 Received: from mail-eopbgr130057.outbound.protection.outlook.com ([40.107.13.57]:52880 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726550AbeLJHL3 (ORCPT ); Mon, 10 Dec 2018 02:11:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cCCN26aWuMqb6zynJYqqyvwDMsQ+lPUpcZOy0S3J+eY=; b=DNZa7suE+JjB0eALaEyAVHlDpxshu4+oor8Wu1BYRT5wMAVUnoAp9AX55n50vFSXFK1PTdP8NnRx3klOKq+NTOPcM17EK/fIltpImjXgFl/C/Ghw6euSghQyiK7iFQsD0IyxARVLC4sOpW6PrRYDTHpnMdIGWr12UwfszmW93aw= Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com (52.134.72.18) by DB3PR0402MB3690.eurprd04.prod.outlook.com (52.134.70.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.19; Mon, 10 Dec 2018 07:11:23 +0000 Received: from DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::adf8:f49d:deb4:58fd]) by DB3PR0402MB3916.eurprd04.prod.outlook.com ([fe80::adf8:f49d:deb4:58fd%3]) with mapi id 15.20.1404.026; Mon, 10 Dec 2018 07:11:23 +0000 From: Anson Huang To: "jic23@kernel.org" , "knaack.h@gmx.de" , "lars@metafoo.de" , "pmeerw@pmeerw.net" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: dl-linux-imx Subject: [PATCH V3 2/2] iio: light: isl29018: add optional vdd/vdda regulator operation support Thread-Topic: [PATCH V3 2/2] iio: light: isl29018: add optional vdd/vdda regulator operation support Thread-Index: AQHUkFeOXAJ625mhG0uxMVEOV8h94Q== Date: Mon, 10 Dec 2018 07:11:23 +0000 Message-ID: <1544425521-775-2-git-send-email-Anson.Huang@nxp.com> References: <1544425521-775-1-git-send-email-Anson.Huang@nxp.com> In-Reply-To: <1544425521-775-1-git-send-email-Anson.Huang@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR0302CA0015.apcprd03.prod.outlook.com (2603:1096:202::25) To DB3PR0402MB3916.eurprd04.prod.outlook.com (2603:10a6:8:10::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB3PR0402MB3690;6:krV063J6NzQ1i5erKzS3DXzrPWuzfnihmM8xolhUKDLG2mdTOVV9A3GDISIasfud/rvM6nNGFqiD5KgYI2eilkfEti7V+fGKtM2Wk7ddPbs0yv9OIDDYsxhlA91xAEybYPjC4F6NI/RQoc+QP2kEmmuJmJoy0KraCC64h4r7boO44RIUaQkojnOMvRfR2/CH6UH2SWgI5buuS/MYBCNZK/6+kcstE59DI98E8gt9+nujBXEWsIcC28ve048ElY2cV0jNS79XjPrl9gXBGsR2k6M7Yfv+I5vZ48nlhZGEskJx8R3LHzAHRnN6ubOIRqlrbxbv14fxoK36uhHTtWyqsAraL7GHCeYd5hSnIMpIkMMz9pK2dcea0ETXUA4OkSB3oDA9r26sD3ydDTbYTL9FgccZKIE7xUboKBv0N5jNbYSjcZenyVpNYt/OzlRyJLacFIPnnORPVl29jScdbBi6LQ==;5:s55c+zf926INEdPBWj9e/IjVbq+BHhFazrqnvQalEab3jX6u1euzmljo1Aoy5R69NZzis3vGHvrJrR2GnJKLlz0MJRIRBLEnfUPmGVJ/86lJrwrNlulqzd2mEtc9Xc5vfbK7kSiWWiIfjP4UeHCCoBLAw3XDIxtTa//hgqtxEJw=;7:ttbAwN7ik/xb3qHjBkgQW9Pn8JcpIzvT8DunzBtRtee625ARSIk6l8ip2CrYo6U0eWFkJtjW20dNRaYBR9SlQkBminLcsBbGzcQatn3NUydWc37qwBQgpCxCTe9mPyx1iTV982uECkJZvIrFEUA6qw== x-ms-office365-filtering-correlation-id: 51feea45-5bd5-4649-a965-08d65e6eb0fa x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB3PR0402MB3690; x-ms-traffictypediagnostic: DB3PR0402MB3690: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(3230017)(999002)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231472)(944501520)(52105112)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:DB3PR0402MB3690;BCL:0;PCL:0;RULEID:;SRVR:DB3PR0402MB3690; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(376002)(39860400002)(346002)(136003)(396003)(199004)(189003)(54534003)(25786009)(76176011)(8676002)(386003)(66066001)(316002)(86362001)(486006)(102836004)(5660300001)(36756003)(52116002)(68736007)(256004)(14444005)(14454004)(6506007)(2201001)(110136005)(105586002)(305945005)(71200400001)(53936002)(71190400001)(2501003)(6116002)(476003)(81156014)(81166006)(6486002)(99286004)(7736002)(4326008)(50226002)(2616005)(186003)(11346002)(6436002)(26005)(97736004)(478600001)(106356001)(3846002)(2906002)(6512007)(8936002)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR0402MB3690;H:DB3PR0402MB3916.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 9Mm0PZs5NaFZPdbRr5CBc2Md01RW7+3ZyqHT13ivuI/E2DWcxK38/2yCz3+yUJFQ9mvlYV4GnbqBf0wRVrPNVZTf8hkB4OIIOAg7HR+Q2JrqzhdGJRzSWQ5BdNbmzbTqE8v6N+YHhladaK2w5FmHr058XTeiwzZznGeYAb1G4JJc6BJ9Q1bSWVHA3crZoQkRhIBXZErmpwNDRHzuuNB4wHIZbNmdVjMeAao6N89WAYjbzGNDsIUpGRLiNG+YJdcv0tYLiEDGnc01pGhGhwLwSk7iVrLECXqpExY0eqvvq1kxGqTjjPPMpcCDdjoG/eql spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51feea45-5bd5-4649-a965-08d65e6eb0fa X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 07:11:23.0506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3690 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The light sensor's power supply could be controlled by regulator on some platforms, such as i.MX6Q-SABRESD board, the light sensor isl29023's power supply is controlled by a GPIO fixed regulator, need to make sure the regulator is enabled before any operation of sensor, this patch adds optional vdd/vdda regulator operation support. Signed-off-by: Anson Huang --- ChangeLog since V2: - Add defer_probe check if the return value from devm_regulator_get_optional is ERR_PTR(-EPROBE_DEFER); - Replace the "vcc" with "vdd" according to datasheet, and add optional "vdda" supply as well since isl29018 also has a vdda supply. --- drivers/iio/light/isl29018.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c index b45400f..477eb95 100644 --- a/drivers/iio/light/isl29018.c +++ b/drivers/iio/light/isl29018.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,8 @@ struct isl29018_chip { struct isl29018_scale scale; int prox_scheme; bool suspended; + struct regulator *vdd_reg; + struct regulator *vdda_reg; }; static int isl29018_set_integration_time(struct isl29018_chip *chip, @@ -735,6 +738,28 @@ static int isl29018_probe(struct i2c_client *client, mutex_init(&chip->lock); + chip->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd"); + if (!IS_ERR(chip->vdd_reg)) { + err = regulator_enable(chip->vdd_reg); + if (err) { + dev_err(&client->dev, "failed to enable VDD regulator\n"); + return err; + } + } else if (chip->vdd_reg == ERR_PTR(-EPROBE_DEFER)) { + return -EPROBE_DEFER; + } + + chip->vdda_reg = devm_regulator_get_optional(&client->dev, "vdda"); + if (!IS_ERR(chip->vdda_reg)) { + err = regulator_enable(chip->vdda_reg); + if (err) { + dev_err(&client->dev, "failed to enable VDDA regulator\n"); + return err; + } + } else if (chip->vdda_reg == ERR_PTR(-EPROBE_DEFER)) { + return -EPROBE_DEFER; + } + chip->type = dev_id; chip->calibscale = 1; chip->ucalibscale = 0; @@ -768,6 +793,7 @@ static int isl29018_probe(struct i2c_client *client, static int isl29018_suspend(struct device *dev) { struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev)); + int ret; mutex_lock(&chip->lock); @@ -777,6 +803,22 @@ static int isl29018_suspend(struct device *dev) * So we do not have much to do here. */ chip->suspended = true; + if (!IS_ERR(chip->vdd_reg)) { + ret = regulator_disable(chip->vdd_reg); + if (ret) { + dev_err(dev, "failed to disable VDD regulator\n"); + mutex_unlock(&chip->lock); + return ret; + } + } + if (!IS_ERR(chip->vdda_reg)) { + ret = regulator_disable(chip->vdda_reg); + if (ret) { + dev_err(dev, "failed to disable VDDA regulator\n"); + mutex_unlock(&chip->lock); + return ret; + } + } mutex_unlock(&chip->lock); @@ -790,6 +832,23 @@ static int isl29018_resume(struct device *dev) mutex_lock(&chip->lock); + if (!IS_ERR(chip->vdd_reg)) { + err = regulator_enable(chip->vdd_reg); + if (err) { + dev_err(dev, "failed to enable VDD regulator\n"); + mutex_unlock(&chip->lock); + return err; + } + } + if (!IS_ERR(chip->vdda_reg)) { + err = regulator_enable(chip->vdda_reg); + if (err) { + dev_err(dev, "failed to enable VDDA regulator\n"); + mutex_unlock(&chip->lock); + return err; + } + } + err = isl29018_chip_init(chip); if (!err) chip->suspended = false;