blob: 15236605503bf164080815b68c5163e3f78d3164 [file] [log] [blame]
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -03001=====================
Ville Syrjalaad8dc962008-02-06 01:39:01 -08002Kernel 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
Linus Walleije0fc62a2017-09-26 20:27:09 +020012wire and the GPIO pin can be specified using GPIO machine descriptor tables.
13It is also possible to define the master using device tree, see
Mauro Carvalho Chehabbb667202021-09-16 11:55:03 +020014Documentation/devicetree/bindings/w1/w1-gpio.yaml
Ville Syrjalaad8dc962008-02-06 01:39:01 -080015
16
17Example (mach-at91)
18-------------------
19
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030020::
Ville Syrjalaad8dc962008-02-06 01:39:01 -080021
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030022 #include <linux/gpio/machine.h>
23 #include <linux/w1-gpio.h>
24
25 static struct gpiod_lookup_table foo_w1_gpiod_table = {
Linus Walleije0fc62a2017-09-26 20:27:09 +020026 .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 },
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030031 };
Linus Walleije0fc62a2017-09-26 20:27:09 +020032
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030033 static struct w1_gpio_platform_data foo_w1_gpio_pdata = {
Linus Walleije0fc62a2017-09-26 20:27:09 +020034 .ext_pullup_enable_pin = -EINVAL,
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030035 };
Ville Syrjalaad8dc962008-02-06 01:39:01 -080036
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030037 static struct platform_device foo_w1_device = {
Ville Syrjalaad8dc962008-02-06 01:39:01 -080038 .name = "w1-gpio",
39 .id = -1,
40 .dev.platform_data = &foo_w1_gpio_pdata,
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030041 };
Ville Syrjalaad8dc962008-02-06 01:39:01 -080042
Mauro Carvalho Chehabe9bb6272019-07-31 17:08:53 -030043 ...
Ville Syrjalaad8dc962008-02-06 01:39:01 -080044 at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1);
45 at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1);
Linus Walleije0fc62a2017-09-26 20:27:09 +020046 gpiod_add_lookup_table(&foo_w1_gpiod_table);
Ville Syrjalaad8dc962008-02-06 01:39:01 -080047 platform_device_register(&foo_w1_device);