]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/patches/kernel/omap/beagle/expansion/0009-Beagle-expansion-add-Aptina-li5m03-camera.patch
kernel: add some omap/pandaboard patches.
[ipfire-2.x.git] / src / patches / kernel / omap / beagle / expansion / 0009-Beagle-expansion-add-Aptina-li5m03-camera.patch
diff --git a/src/patches/kernel/omap/beagle/expansion/0009-Beagle-expansion-add-Aptina-li5m03-camera.patch b/src/patches/kernel/omap/beagle/expansion/0009-Beagle-expansion-add-Aptina-li5m03-camera.patch
new file mode 100644 (file)
index 0000000..28d2d4a
--- /dev/null
@@ -0,0 +1,217 @@
+From cc6ced0a1cbaea65a507ec3fe543a5b98d760d23 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 |  142 +++++++++++++++++++++++++++++++
+ 1 file changed, 142 insertions(+)
+
+diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
+index 3e0313ee..4fb5eae 100644
+--- a/arch/arm/mach-omap2/board-omap3beagle.c
++++ b/arch/arm/mach-omap2/board-omap3beagle.c
+@@ -201,6 +201,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,
+@@ -555,6 +556,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[];
+ /* PHY's VCC regulator might be added later, so flag that we need it */
+@@ -677,11 +686,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[] = {
+@@ -745,6 +786,61 @@ static void __init omap3beagle_tsc2007_init(void)
+ static struct i2c_board_info __initdata beagle_i2c2_bbtoys_ulcd[] = {};
+ #endif
++#if IS_ENABLED(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_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 struct mt9p031_platform_data beagle_mt9p031_platform_data = {
++      .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,
+@@ -869,6 +965,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;
+@@ -1155,8 +1263,42 @@ static void __init omap3_beagle_init(void)
+       pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
+ }
++static int __init omap3_beagle_late_initcall(void)
++{
++      if (!machine_is_omap3_beagle())
++              return 0;
++
++      if (!cpu_is_omap3630())
++              return 0;
++
++#if IS_ENABLED(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.10.4
+