• Home
  • Raw
  • Download

Lines Matching +full:delay +full:- +full:line

1 // SPDX-License-Identifier: GPL-2.0-only
3 * w1-gpio - GPIO w1 bus master driver
12 #include <linux/w1-gpio.h>
17 #include <linux/delay.h>
21 static u8 w1_gpio_set_pullup(void *data, int delay) in w1_gpio_set_pullup() argument
25 if (delay) { in w1_gpio_set_pullup()
26 pdata->pullup_duration = delay; in w1_gpio_set_pullup()
28 if (pdata->pullup_duration) { in w1_gpio_set_pullup()
30 * This will OVERRIDE open drain emulation and force-pull in w1_gpio_set_pullup()
31 * the line high for some time. in w1_gpio_set_pullup()
33 gpiod_set_raw_value(pdata->gpiod, 1); in w1_gpio_set_pullup()
34 msleep(pdata->pullup_duration); in w1_gpio_set_pullup()
36 * This will simply set the line as input since we are doing in w1_gpio_set_pullup()
39 gpiod_set_value(pdata->gpiod, 1); in w1_gpio_set_pullup()
41 pdata->pullup_duration = 0; in w1_gpio_set_pullup()
51 gpiod_set_value(pdata->gpiod, bit); in w1_gpio_write_bit()
58 return gpiod_get_value(pdata->gpiod) ? 1 : 0; in w1_gpio_read_bit()
63 { .compatible = "w1-gpio" },
73 struct device *dev = &pdev->dev; in w1_gpio_probe()
74 struct device_node *np = dev->of_node; in w1_gpio_probe()
80 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in w1_gpio_probe()
82 return -ENOMEM; in w1_gpio_probe()
86 * already set the line into open drain mode, so we should just in w1_gpio_probe()
87 * driver it high/low like we are in full control of the line and in w1_gpio_probe()
90 if (of_property_present(np, "linux,open-drain")) in w1_gpio_probe()
93 pdev->dev.platform_data = pdata; in w1_gpio_probe()
99 return -ENXIO; in w1_gpio_probe()
105 return -ENOMEM; in w1_gpio_probe()
107 pdata->gpiod = devm_gpiod_get_index(dev, NULL, 0, gflags); in w1_gpio_probe()
108 if (IS_ERR(pdata->gpiod)) { in w1_gpio_probe()
110 return PTR_ERR(pdata->gpiod); in w1_gpio_probe()
113 pdata->pullup_gpiod = in w1_gpio_probe()
115 if (IS_ERR(pdata->pullup_gpiod)) { in w1_gpio_probe()
118 return PTR_ERR(pdata->pullup_gpiod); in w1_gpio_probe()
121 master->data = pdata; in w1_gpio_probe()
122 master->read_bit = w1_gpio_read_bit; in w1_gpio_probe()
123 gpiod_direction_output(pdata->gpiod, 1); in w1_gpio_probe()
124 master->write_bit = w1_gpio_write_bit; in w1_gpio_probe()
128 * we need to use this pullup function that hammers the line in w1_gpio_probe()
129 * high using a raw accessor to provide pull-up for the w1 in w1_gpio_probe()
130 * line. in w1_gpio_probe()
133 master->set_pullup = w1_gpio_set_pullup; in w1_gpio_probe()
141 if (pdata->enable_external_pullup) in w1_gpio_probe()
142 pdata->enable_external_pullup(1); in w1_gpio_probe()
144 if (pdata->pullup_gpiod) in w1_gpio_probe()
145 gpiod_set_value(pdata->pullup_gpiod, 1); in w1_gpio_probe()
155 struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); in w1_gpio_remove()
157 if (pdata->enable_external_pullup) in w1_gpio_remove()
158 pdata->enable_external_pullup(0); in w1_gpio_remove()
160 if (pdata->pullup_gpiod) in w1_gpio_remove()
161 gpiod_set_value(pdata->pullup_gpiod, 0); in w1_gpio_remove()
172 if (pdata->enable_external_pullup) in w1_gpio_suspend()
173 pdata->enable_external_pullup(0); in w1_gpio_suspend()
182 if (pdata->enable_external_pullup) in w1_gpio_resume()
183 pdata->enable_external_pullup(1); in w1_gpio_resume()
192 .name = "w1-gpio",