1
0
mirror of https://git.yoctoproject.org/meta-ti synced 2026-06-05 02:11:00 +00:00

linux-omap 2.6.39: add v6 of the MT9P031 sensor support

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
Koen Kooi
2011-06-01 20:17:31 +02:00
parent 05d8fa4670
commit 19714092cc
4 changed files with 230 additions and 48 deletions
@@ -1,18 +1,114 @@
From 244f96b15afbd73942762e2c07523d6c5cf68a7e Mon Sep 17 00:00:00 2001
Delivered-To: koen@beagleboard.org
Received: by 10.151.113.15 with SMTP id q15cs142302ybm;
Wed, 1 Jun 2011 08:40:02 -0700 (PDT)
Received: by 10.101.218.19 with SMTP id v19mr4614809anq.152.1306942801792;
Wed, 01 Jun 2011 08:40:01 -0700 (PDT)
Return-Path: <beagleboard+bncCLbVq8bYBxDHupnvBBoErrmKKA@googlegroups.com>
Received: from mail-gw0-f56.google.com (mail-gw0-f56.google.com [74.125.83.56])
by mx.google.com with ESMTPS id q9si2830757ani.54.2011.06.01.08.40.00
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 01 Jun 2011 08:40:00 -0700 (PDT)
Received-SPF: pass (google.com: domain of beagleboard+bncCLbVq8bYBxDHupnvBBoErrmKKA@googlegroups.com designates 74.125.83.56 as permitted sender) client-ip=74.125.83.56;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of beagleboard+bncCLbVq8bYBxDHupnvBBoErrmKKA@googlegroups.com designates 74.125.83.56 as permitted sender) smtp.mail=beagleboard+bncCLbVq8bYBxDHupnvBBoErrmKKA@googlegroups.com; dkim=pass (test mode) header.i=@googlegroups.com
Received: by gwaa11 with SMTP id a11sf7473558gwa.11
for <multiple recipients>; Wed, 01 Jun 2011 08:40:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlegroups.com; s=beta;
h=domainkey-signature:mime-version:x-beenthere:received-spf:from:to
:cc:subject:date:message-id:x-mailer:x-original-sender
:x-original-authentication-results:reply-to:precedence:mailing-list
:list-id:x-google-group-id:list-post:list-help:list-archive:sender
:list-unsubscribe:content-type;
bh=YBNkufpLpgUhP0Ja/p5xbR4lygvbGJf0W+WAfI5IdB4=;
b=iZQ8TroGI9c5zX6Vw7INxR2O7jT5tg6fO4GUDr3lxYXfWP0o3J/E4yqZ8zZwb9bxmI
gXtiV1FBeOjS0u6+ZrrqCt9HtCMEKFHMI4kYdoD2ABO1pjAXmL6lQtMYgYWM9j+RNIrk
F1mzfEnykk+pYvLCfPf5UU7QbhoSCd1Oc5pv0=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=googlegroups.com; s=beta;
h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date
:message-id:x-mailer:x-original-sender
:x-original-authentication-results:reply-to:precedence:mailing-list
:list-id:x-google-group-id:list-post:list-help:list-archive:sender
:list-unsubscribe:content-type;
b=40K6jHETfDcMlLEICg+kctIZRvOz6uePTaKT9ZUCteaABL3LZMqHmFe/MEqyr2+chL
KsyhPXLjKwYXTz1Qut5mn+PeALOQZYNDlWk8x0hAlQbiM7ydGppZMWyTs+N6q3hUTY1z
jzGEUEKgH+QrbcNJwR7jEXpbLiMaQrxsIVlVI=
Received: by 10.91.101.12 with SMTP id d12mr1050131agm.33.1306942797975;
Wed, 01 Jun 2011 08:39:57 -0700 (PDT)
MIME-Version: 1.0
X-BeenThere: beagleboard@googlegroups.com
Received: by 10.101.212.20 with SMTP id o20ls99205anq.3.gmail; Wed, 01 Jun
2011 08:39:51 -0700 (PDT)
Received: by 10.236.141.14 with SMTP id f14mr4899631yhj.62.1306942791154;
Wed, 01 Jun 2011 08:39:51 -0700 (PDT)
Received: by 10.150.33.26 with SMTP id g26msybg;
Wed, 1 Jun 2011 08:37:12 -0700 (PDT)
Received: by 10.42.140.134 with SMTP id k6mr2743913icu.80.1306942632159;
Wed, 01 Jun 2011 08:37:12 -0700 (PDT)
Received: by 10.42.140.134 with SMTP id k6mr2743912icu.80.1306942632143;
Wed, 01 Jun 2011 08:37:12 -0700 (PDT)
Received: from mail-wy0-f170.google.com (mail-wy0-f170.google.com [74.125.82.170])
by gmr-mx.google.com with ESMTPS id c14si398207icn.7.2011.06.01.08.37.10
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 01 Jun 2011 08:37:10 -0700 (PDT)
Received-SPF: neutral (google.com: 74.125.82.170 is neither permitted nor denied by best guess record for domain of javier.martin@vista-silicon.com) client-ip=74.125.82.170;
Received: by mail-wy0-f170.google.com with SMTP id 34so8538295wyb.1
for <beagleboard@googlegroups.com>; Wed, 01 Jun 2011 08:37:10 -0700 (PDT)
Received: by 10.227.165.10 with SMTP id g10mr7741970wby.91.1306942629902;
Wed, 01 Jun 2011 08:37:09 -0700 (PDT)
Received: from localhost.localdomain (242.51.18.95.dynamic.jazztel.es [95.18.51.242])
by mx.google.com with ESMTPS id fw15sm820685wbb.61.2011.06.01.08.37.01
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 01 Jun 2011 08:37:08 -0700 (PDT)
From: Javier Martin <javier.martin@vista-silicon.com>
Date: Tue, 31 May 2011 11:46:49 +0200
Subject: [PATCH 1/3] Add support for mt9p031 Aptina (Micron) sensor.
To: linux-media@vger.kernel.org
Cc: g.liakhovetski@gmx.de,
laurent.pinchart@ideasonboard.com,
carlighting@yahoo.co.nz,
beagleboard@googlegroups.com,
mch_kot@yahoo.com.cn,
Javier Martin <javier.martin@vista-silicon.com>
Subject: [beagleboard] [PATCH v6 1/2] Add driver for Aptina (Micron) mt9p031 sensor.
Date: Wed, 1 Jun 2011 17:36:48 +0200
Message-Id: <1306942609-2440-1-git-send-email-javier.martin@vista-silicon.com>
X-Mailer: git-send-email 1.7.0.4
X-Original-Sender: javier.martin@vista-silicon.com
X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com:
74.125.82.170 is neither permitted nor denied by best guess record for domain
of javier.martin@vista-silicon.com) smtp.mail=javier.martin@vista-silicon.com
Reply-To: beagleboard@googlegroups.com
Precedence: list
Mailing-list: list beagleboard@googlegroups.com; contact beagleboard+owners@googlegroups.com
List-ID: <beagleboard.googlegroups.com>
X-Google-Group-Id: 1035534660134
List-Post: <http://groups.google.com/group/beagleboard/post?hl=en_US>, <mailto:beagleboard@googlegroups.com>
List-Help: <http://groups.google.com/support/?hl=en_US>, <mailto:beagleboard+help@googlegroups.com>
List-Archive: <http://groups.google.com/group/beagleboard?hl=en_US>
Sender: beagleboard@googlegroups.com
List-Unsubscribe: <http://groups.google.com/group/beagleboard/subscribe?hl=en_US>,
<mailto:beagleboard+unsubscribe@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
This patch adds basic support (no controls) for
mt9p031 sensor. It applies on kernel 2.6.39.
Clock frequency of 57MHz used in previous version was wrong since
when VDD_IO is 1.8V it can only support 48MHz.
Two new platform flags have been added:
- vdd_io: indicates whether the chip is powered with 1.8 or 2.8 VDD_IO.
So that it can use the maximum allowed frequency.
- version: monochrome and color versions of the chip have exactly
the same ID, so the only way to select one of them is through
platform data.
Internal PLL is now used to generate PIXCLK depending on VDD_IO.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
drivers/media/video/Kconfig | 7 +
drivers/media/video/Makefile | 1 +
drivers/media/video/mt9p031.c | 699 +++++++++++++++++++++++++++++++++++++++++
include/media/mt9p031.h | 11 +
4 files changed, 718 insertions(+), 0 deletions(-)
drivers/media/video/mt9p031.c | 763 +++++++++++++++++++++++++++++++++++++++++
include/media/mt9p031.h | 23 ++
4 files changed, 794 insertions(+), 0 deletions(-)
create mode 100644 drivers/media/video/mt9p031.c
create mode 100644 include/media/mt9p031.h
@@ -48,10 +144,10 @@ index ace5d8b..912b29b 100644
obj-$(CONFIG_VIDEO_NOON010PC30) += noon010pc30.o
diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
new file mode 100644
index 0000000..61b46a0
index 0000000..cd830b1
--- /dev/null
+++ b/drivers/media/video/mt9p031.c
@@ -0,0 +1,699 @@
@@ -0,0 +1,763 @@
+/*
+ * Driver for MT9P031 CMOS Image Sensor from Aptina
+ *
@@ -80,7 +176,7 @@ index 0000000..61b46a0
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-device.h>
+
+#define MT9P031_PIXCLK_FREQ 54000000
+#define MT9P031_EXTCLK_FREQ 20000000
+
+#define MT9P031_CHIP_VERSION 0x00
+#define MT9P031_CHIP_VERSION_VALUE 0x1801
@@ -109,6 +205,18 @@ index 0000000..61b46a0
+#define MT9P031_OUTPUT_CONTROL_SYN 1
+#define MT9P031_SHUTTER_WIDTH_UPPER 0x08
+#define MT9P031_SHUTTER_WIDTH 0x09
+#define MT9P031_PLL_CONTROL 0x10
+#define MT9P031_PLL_CONTROL_PWROFF 0x0050
+#define MT9P031_PLL_CONTROL_PWRON 0x0051
+#define MT9P031_PLL_CONTROL_USEPLL 0x0052
+#define MT9P031_PLL_CONFIG_1 0x11
+#define MT9P031_PLL_CONFIG_1_M_48MHZ 0x5000
+#define MT9P031_PLL_CONFIG_1_N_48MHZ 0x05
+#define MT9P031_PLL_CONFIG_1_M_96MHZ 0x3600
+#define MT9P031_PLL_CONFIG_1_N_96MHZ 0x05
+#define MT9P031_PLL_CONFIG_2 0x12
+#define MT9P031_PLL_CONFIG_2_P1_48MHZ 5
+#define MT9P031_PLL_CONFIG_2_P1_96MHZ 2
+#define MT9P031_PIXEL_CLOCK_CONTROL 0x0a
+#define MT9P031_FRAME_RESTART 0x0b
+#define MT9P031_SHUTTER_DELAY 0x0c
@@ -123,9 +231,6 @@ index 0000000..61b46a0
+#define MT9P031_COLUMN_ADDRESS_MODE 0x23
+#define MT9P031_GLOBAL_GAIN 0x35
+
+
+
+
+struct mt9p031 {
+ struct v4l2_subdev subdev;
+ struct media_pad pad;
@@ -199,7 +304,7 @@ index 0000000..61b46a0
+ }
+ /* Emable clock */
+ if (mt9p031->pdata->set_xclk)
+ mt9p031->pdata->set_xclk(&mt9p031->subdev, MT9P031_PIXCLK_FREQ);
+ mt9p031->pdata->set_xclk(&mt9p031->subdev, MT9P031_EXTCLK_FREQ);
+ /* Now RESET_BAR must be high */
+ if (mt9p031->pdata->reset) {
+ mt9p031->pdata->reset(&mt9p031->subdev, 0);
@@ -526,6 +631,51 @@ index 0000000..61b46a0
+ return 0;
+}
+
+static int mt9p031_pll_enable(struct i2c_client *client)
+{
+ struct mt9p031 *mt9p031 = to_mt9p031(client);
+ int ret;
+
+ ret = reg_write(client, MT9P031_PLL_CONTROL, MT9P031_PLL_CONTROL_PWRON);
+ if (ret < 0)
+ return ret;
+
+ /* Always set the maximum frequency allowed by VDD_IO */
+ if (mt9p031->pdata->vdd_io == MT9P031_VDD_IO_2V8) {
+ ret = reg_write(client, MT9P031_PLL_CONFIG_1,
+ MT9P031_PLL_CONFIG_1_M_96MHZ |
+ MT9P031_PLL_CONFIG_1_N_96MHZ);
+ if (ret < 0)
+ return ret;
+ ret = reg_write(client, MT9P031_PLL_CONFIG_2,
+ MT9P031_PLL_CONFIG_2_P1_96MHZ);
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = reg_write(client, MT9P031_PLL_CONFIG_1,
+ MT9P031_PLL_CONFIG_1_M_48MHZ |
+ MT9P031_PLL_CONFIG_1_N_48MHZ);
+ if (ret < 0)
+ return ret;
+ ret = reg_write(client, MT9P031_PLL_CONFIG_2,
+ MT9P031_PLL_CONFIG_2_P1_48MHZ);
+ if (ret < 0)
+ return ret;
+ }
+ mdelay(1);
+ ret = reg_write(client, MT9P031_PLL_CONTROL,
+ MT9P031_PLL_CONTROL_PWRON |
+ MT9P031_PLL_CONTROL_USEPLL);
+ mdelay(1);
+ return ret;
+}
+
+static inline int mt9p031_pll_disable(struct i2c_client *client)
+{
+ return reg_write(client, MT9P031_PLL_CONTROL,
+ MT9P031_PLL_CONTROL_PWROFF);
+}
+
+static int mt9p031_s_stream(struct v4l2_subdev *sd, int enable)
+{
+ struct mt9p031 *mt9p031 = container_of(sd, struct mt9p031, subdev);
@@ -542,10 +692,16 @@ index 0000000..61b46a0
+ /* Switch to master "normal" mode */
+ ret = mt9p031_set_output_control(mt9p031, 0,
+ MT9P031_OUTPUT_CONTROL_CEN);
+ if (ret < 0)
+ return ret;
+ ret = mt9p031_pll_enable(client);
+ } else {
+ /* Stop sensor readout */
+ ret = mt9p031_set_output_control(mt9p031,
+ MT9P031_OUTPUT_CONTROL_CEN, 0);
+ if (ret < 0)
+ return ret;
+ ret = mt9p031_pll_disable(client);
+ }
+ return ret;
+}
@@ -630,7 +786,11 @@ index 0000000..61b46a0
+ mt9p031->rect.left = MT9P031_COLUMN_START_DEF;
+ mt9p031->rect.top = MT9P031_ROW_START_DEF;
+
+ mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+ if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION)
+ mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12;
+ else
+ mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+
+ mt9p031->format.width = MT9P031_WINDOW_WIDTH_DEF;
+ mt9p031->format.height = MT9P031_WINDOW_HEIGHT_DEF;
+ mt9p031->format.field = V4L2_FIELD_NONE;
@@ -753,21 +913,39 @@ index 0000000..61b46a0
+MODULE_LICENSE("GPL v2");
diff --git a/include/media/mt9p031.h b/include/media/mt9p031.h
new file mode 100644
index 0000000..ad37eb3
index 0000000..27b4c75
--- /dev/null
+++ b/include/media/mt9p031.h
@@ -0,0 +1,11 @@
@@ -0,0 +1,23 @@
+#ifndef MT9P031_H
+#define MT9P031_H
+
+struct v4l2_subdev;
+
+enum {
+ MT9P031_COLOR_VERSION = 0,
+ MT9P031_MONOCHROME_VERSION = 1,
+};
+
+enum {
+ MT9P031_VDD_IO_1V8 = 0,
+ MT9P031_VDD_IO_2V8 = 1,
+};
+
+struct mt9p031_platform_data {
+ int (*set_xclk)(struct v4l2_subdev *subdev, int hz);
+ int (*reset)(struct v4l2_subdev *subdev, int active);
+ int vdd_io; /* MT9P031_VDD_IO_1V8 or MT9P031_VDD_IO_2V8 */
+ int version; /* MT9P031_COLOR_VERSION or MT9P031_MONOCHROME_VERSION */
+};
+
+#endif
--
1.6.6.1
1.7.0.4
--
You received this message because you are subscribed to the Google Groups "Beagle Board" group.
To post to this group, send email to beagleboard@googlegroups.com.
To unsubscribe from this group, send email to beagleboard+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
@@ -1,7 +1,7 @@
From 78fdfee2f749cdcdfa69a008b70c4e5629b9c9df Mon Sep 17 00:00:00 2001
From 45b4d28d17536c1ee328706cf5d2a123f8e567f5 Mon Sep 17 00:00:00 2001
From: Detlev Casanova <detlev.casanova@gmail.com>
Date: Sun, 28 Nov 2010 19:07:20 +0100
Subject: [PATCH 2/3] v4l: Add mt9v032 sensor driver
Subject: [PATCH 01/35] v4l: Add mt9v032 sensor driver
The MT9V032 is a parallel wide VGA sensor from Aptina (formerly Micron)
controlled through I2C.
@@ -1,7 +1,7 @@
From 6cce194e3d1fbc5d746b192b4d1ff78aef6099cf Mon Sep 17 00:00:00 2001
From 846c5da448cdd12098df3b89fc97cfd9dd3e2f5b Mon Sep 17 00:00:00 2001
From: Javier Martin <javier.martin@vista-silicon.com>
Date: Mon, 30 May 2011 10:37:17 +0200
Subject: [PATCH 3/3] Add support for mt9p031 (LI-5M03 module) in Beagleboard xM.
Subject: [PATCH] Add support for mt9p031 (LI-5M03 module) in Beagleboard xM.
Since isp clocks have not been exposed yet, this patch
includes a temporal solution for testing mt9p031 driver
@@ -10,9 +10,9 @@ in Beagleboard xM.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
arch/arm/mach-omap2/Makefile | 1 +
arch/arm/mach-omap2/board-omap3beagle-camera.c | 91 ++++++++++++++++++++++++
arch/arm/mach-omap2/board-omap3beagle.c | 5 ++
3 files changed, 97 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-omap3beagle-camera.c | 95 ++++++++++++++++++++++++
arch/arm/mach-omap2/board-omap3beagle.c | 5 +
3 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.c
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
@@ -29,17 +29,17 @@ index 512b152..05cd983 100644
hsmmc.o
diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
new file mode 100644
index 0000000..8387951
index 0000000..2632557
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
@@ -0,0 +1,91 @@
@@ -0,0 +1,95 @@
+#include <linux/gpio.h>
+#include <linux/regulator/machine.h>
+
+#include <plat/i2c.h>
+
+#include <media/mt9p031.h>
+
+#include <asm/mach-types.h>
+#include "devices.h"
+#include "../../../drivers/media/video/omap3isp/isp.h"
+
@@ -68,6 +68,8 @@ index 0000000..8387951
+static struct mt9p031_platform_data beagle_mt9p031_platform_data = {
+ .set_xclk = beagle_cam_set_xclk,
+ .reset = beagle_cam_reset,
+ .vdd_io = MT9P031_VDD_IO_1V8,
+ .version = MT9P031_COLOR_VERSION,
+};
+
+static struct i2c_board_info mt9p031_camera_i2c_device = {
@@ -102,25 +104,27 @@ index 0000000..8387951
+ .subdevs = beagle_camera_subdevs,
+};
+
+static int __init beagle_camera_init(void) {
+ if(cpu_is_omap3630()){
+ 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);
+static int __init beagle_camera_init(void)
+{
+ if (!machine_is_omap3_beagle() || !cpu_is_omap3630())
+ return 0;
+
+ 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);
+ 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);
+
+ omap_register_i2c_bus(2, 100, NULL, 0);
+ gpio_request(MT9P031_RESET_GPIO, "cam_rst");
+ gpio_direction_output(MT9P031_RESET_GPIO, 0);
+ omap3_init_camera(&beagle_isp_platform_data);
+ }
+ 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);
+
+ omap_register_i2c_bus(2, 100, NULL, 0);
+ gpio_request(MT9P031_RESET_GPIO, "cam_rst");
+ gpio_direction_output(MT9P031_RESET_GPIO, 0);
+ omap3_init_camera(&beagle_isp_platform_data);
+ return 0;
+}
+late_initcall(beagle_camera_init);
+2 -2
View File
@@ -7,7 +7,7 @@ COMPATIBLE_MACHINE = "(beagleboard)"
# The main PR is now using MACHINE_KERNEL_PR, for omap3 see conf/machine/include/omap3.inc
SRCREV_pn-${PN} = "v2.6.39"
MACHINE_KERNEL_PR_append = "g"
MACHINE_KERNEL_PR_append = "h"
FILESPATHPKG_prepend = "linux-omap-2.6.39:"
@@ -53,7 +53,7 @@ SRC_URI_append = " \
file://beagle/0004-OMAP3-beagle-add-regulators-for-camera-interface.patch \
file://beagle/0005-OMAP3-beagle-HACK-add-in-1GHz-OPP.patch \
\
file://camera/0001-Add-support-for-mt9p031-Aptina-Micron-sensor.patch \
file://camera/0001-Add-driver-for-Aptina-Micron-mt9p031-sensor.patch \
file://camera/0002-v4l-Add-mt9v032-sensor-driver.patch \
file://camera/0003-Add-support-for-mt9p031-LI-5M03-module-in-Beagleboar.patch \
\