Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Dallas one wire interface with the Linux w1 GPIO bitbanging implement…

…ation on GPIO 4
commit 71871509238d3e7bce4a74cdf616c3f12542acaa 1 parent 48bcd88
Frank Buss authored May 26, 2012

Showing 1 changed file with 23 additions and 0 deletions. Show diff stats Hide diff stats

  1. 23  arch/arm/mach-bcm2708/bcm2708.c
23  arch/arm/mach-bcm2708/bcm2708.c
@@ -32,6 +32,7 @@
32 32
 #include <linux/io.h>
33 33
 #include <linux/module.h>
34 34
 #include <linux/spi/spi.h>
  35
+#include <linux/w1-gpio.h>
35 36
 
36 37
 #include <linux/version.h>
37 38
 #include <linux/clkdev.h>
@@ -68,6 +69,9 @@
68 69
  */
69 70
 #define DMA_MASK_BITS_COMMON 32
70 71
 
  72
+// use GPIO 4 for the one-wire GPIO pin, if enabled
  73
+#define W1_GPIO 4
  74
+
71 75
 static DEFINE_CLOCK_DATA(cd);
72 76
 
73 77
 /* command line parameters */
@@ -388,6 +392,22 @@ static struct platform_device bcm2708_gpio_device = {
388 392
 		.coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON),
389 393
 		},
390 394
 };
  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
+
391 411
 #endif
392 412
 
393 413
 static struct resource bcm2708_systemtimer_resources[] = {
@@ -571,6 +591,9 @@ void __init bcm2708_init(void)
571 591
 	bcm_register_device(&bcm2708_vcio_device);
572 592
 #ifdef CONFIG_BCM2708_GPIO
573 593
 	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
574 597
 #endif
575 598
 	bcm_register_device(&bcm2708_systemtimer_device);
576 599
 #ifdef CONFIG_MMC_BCM2708

0 notes on commit 7187150

Please sign in to comment.
Something went wrong with that request. Please try again.