From patchwork Fri Feb 10 14:30:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Franchi X-Patchwork-Id: 9566867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21EF460216 for ; Fri, 10 Feb 2017 14:31:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E9362858D for ; Fri, 10 Feb 2017 14:31:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037AB2858F; Fri, 10 Feb 2017 14:31:28 +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=-6.9 required=2.0 tests=BAYES_00,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 43E4D2858E for ; Fri, 10 Feb 2017 14:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752618AbdBJObP (ORCPT ); Fri, 10 Feb 2017 09:31:15 -0500 Received: from mail-cys01nam02on0070.outbound.protection.outlook.com ([104.47.37.70]:64832 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752338AbdBJOa7 (ORCPT ); Fri, 10 Feb 2017 09:30:59 -0500 Received: from BN6PR03CA0021.namprd03.prod.outlook.com (10.168.230.159) by DM2PR0301MB0736.namprd03.prod.outlook.com (10.160.97.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Fri, 10 Feb 2017 14:30:50 +0000 Received: from BY2FFO11FD015.protection.gbl (2a01:111:f400:7c0c::130) by BN6PR03CA0021.outlook.office365.com (2603:10b6:404:23::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Fri, 10 Feb 2017 14:30:49 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD015.mail.protection.outlook.com (10.1.14.131) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.888.7 via Frontend Transport; Fri, 10 Feb 2017 14:30:49 +0000 Received: from b58965-3.am.freescale.net (b58965-3.am.freescale.net [10.29.244.100]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v1AEUkeN013147; Fri, 10 Feb 2017 07:30:47 -0700 From: Marco Franchi To: CC: , , , , , Marco Franchi Subject: [PATCH 2/2] hwmon: (sht15) Add DTS support Date: Fri, 10 Feb 2017 12:30:41 -0200 Message-ID: <1486737041-32014-1-git-send-email-marco.franchi@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131312106495568047; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39380400002)(39410400002)(39400400002)(39850400002)(39840400002)(39450400003)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(4326007)(5660300001)(105606002)(110136004)(92566002)(50986999)(53936002)(104016004)(77096006)(8656002)(39060400001)(38730400002)(54906002)(2351001)(68736007)(106466001)(50226002)(33646002)(5003940100001)(50466002)(356003)(305945005)(48376002)(36756003)(2906002)(47776003)(85426001)(8936002)(626004)(189998001)(97736004)(6916009)(81156014)(81166006)(86362001)(8676002)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0736; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD015; 1:SefzwF9wChBCtogkyOsRfG3wTiiXN1FkqvReWa5j0UevkT6XGkPuFJQYPBUGyaoX9Wb7fsRTuFL4B9mxUF8WgFjDKFeOOMaQVWLF0UNr1LaWXhZefdNssfMIR3/D2BERQ2KXsTyZ4mtxqN3HM8p4FSQF4yQKKs04iegOc4pYrj4oCJYZCOon2IJJSbkFDuNsZA67aiiQm1YX5QQZUnPRRV3Vttb37jzN/4idzcAnbphapx5Yhcw0dW/ycyNFILkqtF2Hha2TPyb8qFi3p1Y79zWfJcWfWx3Fkmah4V0oLZyKU+AmQqLBMlWRLb4cYBxngMhOjgm9yNHBHWpKXOcthNYBHMMSWjIjhY9t1MQyK74JcKPZYY1Fp0pEWh2/+nPfDOp9Qo4fJzK4tQIk1tOfjQDGpdxcRlUuWQeK1BTVvmzp0cElPAVk7r7j1OHg0fH5j8EeH7J4cgW6MC64TzezsaiGQXsxRbbx9OW5ZguvuX/kNh2C0fsqCscaVGA0+PhLraXwwgcLC6UAoCSa6y+Y8dEw7EtuH+wfLEHmEIZ6lrgaNT9fuTrhum5bB5+1v7qDxm2xnZeOW3gp7fOGN1BuGUTeC+o4JdMqnsly82bhMu/R6YrWRqd+2u0L6sLT+4o0UzxRjqy3kB0/xD9xiRHL1MMSWyFlgpCcz96njBiPogOGGWVLL1E8i1en19ksOW8ZkFlwXCzqwMj4h3S0Mm20YA== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0e651352-44a3-4383-68af-08d451c168d7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0736; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0736; 3:DnW5fHcg3u/q0LJiesz9PcZb7zGOxx4m+S6Yp9A1BKMw0ChyUcg/Oa/OzdT0wqCQ3UIrCQetMOobBzw3tCh+GQqhkq79ugfFQuRfwTAfUXi7KbiZuI235uYSh2VpXXw7bvpclPm33g2aFU/bXgbwzn6hJAuDPE4vBh7mdHTeW4+/tLxM3TVmeI4xf9O2BxOOCnEV3flxQxinDpduK2LGWpTQ1/UEpy6l7M//eg/vKej3twORAAsMfwzzEx7eZPY1IQy7qeFj3ZeitrTNRKryDXOml+VDS2L5bwyiDuUA+BQ7UpyhOIa+hb/A+N1B1NFqSVm3PBB0Min86jRJra02ft+t5Z46WBBPOC5aZWcLYXu1HGVxugid7UbExdUsm2xX; 25:cMsLi0D4ZWnwOSw6VBZgAsLubASNQbNYWBJ2BVLBzzd3vqW1sMGXRMVmBet+k9kMjzutmIIvgyb4sRzwohjz1PMnamkjeLRnYfvCQJ6qIWOnjBklkJ3ERXzu2Pjr6ctmy1Vtdr9oJBBSrn7V+d60yCQzpZAuaFmgD8EwAL9//2dwKG5N3r/kQqaG7Ug/1ONq4Qm1i05LZPyT1CubEOgMdh5fmZRdMGckX6Bml2C0/LJq2qsQ5VEmx8wgvOtcqymC7gM8w8QYzo4hyrCp3Nww7mxaMOWuLP+he+1UdK12il9WOLjpYuqyPFq85oflcz2snO5avnJPt3CHa2YoXjITbwAVBOOofVzBTNmX3VZMHm4yZwlJmAb2gPiKt0j2Xy3T10vWSFxOnk7O0hKm5cxcYnwh2TYAfs+ODxmQlWcJ/Wq5yxmLSTwtzPifWAXauodRRbSwpzzkGpWOxiMXVplE8w== X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0736; 31:KCyxuOF12hewjRgYDBDhGoTRziCJGGSi5KxWC2kVzvQcyrYaIP0QBvCo58X/NvttwNCLbD0og/QXuhqCcIQRiB7XgGjpOC7eJdOjvO8RKOveP7Gai2QX2xkJk0dpVrradq295K9Yr+Sn/IXuX8i6V4OOL9FkS7sPJozD3qICAylQxtCWu0z1OTKRzFtEhM6QgfKrxXQEVsQDLNztPIghdm4JBeEDF8u+Ds8oKp6qblL85a4ZWoIjnZ3tSklzO+Lm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13017025)(13015025)(13024025)(13018025)(13023025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(20161123559025)(20161123556025); SRVR:DM2PR0301MB0736; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0736; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0736; 4:jA8O2AySxB9GLFhTMv7UODg5NmpXZcBSbVs1XvhallBM2ZF24mAd/llpUhYkh5rCV0708kTiCPwME4pcEWbP44eZIJvlSsTtWxQVIJjOZQHUXS7NnqkXEngNr5uGa3I6VNddoCGn6a28bpaJ4GK4T8CEfslFnzCykWo5/0NivV0/1ZDjldQpwbBSOorVVRv6TNQGLzDcJh1VLDrdr5Eye4cMIVHrrzqMTSBd/dsDPD5sS4A9p0KSwrkHCKifAevlc6enjhkunZo9JXmhWtchbr9bMUHd6c1Y0QA9FNBiL4GaRveZc5WOuA7gCuCYWRMPkx80mxhNHYwMURoKjEFuERaHJTmQB4SaKVncUuGLiJCj1wKqPcIj4fhndYk/fgLHbvlSNG29acvtJjXQlPcBJDNMQ9RyupXQNqXr7hvM6lk6+yTQHOFw0Z9YScBsyvKPm4h1T/HZY+0CpNU2Gh4fWMd+6RpJVZYb6L9W9hwSQM9066I6Q2dmF10XSlRIDRCk6pDG7GKhBoL+sMkeGBye5FSf5oLeewYg9FB+D1T3wFL8aDUhtnxBV5OK1WLnXSIXzoKs/aR4lTsh/91gIHhiDzmrlG90qNr4hAP4hAE4O5Zmy/IP/ok8RuwJTUwlf2cAEWXkDrTAANg0UUHS9QwRMIYeQrpaVb6IPSw3cu8zMpZUpSr0ES8WfYufArkdOdJeIwVdld86zg0MQDJ6k3+ztND+eK6yONffRrKgu2Ki5xYIsLxn3m6f6Utt34zohuZA X-Forefront-PRVS: 0214EB3F68 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0736; 23:OedW09Qc3/ddcdn2/LPWyjSukWta1mGV45VWkAQ?= =?us-ascii?Q?rARxIBlH2WxEp8Z4CQtm04Xan9C5BLkvb1xMb+j9mrpFWWRksviTf5zPwvyn?= =?us-ascii?Q?pVOTPzhPaIFLHgjenGe5aSUbxMPawvqjQEQmi8cuI1GmTJG3FBcRKF/vyPip?= =?us-ascii?Q?Tdw5PHfPunmg/bApndI63BVBQbj1zvdq1K0DniVHSS1QD4hguT21b6ldojh6?= =?us-ascii?Q?TpXzVow+1aD3DXTVu7B/ManZW4NJmNLBAX9pkdWBTnqQfZSNr2ox1/yQpeWq?= =?us-ascii?Q?DPelKiIeWs91ZL//8usGaF7ArrVl2oycImxNZ12lIHYI8jwxbIY9WceOK4EX?= =?us-ascii?Q?rVuYQNUQQnslA3NZiL2ZfDd4w5uFJCSdhJik5XhYWlHOqIJblmWWjQ2M+bEi?= =?us-ascii?Q?dWh4DEVUeoqxS9IGPsJGyQPed3+MeCkYUEENEse8goW8Ooqu/jc0xGh6bRXM?= =?us-ascii?Q?emXhvYLH7D+yKBB/ar4NSpEJ75SdTFkh0SZEZF5NavjYN4MQwEp1H88tIJlo?= =?us-ascii?Q?AdLEUbptINlUS6S/yoSebz4+MQkhk8xo141WF3tGxNpr4btBYUn7X21ETCOq?= =?us-ascii?Q?q5X62dbzyO6oRD34UXL0L+pmbPz5QceG+VhRzBZmZejVa1MenNnTNJwy9K9Q?= =?us-ascii?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aYL2vpD0Dak/w6I/pFZS06rdqoCz+B5lD0/iWXSjZNhZ3ayzxoAK3on3lF9wxZL+TQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2017 14:30:49.3540 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0736 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow the driver to work with dts support. Based on initial patch submission from Peter Fox. Tested on a imx7d-sdb board connected to a SHT15 board via Mikro Bus. Signed-off-by: Marco Franchi --- Documentation/devicetree/bindings/hwmon/sht15.txt | 25 ++++++++ drivers/hwmon/sht15.c | 69 +++++++++++++++++++++-- 2 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/sht15.txt diff --git a/Documentation/devicetree/bindings/hwmon/sht15.txt b/Documentation/devicetree/bindings/hwmon/sht15.txt new file mode 100644 index 0000000..6415f52 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/sht15.txt @@ -0,0 +1,25 @@ +Sensirion SHT15 Humidity and Temperature Sensor + +Required properties: + + - "compatible": must be "sensirion,sht15". + - "data-gpios": GPIO connected to the data line. + - "clk-gpios": GPIO connected to the clock line. + - "vcc-supply": regulator that drives the VCC pin. + +Optional properties: + + - "checksum": boolean property that when present enables the CRC validation of the readings. + - "no-otp-reload": boolean property that when present indicates not to reload from OTP. + - "low-resolution": boolean property that when present indicates that the device operates in + low-resolution mode. +Example: + + temp_humid_sensor: sht15 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sensor>; + compatible = "sensirion,sht15"; + clk-gpios = <&gpio4 12 0>; + data-gpios = <&gpio4 13 0>; + vcc-supply = <®_sht15>; + }; diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index f16687c..608ac9e 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c @@ -34,6 +34,7 @@ #include #include #include +#include /* Commands */ #define SHT15_MEASURE_TEMP 0x03 @@ -911,6 +912,59 @@ static int sht15_invalidate_voltage(struct notifier_block *nb, return NOTIFY_OK; } +#ifdef CONFIG_OF +static const struct of_device_id sht15_dt_match[] = { + { .compatible = "sensirion,sht15" }, + { }, +}; +MODULE_DEVICE_TABLE(of, sht15_dt_match); + +/* + * This function returns 1 if pdev isn't a device instatiated by dt, 0 if it + * could successfully get all information from dt or a negative error number. + */ +static int sht15_probe_dt(struct sht15_data *data, struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct sht15_platform_data *pdata; + + /* no device tree device */ + if (!np) + return 1; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + data->pdata = pdata; + + data->pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0); + if (data->pdata->gpio_data < 0) { + dev_err(&pdev->dev, "data-gpios not found\n"); + return data->pdata->gpio_data; + } + + data->pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0); + if (data->pdata->gpio_sck < 0) { + dev_err(&pdev->dev, "clk-gpios not found\n"); + return data->pdata->gpio_sck; + } + + data->pdata->checksum = of_property_read_bool(np, "checksum"); + data->pdata->no_otp_reload = of_property_read_bool(np, "no-otp-reload"); + data->pdata->low_resolution = of_property_read_bool(np, + "low-resolution"); + + return 0; +} +#else +static inline int sht15_probe_dt(struct sht15_data *data, + struct platform_device *pdev) +{ + return 1; +} +#endif + static int sht15_probe(struct platform_device *pdev) { int ret; @@ -928,11 +982,17 @@ static int sht15_probe(struct platform_device *pdev) data->dev = &pdev->dev; init_waitqueue_head(&data->wait_queue); - if (dev_get_platdata(&pdev->dev) == NULL) { - dev_err(&pdev->dev, "no platform data supplied\n"); - return -EINVAL; + ret = sht15_probe_dt(data, pdev); + if (ret > 0) { + if (dev_get_platdata(&pdev->dev) == NULL) { + dev_err(&pdev->dev, "no platform data supplied\n"); + return -EINVAL; + } + data->pdata = dev_get_platdata(&pdev->dev); + } else if (ret < 0) { + return ret; } - data->pdata = dev_get_platdata(&pdev->dev); + data->supply_uv = data->pdata->supply_mv * 1000; if (data->pdata->checksum) data->checksumming = true; @@ -1075,6 +1135,7 @@ MODULE_DEVICE_TABLE(platform, sht15_device_ids); static struct platform_driver sht15_driver = { .driver = { .name = "sht15", + .of_match_table = of_match_ptr(sht15_dt_match), }, .probe = sht15_probe, .remove = sht15_remove,