aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/pci/b2c2/flexcop-dma.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/drivers/media/pci/b2c2/flexcop-dma.c b/drivers/media/pci/b2c2/flexcop-dma.c
index f07610a1646d..ba45b378d739 100644
--- a/drivers/media/pci/b2c2/flexcop-dma.c
+++ b/drivers/media/pci/b2c2/flexcop-dma.c
@@ -17,7 +17,8 @@ int flexcop_dma_allocate(struct pci_dev *pdev,
17 return -EINVAL; 17 return -EINVAL;
18 } 18 }
19 19
20 if ((tcpu = pci_alloc_consistent(pdev, size, &tdma)) != NULL) { 20 tcpu = pci_alloc_consistent(pdev, size, &tdma);
21 if (tcpu != NULL) {
21 dma->pdev = pdev; 22 dma->pdev = pdev;
22 dma->cpu_addr0 = tcpu; 23 dma->cpu_addr0 = tcpu;
23 dma->dma_addr0 = tdma; 24 dma->dma_addr0 = tdma;
@@ -34,7 +35,7 @@ void flexcop_dma_free(struct flexcop_dma *dma)
34{ 35{
35 pci_free_consistent(dma->pdev, dma->size*2, 36 pci_free_consistent(dma->pdev, dma->size*2,
36 dma->cpu_addr0, dma->dma_addr0); 37 dma->cpu_addr0, dma->dma_addr0);
37 memset(dma,0,sizeof(struct flexcop_dma)); 38 memset(dma, 0, sizeof(struct flexcop_dma));
38} 39}
39EXPORT_SYMBOL(flexcop_dma_free); 40EXPORT_SYMBOL(flexcop_dma_free);
40 41
@@ -42,23 +43,24 @@ int flexcop_dma_config(struct flexcop_device *fc,
42 struct flexcop_dma *dma, 43 struct flexcop_dma *dma,
43 flexcop_dma_index_t dma_idx) 44 flexcop_dma_index_t dma_idx)
44{ 45{
45 flexcop_ibi_value v0x0,v0x4,v0xc; 46 flexcop_ibi_value v0x0, v0x4, v0xc;
46 v0x0.raw = v0x4.raw = v0xc.raw = 0;
47 47
48 v0x0.raw = v0x4.raw = v0xc.raw = 0;
48 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2; 49 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
49 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2; 50 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
50 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4; 51 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
51 52
52 if ((dma_idx & FC_DMA_1) == dma_idx) { 53 if ((dma_idx & FC_DMA_1) == dma_idx) {
53 fc->write_ibi_reg(fc,dma1_000,v0x0); 54 fc->write_ibi_reg(fc, dma1_000, v0x0);
54 fc->write_ibi_reg(fc,dma1_004,v0x4); 55 fc->write_ibi_reg(fc, dma1_004, v0x4);
55 fc->write_ibi_reg(fc,dma1_00c,v0xc); 56 fc->write_ibi_reg(fc, dma1_00c, v0xc);
56 } else if ((dma_idx & FC_DMA_2) == dma_idx) { 57 } else if ((dma_idx & FC_DMA_2) == dma_idx) {
57 fc->write_ibi_reg(fc,dma2_010,v0x0); 58 fc->write_ibi_reg(fc, dma2_010, v0x0);
58 fc->write_ibi_reg(fc,dma2_014,v0x4); 59 fc->write_ibi_reg(fc, dma2_014, v0x4);
59 fc->write_ibi_reg(fc,dma2_01c,v0xc); 60 fc->write_ibi_reg(fc, dma2_01c, v0xc);
60 } else { 61 } else {
61 err("either DMA1 or DMA2 can be configured within one flexcop_dma_config call."); 62 err("either DMA1 or DMA2 can be configured within one %s call.",
63 __func__);
62 return -EINVAL; 64 return -EINVAL;
63 } 65 }
64 66
@@ -72,8 +74,8 @@ int flexcop_dma_xfer_control(struct flexcop_device *fc,
72 flexcop_dma_addr_index_t index, 74 flexcop_dma_addr_index_t index,
73 int onoff) 75 int onoff)
74{ 76{
75 flexcop_ibi_value v0x0,v0xc; 77 flexcop_ibi_value v0x0, v0xc;
76 flexcop_ibi_register r0x0,r0xc; 78 flexcop_ibi_register r0x0, r0xc;
77 79
78 if ((dma_idx & FC_DMA_1) == dma_idx) { 80 if ((dma_idx & FC_DMA_1) == dma_idx) {
79 r0x0 = dma1_000; 81 r0x0 = dma1_000;
@@ -82,15 +84,16 @@ int flexcop_dma_xfer_control(struct flexcop_device *fc,
82 r0x0 = dma2_010; 84 r0x0 = dma2_010;
83 r0xc = dma2_01c; 85 r0xc = dma2_01c;
84 } else { 86 } else {
85 err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call."); 87 err("transfer DMA1 or DMA2 can be started within one %s call.",
88 __func__);
86 return -EINVAL; 89 return -EINVAL;
87 } 90 }
88 91
89 v0x0 = fc->read_ibi_reg(fc,r0x0); 92 v0x0 = fc->read_ibi_reg(fc, r0x0);
90 v0xc = fc->read_ibi_reg(fc,r0xc); 93 v0xc = fc->read_ibi_reg(fc, r0xc);
91 94
92 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw); 95 deb_rdump("reg: %03x: %x\n", r0x0, v0x0.raw);
93 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw); 96 deb_rdump("reg: %03x: %x\n", r0xc, v0xc.raw);
94 97
95 if (index & FC_DMA_SUBADDR_0) 98 if (index & FC_DMA_SUBADDR_0)
96 v0x0.dma_0x0.dma_0start = onoff; 99 v0x0.dma_0x0.dma_0start = onoff;
@@ -98,11 +101,11 @@ int flexcop_dma_xfer_control(struct flexcop_device *fc,
98 if (index & FC_DMA_SUBADDR_1) 101 if (index & FC_DMA_SUBADDR_1)
99 v0xc.dma_0xc.dma_1start = onoff; 102 v0xc.dma_0xc.dma_1start = onoff;
100 103
101 fc->write_ibi_reg(fc,r0x0,v0x0); 104 fc->write_ibi_reg(fc, r0x0, v0x0);
102 fc->write_ibi_reg(fc,r0xc,v0xc); 105 fc->write_ibi_reg(fc, r0xc, v0xc);
103 106
104 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw); 107 deb_rdump("reg: %03x: %x\n", r0x0, v0x0.raw);
105 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw); 108 deb_rdump("reg: %03x: %x\n", r0xc, v0xc.raw);
106 return 0; 109 return 0;
107} 110}
108EXPORT_SYMBOL(flexcop_dma_xfer_control); 111EXPORT_SYMBOL(flexcop_dma_xfer_control);
@@ -112,10 +115,11 @@ static int flexcop_dma_remap(struct flexcop_device *fc,
112 int onoff) 115 int onoff)
113{ 116{
114 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c; 117 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
115 flexcop_ibi_value v = fc->read_ibi_reg(fc,r); 118 flexcop_ibi_value v = fc->read_ibi_reg(fc, r);
116 deb_info("%s\n",__func__); 119
120 deb_info("%s\n", __func__);
117 v.dma_0xc.remap_enable = onoff; 121 v.dma_0xc.remap_enable = onoff;
118 fc->write_ibi_reg(fc,r,v); 122 fc->write_ibi_reg(fc, r, v);
119 return 0; 123 return 0;
120} 124}
121 125
@@ -123,7 +127,7 @@ int flexcop_dma_control_size_irq(struct flexcop_device *fc,
123 flexcop_dma_index_t no, 127 flexcop_dma_index_t no,
124 int onoff) 128 int onoff)
125{ 129{
126 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 130 flexcop_ibi_value v = fc->read_ibi_reg(fc, ctrl_208);
127 131
128 if (no & FC_DMA_1) 132 if (no & FC_DMA_1)
129 v.ctrl_208.DMA1_IRQ_Enable_sig = onoff; 133 v.ctrl_208.DMA1_IRQ_Enable_sig = onoff;
@@ -131,7 +135,7 @@ int flexcop_dma_control_size_irq(struct flexcop_device *fc,
131 if (no & FC_DMA_2) 135 if (no & FC_DMA_2)
132 v.ctrl_208.DMA2_IRQ_Enable_sig = onoff; 136 v.ctrl_208.DMA2_IRQ_Enable_sig = onoff;
133 137
134 fc->write_ibi_reg(fc,ctrl_208,v); 138 fc->write_ibi_reg(fc, ctrl_208, v);
135 return 0; 139 return 0;
136} 140}
137EXPORT_SYMBOL(flexcop_dma_control_size_irq); 141EXPORT_SYMBOL(flexcop_dma_control_size_irq);
@@ -140,7 +144,7 @@ int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
140 flexcop_dma_index_t no, 144 flexcop_dma_index_t no,
141 int onoff) 145 int onoff)
142{ 146{
143 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 147 flexcop_ibi_value v = fc->read_ibi_reg(fc, ctrl_208);
144 148
145 if (no & FC_DMA_1) 149 if (no & FC_DMA_1)
146 v.ctrl_208.DMA1_Timer_Enable_sig = onoff; 150 v.ctrl_208.DMA1_Timer_Enable_sig = onoff;
@@ -148,7 +152,7 @@ int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
148 if (no & FC_DMA_2) 152 if (no & FC_DMA_2)
149 v.ctrl_208.DMA2_Timer_Enable_sig = onoff; 153 v.ctrl_208.DMA2_Timer_Enable_sig = onoff;
150 154
151 fc->write_ibi_reg(fc,ctrl_208,v); 155 fc->write_ibi_reg(fc, ctrl_208, v);
152 return 0; 156 return 0;
153} 157}
154EXPORT_SYMBOL(flexcop_dma_control_timer_irq); 158EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
@@ -158,13 +162,13 @@ int flexcop_dma_config_timer(struct flexcop_device *fc,
158 flexcop_dma_index_t dma_idx, u8 cycles) 162 flexcop_dma_index_t dma_idx, u8 cycles)
159{ 163{
160 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 164 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
161 flexcop_ibi_value v = fc->read_ibi_reg(fc,r); 165 flexcop_ibi_value v = fc->read_ibi_reg(fc, r);
162 166
163 flexcop_dma_remap(fc,dma_idx,0); 167 flexcop_dma_remap(fc, dma_idx, 0);
164 168
165 deb_info("%s\n",__func__); 169 deb_info("%s\n", __func__);
166 v.dma_0x4_write.dmatimer = cycles; 170 v.dma_0x4_write.dmatimer = cycles;
167 fc->write_ibi_reg(fc,r,v); 171 fc->write_ibi_reg(fc, r, v);
168 return 0; 172 return 0;
169} 173}
170EXPORT_SYMBOL(flexcop_dma_config_timer); 174EXPORT_SYMBOL(flexcop_dma_config_timer);