summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/0032-beaglebone-connect-batterycape-GPIO-to-gpio-charger.patch
blob: 6fe7c899a5d71430e17d8cfcb7cd5fdbd0e90d9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From d8f8e88b0ea9cf4e94a601d5ee2601ee8f1b6d52 Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen@dominion.thruhere.net>
Date: Wed, 25 Apr 2012 12:35:07 +0200
Subject: [PATCH 32/79] beaglebone: connect batterycape GPIO to gpio-charger

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
---
 arch/arm/mach-omap2/board-am335xevm.c |   46 ++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index 3adc4ac..717bb8c 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -135,6 +135,36 @@ static const struct display_panel disp_panel = {
 	COLOR_ACTIVE,
 };
 
+
+#if defined(CONFIG_CHARGER_GPIO)
+
+#include <linux/power_supply.h>
+#include <linux/power/gpio-charger.h>
+
+/* charger */
+static char *beaglebone_batteries[] = {
+	"battery",
+};
+
+static struct gpio_charger_platform_data beaglebone_charger_pdata = {
+	.name = "battery-cape",
+	.type = POWER_SUPPLY_TYPE_BATTERY,
+	.gpio = GPIO_TO_PIN(1,16),
+	.gpio_active_low = 0,
+	.supplied_to = beaglebone_batteries,
+	.num_supplicants = ARRAY_SIZE(beaglebone_batteries),
+};
+
+static struct platform_device beaglebone_charger_device = {
+	.name = "gpio-charger",
+	.dev = {
+		.platform_data = &beaglebone_charger_pdata,
+	},
+};
+
+#endif /* gpio-charger */
+
+
 /* LCD backlight platform Data */
 #define AM335X_BACKLIGHT_MAX_BRIGHTNESS        100
 #define AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS    50
@@ -506,6 +536,13 @@ static struct pinmux_config haptics_pin_mux[] = {
 	{NULL, 0},
 };
 
+/* Module pin mux for battery cape */
+static struct pinmux_config batterycape_pin_mux[] = {
+	{"gpmc_a0.gpio1_16",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
+	{NULL, 0},
+};
+
+	
 /* Module pin mux for LCDC */
 static struct pinmux_config lcdc_pin_mux[] = {
 	{"lcd_data0.lcd_data0",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
@@ -2203,7 +2240,14 @@ static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context
 		pr_info("BeagleBone cape: initializing battery cape\n");
 		// gpio1_6, P9_15 lowbat output
 		// AIN4, P9_33 vbat
-		//foo_init(0,0);
+		setup_pin_mux(batterycape_pin_mux);
+		#if defined(CONFIG_CHARGER_GPIO)
+			int err;
+			err = platform_device_register(&beaglebone_charger_device);
+			if (err)
+				pr_err("failed to register BeagleBone battery cape gpio\n");
+		
+		#endif
 	}
 	
 	if (!strncmp("BB-BONE-SERL", cape_config.partnumber, 12)) {
-- 
1.7.10