From patchwork Thu Nov 10 17:19:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9421659 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 402D1601C0 for ; Thu, 10 Nov 2016 17:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1671E297DA for ; Thu, 10 Nov 2016 17:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09FD9297DE; Thu, 10 Nov 2016 17:19:59 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 5DE2F297DA for ; Thu, 10 Nov 2016 17:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935627AbcKJRTk (ORCPT ); Thu, 10 Nov 2016 12:19:40 -0500 Received: from quartz.orcorp.ca ([184.70.90.242]:58328 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934541AbcKJRTj (ORCPT ); Thu, 10 Nov 2016 12:19:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date; bh=FaVnrUENuf0w1tIAomJvU6trCNhEWS8qoRacZH5C/2Q=; b=zOJYaIw1EfSQu6fi+S9TNbngdew8T69j0FACf2rCVbBc6yqZJ+W0NpTBS1aGVTSSRhfoFVcmqAirhYYE9jKMJsKLt1/YdsvTeSJPX8Pj+Z/U0KfYvu8lSTar9CekXX3aE9aj7tqBxR9DY8PduzmD9C8Ru8pyi+XpaV+c6j/jRFA=; Received: from jgg by quartz.orcorp.ca with local (Exim 4.84_2) (envelope-from ) id 1c4t0i-0007i4-NY; Thu, 10 Nov 2016 10:19:36 -0700 Date: Thu, 10 Nov 2016 10:19:36 -0700 From: Jason Gunthorpe To: Guenter Roeck Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org Subject: [PATCH] lm87: Allow LM87_REG_CHANNEL_MODE to be set via DT Message-ID: <20161110171936.GA29537@obsidianresearch.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) 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 This compliments the existing scheme that lets it be set via platform_data. Signed-off-by: Jason Gunthorpe --- Documentation/devicetree/bindings/hwmon/lm87.txt | 27 ++++++++++++++++++++++++ drivers/hwmon/lm87.c | 8 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/lm87.txt diff --git a/Documentation/devicetree/bindings/hwmon/lm87.txt b/Documentation/devicetree/bindings/hwmon/lm87.txt new file mode 100644 index 00000000000000..4ea2646ce8d2f0 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/lm87.txt @@ -0,0 +1,27 @@ +* LM87 I2C Temperature and Fan sensor + +Required properties: +- compatible: should contain one of + * "national,lm87" + * "ti,lm87" + +Optional properties: +- channel-mode: Write the specified value to register 0x16. If not specified + the driver will read the value from the chip at startup. + + The value controls how the driver operates certain multi-use + pins, eg bit 2 will select between temp_input3 or + in0&in5 operation. + +See Documentation/devicetree/bindings/i2c/i2c.txt for more required and +optional properties. + +Example: + +i2c_master { + temperature-sensor@0 { + compatible = "ti,lm87"; + channel-mode = <0x4>; + reg = <0>; + }; +}; diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 81cb898245a107..ccc0c913b4534e 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -853,9 +853,15 @@ static void lm87_restore_config(void *arg) static int lm87_init_client(struct i2c_client *client) { struct lm87_data *data = i2c_get_clientdata(client); + u32 channel; int rc; - if (dev_get_platdata(&client->dev)) { + if (client->dev.of_node && + !of_property_read_u32(client->dev.of_node, "channel-mode", + &channel)) { + data->channel = channel; + lm87_write_value(client, LM87_REG_CHANNEL_MODE, data->channel); + } else if (dev_get_platdata(&client->dev)) { data->channel = *(u8 *)dev_get_platdata(&client->dev); lm87_write_value(client, LM87_REG_CHANNEL_MODE, data->channel);