|
From: <hap...@us...> - 2007-06-26 10:15:31
|
Revision: 1076
http://svn.sourceforge.net/hackndev/?rev=1076&view=rev
Author: happy-slapin
Date: 2007-06-26 03:15:26 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
PXA270+OV9640: made silly merge of driver
Modified Paths:
--------------
linux4palm/linux/trunk/drivers/i2c/chips/i2c-ov9640.c
Modified: linux4palm/linux/trunk/drivers/i2c/chips/i2c-ov9640.c
===================================================================
--- linux4palm/linux/trunk/drivers/i2c/chips/i2c-ov9640.c 2007-06-26 08:56:09 UTC (rev 1075)
+++ linux4palm/linux/trunk/drivers/i2c/chips/i2c-ov9640.c 2007-06-26 10:15:26 UTC (rev 1076)
@@ -6,6 +6,7 @@
#include <asm/hardware.h>
#include <asm/types.h>
#include <linux/delay.h>
+#include <asm/arch/palmz72-gpio.h>
#include "i2c-ov9640.h"
@@ -29,7 +30,7 @@
extern struct i2c_adapter *i2cdev_adaps[];
struct i2c_client *g_client = NULL;
-static unsigned short normal_i2c[] = {OV9640_SLAVE_ADDR ,I2C_CLIENT_END };
+static unsigned short normal_i2c[] = {0x5d, OV9640_SLAVE_ADDR ,I2C_CLIENT_END };
/* static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; */
I2C_CLIENT_INSMOD;
@@ -108,7 +109,22 @@
return i2c_probe(adap,&addr_data,i2c_ov9640_detect_client);
}
+#if 0
+static int a780_camera_adapter_attach(struct i2c_adapter *adap)
+{
+ if(! (a780_camera_client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL)))
+ return -ENOMEM;
+ memcpy(a780_camera_client,&client_template,sizeof(struct i2c_client));
+ a780_camera_client->adapter = adap;
+
+ a780_camera_client->addr = 0x5D;
+
+ i2c_attach_client(a780_camera_client);
+ return 0;
+}
+#endif
+
static int i2c_ov9640_detect_client(struct i2c_adapter *adapter, int address, int kind)
{
struct i2c_client *new_client;
@@ -153,7 +169,9 @@
new_client->driver = &ov9640_driver;
new_client->flags = 0;
- g_client = new_client;
+ g_client = new_client;
+ ov9640_power_down(0);
+ mdelay(1);
/* Now, we do the remaining detection. If no `force' parameter is used. */
@@ -178,7 +196,7 @@
}*/
}
- strcpy(new_client->name, "ov9640");
+ strcpy(new_client->name, "i2c-ov9640");
/* Only if you use this field */
data->valid = 0;
@@ -211,7 +229,7 @@
/* Try to detach the client from i2c space */
if ((err = i2c_detach_client(client))) {
- DPRINTK("ov9640.o: Client deregistration failed, client not detached.\n");
+ DPRINTK("i2c-ov9640.o: Client deregistration failed, client not detached.\n");
return err;
}
@@ -225,15 +243,148 @@
have to be cleaned up! */
static int ov9640_initialized = 0;
+
+
+/***********************************************************************
+* Power & Reset
+***********************************************************************/
+
+
+
+#if 0
+static struct i2c_driver driver = {
+ .name = "a780 camera driver",
+ .id = I2C_A780_CAMERA,
+ //flags: I2C_DF_DUMMY,
+ .attach_adapter = a780_camera_adapter_attach,
+ .detach_client = a780_camera_detach,
+ .owner = THIS_MODULE,
+};
+
+static struct i2c_adapter a780_camera_adapter = {
+ name: "a780 camera adapter",
+ id: I2C_A780_CAMERA,
+ client_register: a780_camera_client_register,
+ client_unregister: a780_camera_client_unregister,
+};
+static struct i2c_client client_template =
+{
+ name: "(unset)",
+ adapter:&a780_camera_adapter,
+};
+struct i2c_client *a780_camera_client;
+
+int ov9640_write(u8 addr, u8 value)
+{
+ char tmp[2]={addr, value};
+ int ret;
+ unsigned int flags;
+
+ ret = a780_camera_write(tmp, 2);
+ local_irq_save(flags)
+ enable_irq(IRQ_I2C);
+ ret = i2c_master_send(a780_camera_client, buf, count);
+ local_irq_restore(flags);
+ if(ret < 0)
+ {
+ err_print("i2c write error code =%d", ret);
+ return -EIO;
+ }
+
+ ddbg_print("addr = 0x%02x, value = 0x%02x", addr,value);
+ return 0;
+}
+#endif
+
+
+void ov9640_soft_reset(void)
+{
+ u8 regValue;
+ regValue = 0x80;
+ ov9640_write(OV9640_COM7, ®Value);
+ mdelay(10);
+ return;
+}
+
+void ov9640_power_down(int powerDown)
+{
+ // OV9640 PWRDWN, 0 = NORMAL, 1=POWER DOWN
+ //GPDR1 |= GPIO_bit(50);
+ //OV9640 reset CIF_RST, 0 = NORMAL, 1=RESET
+ //GPDR0 |= GPIO_bit(19);
+ if (powerDown == 1) {
+ mdelay(200);
+ ov9640_soft_reset();
+ ov9640_write(0x39, 0xf4);
+ ov9640_write(0x1e, 0x80);
+ ov9640_write(0x6b, 0x3f);
+ ov9640_write(0x36, 0x49);
+ ov9640_write(0x12, 0x05);
+ mdelay(800);
+ GPSR1 = GPIO_bit(50);
+ }
+ else {
+ ov9640_write(0x39, 0xf0);
+ ov9640_write(0x1e, 0x00);
+ ov9640_write(0x6b, 0x3f);
+ ov9640_write(0x36, 0x49);
+ ov9640_write(0x12, 0x10);
+ GPCR1 = GPIO_bit(50);
+ //GPSR0 = GPIO_bit(19);
+ mdelay(20);
+ //GPCR0 = GPIO_bit(19);
+ }
+ mdelay(100);
+}
+
+/***********************************************************************
+ *
+ * OV9640 Functions
+ *
+ ***********************************************************************/
+static void ov9640_gpio_init()
+{
+
+ set_GPIO_mode(27 | GPIO_ALT_FN_3_IN); /* CIF_DD[0] */
+ set_GPIO_mode(114 | GPIO_ALT_FN_1_IN); /* CIF_DD[1] */
+ set_GPIO_mode(51 | GPIO_ALT_FN_1_IN); /* CIF_DD[2] */
+ set_GPIO_mode(115 | GPIO_ALT_FN_2_IN); /* CIF_DD[3] */
+ set_GPIO_mode(95 | GPIO_ALT_FN_2_IN); /* CIF_DD[4] */
+ set_GPIO_mode(94 | GPIO_ALT_FN_2_IN); /* CIF_DD[5] */
+ set_GPIO_mode(17 | GPIO_ALT_FN_2_IN); /* CIF_DD[6] */
+ set_GPIO_mode(108 | GPIO_ALT_FN_1_IN); /* CIF_DD[7] */
+ set_GPIO_mode(23 | GPIO_ALT_FN_1_OUT); /* CIF_MCLK */
+ set_GPIO_mode(54 | GPIO_ALT_FN_3_IN); /* CIF_PCLK */
+ set_GPIO_mode(85 | GPIO_ALT_FN_3_IN); /* CIF_LV */
+ set_GPIO_mode(84 | GPIO_ALT_FN_3_IN); /* CIF_FV */
+ set_GPIO_mode(50 | GPIO_OUT); /*CIF_PD */
+ set_GPIO_mode(19 | GPIO_IN); /*CIF_RST */
+
+
+ return;
+
+}
+
+/***********************************************************************
+ *
+ * end of OV9640 Functions
+ *
+ ***********************************************************************/
+
+
int i2c_ov9640_init(void)
{
int res;
if (ov9640_initialized)
return 0;
+// SET_GPIO(112, 1);
DPRINTK("I2C: driver for device ov9640.\n");
+
+ ov9640_gpio_init();
+
if ( (res = i2c_add_driver(&ov9640_driver)) ) {
- DPRINTK("ov9640: Driver registration failed, module not inserted.\n");
+ DPRINTK("i2c-ov9640: Driver registration failed, module not inserted.\n");
i2c_ov9640_cleanup();
return res;
}
@@ -247,15 +398,17 @@
void i2c_ov9640_cleanup(void)
{
+// SET_GPIO(112, 0);
if (ov9640_initialized == 1) {
if (i2c_del_driver(&ov9640_driver)) {
- DPRINTK("ov9640: Driver registration failed, module not removed.\n");
+ DPRINTK("i2c-ov9640: Driver registration failed, module not removed.\n");
return;
}
ov9640_initialized --;
}
}
+
//EXPORT_SYMBOL(i2c_ov9640_init);
EXPORT_SYMBOL(ov9640_write);
EXPORT_SYMBOL(ov9640_read);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|