Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 1 | ===================== |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 2 | Kernel driver w1-gpio |
| 3 | ===================== |
| 4 | |
| 5 | Author: Ville Syrjala <syrjala@sci.fi> |
| 6 | |
| 7 | |
| 8 | Description |
| 9 | ----------- |
| 10 | |
| 11 | GPIO 1-wire bus master driver. The driver uses the GPIO API to control the |
Linus Walleij | e0fc62a | 2017-09-26 20:27:09 +0200 | [diff] [blame] | 12 | wire and the GPIO pin can be specified using GPIO machine descriptor tables. |
| 13 | It is also possible to define the master using device tree, see |
Mauro Carvalho Chehab | bb66720 | 2021-09-16 11:55:03 +0200 | [diff] [blame] | 14 | Documentation/devicetree/bindings/w1/w1-gpio.yaml |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 15 | |
| 16 | |
| 17 | Example (mach-at91) |
| 18 | ------------------- |
| 19 | |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 20 | :: |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 21 | |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 22 | #include <linux/gpio/machine.h> |
| 23 | #include <linux/w1-gpio.h> |
| 24 | |
| 25 | static struct gpiod_lookup_table foo_w1_gpiod_table = { |
Linus Walleij | e0fc62a | 2017-09-26 20:27:09 +0200 | [diff] [blame] | 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 | }, |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 31 | }; |
Linus Walleij | e0fc62a | 2017-09-26 20:27:09 +0200 | [diff] [blame] | 32 | |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 33 | static struct w1_gpio_platform_data foo_w1_gpio_pdata = { |
Linus Walleij | e0fc62a | 2017-09-26 20:27:09 +0200 | [diff] [blame] | 34 | .ext_pullup_enable_pin = -EINVAL, |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 35 | }; |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 36 | |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 37 | static struct platform_device foo_w1_device = { |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 38 | .name = "w1-gpio", |
| 39 | .id = -1, |
| 40 | .dev.platform_data = &foo_w1_gpio_pdata, |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 41 | }; |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 42 | |
Mauro Carvalho Chehab | e9bb627 | 2019-07-31 17:08:53 -0300 | [diff] [blame] | 43 | ... |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 44 | at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1); |
| 45 | at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1); |
Linus Walleij | e0fc62a | 2017-09-26 20:27:09 +0200 | [diff] [blame] | 46 | gpiod_add_lookup_table(&foo_w1_gpiod_table); |
Ville Syrjala | ad8dc96 | 2008-02-06 01:39:01 -0800 | [diff] [blame] | 47 | platform_device_register(&foo_w1_device); |