From b3a428ac863b594fc5538d94e6d706b230a29da7 Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen@dominion.thruhere.net>
Date: Tue, 7 Feb 2012 11:01:13 +0100
Subject: [PATCH 20/21] beaglebone: use P8_6 (gpio1_3) as w1 bus

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
---
 arch/arm/mach-omap2/board-am335xevm.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index c31c0aa..538466d 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -37,6 +37,7 @@
 #include <linux/mfd/tps65217.h>
 #include <linux/pwm_backlight.h>
 #include <linux/pwm/pwm.h>
+#include <linux/w1-gpio.h>
 
 /* LCD controller is similar to DA850 */
 #include <video/da8xx-fb.h>
@@ -603,6 +604,11 @@ static struct pinmux_config bbtoys7_pin_mux[] = {
 	{NULL, 0},
 };
 
+static struct pinmux_config w1_gpio_pin_mux[] = {
+	{"gpmc_ad3.gpio1_3",	OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
+	{NULL, 0},
+};
+
 static struct pinmux_config tsc_pin_mux[] = {
 	{"ain0.ain0",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
 	{"ain1.ain1",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
@@ -1026,6 +1032,19 @@ static struct pinmux_config profibus_pin_mux[] = {
 	{NULL, 0},
 };
 
+#define BEAGLEBONE_W1_GPIO GPIO_TO_PIN(1, 3)
+
+static struct w1_gpio_platform_data bone_w1_gpio_pdata = {
+	.pin		= BEAGLEBONE_W1_GPIO,
+	.is_open_drain	= 0,
+};
+
+static struct platform_device bone_w1_device = {
+	.name			= "w1-gpio",
+	.id			= -1,
+	.dev.platform_data	= &bone_w1_gpio_pdata,
+};
+
 /* LEDS - gpio1_21 -> gpio1_24 */
 
 #define BEAGLEBONE_USR1_LED  GPIO_TO_PIN(1, 21)
@@ -1349,6 +1368,17 @@ static void dvileds_init(int evm_id, int profile )
 		pr_err("failed to register BeagleBone DVI cape LEDS\n");
 }
 
+static void bonew1_gpio_init(int evm_id, int profile )
+{
+	int err;
+	setup_pin_mux(w1_gpio_pin_mux);
+	err = platform_device_register(&bone_w1_device);
+	if (err)
+		pr_err("failed to register w1-gpio\n");
+	else
+		pr_info("w1-gpio connected to P8_6\n");
+}
+
 static void rgmii1_init(int evm_id, int profile)
 {
 	setup_pin_mux(rgmii1_pin_mux);
@@ -2228,6 +2258,7 @@ static struct evm_dev_cfg beaglebone_dev_cfg[] = {
 	{i2c2_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{mmc0_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{boneleds_init,	DEV_ON_BASEBOARD, PROFILE_ALL},
+	{bonew1_gpio_init, DEV_ON_BASEBOARD, PROFILE_ALL},
 	{NULL, 0, 0},
 };
 
-- 
1.7.7.4

