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