diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 23:58:09 -0500 |
commit | 2a7d2b96d5cba7568139d9ab157a0e97ab32440f (patch) | |
tree | ad029d8cc7b7068b7250e914360ec6315fdfa114 /drivers/w1 | |
parent | e3c4877de8b9d93bd47b6ee88eb594b1c1e10da5 (diff) | |
parent | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (diff) |
Merge branch 'akpm' (final batch from Andrew)
Merge third patch-bumb from Andrew Morton:
"This wraps me up for -rc1.
- Lots of misc stuff and things which were deferred/missed from
patchbombings 1 & 2.
- ocfs2 things
- lib/scatterlist
- hfsplus
- fatfs
- documentation
- signals
- procfs
- lockdep
- coredump
- seqfile core
- kexec
- Tejun's large IDR tree reworkings
- ipmi
- partitions
- nbd
- random() things
- kfifo
- tools/testing/selftests updates
- Sasha's large and pointless hlist cleanup"
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (163 commits)
hlist: drop the node parameter from iterators
kcmp: make it depend on CHECKPOINT_RESTORE
selftests: add a simple doc
tools/testing/selftests/Makefile: rearrange targets
selftests/efivarfs: add create-read test
selftests/efivarfs: add empty file creation test
selftests: add tests for efivarfs
kfifo: fix kfifo_alloc() and kfifo_init()
kfifo: move kfifo.c from kernel/ to lib/
arch Kconfig: centralise CONFIG_ARCH_NO_VIRT_TO_BUS
w1: add support for DS2413 Dual Channel Addressable Switch
memstick: move the dereference below the NULL test
drivers/pps/clients/pps-gpio.c: use devm_kzalloc
Documentation/DMA-API-HOWTO.txt: fix typo
include/linux/eventfd.h: fix incorrect filename is a comment
mtd: mtd_stresstest: use prandom_bytes()
mtd: mtd_subpagetest: convert to use prandom library
mtd: mtd_speedtest: use prandom_bytes
mtd: mtd_pagetest: convert to use prandom library
mtd: mtd_oobtest: convert to use prandom library
...
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/slaves/Kconfig | 13 | ||||
-rw-r--r-- | drivers/w1/slaves/Makefile | 3 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2413.c | 177 | ||||
-rw-r--r-- | drivers/w1/w1_family.h | 1 |
4 files changed, 189 insertions, 5 deletions
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 67526690acbc..762561fbabbf 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig | |||
@@ -17,11 +17,16 @@ config W1_SLAVE_SMEM | |||
17 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire. | 17 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire. |
18 | 18 | ||
19 | config W1_SLAVE_DS2408 | 19 | config W1_SLAVE_DS2408 |
20 | tristate "8-Channel Addressable Switch (IO Expander) 0x29 family support (DS2408)" | 20 | tristate "8-Channel Addressable Switch (IO Expander) 0x29 family support (DS2408)" |
21 | help | 21 | help |
22 | Say Y here if you want to use a 1-wire | 22 | Say Y here if you want to use a 1-wire |
23 | DS2408 8-Channel Addressable Switch device support | ||
23 | 24 | ||
24 | DS2408 8-Channel Addressable Switch device support | 25 | config W1_SLAVE_DS2413 |
26 | tristate "Dual Channel Addressable Switch 0x3a family support (DS2413)" | ||
27 | help | ||
28 | Say Y here if you want to use a 1-wire | ||
29 | DS2413 Dual Channel Addressable Switch device support | ||
25 | 30 | ||
26 | config W1_SLAVE_DS2423 | 31 | config W1_SLAVE_DS2423 |
27 | tristate "Counter 1-wire device (DS2423)" | 32 | tristate "Counter 1-wire device (DS2423)" |
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile index 05188f6aab5a..06529f3157ab 100644 --- a/drivers/w1/slaves/Makefile +++ b/drivers/w1/slaves/Makefile | |||
@@ -4,7 +4,8 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o | 5 | obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o |
6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o | 6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o |
7 | obj-$(CONFIG_W1_SLAVE_DS2408) += w1_ds2408.o | 7 | obj-$(CONFIG_W1_SLAVE_DS2408) += w1_ds2408.o |
8 | obj-$(CONFIG_W1_SLAVE_DS2413) += w1_ds2413.o | ||
8 | obj-$(CONFIG_W1_SLAVE_DS2423) += w1_ds2423.o | 9 | obj-$(CONFIG_W1_SLAVE_DS2423) += w1_ds2423.o |
9 | obj-$(CONFIG_W1_SLAVE_DS2431) += w1_ds2431.o | 10 | obj-$(CONFIG_W1_SLAVE_DS2431) += w1_ds2431.o |
10 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o | 11 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o |
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c new file mode 100644 index 000000000000..829786252c6b --- /dev/null +++ b/drivers/w1/slaves/w1_ds2413.c | |||
@@ -0,0 +1,177 @@ | |||
1 | /* | ||
2 | * w1_ds2413.c - w1 family 3a (DS2413) driver | ||
3 | * based on w1_ds2408.c by Jean-Francois Dagenais <dagenaisj@sonatest.com> | ||
4 | * | ||
5 | * Copyright (c) 2013 Mariusz Bialonczyk <manio@skyboo.net> | ||
6 | * | ||
7 | * This source code is licensed under the GNU General Public License, | ||
8 | * Version 2. See the file COPYING for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/moduleparam.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/slab.h> | ||
18 | |||
19 | #include "../w1.h" | ||
20 | #include "../w1_int.h" | ||
21 | #include "../w1_family.h" | ||
22 | |||
23 | MODULE_LICENSE("GPL"); | ||
24 | MODULE_AUTHOR("Mariusz Bialonczyk <manio@skyboo.net>"); | ||
25 | MODULE_DESCRIPTION("w1 family 3a driver for DS2413 2 Pin IO"); | ||
26 | |||
27 | #define W1_F3A_RETRIES 3 | ||
28 | #define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5 | ||
29 | #define W1_F3A_FUNC_PIO_ACCESS_WRITE 0x5A | ||
30 | #define W1_F3A_SUCCESS_CONFIRM_BYTE 0xAA | ||
31 | |||
32 | static ssize_t w1_f3a_read_state( | ||
33 | struct file *filp, struct kobject *kobj, | ||
34 | struct bin_attribute *bin_attr, | ||
35 | char *buf, loff_t off, size_t count) | ||
36 | { | ||
37 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | ||
38 | dev_dbg(&sl->dev, | ||
39 | "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", | ||
40 | bin_attr->attr.name, kobj, (unsigned int)off, count, buf); | ||
41 | |||
42 | if (off != 0) | ||
43 | return 0; | ||
44 | if (!buf) | ||
45 | return -EINVAL; | ||
46 | |||
47 | mutex_lock(&sl->master->bus_mutex); | ||
48 | dev_dbg(&sl->dev, "mutex locked"); | ||
49 | |||
50 | if (w1_reset_select_slave(sl)) { | ||
51 | mutex_unlock(&sl->master->bus_mutex); | ||
52 | return -EIO; | ||
53 | } | ||
54 | |||
55 | w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ); | ||
56 | *buf = w1_read_8(sl->master); | ||
57 | |||
58 | mutex_unlock(&sl->master->bus_mutex); | ||
59 | dev_dbg(&sl->dev, "mutex unlocked"); | ||
60 | |||
61 | /* check for correct complement */ | ||
62 | if ((*buf & 0x0F) != ((~*buf >> 4) & 0x0F)) | ||
63 | return -EIO; | ||
64 | else | ||
65 | return 1; | ||
66 | } | ||
67 | |||
68 | static ssize_t w1_f3a_write_output( | ||
69 | struct file *filp, struct kobject *kobj, | ||
70 | struct bin_attribute *bin_attr, | ||
71 | char *buf, loff_t off, size_t count) | ||
72 | { | ||
73 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | ||
74 | u8 w1_buf[3]; | ||
75 | unsigned int retries = W1_F3A_RETRIES; | ||
76 | |||
77 | if (count != 1 || off != 0) | ||
78 | return -EFAULT; | ||
79 | |||
80 | dev_dbg(&sl->dev, "locking mutex for write_output"); | ||
81 | mutex_lock(&sl->master->bus_mutex); | ||
82 | dev_dbg(&sl->dev, "mutex locked"); | ||
83 | |||
84 | if (w1_reset_select_slave(sl)) | ||
85 | goto error; | ||
86 | |||
87 | /* according to the DS2413 datasheet the most significant 6 bits | ||
88 | should be set to "1"s, so do it now */ | ||
89 | *buf = *buf | 0xFC; | ||
90 | |||
91 | while (retries--) { | ||
92 | w1_buf[0] = W1_F3A_FUNC_PIO_ACCESS_WRITE; | ||
93 | w1_buf[1] = *buf; | ||
94 | w1_buf[2] = ~(*buf); | ||
95 | w1_write_block(sl->master, w1_buf, 3); | ||
96 | |||
97 | if (w1_read_8(sl->master) == W1_F3A_SUCCESS_CONFIRM_BYTE) { | ||
98 | mutex_unlock(&sl->master->bus_mutex); | ||
99 | dev_dbg(&sl->dev, "mutex unlocked, retries:%d", retries); | ||
100 | return 1; | ||
101 | } | ||
102 | if (w1_reset_resume_command(sl->master)) | ||
103 | goto error; | ||
104 | } | ||
105 | |||
106 | error: | ||
107 | mutex_unlock(&sl->master->bus_mutex); | ||
108 | dev_dbg(&sl->dev, "mutex unlocked in error, retries:%d", retries); | ||
109 | return -EIO; | ||
110 | } | ||
111 | |||
112 | #define NB_SYSFS_BIN_FILES 2 | ||
113 | static struct bin_attribute w1_f3a_sysfs_bin_files[NB_SYSFS_BIN_FILES] = { | ||
114 | { | ||
115 | .attr = { | ||
116 | .name = "state", | ||
117 | .mode = S_IRUGO, | ||
118 | }, | ||
119 | .size = 1, | ||
120 | .read = w1_f3a_read_state, | ||
121 | }, | ||
122 | { | ||
123 | .attr = { | ||
124 | .name = "output", | ||
125 | .mode = S_IRUGO | S_IWUSR | S_IWGRP, | ||
126 | }, | ||
127 | .size = 1, | ||
128 | .write = w1_f3a_write_output, | ||
129 | } | ||
130 | }; | ||
131 | |||
132 | static int w1_f3a_add_slave(struct w1_slave *sl) | ||
133 | { | ||
134 | int err = 0; | ||
135 | int i; | ||
136 | |||
137 | for (i = 0; i < NB_SYSFS_BIN_FILES && !err; ++i) | ||
138 | err = sysfs_create_bin_file( | ||
139 | &sl->dev.kobj, | ||
140 | &(w1_f3a_sysfs_bin_files[i])); | ||
141 | if (err) | ||
142 | while (--i >= 0) | ||
143 | sysfs_remove_bin_file(&sl->dev.kobj, | ||
144 | &(w1_f3a_sysfs_bin_files[i])); | ||
145 | return err; | ||
146 | } | ||
147 | |||
148 | static void w1_f3a_remove_slave(struct w1_slave *sl) | ||
149 | { | ||
150 | int i; | ||
151 | for (i = NB_SYSFS_BIN_FILES - 1; i >= 0; --i) | ||
152 | sysfs_remove_bin_file(&sl->dev.kobj, | ||
153 | &(w1_f3a_sysfs_bin_files[i])); | ||
154 | } | ||
155 | |||
156 | static struct w1_family_ops w1_f3a_fops = { | ||
157 | .add_slave = w1_f3a_add_slave, | ||
158 | .remove_slave = w1_f3a_remove_slave, | ||
159 | }; | ||
160 | |||
161 | static struct w1_family w1_family_3a = { | ||
162 | .fid = W1_FAMILY_DS2413, | ||
163 | .fops = &w1_f3a_fops, | ||
164 | }; | ||
165 | |||
166 | static int __init w1_f3a_init(void) | ||
167 | { | ||
168 | return w1_register_family(&w1_family_3a); | ||
169 | } | ||
170 | |||
171 | static void __exit w1_f3a_exit(void) | ||
172 | { | ||
173 | w1_unregister_family(&w1_family_3a); | ||
174 | } | ||
175 | |||
176 | module_init(w1_f3a_init); | ||
177 | module_exit(w1_f3a_exit); | ||
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h index a1f0ce151d53..625dd08f775f 100644 --- a/drivers/w1/w1_family.h +++ b/drivers/w1/w1_family.h | |||
@@ -39,6 +39,7 @@ | |||
39 | #define W1_EEPROM_DS2431 0x2D | 39 | #define W1_EEPROM_DS2431 0x2D |
40 | #define W1_FAMILY_DS2760 0x30 | 40 | #define W1_FAMILY_DS2760 0x30 |
41 | #define W1_FAMILY_DS2780 0x32 | 41 | #define W1_FAMILY_DS2780 0x32 |
42 | #define W1_FAMILY_DS2413 0x3A | ||
42 | #define W1_THERM_DS1825 0x3B | 43 | #define W1_THERM_DS1825 0x3B |
43 | #define W1_FAMILY_DS2781 0x3D | 44 | #define W1_FAMILY_DS2781 0x3D |
44 | #define W1_THERM_DS28EA00 0x42 | 45 | #define W1_THERM_DS28EA00 0x42 |