Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28604
b: refs/heads/master
c: 1200337
h: refs/heads/master
v: v3
  • Loading branch information
Evgeniy Polyakov authored and Greg Kroah-Hartman committed Jun 22, 2006
1 parent dec457c commit 88cda04
Show file tree
Hide file tree
Showing 13 changed files with 446 additions and 133 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 81f6075ebcf3b0800321b7d81e4845d6ad9566d8
refs/heads/master: 12003375acd879e498c6c511faf27531296f9640
98 changes: 98 additions & 0 deletions trunk/Documentation/w1/w1.netlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Userspace communication protocol over connector [1].


Message types.
=============

There are three types of messages between w1 core and userspace:
1. Events. They are generated each time new master or slave device found
either due to automatic or requested search.
2. Userspace commands. Includes read/write and search/alarm search comamnds.
3. Replies to userspace commands.


Protocol.
========

[struct cn_msg] - connector header. It's length field is equal to size of the attached data.
[struct w1_netlink_msg] - w1 netlink header.
__u8 type - message type.
W1_SLAVE_ADD/W1_SLAVE_REMOVE - slave add/remove events.
W1_MASTER_ADD/W1_MASTER_REMOVE - master add/remove events.
W1_MASTER_CMD - userspace command for bus master device (search/alarm search).
W1_SLAVE_CMD - userspace command for slave device (read/write/ search/alarm search
for bus master device where given slave device found).
__u8 res - reserved
__u16 len - size of attached to this header data.
union {
__u8 id; - slave unique device id
struct w1_mst {
__u32 id; - master's id.
__u32 res; - reserved
} mst;
} id;

[strucrt w1_netlink_cmd] - command for gived master or slave device.
__u8 cmd - command opcode.
W1_CMD_READ - read command.
W1_CMD_WRITE - write command.
W1_CMD_SEARCH - search command.
W1_CMD_ALARM_SEARCH - alarm search command.
__u8 res - reserved
__u16 len - length of data for this command.
For read command data must be allocated like for write command.
__u8 data[0] - data for this command.


Each connector message can include one or more w1_netlink_msg with zero of more attached w1_netlink_cmd messages.

For event messages there are no w1_netlink_cmd embedded structures, only connector header
and w1_netlink_msg strucutre with "len" field being zero and filled type (one of event types)
and id - either 8 bytes of slave unique id in host order, or master's id, which is assigned
to bus master device when it is added to w1 core.

Currently replies to userspace commands are only generated for read command request.
One reply is generated exactly for one w1_netlink_cmd read request.
Replies are not combined when sent - i.e. typical reply messages looks like the following:
[cn_msg][w1_netlink_msg][w1_netlink_cmd]
cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd->len;
w1_netlink_msg.len = sizeof(struct w1_netlink_cmd) + cmd->len;
w1_netlink_cmd.len = cmd->len;


Operation steps in w1 core when new command is received.
=======================================================

When new message (w1_netlink_msg) is received w1 core detects if it is master of slave request,
according to w1_netlink_msg.type field.
Then master or slave device is searched for.
When found, master device (requested or those one on where slave device is found) is locked.
If slave command is requested, then reset/select procedure is started to select given device.

Then all requested in w1_netlink_msg operations are performed one by one.
If command requires reply (like read command) it is sent on command completion.

When all commands (w1_netlink_cmd) are processed muster device is unlocked
and next w1_netlink_msg header processing started.


Connector [1] specific documentation.
====================================

Each connector message includes two u32 fields as "address".
w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header.
Each message also includes sequence and acknowledge numbers.
Sequence number for event messages is appropriate bus master sequence number increased with
each event message sent "through" this master.
Sequence number for userspace requests is set by userspace application.
Sequence number for reply is the same as was in request, and
acknowledge number is set to seq+1.


Additional documantion, source code examples.
============================================

1. Documentation/connector
2. http://tservice.net.ru/~s0mbre/archive/w1
This archive includes userspace application w1d.c which
uses read/write/search commands for all master/slave devices found on the bus.
2 changes: 1 addition & 1 deletion trunk/drivers/w1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for the Dallas's 1-wire bus.
#

ifneq ($(CONFIG_NET), y)
ifeq ($(CONFIG_CONNECTOR), n)
EXTRA_CFLAGS += -DNETLINK_DISABLED
endif

Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/w1/slaves/w1_ds2433.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#endif

#include "../w1.h"
#include "../w1_io.h"
#include "../w1_int.h"
#include "../w1_family.h"

Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/w1/slaves/w1_smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <linux/types.h>

#include "../w1.h"
#include "../w1_io.h"
#include "../w1_int.h"
#include "../w1_family.h"

Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/w1/slaves/w1_therm.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <linux/delay.h>

#include "../w1.h"
#include "../w1_io.h"
#include "../w1_int.h"
#include "../w1_family.h"

Expand Down
Loading

0 comments on commit 88cda04

Please sign in to comment.