xref: /linux/Documentation/w1/masters/w1-gpio.rst (revision 15a1fbdcfb519c2bd291ed01c6c94e0b89537a77)
1=====================
2Kernel driver w1-gpio
3=====================
4
5Author: Ville Syrjala <syrjala@sci.fi>
6
7
8Description
9-----------
10
11GPIO 1-wire bus master driver. The driver uses the GPIO API to control the
12wire and the GPIO pin can be specified using GPIO machine descriptor tables.
13It is also possible to define the master using device tree, see
14Documentation/devicetree/bindings/w1/w1-gpio.txt
15
16
17Example (mach-at91)
18-------------------
19
20::
21
22  #include <linux/gpio/machine.h>
23  #include <linux/w1-gpio.h>
24
25  static struct gpiod_lookup_table foo_w1_gpiod_table = {
26	.dev_id = "w1-gpio",
27	.table = {
28		GPIO_LOOKUP_IDX("at91-gpio", AT91_PIN_PB20, NULL, 0,
29			GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN),
30	},
31  };
32
33  static struct w1_gpio_platform_data foo_w1_gpio_pdata = {
34	.ext_pullup_enable_pin	= -EINVAL,
35  };
36
37  static struct platform_device foo_w1_device = {
38	.name			= "w1-gpio",
39	.id			= -1,
40	.dev.platform_data	= &foo_w1_gpio_pdata,
41  };
42
43  ...
44	at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1);
45	at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1);
46	gpiod_add_lookup_table(&foo_w1_gpiod_table);
47	platform_device_register(&foo_w1_device);
48