Lines Matching +full:gpio +full:- +full:open +full:- +full:drain
2 * w1-gpio - GPIO w1 bus master driver
15 #include <linux/w1-gpio.h>
16 #include <linux/gpio/consumer.h>
29 pdata->pullup_duration = delay; in w1_gpio_set_pullup()
31 if (pdata->pullup_duration) { in w1_gpio_set_pullup()
33 * This will OVERRIDE open drain emulation and force-pull in w1_gpio_set_pullup()
36 gpiod_set_raw_value(pdata->gpiod, 1); in w1_gpio_set_pullup()
37 msleep(pdata->pullup_duration); in w1_gpio_set_pullup()
40 * open drain emulation in the GPIO library. in w1_gpio_set_pullup()
42 gpiod_set_value(pdata->gpiod, 1); in w1_gpio_set_pullup()
44 pdata->pullup_duration = 0; in w1_gpio_set_pullup()
54 gpiod_set_value(pdata->gpiod, bit); in w1_gpio_write_bit()
61 return gpiod_get_value(pdata->gpiod) ? 1 : 0; in w1_gpio_read_bit()
66 { .compatible = "w1-gpio" },
76 struct device *dev = &pdev->dev; in w1_gpio_probe()
77 struct device_node *np = dev->of_node; in w1_gpio_probe()
78 /* Enforce open drain mode by default */ in w1_gpio_probe()
83 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in w1_gpio_probe()
85 return -ENOMEM; in w1_gpio_probe()
89 * already set the line into open drain mode, so we should just in w1_gpio_probe()
91 * open drain will happen transparently. in w1_gpio_probe()
93 if (of_get_property(np, "linux,open-drain", NULL)) in w1_gpio_probe()
96 pdev->dev.platform_data = pdata; in w1_gpio_probe()
102 return -ENXIO; in w1_gpio_probe()
109 return -ENOMEM; in w1_gpio_probe()
112 pdata->gpiod = devm_gpiod_get_index(dev, NULL, 0, gflags); in w1_gpio_probe()
113 if (IS_ERR(pdata->gpiod)) { in w1_gpio_probe()
115 return PTR_ERR(pdata->gpiod); in w1_gpio_probe()
118 pdata->pullup_gpiod = in w1_gpio_probe()
120 if (IS_ERR(pdata->pullup_gpiod)) { in w1_gpio_probe()
123 return PTR_ERR(pdata->pullup_gpiod); in w1_gpio_probe()
126 master->data = pdata; in w1_gpio_probe()
127 master->read_bit = w1_gpio_read_bit; in w1_gpio_probe()
128 gpiod_direction_output(pdata->gpiod, 1); in w1_gpio_probe()
129 master->write_bit = w1_gpio_write_bit; in w1_gpio_probe()
132 * If we are using open drain emulation from the GPIO library, in w1_gpio_probe()
134 * high using a raw accessor to provide pull-up for the w1 in w1_gpio_probe()
138 master->set_pullup = w1_gpio_set_pullup; in w1_gpio_probe()
146 if (pdata->enable_external_pullup) in w1_gpio_probe()
147 pdata->enable_external_pullup(1); in w1_gpio_probe()
149 if (pdata->pullup_gpiod) in w1_gpio_probe()
150 gpiod_set_value(pdata->pullup_gpiod, 1); in w1_gpio_probe()
160 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); in w1_gpio_remove()
162 if (pdata->enable_external_pullup) in w1_gpio_remove()
163 pdata->enable_external_pullup(0); in w1_gpio_remove()
165 if (pdata->pullup_gpiod) in w1_gpio_remove()
166 gpiod_set_value(pdata->pullup_gpiod, 0); in w1_gpio_remove()
177 if (pdata->enable_external_pullup) in w1_gpio_suspend()
178 pdata->enable_external_pullup(0); in w1_gpio_suspend()
187 if (pdata->enable_external_pullup) in w1_gpio_resume()
188 pdata->enable_external_pullup(1); in w1_gpio_resume()
197 .name = "w1-gpio",
207 MODULE_DESCRIPTION("GPIO w1 bus master driver");