Skip to contentSkip to conversation

revised driver: w1_ds2406

PATCH Scott Alfter 3 participants 3 messages Jun 17, 2014 – Jun 19, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Some preliminary work at making use of this driver led me to implement CRC-16 checks on read and write to deal with the occasional glitchiness of the 1-Wire bus. The revised driver (attached) returns an I/O error if the CRC check fails. When reading the chip's state, either you get a valid indication or you get an I/O error. When changing its state, either the change is successful or an I/O error is returned.

This patch supersedes the patch I had previously submitted.

Scott Alfter
[email protected]

drivers/w1/slaves/Kconfig +7 -0
index 5e6a3c9..6b04f0f 100644
@@ -38,6 +38,13 @@ config W1_SLAVE_DS2413
 	  Say Y here if you want to use a 1-wire
 	  DS2413 Dual Channel Addressable Switch device support
 
+config W1_SLAVE_DS2406
+	tristate "Dual Channel Addressable Switch 0x12 family support (DS2406)"
+	help
+	  Say Y or M here if you want to use a 1-wire
+	  DS2406 Dual Channel Addressable Switch.  EPROM read/write
+	  support for these devices is not implemented.
+
 config W1_SLAVE_DS2423
 	tristate "Counter 1-wire device (DS2423)"
 	select CRC16
drivers/w1/slaves/Makefile +1 -0
index 06529f3..1e9989a 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_W1_SLAVE_THERM)	+= w1_therm.o
 obj-$(CONFIG_W1_SLAVE_SMEM)	+= w1_smem.o
 obj-$(CONFIG_W1_SLAVE_DS2408)	+= w1_ds2408.o
 obj-$(CONFIG_W1_SLAVE_DS2413)	+= w1_ds2413.o
+obj-$(CONFIG_W1_SLAVE_DS2406)	+= w1_ds2406.o
 obj-$(CONFIG_W1_SLAVE_DS2423)	+= w1_ds2423.o
 obj-$(CONFIG_W1_SLAVE_DS2431)	+= w1_ds2431.o
 obj-$(CONFIG_W1_SLAVE_DS2433)	+= w1_ds2433.o
drivers/w1/w1_family.h +1 -0
index 625dd08..56d8a0c 100644
@@ -40,6 +40,7 @@
 #define W1_FAMILY_DS2760	0x30
 #define W1_FAMILY_DS2780	0x32
 #define W1_FAMILY_DS2413	0x3A
+#define W1_FAMILY_DS2406	0x12
 #define W1_THERM_DS1825		0x3B
 #define W1_FAMILY_DS2781	0x3D
 #define W1_THERM_DS28EA00	0x42
Documentation/w1/slaves/w1_ds2406 new file +25 -0
new file mode 100644
index 0000000..8137fe6
@@ -0,0 +1,25 @@
+w1_ds2406 kernel driver
+=======================
+
+Supported chips:
+  * Maxim DS2406 (and other family 0x12) addressable switches
+
+Author: Scott Alfter <[email protected]>
+
+Description
+-----------
+
+The w1_ds2406 driver allows connected devices to be switched on and off. 
+These chips also provide 128 bytes of OTP EPROM, but reading/writing it is
+not supported.  In TSOC-6 form, the DS2406 provides two switch outputs and
+can be provided with power on a dedicated input.  In TO-92 form, it provides
+one output and uses parasitic power only.
+
+The driver provides two sysfs files.  state is readable; it gives the
+current state of each switch, with PIO A in bit 0 and PIO B in bit 1.  The
+driver ORs this state with 0x30, so shell scripts get an ASCII 0/1/2/3 to
+work with.  output is writable; bits 0 and 1 control PIO A and B,
+respectively.  Bits 2-7 are ignored, so it's safe to write ASCII data.
+
+CRCs are checked on read and write.  Failed checks cause an I/O error to be
+returned.  On a failed write, the switch status is not changed.
drivers/w1/slaves/w1_ds2406.c new file +168 -0

168 lines not on this page · raw message

#1 lore raw

Hi Scott

I've added Greg to copy.

18.06.2014, 00:42, "Scott Alfter" <[email protected]>:

Quoted 10 lines

Some preliminary work at making use of this driver led me to implement CRC-16 checks on read and write to deal with the occasional glitchiness of the 1-Wire bus.  The revised driver (attached) returns an I/O error if the CRC check fails.  When reading the chip's state, either you get a valid indication or you get an I/O error.  When changing its state, either the change is successful or an I/O error is returned.

This patch supersedes the patch I had previously submitted.

Greg, this patch looks good, please pull it into your tree. If you already applied previous ds2406, let us know.

#2 lore raw
Quoted 12 lines · Evgeniy Polyakov

Hi Scott

I've added Greg to copy.

18.06.2014, 00:42, "Scott Alfter" <[email protected]>:

Quoted 7 lines

Some preliminary work at making use of this driver led me to implement CRC-16 checks on read and write to deal with the occasional glitchiness of the 1-Wire bus.  The revised driver (attached) returns an I/O error if the CRC check fails.  When reading the chip's state, either you get a valid indication or you get an I/O error.  When changing its state, either the change is successful or an I/O error is returned.

Quoted 6 lines
Quoted 3 lines

This patch supersedes the patch I had previously submitted.

Greg, this patch looks good, please pull it into your tree. If you already applied previous ds2406, let us know.

I didn't, I'll take this one instead, thanks.

greg k-h