From patchwork Tue Feb 14 13:23:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Franchi X-Patchwork-Id: 9571957 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 BDEAA60586 for ; Tue, 14 Feb 2017 13:24:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF4DA27C2D for ; Tue, 14 Feb 2017 13:24:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2EA92841E; Tue, 14 Feb 2017 13:24:39 +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 C5BB128409 for ; Tue, 14 Feb 2017 13:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753181AbdBNNYc (ORCPT ); Tue, 14 Feb 2017 08:24:32 -0500 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:43955 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753160AbdBNNXE (ORCPT ); Tue, 14 Feb 2017 08:23:04 -0500 Received: from BN6PR03CA0046.namprd03.prod.outlook.com (10.175.124.32) by BN6PR03MB2947.namprd03.prod.outlook.com (10.175.126.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Tue, 14 Feb 2017 13:23:00 +0000 Received: from BN1AFFO11FD008.protection.gbl (2a01:111:f400:7c10::186) by BN6PR03CA0046.outlook.office365.com (2603:10b6:404:10c::32) 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; Tue, 14 Feb 2017 13:23:01 +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 BN1AFFO11FD008.mail.protection.outlook.com (10.58.52.68) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.904.16 via Frontend Transport; Tue, 14 Feb 2017 13:23:00 +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 v1EDMvnj029327; Tue, 14 Feb 2017 06:22:58 -0700 From: Marco Franchi To: CC: , , , , , Marco Franchi Subject: [PATCH v2 2/2] hwmon: (sht15) Add device tree support Date: Tue, 14 Feb 2017 11:23:24 -0200 Message-ID: <1487078605-11067-1-git-send-email-marco.franchi@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131315521809542270; (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)(7916002)(336005)(39450400003)(39850400002)(39860400002)(39840400002)(39400400002)(39380400002)(39410400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(36756003)(86362001)(54906002)(626004)(8656002)(104016004)(305945005)(356003)(77096006)(110136004)(81003)(39060400002)(4326007)(85426001)(38730400002)(2906002)(50986999)(105606002)(47776003)(50226002)(68736007)(48376002)(50466002)(189998001)(5660300001)(97736004)(53936002)(2351001)(106466001)(81166006)(8676002)(33646002)(81156014)(8936002)(6916009)(6666003)(5003940100001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2947; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD008; 1:WV6Y8FXx1I09e0HTzVIDHPVd2gVsO3/auwgT8G7WHsBPvKxgwn0tvqynRnu+ncFPB+06DfrXGW5TTPXAGY0+EQqp4+TVN+S/dzKyoAo3S4wk0AevY8wigsWYnN1/3AQFqTsUt3UmzULEsiZuVkhMA8Lkl3fup+qRQNpOzvKQ4APFjTClpXZol2MUfBOU+1Ml2JrGvz/U08bo5lauzx0FAfMjUx2JwF2QBHhvDW6JI0kCacU6afii79Pphp+WqfrJVDPnjNPaED+C2/VAsNMJngh9i/5X37bR8igdPSc3pp39BUCxKcpDbfiptIA5ap7F/2x8wft2gBB8ipFWa13boYBWmar4V8o8Si5IuJOFQrDAK2LGoZU7YEFPLh8Za2hgQnA9v7B66SkQSY/Yv1JUaqD5JdVPrqYFf4Squl2A758cRR8RGzOt3AaboOZcuwl4of2ffTdRqB8wOskSPLpQRP7/TfpmTeLVFJT/ByeZusUOKpHCEXA5fY5lsl5/lIzrdnydGu8kkgPZDlx0OCNS++t7xN1+06BahYSjcjPXZf0RW+AxOZKNPtjME1JnViYsUV+yQI2hyp5k46TI3ygyPdBUZ+DwLXeTLqTZ7mWKSZamgKXnpINfQExu6EIQ3uLJ4eI8TRIrV/4n8eY0GyaI6hWgoMXZ9ffUxYqeltv3gKDbTrXvwYAA79avdO67oXl6NmHrb1FNhLEEaQ86fLRoNg== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c9c6fdba-7cc5-4707-4435-08d454dc995a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2947; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2947; 3:+wNBoIxwi7Uhro/ZxBFbuv2S/KGT3Wbc5ewyXASod7z40gRTsxj63+i7u0zbLWWI/eY9SR1QBkqLV/Z9sFmIXHZ8pWrOZlIW0t/Cp0SMGlT1vZX5ufOZE/CUFGOx4EPBDsdzPfWrq1ns+wwrEPk/kqjJAmjKp6SHYC44MuVnu91eLHBT4sdT3hrNWGFpsJMmGMmFX7lzzKyzaHLFX9Vpp5jXCrp4s7qXNVn7smNHzbBGmOJkShrn0SH6b02QvcOVwD3MAwWxbsFYDitgYhv5sovvq8KUXQ8mPmkAhyH66DWofAOkxj7n6M74KILoNHTpR9BPGQGGst+/+bsx7f3lRC8kbwCi9HwuXa5sAFx7LC9tGirA+J1sekwgmCbz/B/H; 25:kf+qh6uwsXdDbKbVI+7LFz9hweN1z8FbfDKMjBz2YL4QoopYovqS27BuDNZBm4dbd0EUFZiJJDJo63Gm536jUXkqxZgN2BkH5t+/K0DttJ/cxn9DcI8jZ/j/Wy53m5zfX84LtZWfGU0iaknoFNObmVOfMYNM7Wrx5EEsupd2KaM3vS3tWyaIh3RhJxKKrORIZBG3uHbZwXthqg+TkOQPCeFuJOvmPVHQslTAykArTl2k8VopQCtFOVuOTMw5uf5KYFB0/KRl4IopF6/QiDBZhZj59eD6qD7j4u/IMp5/SstNCBIaSLbdb3+1tzU7D423iqLhIuN4SiNM8U/QHH4Rx0z7BjWfwmzn3fDcWZUFOHT0RCl2aynw1ECZE96SVpixO4R5SpqxCDrmMg5pR4NcUZ698ysKNH2ZdVAkuJb0OI9kYHz6spXZjd9bgQCkCI1vprZCXKJrqiLEh9+pyZLVWw== X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2947; 31:082TIFgFyzlhOgw1tNVb1ls82SRWxAKhCYDjq8tXdgo/tFeEcTtHyGdk4DSU2R0O4y2IDOKnxgmqNnPPhI+iPjoKJXHEUpFhC96TQaoC41p+MDEayUBqeR1nUcj1+jegJpBy3HZoJ+JdXntkxx7Z023CmzH2buSMt6Xh/ZfsucZklMJMAXX+X8DDDfGgac88cWvNBuDuosEARSiHt07kCZoxbnLlTUDT1yZg28jzU8wZ8OEP4U7qenNRW4azLkr1Q05KkLyqp9gjNuV16bCbAQ== 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)(13023025)(13017025)(13015025)(5005006)(8121501046)(13024025)(13018025)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123561025)(20161123565025)(20161123559025)(20161123556025); SRVR:BN6PR03MB2947; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2947; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2947; 4:N6CiqC5WA9eV+ZPt6eC9BcMxWJ0Mvn1fJ4/HM1RtSWJqDkQFo/olFVQwgwUxFNWP3kGpR0Fw9UQLVvLaMnYyt5u7XBCUwvT3WqmdqD5uYbggRuyoo1LQszR5c+mOWzVep1ZO5/07Jnoheeyivss80t/iUeqX5i+Yi2z7mG5KAWS56AJx56s82GWqoLbE2mejlNPqMY+Yy8DvClKCuRueX3Uvihdipjzz9oykf2o1EF9Kl2F4vciRVJVOC59NmJo6KEVYnDSuIaSiHKgchsTD9CEdTMGkYtGnkcZYsmV1UqUdxF+QUyANq3X/lqILE1CA/KD2sTEEkCWJ8kB/KdEyq04I16FwpG276C1fUQjr88vRWUGEM/Fs4W49qH8T5gtx68ZePlQIjApIoGvG2G+79MOaMCXBsQbmRxacRJhbchj6hhRsd3lYT4iaaAaLcxKJ7fpreCCS1yM+PkZIXZM0fDcT9WyGtCXzt1xhGpeQQGrEqkuQL4l5kVyZ3ZTWuKatRpxQE49XZLu+cVQfku0xLbSrR2TbbFzWYyBd3nyUh7HH3GocX5zvAUkMqnSlcmZew2kQvmBU4cYACfaoqTlFcabCy702tQXX0/CmVpJ3L+kG0InPPTdoeJIafRKgileAuXF1PrIE1QiqHwBMi1IbE3uTLwFI0X0K+3FmN9gEMgevi95HjBFIJI5v05owQydUCcGF0LtpQVCy21NE8fYESJfUd2NtA7NT7rK3eiSC0qqyoJT4MvbxNQWPn/AbnbrA X-Forefront-PRVS: 0218A015FA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2947; 23:4MxFlyb0Nif6DWOuuS16S6WM6O9envzrDiDnkyjqf?= =?us-ascii?Q?rLpaNSIawljI5MAGGnFkOSw91BXO6qlxmcV2WRcLU/oGjpo2nyhWhjwMGObU?= =?us-ascii?Q?RUML8cE+un+5S5GmI/T1FC2zmp9TEAAn5Y/Iq0N/VjrvvUTQ0CXTwpAAwpjW?= =?us-ascii?Q?T6vwJ+/I8TOt9a1iYro8DIhGfnMkeuHNDTTsswkbbA6VIf1R+rmQmJHIshpF?= =?us-ascii?Q?9Co/J/2PIGkmsOUmGWY56HKLDIqsof+9ExlrIg+qfZSRtDHK5DP6N0FGJhAD?= =?us-ascii?Q?dUkYNGwejGzBEVrVyIErDNPgiAWxd6QuvyKqNJ+DHfVKyt0uTc703UZjq1bK?= =?us-ascii?Q?vnF1k6aHsW7jO+hRKA4xrtNNjXVgSiNRuFBuTW+Ls0TOq14EISqicJKYuEKe?= =?us-ascii?Q?i5iXY91P1l4o8f4qDJLUVehO/+bfRg+qdvOlXTH45N4moYNxqskBsaHKY8Mc?= =?us-ascii?Q?sC/9ud1wC3sQK6Et1s0Ssvvos0wA8fO1YC7pVU3x2jDTrNk7q0l8n/LunLZu?= =?us-ascii?Q?fiWruz9LVq3MndhFlSzznhZ2sbZd6kdMkbXZiYgEn+G5YHo1XX4u08MB5YDE?= =?us-ascii?Q?+WaOgHqD76ahTAwfCvERNUpBHAaTQ3F4agUKH0/jdO8g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u7vbC0xorIhLZKzLP4RkNnpxUB5oSb9lqr7Z0up4EMz3uFe81p8M2IPGgW4OJieDeb5CUQJfC9vRgTnJbTZzXvBmlvZAhd8kQEM+MOqg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2017 13:23:00.6579 (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: BN6PR03MB2947 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 device tree 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 --- Changes since v1: - reworked to not require int returns in the sht15_probe_dt function; - add a clear preference for dt or platform data - Use 'device tree' instead of 'dts' in the Subject Documentation/devicetree/bindings/hwmon/sht15.txt | 25 +++++++++ drivers/hwmon/sht15.c | 66 +++++++++++++++++++++-- 2 files changed, 87 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..70906f1 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,56 @@ 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 NULL if pdev isn't a device instatiated by dt, + * a pointer to the data if it could successfully get all information + * from dt or a negative error number. + */ +static struct sht15_platform_data *sht15_probe_dt(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct sht15_platform_data *pdata; + + /* no device tree device */ + if (!np) + return NULL; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->gpio_data = of_get_named_gpio(np, "data-gpios", 0); + if (pdata->gpio_data < 0) { + dev_err(dev, "data-gpios not found\n"); + return ERR_PTR(-EINVAL); + } + + pdata->gpio_sck = of_get_named_gpio(np, "clk-gpios", 0); + if (pdata->gpio_sck < 0) { + dev_err(dev, "clk-gpios not found\n"); + return ERR_PTR(-EINVAL); + } + + pdata->checksum = of_property_read_bool(np, "checksum"); + pdata->no_otp_reload = of_property_read_bool(np, "no-otp-reload"); + pdata->low_resolution = of_property_read_bool(np, "low-resolution"); + + return pdata; +} +#else +static inline struct sht15_platform_data *sht15_probe_dt(struct device *dev) +{ + return NULL; +} +#endif + static int sht15_probe(struct platform_device *pdev) { int ret; @@ -928,11 +979,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; + data->pdata = sht15_probe_dt(&pdev->dev); + if (IS_ERR(data->pdata)) + return PTR_ERR(data->pdata); + if (data->pdata == NULL) { + data->pdata = dev_get_platdata(&pdev->dev); + if (data->pdata == NULL) { + dev_err(&pdev->dev, "no platform data supplied\n"); + return -EINVAL; + } } - data->pdata = dev_get_platdata(&pdev->dev); + data->supply_uv = data->pdata->supply_mv * 1000; if (data->pdata->checksum) data->checksumming = true; @@ -1075,6 +1132,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,