From 171028a42de40e9968f75c8d45fa96f63f109a2e Mon Sep 17 00:00:00 2001 From: ckkim Date: Thu, 11 Feb 2016 15:32:06 +0900 Subject: [PATCH] ODROID-C:Support parasite-powerd mode for 1-wire device. Change-Id: I2d6b907af2f28639c49e6a932fd5e4c9b96c62f9 --- drivers/w1/masters/w1-gpio-aml.c | 22 ++++++++++++++++++++++ drivers/w1/w1_int.c | 12 ------------ include/linux/w1-gpio.h | 1 + 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/w1/masters/w1-gpio-aml.c b/drivers/w1/masters/w1-gpio-aml.c index b530cf9a8808..0be3ba2b0ea2 100644 --- a/drivers/w1/masters/w1-gpio-aml.c +++ b/drivers/w1/masters/w1-gpio-aml.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -36,6 +37,26 @@ MODULE_PARM_DESC(w1_gpio_pin,"\n odroid gpio number for 1-wire\n"); module_param(w1_gpio_pullup,int,0644); MODULE_PARM_DESC(w1_gpio_pullup,"\n odroid gpio number for 1-wire ext_pullup\n"); +static u8 w1_gpio_set_pullup(void *data, int delay) +{ + struct w1_gpio_platform_data *pdata = data; + + if (delay) { + pdata->pullup_duration = delay; + } else { + if (pdata->pullup_duration) { + amlogic_gpio_direction_output(pdata->pin, 1, MODULE_NAME); + + msleep(pdata->pullup_duration); + + amlogic_gpio_direction_input(pdata->pin, MODULE_NAME); + } + pdata->pullup_duration = 0; + } + + return 0; +} + static void w1_gpio_write_bit_dir(void *data, u8 bit) { struct w1_gpio_platform_data *pdata = data; @@ -143,6 +164,7 @@ static int w1_gpio_probe(struct platform_device *pdev) } else { amlogic_gpio_direction_input(pdata->pin, MODULE_NAME); master->write_bit = w1_gpio_write_bit_dir; + master->set_pullup = w1_gpio_set_pullup; } 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) printk(KERN_ERR "w1_add_master_device: invalid function set\n"); return(-EINVAL); } - /* While it would be electrically possible to make a device that - * generated a strong pullup in bit bang mode, only hardware that - * controls 1-wire time frames are even expected to support a strong - * pullup. w1_io.c would need to support calling set_pullup before - * the last write_bit operation of a w1_write_8 which it currently - * doesn't. - */ - if (!master->write_byte && !master->touch_bit && master->set_pullup) { - printk(KERN_ERR "w1_add_master_device: set_pullup requires " - "write_byte or touch_bit, disabling\n"); - master->set_pullup = NULL; - } /* Lock until the device is added (or not) to w1_masters. */ 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 { unsigned int is_open_drain:1; void (*enable_external_pullup)(int enable); unsigned int ext_pullup_enable_pin; + unsigned int pullup_duration; }; #endif /* _LINUX_W1_GPIO_H */