diff options
Diffstat (limited to 'drivers/media/video/davinci/vpif.c')
-rw-r--r-- | drivers/media/video/davinci/vpif.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/drivers/media/video/davinci/vpif.c b/drivers/media/video/davinci/vpif.c index aa771268a5a5..3b8eac31ecae 100644 --- a/drivers/media/video/davinci/vpif.c +++ b/drivers/media/video/davinci/vpif.c | |||
@@ -19,7 +19,11 @@ | |||
19 | 19 | ||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/spinlock.h> | ||
22 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/io.h> | ||
26 | #include <mach/hardware.h> | ||
23 | 27 | ||
24 | #include "vpif.h" | 28 | #include "vpif.h" |
25 | 29 | ||
@@ -31,6 +35,12 @@ MODULE_LICENSE("GPL"); | |||
31 | #define VPIF_CH2_MAX_MODES (15) | 35 | #define VPIF_CH2_MAX_MODES (15) |
32 | #define VPIF_CH3_MAX_MODES (02) | 36 | #define VPIF_CH3_MAX_MODES (02) |
33 | 37 | ||
38 | static resource_size_t res_len; | ||
39 | static struct resource *res; | ||
40 | spinlock_t vpif_lock; | ||
41 | |||
42 | void __iomem *vpif_base; | ||
43 | |||
34 | static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val) | 44 | static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val) |
35 | { | 45 | { |
36 | if (val) | 46 | if (val) |
@@ -151,17 +161,17 @@ static void config_vpif_params(struct vpif_params *vpifparams, | |||
151 | else if (config->capture_format) { | 161 | else if (config->capture_format) { |
152 | /* Set the polarity of various pins */ | 162 | /* Set the polarity of various pins */ |
153 | vpif_wr_bit(reg, VPIF_CH_FID_POLARITY_BIT, | 163 | vpif_wr_bit(reg, VPIF_CH_FID_POLARITY_BIT, |
154 | vpifparams->params.raw_params.fid_pol); | 164 | vpifparams->iface.fid_pol); |
155 | vpif_wr_bit(reg, VPIF_CH_V_VALID_POLARITY_BIT, | 165 | vpif_wr_bit(reg, VPIF_CH_V_VALID_POLARITY_BIT, |
156 | vpifparams->params.raw_params.vd_pol); | 166 | vpifparams->iface.vd_pol); |
157 | vpif_wr_bit(reg, VPIF_CH_H_VALID_POLARITY_BIT, | 167 | vpif_wr_bit(reg, VPIF_CH_H_VALID_POLARITY_BIT, |
158 | vpifparams->params.raw_params.hd_pol); | 168 | vpifparams->iface.hd_pol); |
159 | 169 | ||
160 | value = regr(reg); | 170 | value = regr(reg); |
161 | /* Set data width */ | 171 | /* Set data width */ |
162 | value &= ((~(unsigned int)(0x3)) << | 172 | value &= ((~(unsigned int)(0x3)) << |
163 | VPIF_CH_DATA_WIDTH_BIT); | 173 | VPIF_CH_DATA_WIDTH_BIT); |
164 | value |= ((vpifparams->params.raw_params.data_sz) << | 174 | value |= ((vpifparams->params.data_sz) << |
165 | VPIF_CH_DATA_WIDTH_BIT); | 175 | VPIF_CH_DATA_WIDTH_BIT); |
166 | regw(value, reg); | 176 | regw(value, reg); |
167 | } | 177 | } |
@@ -227,8 +237,60 @@ int vpif_channel_getfid(u8 channel_id) | |||
227 | } | 237 | } |
228 | EXPORT_SYMBOL(vpif_channel_getfid); | 238 | EXPORT_SYMBOL(vpif_channel_getfid); |
229 | 239 | ||
230 | void vpif_base_addr_init(void __iomem *base) | 240 | static int __init vpif_probe(struct platform_device *pdev) |
241 | { | ||
242 | int status = 0; | ||
243 | |||
244 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
245 | if (!res) | ||
246 | return -ENOENT; | ||
247 | |||
248 | res_len = res->end - res->start + 1; | ||
249 | |||
250 | res = request_mem_region(res->start, res_len, res->name); | ||
251 | if (!res) | ||
252 | return -EBUSY; | ||
253 | |||
254 | vpif_base = ioremap(res->start, res_len); | ||
255 | if (!vpif_base) { | ||
256 | status = -EBUSY; | ||
257 | goto fail; | ||
258 | } | ||
259 | |||
260 | spin_lock_init(&vpif_lock); | ||
261 | dev_info(&pdev->dev, "vpif probe success\n"); | ||
262 | return 0; | ||
263 | |||
264 | fail: | ||
265 | release_mem_region(res->start, res_len); | ||
266 | return status; | ||
267 | } | ||
268 | |||
269 | static int vpif_remove(struct platform_device *pdev) | ||
231 | { | 270 | { |
232 | vpif_base = base; | 271 | iounmap(vpif_base); |
272 | release_mem_region(res->start, res_len); | ||
273 | return 0; | ||
233 | } | 274 | } |
234 | EXPORT_SYMBOL(vpif_base_addr_init); | 275 | |
276 | static struct platform_driver vpif_driver = { | ||
277 | .driver = { | ||
278 | .name = "vpif", | ||
279 | .owner = THIS_MODULE, | ||
280 | }, | ||
281 | .remove = __devexit_p(vpif_remove), | ||
282 | .probe = vpif_probe, | ||
283 | }; | ||
284 | |||
285 | static void vpif_exit(void) | ||
286 | { | ||
287 | platform_driver_unregister(&vpif_driver); | ||
288 | } | ||
289 | |||
290 | static int __init vpif_init(void) | ||
291 | { | ||
292 | return platform_driver_register(&vpif_driver); | ||
293 | } | ||
294 | subsys_initcall(vpif_init); | ||
295 | module_exit(vpif_exit); | ||
296 | |||