aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/w1/masters/w1-gpio.c22
-rw-r--r--drivers/w1/w1_int.c12
-rw-r--r--include/linux/w1-gpio.h1
3 files changed, 23 insertions, 12 deletions
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index e36b18b2817b..9709b8b484ba 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -18,10 +18,31 @@
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/delay.h>
21 22
22#include "../w1.h" 23#include "../w1.h"
23#include "../w1_int.h" 24#include "../w1_int.h"
24 25
26static u8 w1_gpio_set_pullup(void *data, int delay)
27{
28 struct w1_gpio_platform_data *pdata = data;
29
30 if (delay) {
31 pdata->pullup_duration = delay;
32 } else {
33 if (pdata->pullup_duration) {
34 gpio_direction_output(pdata->pin, 1);
35
36 msleep(pdata->pullup_duration);
37
38 gpio_direction_input(pdata->pin);
39 }
40 pdata->pullup_duration = 0;
41 }
42
43 return 0;
44}
45
25static void w1_gpio_write_bit_dir(void *data, u8 bit) 46static void w1_gpio_write_bit_dir(void *data, u8 bit)
26{ 47{
27 struct w1_gpio_platform_data *pdata = data; 48 struct w1_gpio_platform_data *pdata = data;
@@ -132,6 +153,7 @@ static int w1_gpio_probe(struct platform_device *pdev)
132 } else { 153 } else {
133 gpio_direction_input(pdata->pin); 154 gpio_direction_input(pdata->pin);
134 master->write_bit = w1_gpio_write_bit_dir; 155 master->write_bit = w1_gpio_write_bit_dir;
156 master->set_pullup = w1_gpio_set_pullup;
135 } 157 }
136 158
137 err = w1_add_master_device(master); 159 err = w1_add_master_device(master);
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 5a98649f6abc..590bd8a7cd1b 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -117,18 +117,6 @@ int w1_add_master_device(struct w1_bus_master *master)
117 printk(KERN_ERR "w1_add_master_device: invalid function set\n"); 117 printk(KERN_ERR "w1_add_master_device: invalid function set\n");
118 return(-EINVAL); 118 return(-EINVAL);
119 } 119 }
120 /* While it would be electrically possible to make a device that
121 * generated a strong pullup in bit bang mode, only hardware that
122 * controls 1-wire time frames are even expected to support a strong
123 * pullup. w1_io.c would need to support calling set_pullup before
124 * the last write_bit operation of a w1_write_8 which it currently
125 * doesn't.
126 */
127 if (!master->write_byte && !master->touch_bit && master->set_pullup) {
128 printk(KERN_ERR "w1_add_master_device: set_pullup requires "
129 "write_byte or touch_bit, disabling\n");
130 master->set_pullup = NULL;
131 }
132 120
133 /* Lock until the device is added (or not) to w1_masters. */ 121 /* Lock until the device is added (or not) to w1_masters. */
134 mutex_lock(&w1_mlock); 122 mutex_lock(&w1_mlock);
diff --git a/include/linux/w1-gpio.h b/include/linux/w1-gpio.h
index 065e3ae79ab0..d58594a32324 100644
--- a/include/linux/w1-gpio.h
+++ b/include/linux/w1-gpio.h
@@ -20,6 +20,7 @@ struct w1_gpio_platform_data {
20 unsigned int is_open_drain:1; 20 unsigned int is_open_drain:1;
21 void (*enable_external_pullup)(int enable); 21 void (*enable_external_pullup)(int enable);
22 unsigned int ext_pullup_enable_pin; 22 unsigned int ext_pullup_enable_pin;
23 unsigned int pullup_duration;
23}; 24};
24 25
25#endif /* _LINUX_W1_GPIO_H */ 26#endif /* _LINUX_W1_GPIO_H */