linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09
       [not found] <Pine.LNX.4.64.0910031319320.5857@axis700.grange>
@ 2009-10-03 11:21 ` Guennadi Liakhovetski
  2009-10-05  2:25   ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform Paul Mundt
  0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2009-10-03 11:21 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Paul Mundt, linux-sh

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 arch/sh/boards/mach-kfr2r09/setup.c |  139 +++++++++++++++++++++++++++++++++++
 1 files changed, 139 insertions(+), 0 deletions(-)

diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index c08d33f..ce01d6a 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -18,6 +18,8 @@
 #include <linux/input.h>
 #include <linux/i2c.h>
 #include <linux/usb/r8a66597.h>
+#include <media/soc_camera.h>
+#include <media/sh_mobile_ceu.h>
 #include <video/sh_mobile_lcdc.h>
 #include <asm/clock.h>
 #include <asm/machvec.h>
@@ -212,11 +214,131 @@ static struct platform_device kfr2r09_usb0_gadget_device = {
 	.resource	= kfr2r09_usb0_gadget_resources,
 };
 
+static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
+	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
+};
+
+static struct resource kfr2r09_ceu_resources[] = {
+	[0] = {
+		.name	= "CEU",
+		.start	= 0xfe910000,
+		.end	= 0xfe91009f,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start  = 52,
+		.end  = 52,
+		.flags  = IORESOURCE_IRQ,
+	},
+	[2] = {
+		/* place holder for contiguous memory */
+	},
+};
+
+static struct platform_device kfr2r09_ceu_device = {
+	.name		= "sh_mobile_ceu",
+	.id             = 0, /* "ceu0" clock */
+	.num_resources	= ARRAY_SIZE(kfr2r09_ceu_resources),
+	.resource	= kfr2r09_ceu_resources,
+	.dev	= {
+		.platform_data	= &sh_mobile_ceu_info,
+	},
+	.archdata = {
+		.hwblk_id = HWBLK_CEU0,
+	},
+};
+
+static struct i2c_board_info kfr2r09_i2c_camera = {
+	I2C_BOARD_INFO("rj54n1cb0c", 0x50),
+};
+
+static struct clk *camera_clk;
+
+#define DRVCRB 0xA405018C
+static int camera_power(struct device *dev, int mode)
+{
+	int ret;
+
+	if (mode) {
+		long rate;
+
+		camera_clk = clk_get(NULL, "video_clk");
+		if (IS_ERR(camera_clk))
+			return PTR_ERR(camera_clk);
+
+		/* set VIO_CKO clock to 25MHz */
+		rate = clk_round_rate(camera_clk, 25000000);
+		ret = clk_set_rate(camera_clk, rate);
+		if (ret < 0)
+			goto eclkrate;
+
+		/* set DRVCRB
+		 *
+		 * use 1.8 V for VccQ_VIO
+		 * use 2.85V for VccQ_SR
+		 */
+		ctrl_outw((ctrl_inw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB);
+
+		/* reset clear */
+		ret = gpio_request(GPIO_PTB4, NULL);
+		if (ret < 0)
+			goto eptb4;
+		ret = gpio_request(GPIO_PTB7, NULL);
+		if (ret < 0)
+			goto eptb7;
+
+		ret = gpio_direction_output(GPIO_PTB4, 1);
+		if (!ret)
+			ret = gpio_direction_output(GPIO_PTB7, 1);
+		if (ret < 0)
+			goto egpioout;
+		msleep(1);
+
+		ret = clk_enable(camera_clk);	/* start VIO_CKO */
+		if (ret < 0)
+			goto eclkon;
+
+		return 0;
+	}
+
+	ret = 0;
+
+	clk_disable(camera_clk);
+eclkon:
+	gpio_set_value(GPIO_PTB7, 0);
+egpioout:
+	gpio_set_value(GPIO_PTB4, 0);
+	gpio_free(GPIO_PTB7);
+eptb7:
+	gpio_free(GPIO_PTB4);
+eptb4:
+eclkrate:
+	clk_put(camera_clk);
+	return ret;
+}
+
+static struct soc_camera_link rj54n1_link = {
+	.power		= camera_power,
+	.board_info	= &kfr2r09_i2c_camera,
+	.i2c_adapter_id	= 1,
+	.module_name	= "rj54n1cb0c",
+};
+
+static struct platform_device kfr2r09_camera = {
+	.name	= "soc-camera-pdrv",
+	.id	= 0,
+	.dev	= {
+		.platform_data = &rj54n1_link,
+	},
+};
+
 static struct platform_device *kfr2r09_devices[] __initdata = {
 	&kfr2r09_nor_flash_device,
 	&kfr2r09_nand_flash_device,
 	&kfr2r09_sh_keysc_device,
 	&kfr2r09_sh_lcdc_device,
+	&kfr2r09_ceu_device,
+	&kfr2r09_camera,
 };
 
 #define BSC_CS0BCR 0xfec10004
@@ -361,6 +483,23 @@ static int __init kfr2r09_devices_setup(void)
 	if (kfr2r09_usb0_gadget_setup() = 0)
 		platform_device_register(&kfr2r09_usb0_gadget_device);
 
+	/* CEU */
+	gpio_request(GPIO_FN_VIO_CKO, NULL);
+	gpio_request(GPIO_FN_VIO0_CLK, NULL);
+	gpio_request(GPIO_FN_VIO0_VD, NULL);
+	gpio_request(GPIO_FN_VIO0_HD, NULL);
+	gpio_request(GPIO_FN_VIO0_FLD, NULL);
+	gpio_request(GPIO_FN_VIO0_D7, NULL);
+	gpio_request(GPIO_FN_VIO0_D6, NULL);
+	gpio_request(GPIO_FN_VIO0_D5, NULL);
+	gpio_request(GPIO_FN_VIO0_D4, NULL);
+	gpio_request(GPIO_FN_VIO0_D3, NULL);
+	gpio_request(GPIO_FN_VIO0_D2, NULL);
+	gpio_request(GPIO_FN_VIO0_D1, NULL);
+	gpio_request(GPIO_FN_VIO0_D0, NULL);
+
+	platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20);
+
 	return platform_add_devices(kfr2r09_devices,
 				    ARRAY_SIZE(kfr2r09_devices));
 }
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform
  2009-10-03 11:21 ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 Guennadi Liakhovetski
@ 2009-10-05  2:25   ` Paul Mundt
  2009-10-05 15:20     ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the Guennadi Liakhovetski
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Mundt @ 2009-10-05  2:25 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List, linux-sh

