diff options
author | Manu Abraham <abraham.manu@gmail.com> | 2009-12-04 03:09:47 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-01-17 08:55:34 -0500 |
commit | d8b14f8a76d71c84622a211f57baf15f61cc9703 (patch) | |
tree | 7af98c74163d9cb078a96cd25859cc1a0d805e1c | |
parent | 12855cac87218d0c92ffdebb7270cec040cf5a6a (diff) |
V4L/DVB (13741): [Mantis] Implement HIF Mem Read/Write operations
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/mantis/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_dma.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_evm.c | 3 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_hif.c | 139 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_link.h | 10 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_reg.h | 8 |
6 files changed, 157 insertions, 8 deletions
diff --git a/drivers/media/dvb/mantis/Makefile b/drivers/media/dvb/mantis/Makefile index c4da0d8ed186..d002ef9f7449 100644 --- a/drivers/media/dvb/mantis/Makefile +++ b/drivers/media/dvb/mantis/Makefile | |||
@@ -4,6 +4,7 @@ mantis-objs = mantis_core.o \ | |||
4 | mantis_i2c.o \ | 4 | mantis_i2c.o \ |
5 | mantis_dvb.o \ | 5 | mantis_dvb.o \ |
6 | mantis_evm.o \ | 6 | mantis_evm.o \ |
7 | mantis_hif.o \ | ||
7 | mantis_ca.o \ | 8 | mantis_ca.o \ |
8 | mantis_pcmcia.o \ | 9 | mantis_pcmcia.o \ |
9 | mantis_vp1033.o \ | 10 | mantis_vp1033.o \ |
diff --git a/drivers/media/dvb/mantis/mantis_dma.c b/drivers/media/dvb/mantis/mantis_dma.c index f685992f7d0a..250f49a913aa 100644 --- a/drivers/media/dvb/mantis/mantis_dma.c +++ b/drivers/media/dvb/mantis/mantis_dma.c | |||
@@ -190,7 +190,7 @@ void mantis_dma_start(struct mantis_pci *mantis) | |||
190 | 190 | ||
191 | mantis_risc_program(mantis); | 191 | mantis_risc_program(mantis); |
192 | mmwrite(mantis->risc_dma, MANTIS_RISC_START); | 192 | mmwrite(mantis->risc_dma, MANTIS_RISC_START); |
193 | mmwrite(mmread(MANTIS_GPIF_ADDR) | MANTIS_GPIF_RDWRN, MANTIS_GPIF_ADDR); | 193 | mmwrite(mmread(MANTIS_GPIF_HIFADDR) | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_HIFADDR); |
194 | 194 | ||
195 | mmwrite(0, MANTIS_DMA_CTL); | 195 | mmwrite(0, MANTIS_DMA_CTL); |
196 | mantis->last_block = mantis->finished_block = 0; | 196 | mantis->last_block = mantis->finished_block = 0; |
@@ -210,7 +210,7 @@ void mantis_dma_stop(struct mantis_pci *mantis) | |||
210 | mask = mmread(MANTIS_INT_MASK); | 210 | mask = mmread(MANTIS_INT_MASK); |
211 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Stop DMA engine"); | 211 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Stop DMA engine"); |
212 | 212 | ||
213 | mmwrite((mmread(MANTIS_GPIF_ADDR) & (~(MANTIS_GPIF_RDWRN))), MANTIS_GPIF_ADDR); | 213 | mmwrite((mmread(MANTIS_GPIF_HIFADDR) & (~(MANTIS_GPIF_HIFRDWRN))), MANTIS_GPIF_HIFADDR); |
214 | 214 | ||
215 | mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN | | 215 | mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN | |
216 | MANTIS_DCAP_EN | | 216 | MANTIS_DCAP_EN | |
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c index 745148399981..dbcdca3a8f03 100644 --- a/drivers/media/dvb/mantis/mantis_evm.c +++ b/drivers/media/dvb/mantis/mantis_evm.c | |||
@@ -92,7 +92,7 @@ int mantis_evmgr_init(struct mantis_ca *ca) | |||
92 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); | 92 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); |
93 | mantis_pcmcia_init(ca); | 93 | mantis_pcmcia_init(ca); |
94 | schedule_work(&ca->hif_evm_work); | 94 | schedule_work(&ca->hif_evm_work); |
95 | 95 | mantis_hif_init(ca); | |
96 | return 0; | 96 | return 0; |
97 | } | 97 | } |
98 | 98 | ||
@@ -102,5 +102,6 @@ void mantis_evmgr_exit(struct mantis_ca *ca) | |||
102 | 102 | ||
103 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); | 103 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); |
104 | flush_scheduled_work(); | 104 | flush_scheduled_work(); |
105 | mantis_hif_exit(ca); | ||
105 | mantis_pcmcia_exit(ca); | 106 | mantis_pcmcia_exit(ca); |
106 | } | 107 | } |
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c new file mode 100644 index 000000000000..1472008e257e --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_hif.c | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | Mantis PCI bridge driver | ||
3 | |||
4 | Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com) | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #include "mantis_common.h" | ||
22 | #include "mantis_hif.h" | ||
23 | #include "mantis_link.h" /* temporary due to physical layer stuff */ | ||
24 | |||
25 | static int mantis_hif_data_available(struct mantis_ca *ca) | ||
26 | { | ||
27 | struct mantis_pci *mantis = ca->ca_priv; | ||
28 | int rc = 0; | ||
29 | |||
30 | if (wait_event_interruptible_timeout(ca->hif_data_wq, | ||
31 | ca->sbuf_status & MANTIS_SBUF_DATA_AVAIL, | ||
32 | msecs_to_jiffies(500)) == -ERESTARTSYS) { | ||
33 | |||
34 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Read wait event timeout !", mantis->num); | ||
35 | rc = -EREMOTEIO; | ||
36 | } | ||
37 | ca->sbuf_status &= ~MANTIS_SBUF_DATA_AVAIL; | ||
38 | udelay(2); | ||
39 | return rc; | ||
40 | } | ||
41 | |||
42 | static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca) | ||
43 | { | ||
44 | struct mantis_pci *mantis = ca->ca_priv; | ||
45 | int rc = 0; | ||
46 | |||
47 | if (wait_event_interruptible_timeout(ca->hif_opdone_wq, | ||
48 | ca->hif_event & MANTIS_SBUF_OPDONE, | ||
49 | msecs_to_jiffies(500)) == -ERESTARTSYS) { | ||
50 | |||
51 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Smart buffer operation timeout !", mantis->num); | ||
52 | rc = -EREMOTEIO; | ||
53 | } | ||
54 | ca->hif_event &= ~MANTIS_SBUF_OPDONE; | ||
55 | udelay(5); | ||
56 | return rc; | ||
57 | } | ||
58 | |||
59 | int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr) | ||
60 | { | ||
61 | struct mantis_pci *mantis = ca->ca_priv; | ||
62 | u32 hif_addr = 0, data, count = 4; | ||
63 | |||
64 | hif_addr |= MANTIS_GPIF_HIFRDWRN; | ||
65 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
66 | hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; | ||
67 | hif_addr |= addr; | ||
68 | |||
69 | mmwrite(hif_addr, MANTIS_GPIF_BRADDR); | ||
70 | mmwrite(count, MANTIS_GPIF_BRBYTES); | ||
71 | |||
72 | udelay(20); | ||
73 | |||
74 | mmwrite(hif_addr, MANTIS_GPIF_HIFADDR); | ||
75 | if (mantis_hif_data_available(ca) != 0) { | ||
76 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer burst read failed", mantis->num); | ||
77 | return -EREMOTEIO; | ||
78 | } | ||
79 | if (mantis_hif_sbuf_opdone_wait(ca) != 0) { | ||
80 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num); | ||
81 | return -EREMOTEIO; | ||
82 | } | ||
83 | data = mmread(MANTIS_GPIF_HIFDIN); | ||
84 | |||
85 | return (data >> 24) & 0xff; | ||
86 | } | ||
87 | |||
88 | int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data) | ||
89 | { | ||
90 | struct mantis_slot *slot = ca->slot; | ||
91 | struct mantis_pci *mantis = ca->ca_priv; | ||
92 | u32 hif_addr = 0; | ||
93 | |||
94 | hif_addr &= ~MANTIS_GPIF_HIFRDWRN; | ||
95 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
96 | hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; | ||
97 | hif_addr |= addr; | ||
98 | |||
99 | mmwrite(slot->slave_cfg, MANTIS_GPIF_CFGSLA); /* Slot0 alone for now */ | ||
100 | |||
101 | mmwrite(hif_addr, MANTIS_GPIF_HIFADDR); | ||
102 | mmwrite(data, MANTIS_GPIF_HIFDOUT); | ||
103 | ca->hif_job_queue = MANTIS_HIF_MEMWR; | ||
104 | |||
105 | if (mantis_hif_sbuf_opdone_wait(ca) != 0) { | ||
106 | ca->hif_job_queue &= ~MANTIS_HIF_MEMWR; | ||
107 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); | ||
108 | return -EREMOTEIO; | ||
109 | } | ||
110 | ca->hif_job_queue &= ~MANTIS_HIF_MEMWR; | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | int mantis_hif_init(struct mantis_ca *ca) | ||
115 | { | ||
116 | struct mantis_pci *mantis = ca->ca_priv; | ||
117 | u32 irqcfg; | ||
118 | |||
119 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Initializing Mantis Host Interface", mantis->num); | ||
120 | init_waitqueue_head(&ca->hif_data_wq); | ||
121 | init_waitqueue_head(&ca->hif_opdone_wq); | ||
122 | |||
123 | irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
124 | irqcfg |= MANTIS_MASK_BRRDY; | ||
125 | mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | void mantis_hif_exit(struct mantis_ca *ca) | ||
131 | { | ||
132 | struct mantis_pci *mantis = ca->ca_priv; | ||
133 | u32 irqcfg; | ||
134 | |||
135 | dprintk(verbose, MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num); | ||
136 | irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
137 | irqcfg &= ~MANTIS_MASK_BRRDY; | ||
138 | mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); | ||
139 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h index 33b39b781d2e..8862502866c5 100644 --- a/drivers/media/dvb/mantis/mantis_link.h +++ b/drivers/media/dvb/mantis/mantis_link.h | |||
@@ -31,6 +31,8 @@ enum mantis_sbuf_status { | |||
31 | 31 | ||
32 | struct mantis_slot { | 32 | struct mantis_slot { |
33 | u32 timeout; | 33 | u32 timeout; |
34 | u32 slave_cfg; | ||
35 | u32 bar; | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | /* Physical layer */ | 38 | /* Physical layer */ |
@@ -40,7 +42,7 @@ enum mantis_slot_state { | |||
40 | }; | 42 | }; |
41 | 43 | ||
42 | struct mantis_ca { | 44 | struct mantis_ca { |
43 | struct mantis_slot slot; | 45 | struct mantis_slot slot[4]; |
44 | 46 | ||
45 | struct work_struct hif_evm_work; | 47 | struct work_struct hif_evm_work; |
46 | 48 | ||
@@ -66,4 +68,10 @@ extern void mantis_pcmcia_exit(struct mantis_ca *ca); | |||
66 | extern int mantis_evmgr_init(struct mantis_ca *ca); | 68 | extern int mantis_evmgr_init(struct mantis_ca *ca); |
67 | extern void mantis_evmgr_exit(struct mantis_ca *ca); | 69 | extern void mantis_evmgr_exit(struct mantis_ca *ca); |
68 | 70 | ||
71 | /* HIF */ | ||
72 | extern int mantis_hif_init(struct mantis_ca *ca); | ||
73 | extern void mantis_hif_exit(struct mantis_ca *ca); | ||
74 | extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr); | ||
75 | extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data); | ||
76 | |||
69 | #endif // __MANTIS_LINK_H | 77 | #endif // __MANTIS_LINK_H |
diff --git a/drivers/media/dvb/mantis/mantis_reg.h b/drivers/media/dvb/mantis/mantis_reg.h index d9862b7dbf03..6f5cd4936763 100644 --- a/drivers/media/dvb/mantis/mantis_reg.h +++ b/drivers/media/dvb/mantis/mantis_reg.h | |||
@@ -147,16 +147,16 @@ | |||
147 | #define MANTIS_CARD_RESET 0xac | 147 | #define MANTIS_CARD_RESET 0xac |
148 | 148 | ||
149 | #define MANTIS_GPIF_ADDR 0xb0 | 149 | #define MANTIS_GPIF_ADDR 0xb0 |
150 | #define MANTIS_GPIF_RDWRN (0x01 << 31) | 150 | #define MANTIS_GPIF_HIFRDWRN (0x01 << 31) |
151 | #define MANTIS_GPIF_PCMCIAREG (0x01 << 27) | 151 | #define MANTIS_GPIF_PCMCIAREG (0x01 << 27) |
152 | #define MANTIS_GPIF_PCMCIAIOM (0x01 << 26) | 152 | #define MANTIS_GPIF_PCMCIAIOM (0x01 << 26) |
153 | #define MANTIS_GPIF_HIF_ADDR (0xfffffff << 0) | 153 | #define MANTIS_GPIF_HIFADDR (0xfffffff << 0) |
154 | 154 | ||
155 | #define MANTIS_GPIF_DOUT 0xb4 | 155 | #define MANTIS_GPIF_DOUT 0xb4 |
156 | #define MANTIS_GPIF_HIF_DOUT (0xfffffff << 0) | 156 | #define MANTIS_GPIF_HIFDOUT (0xfffffff << 0) |
157 | 157 | ||
158 | #define MANTIS_GPIF_DIN 0xb8 | 158 | #define MANTIS_GPIF_DIN 0xb8 |
159 | #define MANTIS_GPIF_HIF_DIN (0xfffffff << 0) | 159 | #define MANTIS_GPIF_HIFDIN (0xfffffff << 0) |
160 | 160 | ||
161 | #define MANTIS_GPIF_SPARE 0xbc | 161 | #define MANTIS_GPIF_SPARE 0xbc |
162 | #define MANTIS_GPIF_LOGICRD (0xffff << 16) | 162 | #define MANTIS_GPIF_LOGICRD (0xffff << 16) |