Lines Matching +full:delay +full:- +full:line
1 // SPDX-License-Identifier: GPL-2.0-only
3 * w1-gpio - GPIO w1 bus master driver
8 #include <linux/delay.h>
26 static u8 w1_gpio_set_pullup(void *data, int delay) in w1_gpio_set_pullup() argument
30 if (delay) { in w1_gpio_set_pullup()
31 ddata->pullup_duration = delay; in w1_gpio_set_pullup()
33 if (ddata->pullup_duration) { in w1_gpio_set_pullup()
35 * This will OVERRIDE open drain emulation and force-pull in w1_gpio_set_pullup()
36 * the line high for some time. in w1_gpio_set_pullup()
38 gpiod_set_raw_value(ddata->gpiod, 1); in w1_gpio_set_pullup()
39 msleep(ddata->pullup_duration); in w1_gpio_set_pullup()
41 * This will simply set the line as input since we are doing in w1_gpio_set_pullup()
44 gpiod_set_value(ddata->gpiod, 1); in w1_gpio_set_pullup()
46 ddata->pullup_duration = 0; in w1_gpio_set_pullup()
56 gpiod_set_value(ddata->gpiod, bit); in w1_gpio_write_bit()
63 return gpiod_get_value(ddata->gpiod) ? 1 : 0; in w1_gpio_read_bit()
70 struct device *dev = &pdev->dev; in w1_gpio_probe()
75 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); in w1_gpio_probe()
77 return -ENOMEM; in w1_gpio_probe()
81 * already set the line into open drain mode, so we should just in w1_gpio_probe()
82 * driver it high/low like we are in full control of the line and in w1_gpio_probe()
85 if (device_property_present(dev, "linux,open-drain")) in w1_gpio_probe()
90 return -ENOMEM; in w1_gpio_probe()
92 ddata->gpiod = devm_gpiod_get_index(dev, NULL, 0, gflags); in w1_gpio_probe()
93 if (IS_ERR(ddata->gpiod)) in w1_gpio_probe()
94 return dev_err_probe(dev, PTR_ERR(ddata->gpiod), "gpio_request (pin) failed\n"); in w1_gpio_probe()
96 ddata->pullup_gpiod = in w1_gpio_probe()
98 if (IS_ERR(ddata->pullup_gpiod)) in w1_gpio_probe()
99 return dev_err_probe(dev, PTR_ERR(ddata->pullup_gpiod), in w1_gpio_probe()
102 master->data = ddata; in w1_gpio_probe()
103 master->read_bit = w1_gpio_read_bit; in w1_gpio_probe()
104 gpiod_direction_output(ddata->gpiod, 1); in w1_gpio_probe()
105 master->write_bit = w1_gpio_write_bit; in w1_gpio_probe()
109 * we need to use this pullup function that hammers the line in w1_gpio_probe()
110 * high using a raw accessor to provide pull-up for the w1 in w1_gpio_probe()
111 * line. in w1_gpio_probe()
114 master->set_pullup = w1_gpio_set_pullup; in w1_gpio_probe()
120 gpiod_set_value(ddata->pullup_gpiod, 1); in w1_gpio_probe()
130 struct w1_gpio_ddata *ddata = master->data; in w1_gpio_remove()
132 gpiod_set_value(ddata->pullup_gpiod, 0); in w1_gpio_remove()
138 { .compatible = "w1-gpio" },
145 .name = "w1-gpio",