#include <linux/pinctrl/consumer.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/of_gpio.h>
+#include <linux/rockchip/cpu.h>
#include <media/camsys_head.h>
+#include <linux/rockchip-iovmm.h>
+
+
+
/*
* C A M S Y S D R I V E R V E R S I O N
*
* 1) iomux d0 d1 for cif phy raw10 in rk319x after i2c operated;
* 2) check mis value in camsys_irq_connect;
* 3) add soft rest callback;
-*v0.0.7:
+*v0.7.0:
* 1) check extdev is activate or not before delete from camsys_dev active list;
+*v0.8.0:
+* 1) fix deregister a unregister extdev oops in camsys_extdev_deregister;
+*v0.9.0: 1) set isp freq to 210M
+*v0.a.0:
+* 1) fix camsys_i2c_write and camsys_i2c_write can't support reg_size=0;
+*v0.b.0:
+ 1) control ddr freq by marvin self other than by clk unit.
+*v0.c.0:
+* 1) add flash_trigger_out control
+*v0.d.0:
+* 1) add Isp_SoftRst for rk3288;
+*v0.e.0:
+* 1) isp_clk 208.8M for 1lane, isp_clk 416.6M for 2lane;
+*v0.f.0:
+ 1) mi_mis register may read erro, this may cause mistaken mi frame_end irqs.
+*v0.0x10.0:
+ 1) add flash_prelight control.
+*v0.0x11.0:
+ 1) raise qos of isp up to the same as lcdc.
+*v0.0x12.0:
+ 1) support iommu.
+*v0.0x13.0:
+ 1) camsys_extdev_register return failed when this dev_id has been registered;
+ 2) add support JPG irq connect;
+*v0.0x14.0:
+ 1) camsys_extdev_register return -EBUSY when this dev_id has been registered;
+*v0.0x15.0:
+ 1) check extdev name when dev_id has been registered;
+*v0.0x16.0:
+ 1) enable or disable IOMMU just depending on CONFIG_ROCKCHIP_IOMMU.
+*v0.0x17.0:
+ 1) isp iommu status depend on vpu iommu status.
+*v0.0x18.0:
+ 1) add flashlight RT8547 driver
+ 2) support torch mode
+*v0.0x19.0:
+ 1) set CONFIG_CAMSYS_DRV disable as default,enable in defconfig file if needed.
+*v0.0x1a.0:
+ 1) vpu_node changed from "vpu_service" to "rockchip,vpu_sub"
+*v0.0x1b.0:
+ 1) use of_find_node_by_name to get vpu node instead of of_find_compatible_node
*/
-#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0,6)
+#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0x1b,0)
#define CAMSYS_PLATFORM_DRV_NAME "RockChip-CamSys"
#define CAMSYS_REGISTER_MEM_NAME CAMSYS_REGISTER_RES_NAME
#define CAMSYS_I2C_MEM_NAME "CamSys_I2cMem"
+#define CAMSYS_MIPIPHY_MEM_NAME CAMSYS_REGISTER_MIPIPHY_RES_NAME
#define CAMSYS_NAMELEN_MIN(a) ((strlen(a)>(CAMSYS_NAME_LEN-1))?(CAMSYS_NAME_LEN-1):strlen(a))
#define CAMSYS_IRQPOOL_NUM 128
#define camsys_trace(level, msg,...) \
do { \
- if (1/*camsys_debug >= level*/) \
+ if (camsys_debug >= level) \
printk("D%d:%s(%d): " msg "\n",level, __FUNCTION__,__LINE__, ## __VA_ARGS__); \
} while (0)
} camsys_gpio_t;
typedef struct camsys_flash_s {
camsys_gpio_t fl;
+ camsys_gpio_t fl_en;
+ void* ext_fsh_dev;
+ //flash call back
} camsys_flash_t;
typedef struct camsys_extdev_s {
+ unsigned char dev_name[CAMSYS_NAME_LEN];
unsigned int dev_id;
camsys_regulator_t avdd;
camsys_regulator_t dovdd;
camsys_gpio_t rst;
camsys_gpio_t afpwr;
camsys_gpio_t afpwrdn;
+ camsys_gpio_t pwren;
camsys_flash_t fl;
} camsys_extdev_t;
typedef struct camsys_phyinfo_s {
- void *clk;
- camsys_meminfo_t *reg;
+ unsigned int phycnt;
+ void *clk;
+ camsys_meminfo_t *reg;
int (*clkin_cb)(void *ptr, unsigned int on);
- int (*ops) (void *phy, void *phyinfo, unsigned int on);
+ int (*ops) (void *ptr, camsys_mipiphy_t *phy);
int (*remove)(struct platform_device *pdev);
} camsys_phyinfo_t;
struct miscdevice miscdev;
void *clk;
- camsys_phyinfo_t mipiphy;
+ camsys_phyinfo_t *mipiphy;
camsys_phyinfo_t cifphy;
camsys_exdevs_t extdevs;
struct list_head list;
struct platform_device *pdev;
+ void *soc;
+
int (*clkin_cb)(void *ptr, unsigned int on);
- int (*clkout_cb)(void *ptr,unsigned int on);
- int (*reset_cb)(void *ptr);
- int (*phy_cb) (camsys_extdev_phy_t *phy,void* ptr, unsigned int on);
+ int (*clkout_cb)(void *ptr,unsigned int on,unsigned int clk);
+ int (*reset_cb)(void *ptr, unsigned int on);
+ int (*phy_cb) (camsys_extdev_t *extdev, camsys_sysctrl_t *devctl, void* ptr);
int (*iomux)(camsys_extdev_t *extdev,void *ptr);
int (*platform_remove)(struct platform_device *pdev);
+ int (*flash_trigger_cb)(void *ptr,int mode , unsigned int on);
+ int (*iommu_cb)(void *ptr,camsys_sysctrl_t *devctl);
} camsys_dev_t;
camsys_regulator_t *regulator;
camsys_gpio_t *gpio;
- if (devctl->ops < CamSys_Vdd_Tag) {
+ if ((devctl->ops>CamSys_Vdd_Start_Tag) && (devctl->ops < CamSys_Vdd_End_Tag)) {
regulator = &extdev->avdd;
- regulator += devctl->ops;
-
- //printk("regulator: %p regulator->ldo: %p\n",regulator,regulator->ldo);
+ regulator += devctl->ops-1;
+
if (!IS_ERR_OR_NULL(regulator->ldo)) {
if (devctl->on) {
- regulator_set_voltage(regulator->ldo,regulator->min_uv,regulator->max_uv);
- regulator_enable(regulator->ldo);
+ err = regulator_set_voltage(regulator->ldo,regulator->min_uv,regulator->max_uv);
+ err |= regulator_enable(regulator->ldo);
camsys_trace(1,"Sysctl %d success, regulator set (%d,%d) uv!",devctl->ops, regulator->min_uv,regulator->max_uv);
} else {
while(regulator_is_enabled(regulator->ldo)>0)
camsys_trace(1,"Sysctl %d success, regulator off!",devctl->ops);
}
} else {
- camsys_err("Sysctl %d failed, because regulator ldo is NULL!",devctl->ops);
+ //camsys_err("Sysctl %d failed, because regulator ldo is NULL!",devctl->ops);
err = -EINVAL;
goto end;
}
- } else if (devctl->ops < CamSys_Gpio_Tag) {
+ } else if ((devctl->ops>CamSys_Gpio_Start_Tag) && (devctl->ops < CamSys_Gpio_End_Tag)) {
gpio = &extdev->pwrdn;
- gpio += devctl->ops - CamSys_Vdd_Tag -1;
+ gpio += devctl->ops - CamSys_Gpio_Start_Tag -1;
if (gpio->io != 0xffffffff) {
if (devctl->on) {
}
} else if (devctl->ops == CamSys_ClkIn) {
if (camsys_dev->clkout_cb)
- camsys_dev->clkout_cb(camsys_dev, extdev->clk.in_rate);
+ camsys_dev->clkout_cb(camsys_dev,devctl->on,extdev->clk.in_rate);
+ } else if (devctl->ops == CamSys_Phy) {
if (camsys_dev->phy_cb)
- camsys_dev->phy_cb(&extdev->phy, camsys_dev, devctl->on);
+ (camsys_dev->phy_cb)(extdev,devctl,(void*)camsys_dev);
}
end: