From 68aee7b7879973e6fd9fa745da1924fe9f286fbf Mon Sep 17 00:00:00 2001 From: zyc Date: Thu, 5 Jun 2014 08:48:02 +0800 Subject: [PATCH] camsys_drv:v0.c.0 camsys_head:v0.7.0 --- arch/arm/boot/dts/rk3288-pinctrl.dtsi | 6 ++ arch/arm/boot/dts/rk3288.dtsi | 9 ++- drivers/media/video/rk_camsys/camsys_drv.c | 6 +- .../media/video/rk_camsys/camsys_internal.h | 6 +- drivers/media/video/rk_camsys/camsys_marvin.c | 70 ++++++++++++++++++- drivers/media/video/rk_camsys/camsys_marvin.h | 5 ++ include/media/camsys_head.h | 9 ++- 7 files changed, 102 insertions(+), 9 deletions(-) diff --git a/arch/arm/boot/dts/rk3288-pinctrl.dtsi b/arch/arm/boot/dts/rk3288-pinctrl.dtsi index 960f2ec8cb5d..55631e24c948 100755 --- a/arch/arm/boot/dts/rk3288-pinctrl.dtsi +++ b/arch/arm/boot/dts/rk3288-pinctrl.dtsi @@ -1179,6 +1179,12 @@ rockchip,drive = ; //rockchip,tristate = ; }; + isp_flash_trigger_as_gpio:isp_flash_trigger_as_gpio { + rockchip,pins = ; + rockchip,pull = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; }; }; diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index 7d97d6b3e7c5..e7f71f7e6c0e 100755 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi @@ -1208,17 +1208,20 @@ interrupts = ; clocks = <&clk_gates16 2>, <&clk_gates16 1>, <&clk_isp>, <&clk_isp_jpe>, <&clkin_isp>, <&clk_cif_out>, <&clk_gates5 15>, <&clk_cif_pll>, <&pd_isp>, <&clk_gates16 6>; clock-names = "aclk_isp", "hclk_isp", "clk_isp", "clk_isp_jpe", "pclkin_isp", "clk_cif_out", "clk_mipi_24m", "clk_cif_pll", "pd_isp", "hclk_mipiphy1"; - pinctrl-names = "default", "isp_dvp8bit2", "isp_dvp10bit", "isp_dvp12bit", "isp_dvp8bit0", "isp_mipi_fl", "isp_mipi_fl_prefl"; + pinctrl-names = "default", "isp_dvp8bit2", "isp_dvp10bit", "isp_dvp12bit", "isp_dvp8bit0", "isp_mipi_fl", "isp_mipi_fl_prefl","isp_flash_as_gpio","isp_flash_as_trigger_out"; pinctrl-0 = <&isp_mipi>; pinctrl-1 = <&isp_mipi &isp_dvp_d2d9>; pinctrl-2 = <&isp_mipi &isp_dvp_d2d9 &isp_dvp_d0d1>; pinctrl-3 = <&isp_mipi &isp_dvp_d2d9 &isp_dvp_d0d1 &isp_dvp_d10d11>; pinctrl-4 = <&isp_mipi &isp_dvp_d0d7>; - pinctrl-5 = <&isp_mipi &isp_flash_trigger>; - pinctrl-6 = <&isp_mipi &isp_flash_trigger &isp_prelight>; + pinctrl-5 = <&isp_mipi>; + pinctrl-6 = <&isp_mipi &isp_prelight>; + pinctrl-7 = <&isp_flash_trigger_as_gpio>; + pinctrl-8 = <&isp_flash_trigger>; rockchip,isp,mipiphy = <2>; rockchip,isp,cifphy = <1>; rockchip,isp,mipiphy1,reg = <0xff968000 0x4000>; + rockchip,gpios = <&gpio7 GPIO_B5 GPIO_ACTIVE_HIGH>; status = "okay"; }; diff --git a/drivers/media/video/rk_camsys/camsys_drv.c b/drivers/media/video/rk_camsys/camsys_drv.c index cd067d291f1d..c5262861d581 100755 --- a/drivers/media/video/rk_camsys/camsys_drv.c +++ b/drivers/media/video/rk_camsys/camsys_drv.c @@ -377,7 +377,11 @@ static int camsys_sysctl(camsys_sysctrl_t *devctl, camsys_dev_t *camsys_dev) { camsys_dev->reset_cb(camsys_dev, devctl->on); break; - } + } + case CamSys_Flash_Trigger: + { + camsys_dev->flash_trigger_cb(camsys_dev, devctl->on); + } default: break; diff --git a/drivers/media/video/rk_camsys/camsys_internal.h b/drivers/media/video/rk_camsys/camsys_internal.h index ebf92d262aec..ba57c84932ea 100755 --- a/drivers/media/video/rk_camsys/camsys_internal.h +++ b/drivers/media/video/rk_camsys/camsys_internal.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -76,8 +77,10 @@ * 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 */ -#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0xb,0) +#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0xc,0) #define CAMSYS_PLATFORM_DRV_NAME "RockChip-CamSys" @@ -236,6 +239,7 @@ typedef struct camsys_dev_s { 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, unsigned int on); } camsys_dev_t; diff --git a/drivers/media/video/rk_camsys/camsys_marvin.c b/drivers/media/video/rk_camsys/camsys_marvin.c index 1801637d3527..74493356fb47 100755 --- a/drivers/media/video/rk_camsys/camsys_marvin.c +++ b/drivers/media/video/rk_camsys/camsys_marvin.c @@ -1,5 +1,6 @@ #include "camsys_marvin.h" #include "camsys_soc_priv.h" +#include "camsys_gpio.h" #include #include @@ -9,6 +10,7 @@ extern int rockchip_clear_system_status(unsigned long status); static const char miscdev_name[] = CAMSYS_MARVIN_DEVNAME; + static int camsys_mrv_iomux_cb(camsys_extdev_t *extdev,void *ptr) { struct pinctrl *pinctrl; @@ -110,11 +112,75 @@ fail: return -1; } +static int camsys_mrv_flash_trigger_cb(void *ptr,unsigned int on) +{ + camsys_dev_t *camsys_dev = (camsys_dev_t*)ptr; + struct device *dev = &(camsys_dev->pdev->dev); + int flash_trigger_io ; + struct pinctrl *pinctrl; + struct pinctrl_state *state; + char state_str[20] = {0}; + int retval = 0; + enum of_gpio_flags flags; + + if(!on){ + strcpy(state_str,"isp_flash_as_gpio"); + pinctrl = devm_pinctrl_get(dev); + if (IS_ERR(pinctrl)) { + camsys_err("devm_pinctrl_get failed!"); + } + state = pinctrl_lookup_state(pinctrl, + state_str); + if (IS_ERR(state)){ + camsys_err("pinctrl_lookup_state failed!"); + } + + if (!IS_ERR(state)) { + retval = pinctrl_select_state(pinctrl, state); + if (retval){ + camsys_err("pinctrl_select_state failed!"); + } + + } + + //get gpio index + flash_trigger_io = of_get_named_gpio_flags(camsys_dev->pdev->dev.of_node, "rockchip,gpios", 0, &flags); + if(gpio_is_valid(flash_trigger_io)){ + flash_trigger_io = of_get_named_gpio_flags(camsys_dev->pdev->dev.of_node, "rockchip,gpios", 0, &flags); + gpio_request(flash_trigger_io,"camsys_gpio"); + gpio_direction_output(flash_trigger_io, 1); + } + + }else{ + strcpy(state_str,"isp_flash_as_trigger_out"); + pinctrl = devm_pinctrl_get(dev); + if (IS_ERR(pinctrl)) { + camsys_err("devm_pinctrl_get failed!"); + } + state = pinctrl_lookup_state(pinctrl, + state_str); + if (IS_ERR(state)){ + camsys_err("pinctrl_lookup_state failed!"); + } + + if (!IS_ERR(state)) { + retval = pinctrl_select_state(pinctrl, state); + if (retval){ + camsys_err("pinctrl_select_state failed!"); + } + + } + } + return retval; +} + + static int camsys_mrv_reset_cb(void *ptr,unsigned int on) { camsys_dev_t *camsys_dev = (camsys_dev_t*)ptr; camsys_soc_priv_t *soc; + if (camsys_dev->soc) { soc = (camsys_soc_priv_t*)camsys_dev->soc; if (soc->soc_cfg) { @@ -144,7 +210,7 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on) clk_prepare_enable(clk->clk_mipi_24m); clk_prepare_enable(clk->pclkin_isp); clk_prepare_enable(clk->pd_isp); - + clk->in_on = true; camsys_trace(1, "%s clock in turn on",dev_name(camsys_dev->miscdev.this_device)); @@ -154,7 +220,6 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on) } else if (!on && clk->in_on) { - clk_disable_unprepare(clk->aclk_isp); clk_disable_unprepare(clk->hclk_isp); clk_disable_unprepare(clk->isp); @@ -357,6 +422,7 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev) camsys_dev->clkout_cb = camsys_mrv_clkout_cb; camsys_dev->reset_cb = camsys_mrv_reset_cb; camsys_dev->iomux = camsys_mrv_iomux_cb; + camsys_dev->flash_trigger_cb = camsys_mrv_flash_trigger_cb; camsys_dev->miscdev.minor = MISC_DYNAMIC_MINOR; camsys_dev->miscdev.name = miscdev_name; diff --git a/drivers/media/video/rk_camsys/camsys_marvin.h b/drivers/media/video/rk_camsys/camsys_marvin.h index a066807e3148..000310a090b4 100755 --- a/drivers/media/video/rk_camsys/camsys_marvin.h +++ b/drivers/media/video/rk_camsys/camsys_marvin.h @@ -20,7 +20,12 @@ #define MRV_MI_MIS (MRV_MI_BASE+0x100) #define MRV_MI_ICR (MRV_MI_BASE+0x104) +#define MRV_FLASH_CONFIG (0x664) +typedef enum IO_USE_TYPE_e{ + USE_AS_GPIO, + USE_AS_ISP_INTERNAL, +}IO_USE_TYPE_t; typedef struct camsys_mrv_clk_s { struct clk *pd_isp; diff --git a/include/media/camsys_head.h b/include/media/camsys_head.h index 891b1d3e0f00..94d624bcd182 100755 --- a/include/media/camsys_head.h +++ b/include/media/camsys_head.h @@ -19,8 +19,10 @@ *v0.6.0: * 1) add support mipi phy configuration; * 2) add support io domain and mclk driver strength configuration; +*v0.7.0: + 1) add flash_trigger_out control */ -#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,6,0) +#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,7,0) #define CAMSYS_MARVIN_DEVNAME "camsys_marvin" #define CAMSYS_CIF0_DEVNAME "camsys_cif0" @@ -111,7 +113,10 @@ typedef enum camsys_sysctrl_ops_e { CamSys_Phy_Start_Tag, CamSys_Phy, - CamSys_Phy_End_Tag + CamSys_Phy_End_Tag, + CamSys_Flash_Trigger_Start_Tag, + CamSys_Flash_Trigger, + CamSys_Flash_Trigger_End_Tag } camsys_sysctrl_ops_t; -- 2.34.1