Commit d2b9a8a9 authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

V4L: omap camera builds again

Fix some bitrot, including basic build/load functionality:

  - ov9640 code had syntax errors (!) and referenced missing fields
  - camera core included all kinds of crap, but not the v4l2 stuff
  - both omap16xx and 17xx used the wrong base clock
  - 16xx oopsed because its base clock did not exist
  - misuse of machine_is_omap_h3() in place of cpu_is_omap1710()
  - several exported symbols were goofed up
  - used bad call to reserve mem region
  - didn't destroy platform device correctly
  - ov9640 needed MODULE_LICENSE("GPL")

It's probably best to think of this as just making the camera code
build again, load/unload as modules, stop oopsing on 16xx, and be
a smidgeon cleaner ... since my (early/prototype) Mistral board won't
actually get to UBoot when a camera is connected.  :(
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 0b6b5f29
...@@ -20,40 +20,24 @@ ...@@ -20,40 +20,24 @@
* History: * History:
* 27/03/05 Vladimir Barinov - Added support for power management * 27/03/05 Vladimir Barinov - Added support for power management
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/ctype.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/videodev.h>
#include <linux/pci.h>
#include <linux/version.h> #include <linux/version.h>
#include <asm/semaphore.h>
#include <asm/processor.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <media/v4l2-common.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
#include "sensor_if.h" #include "sensor_if.h"
#include "camera_hw_if.h" #include "camera_hw_if.h"
#include "camera_core.h" #include "camera_core.h"
struct camera_device *camera_dev;
extern struct omap_camera_sensor camera_sensor_if; static struct camera_device *camera_dev;
extern struct camera_hardware camera_hardware_if;
static void camera_core_sgdma_process(struct camera_device *cam); static void camera_core_sgdma_process(struct camera_device *cam);
/* module parameters */ /* module parameters */
...@@ -1165,39 +1149,38 @@ static struct platform_driver camera_core_driver = { ...@@ -1165,39 +1149,38 @@ static struct platform_driver camera_core_driver = {
#endif #endif
}; };
static struct platform_device camera_core_device = { /* FIXME register omap16xx or omap24xx camera device in arch/arm/...
.name = CAM_NAME, * system init code, with its resources and mux setup, NOT here.
.dev = { * Then MODULE_ALIAS(CAM_NAME) so it hotplugs and coldplugs; this
.release = NULL, * "legacy" driver style is trouble.
}, */
.id = 0, static struct platform_device *cam;
};
void __exit static void __exit
camera_core_cleanup(void) camera_core_cleanup(void)
{ {
platform_driver_unregister(&camera_core_driver); platform_driver_unregister(&camera_core_driver);
platform_device_unregister(&camera_core_device); platform_device_unregister(cam);
return;
} }
static char banner[] __initdata = KERN_INFO "OMAP Camera driver initialzing\n"; static char banner[] __initdata = KERN_INFO "OMAP Camera driver initialzing\n";
int __init static int __init
camera_core_init(void) camera_core_init(void)
{ {
printk(banner); printk(banner);
platform_device_register(&camera_core_device);
platform_driver_register(&camera_core_driver); platform_driver_register(&camera_core_driver);
cam = platform_device_register_simple(CAM_NAME, -1, NULL, 0);
return 0; return 0;
} }
MODULE_AUTHOR("Texas Instruments."); MODULE_AUTHOR("Texas Instruments.");
MODULE_DESCRIPTION("OMAP Video for Linux camera driver"); MODULE_DESCRIPTION("OMAP Video for Linux camera driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_param(video_nr, int, 0); module_param(video_nr, int, 0);
MODULE_PARM_DESC(video_nr, MODULE_PARM_DESC(video_nr,
"Minor number for video device (-1 ==> auto assign)"); "Minor number for video device (-1 ==> auto assign)");
......
...@@ -151,6 +151,6 @@ struct camera_fh { ...@@ -151,6 +151,6 @@ struct camera_fh {
struct videobuf_queue vbq; struct videobuf_queue vbq;
}; };
#define CAM_NAME "omap-camera" #define CAM_NAME "omap_camera"
#endif /* CAMERA_CORE__H */ #endif /* CAMERA_CORE__H */
...@@ -44,5 +44,7 @@ struct camera_hardware { ...@@ -44,5 +44,7 @@ struct camera_hardware {
void *, void *, void *); void *, void *, void *);
int (*finish_dma)(void *); int (*finish_dma)(void *);
}; };
extern struct camera_hardware camera_hardware_if;
#endif /* OMAP_CAMERA_HW_IF_H */ #endif /* OMAP_CAMERA_HW_IF_H */
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
#include "omap16xxcam.h" #include "omap16xxcam.h"
#include "camera_hw_if.h" #include "camera_hw_if.h"
#include "camera_core.h" #include "camera_core.h"
#define CONF_CAMERAIF_RESET_R 5 #define CONF_CAMERAIF_RESET_R 5
#define EN_PER 0 #define EN_PER 0
...@@ -68,7 +69,9 @@ struct omap16xxcam { ...@@ -68,7 +69,9 @@ struct omap16xxcam {
unsigned long iobase_phys; unsigned long iobase_phys;
/* frequncy (in Hz) of camera interface functional clock (ocp_clk) */ /* frequncy (in Hz) of camera interface functional clock (ocp_clk) */
unsigned long ocp_clk; unsigned long ocp_clk;
struct clk *func_clk;
/* dma related stuff */ /* dma related stuff */
spinlock_t dma_lock; spinlock_t dma_lock;
...@@ -79,7 +82,7 @@ struct omap16xxcam { ...@@ -79,7 +82,7 @@ struct omap16xxcam {
int dma_channel_number2; int dma_channel_number2;
wait_queue_head_t vsync_wait; wait_queue_head_t vsync_wait;
int new; int new;
}; };
static struct omap16xxcam hardware_data; static struct omap16xxcam hardware_data;
...@@ -124,15 +127,10 @@ omap16xx_cam_init(void) ...@@ -124,15 +127,10 @@ omap16xx_cam_init(void)
OMAP1610_RESET_CONTROL); OMAP1610_RESET_CONTROL);
/* Enable peripheral reset */ /* Enable peripheral reset */
omap_writew(omap_readw(ARM_RSTCT2) | (1 << EN_PER), ARM_RSTCT2); omap_writew(omap_readw(ARM_RSTCT2) | (1 << EN_PER), ARM_RSTCT2);
/* enable peripheral clock */ /* enable peripheral clock */
if (machine_is_omap_h3()) clk_enable(hardware_data.func_clk);
clk_enable(clk_get(0, "tc2_ck"));
else {
clk_enable(clk_get(0, "armper_ck"));
clk_enable(clk_get(0, "armxor_ck"));
}
} }
static void static void
...@@ -321,8 +319,8 @@ omap16xxcam_start_dma(struct sgdma_state *sgdma, ...@@ -321,8 +319,8 @@ omap16xxcam_start_dma(struct sgdma_state *sgdma,
data->camdma[count].callback = callback; data->camdma[count].callback = callback;
data->camdma[count].arg1 = arg1; data->camdma[count].arg1 = arg1;
data->camdma[count].arg2 = arg2; data->camdma[count].arg2 = arg2;
if (machine_is_omap_h3()) if (cpu_is_omap1710())
omap_set_dma_src_params(dmach, OMAP_DMA_PORT_OCP_T1, omap_set_dma_src_params(dmach, OMAP_DMA_PORT_OCP_T1,
OMAP_DMA_AMODE_CONSTANT, CAM_CAMDATA_REG, OMAP_DMA_AMODE_CONSTANT, CAM_CAMDATA_REG,
0, 0); 0, 0);
...@@ -507,19 +505,25 @@ omap16xxcam_cleanup(void *priv) ...@@ -507,19 +505,25 @@ omap16xxcam_cleanup(void *priv)
{ {
struct omap16xxcam *data = (struct omap16xxcam *) priv; struct omap16xxcam *data = (struct omap16xxcam *) priv;
if (!data->camera_regs)
return -EINVAL;
omap16xxcam_disable(data); omap16xxcam_disable(data);
if (machine_is_omap_h3()) { if (cpu_is_omap1710())
if (data->camera_regs) { iounmap((void *)data->camera_regs);
iounmap((void *)data->camera_regs); data->camera_regs= NULL;
data->camera_regs= NULL;
}
}
if (data->iobase_phys) { if (data->iobase_phys) {
release_mem_region(data->iobase_phys, CAMERA_IOSIZE); release_mem_region(data->iobase_phys, CAMERA_IOSIZE);
data->iobase_phys = 0; data->iobase_phys = 0;
} }
if (hardware_data.func_clk) {
clk_disable(hardware_data.func_clk);
clk_put(hardware_data.func_clk);
hardware_data.func_clk = NULL;
}
return 0; return 0;
} }
...@@ -529,13 +533,15 @@ omap16xxcam_init(void) ...@@ -529,13 +533,15 @@ omap16xxcam_init(void)
{ {
unsigned long cam_iobase; unsigned long cam_iobase;
if (!request_region(CAMERA_BASE, CAMERA_IOSIZE, "OAMP16xx Camera")) { if (!request_mem_region(CAMERA_BASE, CAMERA_IOSIZE,
printk ("OMAP16XX Parallel Camera Interface is already in use\n"); camera_hardware_if.name)) {
pr_debug("%s is already in use\n", camera_hardware_if.name);
return NULL; return NULL;
} }
if (machine_is_omap_h3()) { if (cpu_is_omap1710()) {
cam_iobase = (unsigned long) ioremap (CAMERA_BASE, CAMERA_IOSIZE); cam_iobase = (unsigned long) ioremap (CAMERA_BASE,
CAMERA_IOSIZE);
if (!cam_iobase) { if (!cam_iobase) {
printk("CANNOT MAP CAMERA REGISTER\n"); printk("CANNOT MAP CAMERA REGISTER\n");
return NULL; return NULL;
...@@ -547,11 +553,13 @@ omap16xxcam_init(void) ...@@ -547,11 +553,13 @@ omap16xxcam_init(void)
/* Set the base address of the camera registers */ /* Set the base address of the camera registers */
hardware_data.camera_regs = (camera_regs_t *)cam_iobase; hardware_data.camera_regs = (camera_regs_t *)cam_iobase;
hardware_data.iobase_phys = (unsigned long) CAMERA_BASE; hardware_data.iobase_phys = (unsigned long) CAMERA_BASE;
/* get the input clock value to camera interface and store it */
if (machine_is_omap_h3()) /* get the input clock value to camera interface and store it */
hardware_data.ocp_clk = clk_get_rate(clk_get(0, "tc_ck")); if (cpu_is_omap1710())
hardware_data.func_clk = clk_get(0, "tc2_ck");
else else
hardware_data.ocp_clk = clk_get_rate(clk_get(0, "mpuper_ck")); hardware_data.func_clk = clk_get(0, "armper_ck");
hardware_data.ocp_clk = clk_get_rate(hardware_data.func_clk);
/* Init the camera IF */ /* Init the camera IF */
omap16xx_cam_init(); omap16xx_cam_init();
...@@ -566,7 +574,7 @@ omap16xxcam_init(void) ...@@ -566,7 +574,7 @@ omap16xxcam_init(void)
struct camera_hardware camera_hardware_if = { struct camera_hardware camera_hardware_if = {
.version = 0x01, .version = 0x01,
.name = "OMAP16xx Camera Parallel", .name = "OMAP16xx Parallel Camera",
.init = omap16xxcam_init, .init = omap16xxcam_init,
.cleanup = omap16xxcam_cleanup, .cleanup = omap16xxcam_cleanup,
.open = omap16xxcam_open, .open = omap16xxcam_open,
......
...@@ -44,5 +44,7 @@ struct omap_camera_sensor { ...@@ -44,5 +44,7 @@ struct omap_camera_sensor {
int (*set_control)(struct v4l2_control *, void *); int (*set_control)(struct v4l2_control *, void *);
}; };
extern struct omap_camera_sensor camera_sensor_if;
#endif #endif
...@@ -20,14 +20,13 @@ ...@@ -20,14 +20,13 @@
#include <media/video-buf.h> #include <media/video-buf.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/arch/gpio.h>
#include "sensor_if.h" #include "sensor_if.h"
#include "ov9640.h" #include "ov9640.h"
#include "h3sensorpower.h" #include "h3sensorpower.h"
#include "h4sensorpower.h" #include "h4sensorpower.h"
#define CAMERA_OV9640
#ifdef CAMERA_OV9640
struct ov9640_sensor { struct ov9640_sensor {
/* I2C parameters */ /* I2C parameters */
...@@ -696,6 +695,11 @@ ov9640_powerup(void) ...@@ -696,6 +695,11 @@ ov9640_powerup(void)
if (machine_is_omap_h2()) if (machine_is_omap_h2())
return 0; return 0;
#ifdef CONFIG_OMAP_OSK_MISTRAL
if (machine_is_omap_osk())
omap_set_gpio_dataout(11, 1);
#endif
if (machine_is_omap_h3()) { if (machine_is_omap_h3()) {
err = h3_sensor_powerup(); err = h3_sensor_powerup();
if (err) if (err)
...@@ -718,6 +722,11 @@ ov9640_powerdown(void) ...@@ -718,6 +722,11 @@ ov9640_powerdown(void)
if (machine_is_omap_h2()) if (machine_is_omap_h2())
return 0; return 0;
#ifdef CONFIG_OMAP_OSK_MISTRAL
if (machine_is_omap_osk())
omap_set_gpio_dataout(11, 0);
#endif
if (machine_is_omap_h3()) { if (machine_is_omap_h3()) {
err = h3_sensor_powerdown(); err = h3_sensor_powerdown();
if (err) if (err)
...@@ -806,6 +815,7 @@ ov9640_i2c_attach_client(struct i2c_adapter *adap, int addr, int probe) ...@@ -806,6 +815,7 @@ ov9640_i2c_attach_client(struct i2c_adapter *adap, int addr, int probe)
client->addr = addr; client->addr = addr;
client->driver = &ov9640sensor_i2c_driver; client->driver = &ov9640sensor_i2c_driver;
client->adapter = adap; client->adapter = adap;
strcpy(client->name, ov9640sensor_i2c_driver.driver.name);
err = i2c_attach_client(client); err = i2c_attach_client(client);
if (err) { if (err) {
...@@ -1125,7 +1135,7 @@ ov9640sensor_cleanup(void *priv) ...@@ -1125,7 +1135,7 @@ ov9640sensor_cleanup(void *priv)
static struct i2c_driver ov9640sensor_i2c_driver = { static struct i2c_driver ov9640sensor_i2c_driver = {
.driver { .driver = {
.name = "ov9640", .name = "ov9640",
}, },
.id = I2C_DRIVERID_MISC, /*FIXME:accroding to i2c-ids.h */ .id = I2C_DRIVERID_MISC, /*FIXME:accroding to i2c-ids.h */
...@@ -1180,10 +1190,6 @@ ov9640sensor_init(struct v4l2_pix_format *pix) ...@@ -1180,10 +1190,6 @@ ov9640sensor_init(struct v4l2_pix_format *pix)
struct omap_camera_sensor camera_sensor_if = { struct omap_camera_sensor camera_sensor_if = {
.version = 0x01, .version = 0x01,
.name = "OV9640", .name = "OV9640",
.parallel_mode = PAR_MODE_NOBT8,
.hs_polarity = SYNC_ACTIVE_HIGH,
.vs_polarity = SYNC_ACTIVE_LOW,
.image_swap = 0,
.init = ov9640sensor_init, .init = ov9640sensor_init,
.cleanup = ov9640sensor_cleanup, .cleanup = ov9640sensor_cleanup,
.enum_pixformat = ov9640sensor_enum_pixformat, .enum_pixformat = ov9640sensor_enum_pixformat,
...@@ -1196,7 +1202,11 @@ struct omap_camera_sensor camera_sensor_if = { ...@@ -1196,7 +1202,11 @@ struct omap_camera_sensor camera_sensor_if = {
.power_on = ov9640sensor_power_on, .power_on = ov9640sensor_power_on,
.power_off = ov9640sensor_power_off, .power_off = ov9640sensor_power_off,
}; };
EXPORT_SYMBOL_GPL(camera_sensor_if);
MODULE_LICENSE("GPL");
#if 0
void print_ov9640_regs(void *priv) void print_ov9640_regs(void *priv)
{ {
struct ov9640_sensor *sensor = (struct ov9640_sensor *) priv; struct ov9640_sensor *sensor = (struct ov9640_sensor *) priv;
...@@ -1207,5 +1217,4 @@ void print_ov9640_regs(void *priv) ...@@ -1207,5 +1217,4 @@ void print_ov9640_regs(void *priv)
else else
printk("reg %x = %x\n", reg, val); printk("reg %x = %x\n", reg, val);
} }
#endif
#endif /* ifdef CAMERA_OV9640 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment