Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757865AbcC2RVb (ORCPT ); Tue, 29 Mar 2016 13:21:31 -0400 Received: from 94-40-87-198.alarmadi.pl ([94.40.87.198]:49390 "EHLO skyboo.net" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753103AbcC2RV3 (ORCPT ); Tue, 29 Mar 2016 13:21:29 -0400 X-Greylist: delayed 2307 seconds by postgrey-1.27 at vger.kernel.org; Tue, 29 Mar 2016 13:21:29 EDT From: Mariusz Bialonczyk To: linux-kernel@vger.kernel.org, Evgeniy Polyakov , Ben Gardner , Michael Arndt Cc: Mariusz Bialonczyk Date: Tue, 29 Mar 2016 18:41:38 +0200 Message-Id: <1459269698-11500-1-git-send-email-manio@skyboo.net> X-Mailer: git-send-email 2.8.0.rc3 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: manio@skyboo.net Subject: [PATCH] w1: enable active pullup for DS2482 by default X-SA-Exim-Version: 4.2.1 (built Mon, 06 Jul 2015 07:28:29 +0000) X-SA-Exim-Scanned: Yes (on skyboo.net) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2342 Lines: 68 This commit enables the active pullup (APU bit) by default for the DS2482 1-Wire master. >From the DS2482 datasheet: "The APU bit controls whether an active pullup (controlled slew-rate transistor) or a passive pullup (Rwpu resistor) will be used to drive a 1-Wire line from low to high. When APU = 0, active pullup is disabled (resistor mode). Active Pullup should always be selected unless there is only a single slave on the 1-Wire line." According to the module author, Ben Gardner: "It doesn't look like active pullup would cause any hurt if there is only a single slave." And my tests with multiple and single slaves on 1-Wire bus confirms that. This active pullup can be manually disabled using the introduced module parameter: active_pullup = 0 --- drivers/w1/masters/ds2482.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c index b05e8fe..2e30db1 100644 --- a/drivers/w1/masters/ds2482.c +++ b/drivers/w1/masters/ds2482.c @@ -24,6 +24,19 @@ #include "../w1_int.h" /** + * Allow the active pullup to be disabled, default is enabled. + * + * Note from the DS2482 datasheet: + * The APU bit controls whether an active pullup (controlled slew-rate + * transistor) or a passive pullup (Rwpu resistor) will be used to drive + * a 1-Wire line from low to high. When APU = 0, active pullup is disabled + * (resistor mode). Active Pullup should always be selected unless there is + * only a single slave on the 1-Wire line. + */ +static int ds2482_active_pullup = 1; +module_param_named(active_pullup, ds2482_active_pullup, int, 0644); + +/** * The DS2482 registers - there are 3 registers that are addressed by a read * pointer. The read pointer is set by the last command executed. * @@ -138,6 +151,9 @@ struct ds2482_data { */ static inline u8 ds2482_calculate_config(u8 conf) { + if (ds2482_active_pullup) + conf |= DS2482_REG_CFG_APU; + return conf | ((~conf & 0x0f) << 4); } @@ -546,6 +562,8 @@ static int ds2482_remove(struct i2c_client *client) module_i2c_driver(ds2482_driver); +MODULE_PARM_DESC(active_pullup, "Active pullup (apply to all buses): " \ + "0-disable, 1-enable (default)"); MODULE_AUTHOR("Ben Gardner "); MODULE_DESCRIPTION("DS2482 driver"); MODULE_LICENSE("GPL"); -- 2.8.0.rc3