summaryrefslogtreecommitdiff
path: root/recipes/linux/linux-omap-psp-2.6.32/cam/0023-omap3beagle-camera-Fix-powerup-sequence.patch
blob: 56a5e6ee037c98b05e8e98909f9645b1009c6eef (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From 1f300b7451ed1aef6f9b9902f2070b7340cb4d0a Mon Sep 17 00:00:00 2001
From: Sergio Aguirre <saaguirre@ti.com>
Date: Thu, 24 Jun 2010 18:21:52 -0500
Subject: [PATCH 23/71] omap3beagle: camera: Fix powerup sequence

The powerup sequence was very incomplete. After revisiting the
Aptina developer's guide, the resulting powerup sequence is followed.

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle-camera.c |   49 ++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
index 6babaf3..792c48d 100644
--- a/arch/arm/mach-omap2/board-omap3beagle-camera.c
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
@@ -51,6 +51,8 @@
 
 #define ISP_MT9T111_MCLK		216000000
 
+#define LEOPARD_RESET_GPIO		98
+
 static struct regulator *beagle_mt9t111_1_8v;
 static struct regulator *beagle_mt9t111_2_8v;
 
@@ -174,16 +176,42 @@ static int mt9t111_power_set(struct v4l2_int_device *s, enum v4l2_power power)
 		break;
 
 	case V4L2_POWER_ON:
-		isp_set_xclk(vdev->cam->isp, MT9T111_CLK_MIN, CAM_USE_XCLKA);
-
 #if defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
 		isp_configure_interface(vdev->cam->isp, &mt9t111_if_config);
 #endif
 
-		/* turn on analog power */
+		/* Set RESET_BAR to 0 */
+		gpio_set_value(LEOPARD_RESET_GPIO, 0);
+
+		/* turn on VDD */
 		regulator_enable(beagle_mt9t111_1_8v);
+
+		mdelay(1);
+
+		/* turn on VDD_IO */
 		regulator_enable(beagle_mt9t111_2_8v);
-		udelay(100);
+
+		mdelay(50);
+
+		/* Enable EXTCLK */
+		isp_set_xclk(vdev->cam->isp, MT9T111_CLK_MIN, CAM_USE_XCLKA);
+
+		/*
+		 * Wait at least 70 CLK cycles (w/EXTCLK = 6MHz, or CLK_MIN):
+		 * ((1000000 * 70) / 6000000) = aprox 12 us.
+		 */
+
+		udelay(12);
+
+		/* Set RESET_BAR to 1 */
+		gpio_set_value(LEOPARD_RESET_GPIO, 1);
+
+		/*
+		 * Wait at least 100 CLK cycles (w/EXTCLK = 6MHz, or CLK_MIN):
+		 * ((1000000 * 100) / 6000000) = aprox 17 us.
+		 */
+
+		udelay(17);
 
 		break;
 
@@ -224,6 +252,17 @@ static int beagle_cam_probe(struct platform_device *pdev)
 		return PTR_ERR(beagle_mt9t111_2_8v);
 	}
 
+	if (gpio_request(LEOPARD_RESET_GPIO, "cam_rst") != 0) {
+		dev_err(&pdev->dev, "Could not request GPIO %d",
+			LEOPARD_RESET_GPIO);
+		regulator_put(beagle_mt9t111_2_8v);
+		regulator_put(beagle_mt9t111_1_8v);
+		return -ENODEV;
+	}
+
+	/* set to output mode, default value 0 */
+	gpio_direction_output(LEOPARD_RESET_GPIO, 0);
+
 	printk(KERN_INFO MODULE_NAME ": Driver registration complete \n");
 
 	return 0;
@@ -238,6 +277,8 @@ static int beagle_cam_remove(struct platform_device *pdev)
 		regulator_disable(beagle_mt9t111_2_8v);
 	regulator_put(beagle_mt9t111_2_8v);
 
+	gpio_free(LEOPARD_RESET_GPIO);
+
 	return 0;
 }
 
-- 
1.6.6.1