1 Index: linux-2.6.24.7/drivers/w1/masters/Kconfig
2 ===================================================================
3 --- linux-2.6.24.7.orig/drivers/w1/masters/Kconfig
4 +++ linux-2.6.24.7/drivers/w1/masters/Kconfig
5 @@ -42,5 +42,15 @@ config W1_MASTER_DS1WM
6 in HP iPAQ devices like h5xxx, h2200, and ASIC3-based like
10 + tristate "GPIO 1-wire busmaster"
11 + depends on GENERIC_GPIO
13 + Say Y here if you want to communicate with your 1-wire devices using
14 + GPIO pins. This driver uses the GPIO API to control the wire.
16 + This support is also available as a module. If so, the module
17 + will be called w1-gpio.ko.
21 Index: linux-2.6.24.7/drivers/w1/masters/Makefile
22 ===================================================================
23 --- linux-2.6.24.7.orig/drivers/w1/masters/Makefile
24 +++ linux-2.6.24.7/drivers/w1/masters/Makefile
25 @@ -6,3 +6,4 @@ obj-$(CONFIG_W1_MASTER_MATROX) += matro
26 obj-$(CONFIG_W1_MASTER_DS2490) += ds2490.o
27 obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o
28 obj-$(CONFIG_W1_MASTER_DS1WM) += ds1wm.o
29 +obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o
30 Index: linux-2.6.24.7/drivers/w1/masters/w1-gpio.c
31 ===================================================================
33 +++ linux-2.6.24.7/drivers/w1/masters/w1-gpio.c
36 + * w1-gpio - GPIO w1 bus master driver
38 + * Copyright (C) 2007 Ville Syrjala <syrjala@sci.fi>
40 + * This program is free software; you can redistribute it and/or modify
41 + * it under the terms of the GNU General Public License version 2
42 + * as published by the Free Software Foundation.
45 +#include <linux/init.h>
46 +#include <linux/module.h>
47 +#include <linux/platform_device.h>
48 +#include <linux/w1-gpio.h>
51 +#include "../w1_int.h"
53 +#include <asm/gpio.h>
55 +static void w1_gpio_write_bit_dir(void *data, u8 bit)
57 + struct w1_gpio_platform_data *pdata = data;
60 + gpio_direction_input(pdata->pin);
62 + gpio_direction_output(pdata->pin, 0);
65 +static void w1_gpio_write_bit_val(void *data, u8 bit)
67 + struct w1_gpio_platform_data *pdata = data;
69 + gpio_set_value(pdata->pin, bit);
72 +static u8 w1_gpio_read_bit(void *data)
74 + struct w1_gpio_platform_data *pdata = data;
76 + return gpio_get_value(pdata->pin);
79 +static int __init w1_gpio_probe(struct platform_device *pdev)
81 + struct w1_bus_master *master;
82 + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
88 + master = kzalloc(sizeof(struct w1_bus_master), GFP_KERNEL);
92 + err = gpio_request(pdata->pin, "w1");
96 + master->data = pdata;
97 + master->read_bit = w1_gpio_read_bit;
99 + if (pdata->is_open_drain) {
100 + gpio_direction_output(pdata->pin, 1);
101 + master->write_bit = w1_gpio_write_bit_val;
103 + gpio_direction_input(pdata->pin);
104 + master->write_bit = w1_gpio_write_bit_dir;
107 + err = w1_add_master_device(master);
111 + platform_set_drvdata(pdev, master);
116 + gpio_free(pdata->pin);
123 +static int __exit w1_gpio_remove(struct platform_device *pdev)
125 + struct w1_bus_master *master = platform_get_drvdata(pdev);
126 + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
128 + w1_remove_master_device(master);
129 + gpio_free(pdata->pin);
135 +static struct platform_driver w1_gpio_driver = {
138 + .owner = THIS_MODULE,
140 + .remove = __exit_p(w1_gpio_remove),
143 +static int __init w1_gpio_init(void)
145 + return platform_driver_probe(&w1_gpio_driver, w1_gpio_probe);
148 +static void __exit w1_gpio_exit(void)
150 + platform_driver_unregister(&w1_gpio_driver);
153 +module_init(w1_gpio_init);
154 +module_exit(w1_gpio_exit);
156 +MODULE_DESCRIPTION("GPIO w1 bus master driver");
157 +MODULE_AUTHOR("Ville Syrjala <syrjala@sci.fi>");
158 +MODULE_LICENSE("GPL");
159 Index: linux-2.6.24.7/include/linux/w1-gpio.h
160 ===================================================================
162 +++ linux-2.6.24.7/include/linux/w1-gpio.h
165 + * w1-gpio interface to platform code
167 + * Copyright (C) 2007 Ville Syrjala <syrjala@sci.fi>
169 + * This program is free software; you can redistribute it and/or modify
170 + * it under the terms of the GNU General Public License version 2
171 + * as published by the Free Software Foundation.
173 +#ifndef _LINUX_W1_GPIO_H
174 +#define _LINUX_W1_GPIO_H
177 + * struct w1_gpio_platform_data - Platform-dependent data for w1-gpio
178 + * @pin: GPIO pin to use
179 + * @is_open_drain: GPIO pin is configured as open drain
181 +struct w1_gpio_platform_data {
183 + unsigned int is_open_drain:1;
186 +#endif /* _LINUX_W1_GPIO_H */