camsys_drv: v0.7.0 camsys_head: v0.6.0
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / rk_camsys / camsys_soc_priv.c
1
2 #include "camsys_soc_priv.h"
3
4
5
6 static camsys_soc_priv_t* camsys_soc_p;
7
8 #include "camsys_soc_rk3288.c"
9
10 static int camsys_rk3288_cfg (camsys_soc_cfg_t cfg_cmd, void* cfg_para)
11 {
12     unsigned int *para_int;
13     
14     switch (cfg_cmd)
15     {
16         case Clk_DriverStrength_Cfg:
17         {
18             para_int = (unsigned int*)cfg_para;
19             __raw_writel((((*para_int)&0x03)<<3)|(0x03<<3), RK_GRF_VIRT+0x01d4);
20             break;
21         }
22
23         case Cif_IoDomain_Cfg:
24         {
25             para_int = (unsigned int*)cfg_para;
26             if (*para_int < 28000000) {
27                 __raw_writel(((1<<1)|(1<<(1+16))),RK_GRF_VIRT+0x0380);    // 1.8v IO
28             } else {
29                 __raw_writel(((0<<1)|(1<<(1+16))),RK_GRF_VIRT+0x0380);    // 3.3v IO
30             }
31             break;
32         }
33
34         case Mipi_Phy_Cfg:
35         {
36             camsys_rk3288_mipihpy_cfg((camsys_mipiphy_soc_para_t*)cfg_para);
37             break;
38         }
39
40         case Isp_SoftRst:
41         {
42
43             break;
44         }
45
46         default:
47         {
48             camsys_warn("cfg_cmd: 0x%x isn't support for %s",cfg_cmd,camsys_soc_p->name);
49             break;
50         }
51
52     }
53
54     return 0;
55
56
57 }
58
59 camsys_soc_priv_t* camsys_soc_get(void)
60 {
61     if (camsys_soc_p != NULL) {
62         return camsys_soc_p;
63     } else {
64         return NULL;
65     }
66 }
67
68 int camsys_soc_init(void)
69 {    
70     camsys_soc_p = kzalloc(sizeof(camsys_soc_priv_t),GFP_KERNEL);
71     if (camsys_soc_p == NULL) {
72         camsys_err("malloc camsys_soc_priv_t failed!");
73         goto fail;
74     }
75
76     if (soc_is_rk3288()) {
77         strlcpy(camsys_soc_p->name,"camsys_rk3288",31);
78         camsys_soc_p->soc_cfg = camsys_rk3288_cfg;
79     } else {
80         camsys_err("camsys isn't support soc: 0x%lx!",rockchip_soc_id);
81         goto fail;
82     }
83     
84     return 0;
85 fail:
86     if (camsys_soc_p != NULL) {
87         kfree(camsys_soc_p);
88         camsys_soc_p = NULL;
89     }
90     return -1;
91 }
92
93 int camsys_soc_deinit(void)
94 {
95     if (camsys_soc_p != NULL) {
96         kfree(camsys_soc_p);
97         camsys_soc_p = NULL;
98     }
99     return 0;
100 }