2 * Copyright (C) 2010 Texas Instruments Inc
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/ctype.h>
21 #include <linux/delay.h>
22 #include <linux/device.h>
23 #include <linux/interrupt.h>
24 #include <linux/platform_device.h>
25 #include <linux/videodev2.h>
26 #include <linux/slab.h>
28 #include <mach/hardware.h>
30 #include <linux/platform_data/i2c-davinci.h>
34 #include <media/davinci/vpbe_types.h>
35 #include <media/davinci/vpbe_venc.h>
36 #include <media/davinci/vpss.h>
37 #include <media/v4l2-device.h>
39 #include "vpbe_venc_regs.h"
41 #define MODULE_NAME "davinci-vpbe-venc"
43 static struct platform_device_id vpbe_venc_devtype
[] = {
45 .name
= DM644X_VPBE_VENC_SUBDEV_NAME
,
46 .driver_data
= VPBE_VERSION_1
,
48 .name
= DM365_VPBE_VENC_SUBDEV_NAME
,
49 .driver_data
= VPBE_VERSION_2
,
51 .name
= DM355_VPBE_VENC_SUBDEV_NAME
,
52 .driver_data
= VPBE_VERSION_3
,
59 MODULE_DEVICE_TABLE(platform
, vpbe_venc_devtype
);
62 module_param(debug
, int, 0644);
63 MODULE_PARM_DESC(debug
, "Debug level 0-2");
66 struct v4l2_subdev sd
;
67 struct venc_callback
*callback
;
68 struct venc_platform_data
*pdata
;
73 void __iomem
*venc_base
;
74 void __iomem
*vdaccfg_reg
;
75 enum vpbe_version venc_type
;
78 static inline struct venc_state
*to_state(struct v4l2_subdev
*sd
)
80 return container_of(sd
, struct venc_state
, sd
);
83 static inline u32
venc_read(struct v4l2_subdev
*sd
, u32 offset
)
85 struct venc_state
*venc
= to_state(sd
);
87 return readl(venc
->venc_base
+ offset
);
90 static inline u32
venc_write(struct v4l2_subdev
*sd
, u32 offset
, u32 val
)
92 struct venc_state
*venc
= to_state(sd
);
94 writel(val
, (venc
->venc_base
+ offset
));
99 static inline u32
venc_modify(struct v4l2_subdev
*sd
, u32 offset
,
102 u32 new_val
= (venc_read(sd
, offset
) & ~mask
) | (val
& mask
);
104 venc_write(sd
, offset
, new_val
);
109 static inline u32
vdaccfg_write(struct v4l2_subdev
*sd
, u32 val
)
111 struct venc_state
*venc
= to_state(sd
);
113 writel(val
, venc
->vdaccfg_reg
);
115 val
= readl(venc
->vdaccfg_reg
);
120 #define VDAC_COMPONENT 0x543
121 #define VDAC_S_VIDEO 0x210
122 /* This function sets the dac of the VPBE for various outputs
124 static int venc_set_dac(struct v4l2_subdev
*sd
, u32 out_index
)
128 v4l2_dbg(debug
, 1, sd
, "Setting output to Composite\n");
129 venc_write(sd
, VENC_DACSEL
, 0);
132 v4l2_dbg(debug
, 1, sd
, "Setting output to Component\n");
133 venc_write(sd
, VENC_DACSEL
, VDAC_COMPONENT
);
136 v4l2_dbg(debug
, 1, sd
, "Setting output to S-video\n");
137 venc_write(sd
, VENC_DACSEL
, VDAC_S_VIDEO
);
146 static void venc_enabledigitaloutput(struct v4l2_subdev
*sd
, int benable
)
148 struct venc_state
*venc
= to_state(sd
);
150 v4l2_dbg(debug
, 2, sd
, "venc_enabledigitaloutput\n");
153 venc_write(sd
, VENC_VMOD
, 0);
154 venc_write(sd
, VENC_CVBS
, 0);
155 venc_write(sd
, VENC_LCDOUT
, 0);
156 venc_write(sd
, VENC_HSPLS
, 0);
157 venc_write(sd
, VENC_HSTART
, 0);
158 venc_write(sd
, VENC_HVALID
, 0);
159 venc_write(sd
, VENC_HINT
, 0);
160 venc_write(sd
, VENC_VSPLS
, 0);
161 venc_write(sd
, VENC_VSTART
, 0);
162 venc_write(sd
, VENC_VVALID
, 0);
163 venc_write(sd
, VENC_VINT
, 0);
164 venc_write(sd
, VENC_YCCCTL
, 0);
165 venc_write(sd
, VENC_DACSEL
, 0);
168 venc_write(sd
, VENC_VMOD
, 0);
169 /* disable VCLK output pin enable */
170 venc_write(sd
, VENC_VIDCTL
, 0x141);
172 /* Disable output sync pins */
173 venc_write(sd
, VENC_SYNCCTL
, 0);
176 venc_write(sd
, VENC_DCLKCTL
, 0);
177 venc_write(sd
, VENC_DRGBX1
, 0x0000057C);
179 /* Disable LCD output control (accepting default polarity) */
180 venc_write(sd
, VENC_LCDOUT
, 0);
181 if (venc
->venc_type
!= VPBE_VERSION_3
)
182 venc_write(sd
, VENC_CMPNT
, 0x100);
183 venc_write(sd
, VENC_HSPLS
, 0);
184 venc_write(sd
, VENC_HINT
, 0);
185 venc_write(sd
, VENC_HSTART
, 0);
186 venc_write(sd
, VENC_HVALID
, 0);
188 venc_write(sd
, VENC_VSPLS
, 0);
189 venc_write(sd
, VENC_VINT
, 0);
190 venc_write(sd
, VENC_VSTART
, 0);
191 venc_write(sd
, VENC_VVALID
, 0);
193 venc_write(sd
, VENC_HSDLY
, 0);
194 venc_write(sd
, VENC_VSDLY
, 0);
196 venc_write(sd
, VENC_YCCCTL
, 0);
197 venc_write(sd
, VENC_VSTARTA
, 0);
199 /* Set OSD clock and OSD Sync Adavance registers */
200 venc_write(sd
, VENC_OSDCLK0
, 1);
201 venc_write(sd
, VENC_OSDCLK1
, 2);
206 venc_enable_vpss_clock(int venc_type
,
207 enum vpbe_enc_timings_type type
,
210 if (venc_type
== VPBE_VERSION_1
)
213 if (venc_type
== VPBE_VERSION_2
&& (type
== VPBE_ENC_STD
|| (type
==
214 VPBE_ENC_DV_TIMINGS
&& pclock
<= 27000000))) {
215 vpss_enable_clock(VPSS_VENC_CLOCK_SEL
, 1);
216 vpss_enable_clock(VPSS_VPBE_CLOCK
, 1);
220 if (venc_type
== VPBE_VERSION_3
&& type
== VPBE_ENC_STD
)
221 vpss_enable_clock(VPSS_VENC_CLOCK_SEL
, 0);
224 #define VDAC_CONFIG_SD_V3 0x0E21A6B6
225 #define VDAC_CONFIG_SD_V2 0x081141CF
229 static int venc_set_ntsc(struct v4l2_subdev
*sd
)
232 struct venc_state
*venc
= to_state(sd
);
233 struct venc_platform_data
*pdata
= venc
->pdata
;
235 v4l2_dbg(debug
, 2, sd
, "venc_set_ntsc\n");
237 /* Setup clock at VPSS & VENC for SD */
238 vpss_enable_clock(VPSS_VENC_CLOCK_SEL
, 1);
239 if (pdata
->setup_clock(VPBE_ENC_STD
, V4L2_STD_525_60
) < 0)
242 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_STD
, V4L2_STD_525_60
);
243 venc_enabledigitaloutput(sd
, 0);
245 if (venc
->venc_type
== VPBE_VERSION_3
) {
246 venc_write(sd
, VENC_CLKCTL
, 0x01);
247 venc_write(sd
, VENC_VIDCTL
, 0);
248 val
= vdaccfg_write(sd
, VDAC_CONFIG_SD_V3
);
249 } else if (venc
->venc_type
== VPBE_VERSION_2
) {
250 venc_write(sd
, VENC_CLKCTL
, 0x01);
251 venc_write(sd
, VENC_VIDCTL
, 0);
252 vdaccfg_write(sd
, VDAC_CONFIG_SD_V2
);
254 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
255 venc_modify(sd
, VENC_VIDCTL
, 0, 1 << 1);
256 /* Set REC656 Mode */
257 venc_write(sd
, VENC_YCCCTL
, 0x1);
258 venc_modify(sd
, VENC_VDPRO
, 0, VENC_VDPRO_DAFRQ
);
259 venc_modify(sd
, VENC_VDPRO
, 0, VENC_VDPRO_DAUPS
);
262 venc_write(sd
, VENC_VMOD
, 0);
263 venc_modify(sd
, VENC_VMOD
, (1 << VENC_VMOD_VIE_SHIFT
),
265 venc_modify(sd
, VENC_VMOD
, (0 << VENC_VMOD_VMD
), VENC_VMOD_VMD
);
266 venc_modify(sd
, VENC_VMOD
, (0 << VENC_VMOD_TVTYP_SHIFT
),
268 venc_write(sd
, VENC_DACTST
, 0x0);
269 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
277 static int venc_set_pal(struct v4l2_subdev
*sd
)
279 struct venc_state
*venc
= to_state(sd
);
281 v4l2_dbg(debug
, 2, sd
, "venc_set_pal\n");
283 /* Setup clock at VPSS & VENC for SD */
284 vpss_enable_clock(VPSS_VENC_CLOCK_SEL
, 1);
285 if (venc
->pdata
->setup_clock(VPBE_ENC_STD
, V4L2_STD_625_50
) < 0)
288 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_STD
, V4L2_STD_625_50
);
289 venc_enabledigitaloutput(sd
, 0);
291 if (venc
->venc_type
== VPBE_VERSION_3
) {
292 venc_write(sd
, VENC_CLKCTL
, 0x1);
293 venc_write(sd
, VENC_VIDCTL
, 0);
294 vdaccfg_write(sd
, VDAC_CONFIG_SD_V3
);
295 } else if (venc
->venc_type
== VPBE_VERSION_2
) {
296 venc_write(sd
, VENC_CLKCTL
, 0x1);
297 venc_write(sd
, VENC_VIDCTL
, 0);
298 vdaccfg_write(sd
, VDAC_CONFIG_SD_V2
);
300 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
301 venc_modify(sd
, VENC_VIDCTL
, 0, 1 << 1);
302 /* Set REC656 Mode */
303 venc_write(sd
, VENC_YCCCTL
, 0x1);
306 venc_modify(sd
, VENC_SYNCCTL
, 1 << VENC_SYNCCTL_OVD_SHIFT
,
308 venc_write(sd
, VENC_VMOD
, 0);
309 venc_modify(sd
, VENC_VMOD
,
310 (1 << VENC_VMOD_VIE_SHIFT
),
312 venc_modify(sd
, VENC_VMOD
,
313 (0 << VENC_VMOD_VMD
), VENC_VMOD_VMD
);
314 venc_modify(sd
, VENC_VMOD
,
315 (1 << VENC_VMOD_TVTYP_SHIFT
),
317 venc_write(sd
, VENC_DACTST
, 0x0);
318 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
323 #define VDAC_CONFIG_HD_V2 0x081141EF
327 * This function configures the video encoder to EDTV(525p) component setting.
329 static int venc_set_480p59_94(struct v4l2_subdev
*sd
)
331 struct venc_state
*venc
= to_state(sd
);
332 struct venc_platform_data
*pdata
= venc
->pdata
;
334 v4l2_dbg(debug
, 2, sd
, "venc_set_480p59_94\n");
335 if (venc
->venc_type
!= VPBE_VERSION_1
&&
336 venc
->venc_type
!= VPBE_VERSION_2
)
339 /* Setup clock at VPSS & VENC for SD */
340 if (pdata
->setup_clock(VPBE_ENC_DV_TIMINGS
, 27000000) < 0)
343 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_DV_TIMINGS
, 27000000);
344 venc_enabledigitaloutput(sd
, 0);
346 if (venc
->venc_type
== VPBE_VERSION_2
)
347 vdaccfg_write(sd
, VDAC_CONFIG_HD_V2
);
348 venc_write(sd
, VENC_OSDCLK0
, 0);
349 venc_write(sd
, VENC_OSDCLK1
, 1);
351 if (venc
->venc_type
== VPBE_VERSION_1
) {
352 venc_modify(sd
, VENC_VDPRO
, VENC_VDPRO_DAFRQ
,
354 venc_modify(sd
, VENC_VDPRO
, VENC_VDPRO_DAUPS
,
358 venc_write(sd
, VENC_VMOD
, 0);
359 venc_modify(sd
, VENC_VMOD
, (1 << VENC_VMOD_VIE_SHIFT
),
361 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_HDMD
, VENC_VMOD_HDMD
);
362 venc_modify(sd
, VENC_VMOD
, (HDTV_525P
<< VENC_VMOD_TVTYP_SHIFT
),
364 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VDMD_YCBCR8
<<
365 VENC_VMOD_VDMD_SHIFT
, VENC_VMOD_VDMD
);
367 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
375 * This function configures the video encoder to HDTV(625p) component setting
377 static int venc_set_576p50(struct v4l2_subdev
*sd
)
379 struct venc_state
*venc
= to_state(sd
);
380 struct venc_platform_data
*pdata
= venc
->pdata
;
382 v4l2_dbg(debug
, 2, sd
, "venc_set_576p50\n");
384 if (venc
->venc_type
!= VPBE_VERSION_1
&&
385 venc
->venc_type
!= VPBE_VERSION_2
)
387 /* Setup clock at VPSS & VENC for SD */
388 if (pdata
->setup_clock(VPBE_ENC_DV_TIMINGS
, 27000000) < 0)
391 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_DV_TIMINGS
, 27000000);
392 venc_enabledigitaloutput(sd
, 0);
394 if (venc
->venc_type
== VPBE_VERSION_2
)
395 vdaccfg_write(sd
, VDAC_CONFIG_HD_V2
);
397 venc_write(sd
, VENC_OSDCLK0
, 0);
398 venc_write(sd
, VENC_OSDCLK1
, 1);
400 if (venc
->venc_type
== VPBE_VERSION_1
) {
401 venc_modify(sd
, VENC_VDPRO
, VENC_VDPRO_DAFRQ
,
403 venc_modify(sd
, VENC_VDPRO
, VENC_VDPRO_DAUPS
,
407 venc_write(sd
, VENC_VMOD
, 0);
408 venc_modify(sd
, VENC_VMOD
, (1 << VENC_VMOD_VIE_SHIFT
),
410 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_HDMD
, VENC_VMOD_HDMD
);
411 venc_modify(sd
, VENC_VMOD
, (HDTV_625P
<< VENC_VMOD_TVTYP_SHIFT
),
414 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VDMD_YCBCR8
<<
415 VENC_VMOD_VDMD_SHIFT
, VENC_VMOD_VDMD
);
416 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
422 * venc_set_720p60_internal - Setup 720p60 in venc for dm365 only
424 static int venc_set_720p60_internal(struct v4l2_subdev
*sd
)
426 struct venc_state
*venc
= to_state(sd
);
427 struct venc_platform_data
*pdata
= venc
->pdata
;
429 if (pdata
->setup_clock(VPBE_ENC_DV_TIMINGS
, 74250000) < 0)
432 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_DV_TIMINGS
, 74250000);
433 venc_enabledigitaloutput(sd
, 0);
435 venc_write(sd
, VENC_OSDCLK0
, 0);
436 venc_write(sd
, VENC_OSDCLK1
, 1);
438 venc_write(sd
, VENC_VMOD
, 0);
439 /* DM365 component HD mode */
440 venc_modify(sd
, VENC_VMOD
, (1 << VENC_VMOD_VIE_SHIFT
),
442 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_HDMD
, VENC_VMOD_HDMD
);
443 venc_modify(sd
, VENC_VMOD
, (HDTV_720P
<< VENC_VMOD_TVTYP_SHIFT
),
445 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
446 venc_write(sd
, VENC_XHINTVL
, 0);
451 * venc_set_1080i30_internal - Setup 1080i30 in venc for dm365 only
453 static int venc_set_1080i30_internal(struct v4l2_subdev
*sd
)
455 struct venc_state
*venc
= to_state(sd
);
456 struct venc_platform_data
*pdata
= venc
->pdata
;
458 if (pdata
->setup_clock(VPBE_ENC_DV_TIMINGS
, 74250000) < 0)
461 venc_enable_vpss_clock(venc
->venc_type
, VPBE_ENC_DV_TIMINGS
, 74250000);
462 venc_enabledigitaloutput(sd
, 0);
464 venc_write(sd
, VENC_OSDCLK0
, 0);
465 venc_write(sd
, VENC_OSDCLK1
, 1);
468 venc_write(sd
, VENC_VMOD
, 0);
469 /* DM365 component HD mode */
470 venc_modify(sd
, VENC_VMOD
, (1 << VENC_VMOD_VIE_SHIFT
),
472 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_HDMD
, VENC_VMOD_HDMD
);
473 venc_modify(sd
, VENC_VMOD
, (HDTV_1080I
<< VENC_VMOD_TVTYP_SHIFT
),
475 venc_modify(sd
, VENC_VMOD
, VENC_VMOD_VENC
, VENC_VMOD_VENC
);
476 venc_write(sd
, VENC_XHINTVL
, 0);
480 static int venc_s_std_output(struct v4l2_subdev
*sd
, v4l2_std_id norm
)
482 v4l2_dbg(debug
, 1, sd
, "venc_s_std_output\n");
484 if (norm
& V4L2_STD_525_60
)
485 return venc_set_ntsc(sd
);
486 else if (norm
& V4L2_STD_625_50
)
487 return venc_set_pal(sd
);
492 static int venc_s_dv_timings(struct v4l2_subdev
*sd
,
493 struct v4l2_dv_timings
*dv_timings
)
495 struct venc_state
*venc
= to_state(sd
);
496 u32 height
= dv_timings
->bt
.height
;
499 v4l2_dbg(debug
, 1, sd
, "venc_s_dv_timings\n");
502 return venc_set_576p50(sd
);
503 else if (height
== 480)
504 return venc_set_480p59_94(sd
);
505 else if ((height
== 720) &&
506 (venc
->venc_type
== VPBE_VERSION_2
)) {
507 /* TBD setup internal 720p mode here */
508 ret
= venc_set_720p60_internal(sd
);
509 /* for DM365 VPBE, there is DAC inside */
510 vdaccfg_write(sd
, VDAC_CONFIG_HD_V2
);
512 } else if ((height
== 1080) &&
513 (venc
->venc_type
== VPBE_VERSION_2
)) {
514 /* TBD setup internal 1080i mode here */
515 ret
= venc_set_1080i30_internal(sd
);
516 /* for DM365 VPBE, there is DAC inside */
517 vdaccfg_write(sd
, VDAC_CONFIG_HD_V2
);
523 static int venc_s_routing(struct v4l2_subdev
*sd
, u32 input
, u32 output
,
526 struct venc_state
*venc
= to_state(sd
);
529 v4l2_dbg(debug
, 1, sd
, "venc_s_routing\n");
531 ret
= venc_set_dac(sd
, output
);
533 venc
->output
= output
;
538 static long venc_ioctl(struct v4l2_subdev
*sd
,
546 val
= venc_read(sd
, VENC_VSTAT
);
547 *((int *)arg
) = ((val
& VENC_VSTAT_FIDST
) ==
551 v4l2_err(sd
, "Wrong IOCTL cmd\n");
558 static const struct v4l2_subdev_core_ops venc_core_ops
= {
562 static const struct v4l2_subdev_video_ops venc_video_ops
= {
563 .s_routing
= venc_s_routing
,
564 .s_std_output
= venc_s_std_output
,
565 .s_dv_timings
= venc_s_dv_timings
,
568 static const struct v4l2_subdev_ops venc_ops
= {
569 .core
= &venc_core_ops
,
570 .video
= &venc_video_ops
,
573 static int venc_initialize(struct v4l2_subdev
*sd
)
575 struct venc_state
*venc
= to_state(sd
);
578 /* Set default to output to composite and std to NTSC */
580 venc
->std
= V4L2_STD_525_60
;
582 ret
= venc_s_routing(sd
, 0, venc
->output
, 0);
584 v4l2_err(sd
, "Error setting output during init\n");
588 ret
= venc_s_std_output(sd
, venc
->std
);
590 v4l2_err(sd
, "Error setting std during init\n");
597 static int venc_device_get(struct device
*dev
, void *data
)
599 struct platform_device
*pdev
= to_platform_device(dev
);
600 struct venc_state
**venc
= data
;
602 if (strstr(pdev
->name
, "vpbe-venc") != NULL
)
603 *venc
= platform_get_drvdata(pdev
);
608 struct v4l2_subdev
*venc_sub_dev_init(struct v4l2_device
*v4l2_dev
,
609 const char *venc_name
)
611 struct venc_state
*venc
;
614 err
= bus_for_each_dev(&platform_bus_type
, NULL
, &venc
,
619 v4l2_subdev_init(&venc
->sd
, &venc_ops
);
621 strcpy(venc
->sd
.name
, venc_name
);
622 if (v4l2_device_register_subdev(v4l2_dev
, &venc
->sd
) < 0) {
624 "vpbe unable to register venc sub device\n");
627 if (venc_initialize(&venc
->sd
)) {
629 "vpbe venc initialization failed\n");
635 EXPORT_SYMBOL(venc_sub_dev_init
);
637 static int venc_probe(struct platform_device
*pdev
)
639 const struct platform_device_id
*pdev_id
;
640 struct venc_state
*venc
;
641 struct resource
*res
;
644 venc
= kzalloc(sizeof(struct venc_state
), GFP_KERNEL
);
648 pdev_id
= platform_get_device_id(pdev
);
653 venc
->venc_type
= pdev_id
->driver_data
;
654 venc
->pdev
= &pdev
->dev
;
655 venc
->pdata
= pdev
->dev
.platform_data
;
656 if (NULL
== venc
->pdata
) {
657 dev_err(venc
->pdev
, "Unable to get platform data for"
662 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
665 "Unable to get VENC register address map\n");
670 if (!request_mem_region(res
->start
, resource_size(res
), "venc")) {
671 dev_err(venc
->pdev
, "Unable to reserve VENC MMIO region\n");
676 venc
->venc_base
= ioremap_nocache(res
->start
, resource_size(res
));
677 if (!venc
->venc_base
) {
678 dev_err(venc
->pdev
, "Unable to map VENC IO space\n");
680 goto release_venc_mem_region
;
683 if (venc
->venc_type
!= VPBE_VERSION_1
) {
684 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
687 "Unable to get VDAC_CONFIG address map\n");
692 if (!request_mem_region(res
->start
,
693 resource_size(res
), "venc")) {
695 "Unable to reserve VDAC_CONFIG MMIO region\n");
700 venc
->vdaccfg_reg
= ioremap_nocache(res
->start
,
702 if (!venc
->vdaccfg_reg
) {
704 "Unable to map VDAC_CONFIG IO space\n");
706 goto release_vdaccfg_mem_region
;
709 spin_lock_init(&venc
->lock
);
710 platform_set_drvdata(pdev
, venc
);
711 dev_notice(venc
->pdev
, "VENC sub device probe success\n");
714 release_vdaccfg_mem_region
:
715 release_mem_region(res
->start
, resource_size(res
));
717 iounmap(venc
->venc_base
);
718 release_venc_mem_region
:
719 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
720 release_mem_region(res
->start
, resource_size(res
));
726 static int venc_remove(struct platform_device
*pdev
)
728 struct venc_state
*venc
= platform_get_drvdata(pdev
);
729 struct resource
*res
;
731 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
732 iounmap((void *)venc
->venc_base
);
733 release_mem_region(res
->start
, resource_size(res
));
734 if (venc
->venc_type
!= VPBE_VERSION_1
) {
735 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
736 iounmap((void *)venc
->vdaccfg_reg
);
737 release_mem_region(res
->start
, resource_size(res
));
744 static struct platform_driver venc_driver
= {
746 .remove
= venc_remove
,
749 .owner
= THIS_MODULE
,
751 .id_table
= vpbe_venc_devtype
754 module_platform_driver(venc_driver
);
756 MODULE_LICENSE("GPL");
757 MODULE_DESCRIPTION("VPBE VENC Driver");
758 MODULE_AUTHOR("Texas Instruments");