aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx18/cx18-io.c')
-rw-r--r--drivers/media/video/cx18/cx18-io.c115
1 files changed, 54 insertions, 61 deletions
diff --git a/drivers/media/video/cx18/cx18-io.c b/drivers/media/video/cx18/cx18-io.c
index c53d9b6e5e46..d92f627d35e4 100644
--- a/drivers/media/video/cx18/cx18-io.c
+++ b/drivers/media/video/cx18/cx18-io.c
@@ -21,76 +21,69 @@
21 */ 21 */
22 22
23#include "cx18-driver.h" 23#include "cx18-driver.h"
24#include "cx18-io.h"
24#include "cx18-irq.h" 25#include "cx18-irq.h"
25 26
26void cx18_raw_writel(struct cx18 *cx, u32 val, void __iomem *addr)
27{
28 __raw_writel(val, addr);
29}
30
31u32 cx18_raw_readl(struct cx18 *cx, const void __iomem *addr)
32{
33 return __raw_readl(addr);
34}
35
36u32 cx18_write_sync(struct cx18 *cx, u32 val, void __iomem *addr)
37{
38 writel(val, addr);
39 return readl(addr);
40}
41
42void cx18_writel(struct cx18 *cx, u32 val, void __iomem *addr)
43{
44 writel(val, addr);
45}
46
47u32 cx18_readl(struct cx18 *cx, const void __iomem *addr)
48{
49 return readl(addr);
50}
51
52
53/* Access "register" region of CX23418 memory mapped I/O */
54u32 cx18_read_reg(struct cx18 *cx, u32 reg)
55{
56 return readl(cx->reg_mem + reg);
57}
58
59void cx18_write_reg(struct cx18 *cx, u32 val, u32 reg)
60{
61 writel(val, cx->reg_mem + reg);
62}
63
64u32 cx18_write_reg_sync(struct cx18 *cx, u32 val, u32 reg)
65{
66 return cx18_write_sync(cx, val, cx->reg_mem + reg);
67}
68
69/* Access "encoder memory" region of CX23418 memory mapped I/O */
70u32 cx18_read_enc(struct cx18 *cx, u32 addr)
71{
72 return readl(cx->enc_mem + addr);
73}
74
75void cx18_write_enc(struct cx18 *cx, u32 val, u32 addr)
76{
77 writel(val, cx->enc_mem + addr);
78}
79
80u32 cx18_write_enc_sync(struct cx18 *cx, u32 val, u32 addr)
81{
82 return cx18_write_sync(cx, val, cx->enc_mem + addr);
83}
84
85void cx18_memcpy_fromio(struct cx18 *cx, void *to, 27void cx18_memcpy_fromio(struct cx18 *cx, void *to,
86 const void __iomem *from, unsigned int len) 28 const void __iomem *from, unsigned int len)
87{ 29{
88 memcpy_fromio(to, from, len); 30 /* Align reads on the CX23418's addresses */
31 if ((len > 0) && ((unsigned)from & 1)) {
32 *((u8 *)to) = cx18_readb(cx, from);
33 len--;
34 to++;
35 from++;
36 }
37 if ((len > 1) && ((unsigned)from & 2)) {
38 *((u16 *)to) = cx18_raw_readw(cx, from);
39 len -= 2;
40 to += 2;
41 from += 2;
42 }
43 while (len > 3) {
44 *((u32 *)to) = cx18_raw_readl(cx, from);
45 len -= 4;
46 to += 4;
47 from += 4;
48 }
49 if (len > 1) {
50 *((u16 *)to) = cx18_raw_readw(cx, from);
51 len -= 2;
52 to += 2;
53 from += 2;
54 }
55 if (len > 0)
56 *((u8 *)to) = cx18_readb(cx, from);
89} 57}
90 58
91void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count) 59void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
92{ 60{
93 memset_io(addr, val, count); 61 u16 val2 = val | (val << 8);
62 u32 val4 = val2 | (val2 << 16);
63
64 /* Align writes on the CX23418's addresses */
65 if ((count > 0) && ((unsigned)addr & 1)) {
66 cx18_writeb(cx, (u8) val, addr);
67 count--;
68 addr++;
69 }
70 if ((count > 1) && ((unsigned)addr & 2)) {
71 cx18_writew(cx, val2, addr);
72 count -= 2;
73 addr += 2;
74 }
75 while (count > 3) {
76 cx18_writel(cx, val4, addr);
77 count -= 4;
78 addr += 4;
79 }
80 if (count > 1) {
81 cx18_writew(cx, val2, addr);
82 count -= 2;
83 addr += 2;
84 }
85 if (count > 0)
86 cx18_writeb(cx, (u8) val, addr);
94} 87}
95 88
96void cx18_sw1_irq_enable(struct cx18 *cx, u32 val) 89void cx18_sw1_irq_enable(struct cx18 *cx, u32 val)