diff mbox

[v4,19/26] ARM: pxa: magician: Add support for Omnivision OV9640 camera

Message ID 5609B365.4060307@tul.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Petr Cvek Sept. 28, 2015, 9:38 p.m. UTC
This patch adds support for an OV9640 camera to the HTC Magician machine.

Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
---
 arch/arm/mach-pxa/magician.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

Comments

Philipp Zabel Oct. 3, 2015, 12:50 p.m. UTC | #1
Am Montag, den 28.09.2015, 23:38 +0200 schrieb Petr Cvek:
> This patch adds support for an OV9640 camera to the HTC Magician
> machine.
> 
> Signed-off-by: Petr Cvek <petr.cvek@tul.cz>

Still untested, but looks good to me.

regards
Philipp
Robert Jarzmik Oct. 7, 2015, 7:49 p.m. UTC | #2
Philipp Zabel <philipp.zabel@gmail.com> writes:

> Am Montag, den 28.09.2015, 23:38 +0200 schrieb Petr Cvek:
>> This patch adds support for an OV9640 camera to the HTC Magician
>> machine.
>> 
>> Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
>
> Still untested, but looks good to me.
I'm still reluctant to have the reset with the timings handled in the board code
as I consider this should be in the camera driver code
(magician_camera_reset()).

Cheers.
Petr Cvek Oct. 8, 2015, 6:05 a.m. UTC | #3
Dne 7.10.2015 v 21:49 Robert Jarzmik napsal(a):
> Philipp Zabel <philipp.zabel@gmail.com> writes:
> 
>> Am Montag, den 28.09.2015, 23:38 +0200 schrieb Petr Cvek:
>>> This patch adds support for an OV9640 camera to the HTC Magician
>>> machine.
>>>
>>> Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
>>
>> Still untested, but looks good to me.
> I'm still reluctant to have the reset with the timings handled in the board code
> as I consider this should be in the camera driver code
> (magician_camera_reset()).

It supports an actual state of the OV9640 driver handling. But I can exclude it until
OV9640 will be transitioned. I don't have enough information about gpiod and soc-camera
and not enough time to maintain multiple different (and dependent) patchsets.

I forgot to test the timings ... actually I think I forgot results :-D . It was around the same time
I have found I2C fast mode is not working. Will test again.

Petr
diff mbox

Patch

diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 450f35f..d844b9c 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -49,6 +49,9 @@ 
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/spi/ads7846.h>
 
+#include <linux/platform_data/camera-pxa.h>
+#include <media/soc_camera.h>
+
 #include "devices.h"
 #include "generic.h"
 
@@ -960,6 +963,60 @@  static struct spi_board_info ads7846_spi_board_info[] __initdata = {
 };
 
 /*
+ * SoC Camera for OV9640 chip
+ */
+
+static struct pxacamera_platform_data magician_pxacamera_pdata = {
+	.flags		= PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
+		PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
+	.mclk_10khz	= 4800,
+};
+
+static int magician_camera_power(struct device *dev, int power)
+{
+	pr_debug("Camera power = %i\n", power);
+
+	gpio_set_value(GPIO116_MAGICIAN_nCAM_EN, !power);
+	mdelay(3);
+
+	return 0;
+}
+
+static int magician_camera_reset(struct device *dev)
+{
+	pr_debug("Camera reset\n");
+
+	gpio_set_value(GPIO57_MAGICIAN_CAM_RESET, 1);
+	mdelay(3);
+	gpio_set_value(GPIO57_MAGICIAN_CAM_RESET, 0);
+	mdelay(3);
+
+	return 0;
+}
+
+static struct i2c_board_info magician_camera_i2c_board_info = {
+	I2C_BOARD_INFO("ov9640", 0x30),
+	.flags = I2C_CLIENT_SCCB,
+};
+
+static struct soc_camera_link magician_camera_iclink = {
+	.bus_id		= 0,
+	.flags		= SOCAM_DATAWIDTH_8,
+	.i2c_adapter_id	= 0,
+	.board_info	= &magician_camera_i2c_board_info,
+	.power		= magician_camera_power,
+	.reset		= magician_camera_reset,
+};
+
+static struct platform_device magician_camera = {
+	.name	= "soc-camera-pdrv",
+	.id	= 0,
+	.dev	= {
+		.platform_data = &magician_camera_iclink,
+	},
+};
+
+/*
  * Platform devices
  */
 
@@ -974,6 +1031,7 @@  static struct platform_device *devices[] __initdata = {
 	&power_supply,
 	&strataflash,
 	&leds_gpio,
+	&magician_camera,
 };
 
 static struct gpio magician_global_gpios[] = {
@@ -984,6 +1042,8 @@  static struct gpio magician_global_gpios[] = {
 	{ GPIO106_MAGICIAN_LCD_DCDC_NRESET, GPIOF_OUT_INIT_LOW, "LCD DCDC nreset" },
 	{ GPIO104_MAGICIAN_LCD_VOFF_EN, GPIOF_OUT_INIT_LOW, "LCD VOFF enable" },
 	{ GPIO105_MAGICIAN_LCD_VON_EN, GPIOF_OUT_INIT_LOW, "LCD VON enable" },
+	{ GPIO57_MAGICIAN_CAM_RESET, GPIOF_OUT_INIT_HIGH, "Camera reset" },
+	{ GPIO116_MAGICIAN_nCAM_EN, GPIOF_OUT_INIT_HIGH, "Camera power" },
 };
 
 static void __init magician_init(void)
@@ -1030,6 +1090,7 @@  static void __init magician_init(void)
 	pxa2xx_set_spi_info(2, &magician_spi_info);
 	spi_register_board_info(ARRAY_AND_SIZE(ads7846_spi_board_info));
 
+	pxa_set_camera_info(&magician_pxacamera_pdata);
 }
 
 MACHINE_START(MAGICIAN, "HTC Magician")