1472008e257eaa7365708aefc8e2975b626c6ae6
2 Mantis PCI bridge driver
4 Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
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.
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.
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.
21 #include "mantis_common.h"
22 #include "mantis_hif.h"
23 #include "mantis_link.h" /* temporary due to physical layer stuff */
25 static int mantis_hif_data_available(struct mantis_ca
*ca
)
27 struct mantis_pci
*mantis
= ca
->ca_priv
;
30 if (wait_event_interruptible_timeout(ca
->hif_data_wq
,
31 ca
->sbuf_status
& MANTIS_SBUF_DATA_AVAIL
,
32 msecs_to_jiffies(500)) == -ERESTARTSYS
) {
34 dprintk(verbose
, MANTIS_ERROR
, 1, "Adapter(%d) Slot(0): HIF Read wait event timeout !", mantis
->num
);
37 ca
->sbuf_status
&= ~MANTIS_SBUF_DATA_AVAIL
;
42 static int mantis_hif_sbuf_opdone_wait(struct mantis_ca
*ca
)
44 struct mantis_pci
*mantis
= ca
->ca_priv
;
47 if (wait_event_interruptible_timeout(ca
->hif_opdone_wq
,
48 ca
->hif_event
& MANTIS_SBUF_OPDONE
,
49 msecs_to_jiffies(500)) == -ERESTARTSYS
) {
51 dprintk(verbose
, MANTIS_ERROR
, 1, "Adapter(%d) Slot(0): Smart buffer operation timeout !", mantis
->num
);
54 ca
->hif_event
&= ~MANTIS_SBUF_OPDONE
;
59 int mantis_hif_read_mem(struct mantis_ca
*ca
, u32 addr
)
61 struct mantis_pci
*mantis
= ca
->ca_priv
;
62 u32 hif_addr
= 0, data
, count
= 4;
64 hif_addr
|= MANTIS_GPIF_HIFRDWRN
;
65 hif_addr
&= ~MANTIS_GPIF_PCMCIAREG
;
66 hif_addr
&= ~MANTIS_GPIF_PCMCIAIOM
;
69 mmwrite(hif_addr
, MANTIS_GPIF_BRADDR
);
70 mmwrite(count
, MANTIS_GPIF_BRBYTES
);
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
);
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
);
83 data
= mmread(MANTIS_GPIF_HIFDIN
);
85 return (data
>> 24) & 0xff;
88 int mantis_hif_write_mem(struct mantis_ca
*ca
, u32 addr
, u8 data
)
90 struct mantis_slot
*slot
= ca
->slot
;
91 struct mantis_pci
*mantis
= ca
->ca_priv
;
94 hif_addr
&= ~MANTIS_GPIF_HIFRDWRN
;
95 hif_addr
&= ~MANTIS_GPIF_PCMCIAREG
;
96 hif_addr
&= ~MANTIS_GPIF_PCMCIAIOM
;
99 mmwrite(slot
->slave_cfg
, MANTIS_GPIF_CFGSLA
); /* Slot0 alone for now */
101 mmwrite(hif_addr
, MANTIS_GPIF_HIFADDR
);
102 mmwrite(data
, MANTIS_GPIF_HIFDOUT
);
103 ca
->hif_job_queue
= MANTIS_HIF_MEMWR
;
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
);
110 ca
->hif_job_queue
&= ~MANTIS_HIF_MEMWR
;
114 int mantis_hif_init(struct mantis_ca
*ca
)
116 struct mantis_pci
*mantis
= ca
->ca_priv
;
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
);
123 irqcfg
= mmread(MANTIS_GPIF_IRQCFG
);
124 irqcfg
|= MANTIS_MASK_BRRDY
;
125 mmwrite(irqcfg
, MANTIS_GPIF_IRQCFG
);
130 void mantis_hif_exit(struct mantis_ca
*ca
)
132 struct mantis_pci
*mantis
= ca
->ca_priv
;
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
);
This page took 0.070146 seconds and 4 git commands to generate.