diff options
| author | Evgeny Boger <boger@contactless.ru> | 2014-01-23 18:56:18 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:37:04 -0500 |
| commit | 3089a4c8d3abc7e2ab105d1d39d415110d1566d6 (patch) | |
| tree | 5064f69853949cb8b5d245c932f65a3202d21219 /drivers | |
| parent | 63509beaf7ed7a9dc8c574be61189fce791489f0 (diff) | |
drivers/w1/masters/w1-gpio.c: add strong pullup emulation
Strong pullup is emulated by driving pin logic high after write command
when using tri-state push-pull GPIO.
Signed-off-by: Evgeny Boger <boger@contactless.ru>
Cc: Greg KH <greg@kroah.com>
Acked-by: David Fries <david@fries.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/w1/masters/w1-gpio.c | 22 | ||||
| -rw-r--r-- | drivers/w1/w1_int.c | 12 |
2 files changed, 22 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 | ||
| 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 | |||
| 25 | static void w1_gpio_write_bit_dir(void *data, u8 bit) | 46 | static 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); |