On Sat, Oct 03, 2009 at 01:21:30PM +0200, Guennadi Liakhovetski wrote:
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  arch/sh/boards/mach-kfr2r09/setup.c |  139 +++++++++++++++++++++++++++++++++++
>  1 files changed, 139 insertions(+), 0 deletions(-)
> 
This seems to depend on the RJ54N1CB0C driver, so I'll queue this up
after that has been merged in the v4l tree. If it's available on a topic
branch upstream that isn't going to be rebased, then I can pull that in,
but this is not so critical either way.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the
  2009-10-05  2:25   ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform Paul Mundt
@ 2009-10-05 15:20     ` Guennadi Liakhovetski
  2009-10-09  1:44       ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform Paul Mundt
  0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2009-10-05 15:20 UTC (permalink / raw)
  To: Paul Mundt; +Cc: Linux Media Mailing List, linux-sh

On Mon, 5 Oct 2009, Paul Mundt wrote:

> On Sat, Oct 03, 2009 at 01:21:30PM +0200, Guennadi Liakhovetski wrote:
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> >  arch/sh/boards/mach-kfr2r09/setup.c |  139 +++++++++++++++++++++++++++++++++++
> >  1 files changed, 139 insertions(+), 0 deletions(-)
> > 
> This seems to depend on the RJ54N1CB0C driver, so I'll queue this up
> after that has been merged in the v4l tree. If it's available on a topic
> branch upstream that isn't going to be rebased, then I can pull that in,
> but this is not so critical either way.

It actually shouldn't depend on the driver patch. The driver has no 
headers, so... I haven't verified, but it should work either way. OTOH, 
waiting for the driver patch is certainly a safe bet:-)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform
  2009-10-05 15:20     ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the Guennadi Liakhovetski
@ 2009-10-09  1:44       ` Paul Mundt
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2009-10-09  1:44 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List, linux-sh

On Mon, Oct 05, 2009 at 05:20:48PM +0200, Guennadi Liakhovetski wrote:
> On Mon, 5 Oct 2009, Paul Mundt wrote:
> 
> > On Sat, Oct 03, 2009 at 01:21:30PM +0200, Guennadi Liakhovetski wrote:
> > > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > > ---
> > >  arch/sh/boards/mach-kfr2r09/setup.c |  139 +++++++++++++++++++++++++++++++++++
> > >  1 files changed, 139 insertions(+), 0 deletions(-)
> > > 
> > This seems to depend on the RJ54N1CB0C driver, so I'll queue this up
> > after that has been merged in the v4l tree. If it's available on a topic
> > branch upstream that isn't going to be rebased, then I can pull that in,
> > but this is not so critical either way.
> 
> It actually shouldn't depend on the driver patch. The driver has no 
> headers, so... I haven't verified, but it should work either way. OTOH, 
> waiting for the driver patch is certainly a safe bet:-)
> 
I thought it had a header dependency, but I must have been imagining
things. So in that regard it looks fine, I'll split out my 2.6.32 stuff
in to a separate branch momentarily and then roll this in when I start
taking 2.6.33 stuff. This should at least allow us to start testing in
-next when the driver is merged.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-09  1:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.64.0910031319320.5857@axis700.grange>
2009-10-03 11:21 ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 Guennadi Liakhovetski
2009-10-05  2:25   ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform Paul Mundt
2009-10-05 15:20     ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the Guennadi Liakhovetski
2009-10-09  1:44       ` [PATCH 1/2] SH: add support for the RJ54N1CB0C camera for the kfr2r09 platform Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).