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