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