Lines Matching +full:gpio +full:- +full:open +full:- +full:drain
1 // SPDX-License-Identifier: GPL-2.0-only
3 * w1-gpio - GPIO w1 bus master driver
11 #include <linux/gpio/consumer.h>
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()
38 gpiod_set_raw_value(ddata->gpiod, 1); in w1_gpio_set_pullup()
39 msleep(ddata->pullup_duration); in w1_gpio_set_pullup()
42 * open drain emulation in the GPIO library. 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()
71 /* Enforce open drain mode by default */ 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()
83 * open drain will happen transparently. 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()
108 * If we are using open drain emulation from the GPIO library, in w1_gpio_probe()
110 * high using a raw accessor to provide pull-up for the w1 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",
154 MODULE_DESCRIPTION("GPIO w1 bus master driver");