9f7fb006e2ce33539ce23149854e6deb1af96c2c
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-omap-2.6.39 / camera / 0003-Add-support-for-mt9p031-LI-5M03-module-in-Beagleboar.patch
1 From 6cce194e3d1fbc5d746b192b4d1ff78aef6099cf Mon Sep 17 00:00:00 2001
2 From: Javier Martin <javier.martin@vista-silicon.com>
3 Date: Mon, 30 May 2011 10:37:17 +0200
4 Subject: [PATCH 3/3] Add support for mt9p031 (LI-5M03 module) in Beagleboard xM.
6 Since isp clocks have not been exposed yet, this patch
7 includes a temporal solution for testing mt9p031 driver
8 in Beagleboard xM.
10 Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
11 ---
12 arch/arm/mach-omap2/Makefile | 1 +
13 arch/arm/mach-omap2/board-omap3beagle-camera.c | 91 ++++++++++++++++++++++++
14 arch/arm/mach-omap2/board-omap3beagle.c | 5 ++
15 3 files changed, 97 insertions(+), 0 deletions(-)
16 create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.c
18 diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
19 index 512b152..05cd983 100644
20 --- a/arch/arm/mach-omap2/Makefile
21 +++ b/arch/arm/mach-omap2/Makefile
22 @@ -179,6 +179,7 @@ obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o \
23 hsmmc.o
24 obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
25 obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \
26 + board-omap3beagle-camera.o \
27 hsmmc.o
28 obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \
29 hsmmc.o
30 diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
31 new file mode 100644
32 index 0000000..8387951
33 --- /dev/null
34 +++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
35 @@ -0,0 +1,91 @@
36 +#include <linux/gpio.h>
37 +#include <linux/regulator/machine.h>
38 +
39 +#include <plat/i2c.h>
40 +
41 +#include <media/mt9p031.h>
42 +
43 +#include "devices.h"
44 +#include "../../../drivers/media/video/omap3isp/isp.h"
45 +
46 +#define MT9P031_RESET_GPIO 98
47 +#define MT9P031_XCLK ISP_XCLK_A
48 +
49 +static struct regulator *reg_1v8, *reg_2v8;
50 +
51 +static int beagle_cam_set_xclk(struct v4l2_subdev *subdev, int hz)
52 +{
53 + struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
54 + int ret;
55 +
56 + ret = isp->platform_cb.set_xclk(isp, hz, MT9P031_XCLK);
57 + return 0;
58 +}
59 +
60 +static int beagle_cam_reset(struct v4l2_subdev *subdev, int active)
61 +{
62 + /* Set RESET_BAR to !active */
63 + gpio_set_value(MT9P031_RESET_GPIO, !active);
64 +
65 + return 0;
66 +}
67 +
68 +static struct mt9p031_platform_data beagle_mt9p031_platform_data = {
69 + .set_xclk = beagle_cam_set_xclk,
70 + .reset = beagle_cam_reset,
71 +};
72 +
73 +static struct i2c_board_info mt9p031_camera_i2c_device = {
74 + I2C_BOARD_INFO("mt9p031", 0x48),
75 + .platform_data = &beagle_mt9p031_platform_data,
76 +};
77 +
78 +static struct isp_subdev_i2c_board_info mt9p031_camera_subdevs[] = {
79 + {
80 + .board_info = &mt9p031_camera_i2c_device,
81 + .i2c_adapter_id = 2,
82 + },
83 + { NULL, 0, },
84 +};
85 +
86 +static struct isp_v4l2_subdevs_group beagle_camera_subdevs[] = {
87 + {
88 + .subdevs = mt9p031_camera_subdevs,
89 + .interface = ISP_INTERFACE_PARALLEL,
90 + .bus = {
91 + .parallel = {
92 + .data_lane_shift = 0,
93 + .clk_pol = 1,
94 + .bridge = ISPCTRL_PAR_BRIDGE_DISABLE,
95 + }
96 + },
97 + },
98 + { },
99 +};
100 +
101 +static struct isp_platform_data beagle_isp_platform_data = {
102 + .subdevs = beagle_camera_subdevs,
103 +};
104 +
105 +static int __init beagle_camera_init(void) {
106 + if(cpu_is_omap3630()){
107 + reg_1v8 = regulator_get(NULL, "cam_1v8");
108 + if (IS_ERR(reg_1v8))
109 + pr_err("%s: cannot get cam_1v8 regulator\n", __func__);
110 + else
111 + regulator_enable(reg_1v8);
112 +
113 + reg_2v8 = regulator_get(NULL, "cam_2v8");
114 + if (IS_ERR(reg_2v8))
115 + pr_err("%s: cannot get cam_2v8 regulator\n", __func__);
116 + else
117 + regulator_enable(reg_2v8);
118 +
119 + omap_register_i2c_bus(2, 100, NULL, 0);
120 + gpio_request(MT9P031_RESET_GPIO, "cam_rst");
121 + gpio_direction_output(MT9P031_RESET_GPIO, 0);
122 + omap3_init_camera(&beagle_isp_platform_data);
123 + }
124 + return 0;
125 +}
126 +late_initcall(beagle_camera_init);
127 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
128 index 221bfda..dd6e31f 100644
129 --- a/arch/arm/mach-omap2/board-omap3beagle.c
130 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
131 @@ -25,12 +25,16 @@
132 #include <linux/input.h>
133 #include <linux/gpio_keys.h>
134 #include <linux/opp.h>
135 +#include <linux/i2c.h>
136 +#include <linux/mm.h>
137 +#include <linux/videodev2.h>
139 #include <linux/mtd/mtd.h>
140 #include <linux/mtd/partitions.h>
141 #include <linux/mtd/nand.h>
142 #include <linux/mmc/host.h>
144 +#include <linux/gpio.h>
145 #include <linux/regulator/machine.h>
146 #include <linux/i2c/twl.h>
148 @@ -48,6 +52,7 @@
149 #include <plat/nand.h>
150 #include <plat/usb.h>
151 #include <plat/omap_device.h>
152 +#include <plat/i2c.h>
154 #include "mux.h"
155 #include "hsmmc.h"
156 --
157 1.6.6.1