From patchwork Wed Jul 9 13:58:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Trumtrar X-Patchwork-Id: 368229 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40A1F14011B for ; Wed, 9 Jul 2014 23:58:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755575AbaGIN6b (ORCPT ); Wed, 9 Jul 2014 09:58:31 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:47722 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755276AbaGIN6b (ORCPT ); Wed, 9 Jul 2014 09:58:31 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:a236:9fff:fe00:814]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1X4sOE-0002Jp-0T; Wed, 09 Jul 2014 15:58:30 +0200 Received: from str by dude.hi.pengutronix.de with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1X4sOB-00025H-9b; Wed, 09 Jul 2014 15:58:27 +0200 From: Steffen Trumtrar To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Evgeniy Polyakov , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring , Steffen Trumtrar Subject: [PATCH] w1: ds2482: add support for ds2482-101 sleep pin Date: Wed, 9 Jul 2014 15:58:17 +0200 Message-Id: <1404914297-3108-1-git-send-email-s.trumtrar@pengutronix.de> X-Mailer: git-send-email 2.0.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:a236:9fff:fe00:814 X-SA-Exim-Mail-From: str@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The ds2482-101 version of the chip has an active-low sleep pin. Add this as a gpio to the probe function and describe the DT binding accordingly. If the pin wouldn't be added and pulled high, the device would not be able to be probed. Signed-off-by: Steffen Trumtrar --- Documentation/devicetree/bindings/w1/ds2482.txt | 18 ++++++++++++++++++ drivers/w1/masters/ds2482.c | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/w1/ds2482.txt diff --git a/Documentation/devicetree/bindings/w1/ds2482.txt b/Documentation/devicetree/bindings/w1/ds2482.txt new file mode 100644 index 0000000..e065207 --- /dev/null +++ b/Documentation/devicetree/bindings/w1/ds2482.txt @@ -0,0 +1,18 @@ +ds2482 devicetree bindings + +Required properties: + + - compatible: "dallas,ds2482" + +Optional properties: + + - sleep-gpios: if specified, the ds2482 has a low-active sleep-pin (ds2482-101). + +Example: + + 1wire@18 { + compatible = "dallas,ds2482"; + reg = <0x18>; + sleep-gpios = <&gpio4 2 0>; + }; + diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c index e033491..b6b6024 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "../w1.h" @@ -128,6 +129,7 @@ struct ds2482_data { u8 channel; u8 read_prt; /* see DS2482_PTR_CODE_xxx */ u8 reg_config; + struct gpio_desc *slpz_gpio; }; @@ -449,6 +451,7 @@ static int ds2482_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ds2482_data *data; + struct gpio_desc *gpio; int err = -ENODEV; int temp1; int idx; @@ -466,6 +469,12 @@ static int ds2482_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, data); + gpio = devm_gpiod_get(&client->dev, "sleep"); + if (!IS_ERR(gpio)) { + data->slpz_gpio = gpio; + gpiod_direction_output(data->slpz_gpio, 1); + } + /* Reset the device (sets the read_ptr to status) */ if (ds2482_send_cmd(data, DS2482_CMD_RESET) < 0) { dev_warn(&client->dev, "DS2482 reset failed.\n");