Skip to content

Commit

Permalink
onewire: w1-gpio: add ext_pullup_enable pin in platform data
Browse files Browse the repository at this point in the history
In the process of porting boards to devicetree implemenation, we should
keep information about external circuitry where they belong - the
individual drivers.

This patch adds a way to specify a GPIO to drive the (optional) external
pull-up logic, rather than using a function pointer for that.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Acked-by: Ville Syrjälä <syrjala@sci.fi>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Daniel Mack authored and Greg Kroah-Hartman committed Aug 16, 2012
1 parent 5f3d138 commit d2323cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/w1/masters/w1-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ static int __init w1_gpio_probe(struct platform_device *pdev)
if (err)
goto free_master;

if (gpio_is_valid(pdata->ext_pullup_enable_pin)) {
err = gpio_request_one(pdata->ext_pullup_enable_pin,
GPIOF_INIT_LOW, "w1 pullup");
if (err < 0)
goto free_gpio;
}

master->data = pdata;
master->read_bit = w1_gpio_read_bit;

Expand All @@ -117,15 +124,21 @@ static int __init w1_gpio_probe(struct platform_device *pdev)

err = w1_add_master_device(master);
if (err)
goto free_gpio;
goto free_gpio_ext_pu;

if (pdata->enable_external_pullup)
pdata->enable_external_pullup(1);

if (gpio_is_valid(pdata->ext_pullup_enable_pin))
gpio_set_value(pdata->ext_pullup_enable_pin, 1);

platform_set_drvdata(pdev, master);

return 0;

free_gpio_ext_pu:
if (gpio_is_valid(pdata->ext_pullup_enable_pin))
gpio_free(pdata->ext_pullup_enable_pin);
free_gpio:
gpio_free(pdata->pin);
free_master:
Expand All @@ -142,6 +155,9 @@ static int __exit w1_gpio_remove(struct platform_device *pdev)
if (pdata->enable_external_pullup)
pdata->enable_external_pullup(0);

if (gpio_is_valid(pdata->ext_pullup_enable_pin))
gpio_set_value(pdata->ext_pullup_enable_pin, 0);

w1_remove_master_device(master);
gpio_free(pdata->pin);
kfree(master);
Expand Down
1 change: 1 addition & 0 deletions include/linux/w1-gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct w1_gpio_platform_data {
unsigned int pin;
unsigned int is_open_drain:1;
void (*enable_external_pullup)(int enable);
unsigned int ext_pullup_enable_pin;
};

#endif /* _LINUX_W1_GPIO_H */

0 comments on commit d2323cf

Please sign in to comment.