ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / board-rk30-sdk-camera.c
1 #ifdef CONFIG_VIDEO_RK29
2
3 #include <plat/rk_camera.h>
4 /* Notes:
5
6 Simple camera device registration:
7
8        new_camera_device(sensor_name,\       // sensor name, it is equal to CONFIG_SENSOR_X
9                           face,\              // sensor face information, it can be back or front
10                           pwdn_io,\           // power down gpio configuration, it is equal to CONFIG_SENSOR_POWERDN_PIN_XX
11                           flash_attach,\      // sensor is attach flash or not
12                           mir,\               // sensor image mirror and flip control information
13                           i2c_chl,\           // i2c channel which the sensor attached in hardware, it is equal to CONFIG_SENSOR_IIC_ADAPTER_ID_X
14                           cif_chl)  \         // cif channel which the sensor attached in hardware, it is equal to CONFIG_SENSOR_CIF_INDEX_X
15
16 Comprehensive camera device registration:
17
18       new_camera_device_ex(sensor_name,\
19                              face,\
20                              ori,\            // sensor orientation, it is equal to CONFIG_SENSOR_ORIENTATION_X
21                              pwr_io,\         // sensor power gpio configuration, it is equal to CONFIG_SENSOR_POWER_PIN_XX
22                              pwr_active,\     // sensor power active level, is equal to CONFIG_SENSOR_RESETACTIVE_LEVEL_X
23                              rst_io,\         // sensor reset gpio configuration, it is equal to CONFIG_SENSOR_RESET_PIN_XX
24                              rst_active,\     // sensor reset active level, is equal to CONFIG_SENSOR_RESETACTIVE_LEVEL_X
25                              pwdn_io,\
26                              pwdn_active,\    // sensor power down active level, is equal to CONFIG_SENSOR_POWERDNACTIVE_LEVEL_X
27                              flash_attach,\
28                              res,\            // sensor resolution, this is real resolution or resoltuion after interpolate
29                              mir,\
30                              i2c_chl,\
31                              i2c_spd,\        // i2c speed , 100000 = 100KHz
32                              i2c_addr,\       // the i2c slave device address for sensor
33                              cif_chl,\
34                              mclk)\           // sensor input clock rate, 24 or 48
35                           
36 */
37 static struct rkcamera_platform_data new_camera[] = {      
38     new_camera_device(RK29_CAM_SENSOR_OV5640,
39                         back,
40                         RK30_PIN1_PD6,
41                         0,
42                         0,
43                         4,
44                         1),
45
46     /*                         
47     new_camera_device(RK29_CAM_SENSOR_OV5642,
48                         back,
49                         RK30_PIN1_PD6,
50                         0,
51                         0,
52                         4,
53                         1),                        
54     
55     new_camera_device(RK29_CAM_SENSOR_HM5065,
56                         back,
57                         RK30_PIN1_PD6,
58                         0,
59                         0,
60                         4,
61                         1),
62     
63     */
64     /*
65     new_camera_device_ex(RK29_CAM_SENSOR_MT9P111,
66                         back,
67                         INVALID_VALUE,
68                         INVALID_VALUE,
69                         INVALID_VALUE,
70                         INVALID_VALUE,
71                         INVALID_VALUE,
72                         RK30_PIN1_PD6,
73                         CONS(RK29_CAM_SENSOR_MT9P111,_PWRDN_ACTIVE),
74                         0,
75                         CONS(RK29_CAM_SENSOR_MT9P111,_FULL_RESOLUTION),
76                         0x00,
77                         4,
78                         100000,
79                         CONS(RK29_CAM_SENSOR_MT9P111,_I2C_ADDR),
80                         1,
81                         24),
82     
83
84     */
85     /*
86     new_camera_device(RK29_CAM_SENSOR_SP2518,
87                       front,
88                       RK30_PIN1_PB7,
89                       0,
90                       0,
91                       3,
92                       0),
93     */ 
94     /*
95     new_camera_device(RK29_CAM_SENSOR_GC2035,
96                       front,
97                       RK30_PIN1_PB7,
98                       0,
99                       0,
100                       3,
101                       0),
102     
103     
104     */ 
105     new_camera_device(RK29_CAM_SENSOR_OV2659,
106                       front,
107                       RK30_PIN1_PB7,
108                       0,
109                       0,
110                       3,
111                       0),
112     
113       
114     new_camera_device_end
115 };
116 #endif  //#ifdef CONFIG_VIDEO_RK29
117
118 /*---------------- Camera Sensor Configuration Macro End------------------------*/
119 #include "../../../drivers/media/video/rk30_camera.c"
120 /*---------------- Camera Sensor Macro Define End  ---------*/
121
122 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
123 /*****************************************************************************************
124  * camera  devices
125  * author: ddl@rock-chips.com
126  *****************************************************************************************/
127 #ifdef CONFIG_VIDEO_RK29
128 #define CONFIG_SENSOR_POWER_IOCTL_USR      1 //define this refer to your board layout
129 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
130 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR          0
131 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
132
133 #if CONFIG_SENSOR_POWER_IOCTL_USR
134 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
135 {
136         //#error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
137     struct regulator *ldo_18,*ldo_28;
138
139     ldo_28 = regulator_get(NULL, "ldo7");       // vcc28_cif
140     ldo_18 = regulator_get(NULL, "ldo1");       // vcc18_cif
141     if (ldo_28 == NULL || IS_ERR(ldo_28) || ldo_18 == NULL || IS_ERR(ldo_18)){
142         printk("get cif ldo failed!\n");
143         return -1;
144     }
145     if(on == 0){
146         while(regulator_is_enabled(ldo_28)>0)   
147             regulator_disable(ldo_28);
148         regulator_put(ldo_28);
149         while(regulator_is_enabled(ldo_18)>0)
150             regulator_disable(ldo_18);
151         regulator_put(ldo_18);
152         mdelay(10);
153     } else {
154         regulator_set_voltage(ldo_28, 2800000, 2800000);
155         regulator_enable(ldo_28);
156         //printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28));
157         regulator_put(ldo_28);
158
159         regulator_set_voltage(ldo_18, 1800000, 1800000);
160         //regulator_set_suspend_voltage(ldo, 1800000);
161         regulator_enable(ldo_18);
162         //printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_18));
163         regulator_put(ldo_18);
164     }
165
166     return 0;
167 }
168 #endif
169
170 #if CONFIG_SENSOR_RESET_IOCTL_USR
171 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
172 {
173         #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
174 }
175 #endif
176
177 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
178 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
179 {
180         #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
181 }
182 #endif
183
184 #if CONFIG_SENSOR_FLASH_IOCTL_USR
185 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
186 {
187         #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
188 }
189 #endif
190
191 static struct rk29camera_platform_ioctl_cb      sensor_ioctl_cb = {
192         #if CONFIG_SENSOR_POWER_IOCTL_USR
193         .sensor_power_cb = sensor_power_usr_cb,
194         #else
195         .sensor_power_cb = NULL,
196         #endif
197
198         #if CONFIG_SENSOR_RESET_IOCTL_USR
199         .sensor_reset_cb = sensor_reset_usr_cb,
200         #else
201         .sensor_reset_cb = NULL,
202         #endif
203
204         #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
205         .sensor_powerdown_cb = sensor_powerdown_usr_cb,
206         #else
207         .sensor_powerdown_cb = NULL,
208         #endif
209
210         #if CONFIG_SENSOR_FLASH_IOCTL_USR
211         .sensor_flash_cb = sensor_flash_usr_cb,
212         #else
213         .sensor_flash_cb = NULL,
214         #endif
215 };
216
217
218 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] ;
219 #include "../../../drivers/media/video/rk30_camera.c"
220
221 #endif /* CONFIG_VIDEO_RK29 */