/
0009-Beagle-expansion-add-Aptina-li5m03-camera.patch
227 lines (211 loc) · 6.2 KB
/
0009-Beagle-expansion-add-Aptina-li5m03-camera.patch
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
From 577481a306e6181c1c2a664c1ecac2938c362f9b Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 11 Dec 2012 06:58:15 -0600
Subject: [PATCH 09/10] Beagle: expansion: add Aptina li5m03 camera
Based on:
https://github.com/Aptina/BeagleBoard-xM/blob/master/tools/0266-Adding-MT9P031-Support-files.patch
And on Max Galemin's patch
https://github.com/MaxGalemin/buildroot/blob/master/board/beagleboard/xm/kernel-patches/linux-0003-Add-support-for-MT9P031-Aptina-image-sensor-driver.patch
And Koen Kooi Previous work's
https://github.com/beagleboard/kernel/blob/beagleboard-3.2/patches/camera/0003-beagleboard-fix-i2c2-init.patch
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
arch/arm/mach-omap2/board-omap3beagle.c | 152 +++++++++++++++++++++++++++++++
1 files changed, 152 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 64b3444..c64ea55 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -168,6 +168,7 @@ static void __init omap3_beagle_init_rev(void)
char expansionboard_name[16];
char expansionboard2_name[16];
+char camera_name[16];
enum {
EXPANSION_MMC_NONE = 0,
@@ -520,6 +521,14 @@ static struct regulator_consumer_supply beagle_vsim_supply[] = {
REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
};
+static struct regulator_consumer_supply beagle_vaux3_supply = {
+ .supply = "cam_1v8",
+};
+
+static struct regulator_consumer_supply beagle_vaux4_supply = {
+ .supply = "cam_2v8",
+};
+
static struct gpio_led gpio_leds[];
static int beagle_twl_gpio_setup(struct device *dev,
@@ -628,11 +637,43 @@ static struct regulator_init_data beagle_vsim = {
.consumer_supplies = beagle_vsim_supply,
};
+/* VAUX3 for CAM_1V8 */
+static struct regulator_init_data beagle_vaux3 = {
+ .constraints = {
+ .min_uV = 1800000,
+ .max_uV = 1800000,
+ .apply_uV = true,
+ .valid_modes_mask = REGULATOR_MODE_NORMAL
+ | REGULATOR_MODE_STANDBY,
+ .valid_ops_mask = REGULATOR_CHANGE_MODE
+ | REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &beagle_vaux3_supply,
+};
+
+/* VAUX4 for CAM_2V8 */
+static struct regulator_init_data beagle_vaux4 = {
+ .constraints = {
+ .min_uV = 1800000,
+ .max_uV = 1800000,
+ .apply_uV = true,
+ .valid_modes_mask = REGULATOR_MODE_NORMAL
+ | REGULATOR_MODE_STANDBY,
+ .valid_ops_mask = REGULATOR_CHANGE_MODE
+ | REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &beagle_vaux4_supply,
+};
+
static struct twl4030_platform_data beagle_twldata = {
/* platform_data for children goes here */
.gpio = &beagle_gpio_data,
.vmmc1 = &beagle_vmmc1,
.vsim = &beagle_vsim,
+ .vaux3 = &beagle_vaux3,
+ .vaux4 = &beagle_vaux4,
};
static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
@@ -697,6 +738,71 @@ static struct i2c_board_info __initdata beagle_i2c2_bbtoys_ulcd[] = {};
static void __init omap3beagle_tsc2007_init(void) { return; }
#endif
+#if defined(CONFIG_VIDEO_MT9P031)
+/* needed for: omap3_beagle_late_initcall */
+#include "devices.h"
+#include <media/omap3isp.h>
+#include <media/mt9p031.h>
+/* needed for: v4l2_dev_to_isp_device */
+#include "../../../drivers/media/platform/omap3isp/isp.h"
+
+#define MT9P031_XCLK ISP_XCLK_A
+
+#define MT9P031_RESET_GPIO 98
+#define MT9P031_EXT_FREQ 21000000
+#define MT9P031_TARGET_FREQ 48000000
+
+#define MT9P031_I2C_ADDR 0x48
+#define MT9P031_I2C_BUS 2
+
+static struct regulator *reg_1v8, *reg_2v8;
+
+static int beagle_cam_set_xclk(struct v4l2_subdev *subdev, int hz)
+{
+ struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
+
+ return isp->platform_cb.set_xclk(isp, hz, MT9P031_XCLK);
+}
+
+static struct mt9p031_platform_data beagle_mt9p031_platform_data = {
+ .set_xclk = beagle_cam_set_xclk,
+ .reset = MT9P031_RESET_GPIO,
+ .ext_freq = MT9P031_EXT_FREQ,
+ .target_freq = MT9P031_TARGET_FREQ,
+};
+
+static struct i2c_board_info mt9p031_camera_i2c_device = {
+ I2C_BOARD_INFO("mt9p031", MT9P031_I2C_ADDR),
+ .platform_data = &beagle_mt9p031_platform_data,
+};
+
+static struct isp_subdev_i2c_board_info mt9p031_camera_subdevs[] = {
+ {
+ .board_info = &mt9p031_camera_i2c_device,
+ .i2c_adapter_id = MT9P031_I2C_BUS,
+ },
+ { NULL, 0, },
+};
+
+static struct isp_v4l2_subdevs_group beagle_camera_subdevs[] = {
+ {
+ .subdevs = mt9p031_camera_subdevs,
+ .interface = ISP_INTERFACE_PARALLEL,
+ .bus = {
+ .parallel = {
+ .data_lane_shift = 0,
+ .clk_pol = 1,
+ }
+ },
+ },
+ { },
+};
+
+static struct isp_platform_data beagle_isp_platform_data = {
+ .subdevs = beagle_camera_subdevs,
+};
+#endif
+
static int __init omap3_beagle_i2c_init(void)
{
omap3_pmic_get_config(&beagle_twldata,
@@ -833,6 +939,18 @@ static int __init expansionboard2_setup(char *str)
return 0;
}
+static int __init camera_setup(char *str)
+{
+ if (!machine_is_omap3_beagle())
+ return 0;
+
+ if (!str)
+ return -EINVAL;
+ strncpy(camera_name, str, 16);
+ pr_info("Beagle camera: %s\n", camera_name);
+ return 0;
+}
+
static int __init beagle_opp_init(void)
{
int r = 0;
@@ -1109,8 +1227,42 @@ static void __init omap3_beagle_init(void)
omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
}
+static int __init omap3_beagle_late_initcall(void)
+{
+ if (!machine_is_omap3_beagle())
+ return 0;
+
+ if (!cpu_is_omap3630())
+ return 0;
+
+#if defined(CONFIG_VIDEO_MT9P031)
+ if ((!strcmp(camera_name, "lbcm5m1")) || (!strcmp(camera_name, "li5m03")))
+ {
+ pr_info("Beagle camera: MT9P031 init\n");
+
+ reg_1v8 = regulator_get(NULL, "cam_1v8");
+ if (IS_ERR(reg_1v8))
+ pr_err("%s: cannot get cam_1v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_1v8);
+
+ reg_2v8 = regulator_get(NULL, "cam_2v8");
+ if (IS_ERR(reg_2v8))
+ pr_err("%s: cannot get cam_2v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_2v8);
+
+ omap3_init_camera(&beagle_isp_platform_data);
+ }
+#endif
+ return 0;
+}
+
early_param("buddy", expansionboard_setup);
early_param("buddy2", expansionboard2_setup);
+early_param("camera", camera_setup);
+
+late_initcall(omap3_beagle_late_initcall);
MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
/* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
--
1.7.7.6