Skip to content

Commit 7187150

Browse files
committed
Dallas one wire interface with the Linux w1 GPIO bitbanging implementation on GPIO 4
1 parent 48bcd88 commit 7187150

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

arch/arm/mach-bcm2708/bcm2708.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/io.h>
3333
#include <linux/module.h>
3434
#include <linux/spi/spi.h>
35+
#include <linux/w1-gpio.h>
3536

3637
#include <linux/version.h>
3738
#include <linux/clkdev.h>
@@ -68,6 +69,9 @@
6869
*/
6970
#define DMA_MASK_BITS_COMMON 32
7071

72+
// use GPIO 4 for the one-wire GPIO pin, if enabled
73+
#define W1_GPIO 4
74+
7175
static DEFINE_CLOCK_DATA(cd);
7276

7377
/* command line parameters */
@@ -388,6 +392,22 @@ static struct platform_device bcm2708_gpio_device = {
388392
.coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON),
389393
},
390394
};
395+
396+
#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
397+
static struct w1_gpio_platform_data w1_gpio_pdata = {
398+
/* If you choose to use a pin other than PB16 it needs to be 3.3V */
399+
.pin = W1_GPIO,
400+
.is_open_drain = 0,
401+
};
402+
403+
static struct platform_device w1_device = {
404+
.name = "w1-gpio",
405+
.id = -1,
406+
.dev.platform_data = &w1_gpio_pdata,
407+
};
408+
409+
#endif
410+
391411
#endif
392412

393413
static struct resource bcm2708_systemtimer_resources[] = {
@@ -571,6 +591,9 @@ void __init bcm2708_init(void)
571591
bcm_register_device(&bcm2708_vcio_device);
572592
#ifdef CONFIG_BCM2708_GPIO
573593
bcm_register_device(&bcm2708_gpio_device);
594+
#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
595+
platform_device_register(&w1_device);
596+
#endif
574597
#endif
575598
bcm_register_device(&bcm2708_systemtimer_device);
576599
#ifdef CONFIG_MMC_BCM2708

0 commit comments

Comments
 (0)