File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818#include <linux/of_gpio.h>
1919#include <linux/err.h>
2020#include <linux/of.h>
21+ #include <linux/delay.h>
2122
2223#include "../w1.h"
2324#include "../w1_int.h"
2425
26+ static 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+
2546static void w1_gpio_write_bit_dir (void * data , u8 bit )
2647{
2748 struct w1_gpio_platform_data * pdata = data ;
@@ -132,6 +153,7 @@ static int w1_gpio_probe(struct platform_device *pdev)
132153 } else {
133154 gpio_direction_input (pdata -> pin );
134155 master -> write_bit = w1_gpio_write_bit_dir ;
156+ master -> set_pullup = w1_gpio_set_pullup ;
135157 }
136158
137159 err = w1_add_master_device (master );
Original file line number Diff line number Diff line change @@ -117,18 +117,6 @@ int w1_add_master_device(struct w1_bus_master *master)
117117 printk (KERN_ERR "w1_add_master_device: invalid function set\n" );
118118 return (- EINVAL );
119119 }
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- }
132120
133121 /* Lock until the device is added (or not) to w1_masters. */
134122 mutex_lock (& w1_mlock );
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ struct w1_gpio_platform_data {
2020 unsigned int is_open_drain :1 ;
2121 void (* enable_external_pullup )(int enable );
2222 unsigned int ext_pullup_enable_pin ;
23+ unsigned int pullup_duration ;
2324};
2425
2526#endif /* _LINUX_W1_GPIO_H */
You can’t perform that action at this time.
0 commit comments