2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
10 * MOATB Core Services driver.
13 #include <linux/interrupt.h>
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/types.h>
17 #include <linux/ioport.h>
18 #include <linux/kernel.h>
19 #include <linux/notifier.h>
20 #include <linux/reboot.h>
21 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/device.h>
26 #include <linux/uio.h>
27 #include <linux/mutex.h>
28 #include <linux/slab.h>
30 #include <asm/uaccess.h>
31 #include <asm/pgtable.h>
32 #include <asm/sn/addrs.h>
33 #include <asm/sn/intr.h>
34 #include <asm/sn/tiocx.h>
39 #define DBG(fmt...) printk(KERN_ALERT fmt)
43 static DEFINE_MUTEX(mbcs_mutex
);
44 static int mbcs_major
;
46 static LIST_HEAD(soft_list
);
51 static const struct file_operations mbcs_ops
= {
53 .llseek
= mbcs_sram_llseek
,
54 .read
= mbcs_sram_read
,
55 .write
= mbcs_sram_write
,
56 .mmap
= mbcs_gscr_mmap
,
59 struct mbcs_callback_arg
{
61 struct cx_dev
*cx_dev
;
64 static inline void mbcs_getdma_init(struct getdma
*gdma
)
66 memset(gdma
, 0, sizeof(struct getdma
));
67 gdma
->DoneIntEnable
= 1;
70 static inline void mbcs_putdma_init(struct putdma
*pdma
)
72 memset(pdma
, 0, sizeof(struct putdma
));
73 pdma
->DoneIntEnable
= 1;
76 static inline void mbcs_algo_init(struct algoblock
*algo_soft
)
78 memset(algo_soft
, 0, sizeof(struct algoblock
));
81 static inline void mbcs_getdma_set(void *mmr
,
90 uint64_t amoModType
, uint64_t intrHostDest
,
93 union dma_control rdma_control
;
94 union dma_amo_dest amo_dest
;
95 union intr_dest intr_dest
;
96 union dma_localaddr local_addr
;
97 union dma_hostaddr host_addr
;
99 rdma_control
.dma_control_reg
= 0;
100 amo_dest
.dma_amo_dest_reg
= 0;
101 intr_dest
.intr_dest_reg
= 0;
102 local_addr
.dma_localaddr_reg
= 0;
103 host_addr
.dma_hostaddr_reg
= 0;
105 host_addr
.dma_sys_addr
= hostAddr
;
106 MBCS_MMR_SET(mmr
, MBCS_RD_DMA_SYS_ADDR
, host_addr
.dma_hostaddr_reg
);
108 local_addr
.dma_ram_addr
= localAddr
;
109 local_addr
.dma_ram_sel
= localRamSel
;
110 MBCS_MMR_SET(mmr
, MBCS_RD_DMA_LOC_ADDR
, local_addr
.dma_localaddr_reg
);
112 rdma_control
.dma_op_length
= numPkts
;
113 rdma_control
.done_amo_en
= amoEnable
;
114 rdma_control
.done_int_en
= intrEnable
;
115 rdma_control
.pio_mem_n
= peerIO
;
116 MBCS_MMR_SET(mmr
, MBCS_RD_DMA_CTRL
, rdma_control
.dma_control_reg
);
118 amo_dest
.dma_amo_sys_addr
= amoHostDest
;
119 amo_dest
.dma_amo_mod_type
= amoModType
;
120 MBCS_MMR_SET(mmr
, MBCS_RD_DMA_AMO_DEST
, amo_dest
.dma_amo_dest_reg
);
122 intr_dest
.address
= intrHostDest
;
123 intr_dest
.int_vector
= intrVector
;
124 MBCS_MMR_SET(mmr
, MBCS_RD_DMA_INT_DEST
, intr_dest
.intr_dest_reg
);
128 static inline void mbcs_putdma_set(void *mmr
,
131 uint64_t localRamSel
,
136 uint64_t amoHostDest
,
138 uint64_t intrHostDest
, uint64_t intrVector
)
140 union dma_control wdma_control
;
141 union dma_amo_dest amo_dest
;
142 union intr_dest intr_dest
;
143 union dma_localaddr local_addr
;
144 union dma_hostaddr host_addr
;
146 wdma_control
.dma_control_reg
= 0;
147 amo_dest
.dma_amo_dest_reg
= 0;
148 intr_dest
.intr_dest_reg
= 0;
149 local_addr
.dma_localaddr_reg
= 0;
150 host_addr
.dma_hostaddr_reg
= 0;
152 host_addr
.dma_sys_addr
= hostAddr
;
153 MBCS_MMR_SET(mmr
, MBCS_WR_DMA_SYS_ADDR
, host_addr
.dma_hostaddr_reg
);
155 local_addr
.dma_ram_addr
= localAddr
;
156 local_addr
.dma_ram_sel
= localRamSel
;
157 MBCS_MMR_SET(mmr
, MBCS_WR_DMA_LOC_ADDR
, local_addr
.dma_localaddr_reg
);
159 wdma_control
.dma_op_length
= numPkts
;
160 wdma_control
.done_amo_en
= amoEnable
;
161 wdma_control
.done_int_en
= intrEnable
;
162 wdma_control
.pio_mem_n
= peerIO
;
163 MBCS_MMR_SET(mmr
, MBCS_WR_DMA_CTRL
, wdma_control
.dma_control_reg
);
165 amo_dest
.dma_amo_sys_addr
= amoHostDest
;
166 amo_dest
.dma_amo_mod_type
= amoModType
;
167 MBCS_MMR_SET(mmr
, MBCS_WR_DMA_AMO_DEST
, amo_dest
.dma_amo_dest_reg
);
169 intr_dest
.address
= intrHostDest
;
170 intr_dest
.int_vector
= intrVector
;
171 MBCS_MMR_SET(mmr
, MBCS_WR_DMA_INT_DEST
, intr_dest
.intr_dest_reg
);
175 static inline void mbcs_algo_set(void *mmr
,
176 uint64_t amoHostDest
,
178 uint64_t intrHostDest
,
179 uint64_t intrVector
, uint64_t algoStepCount
)
181 union dma_amo_dest amo_dest
;
182 union intr_dest intr_dest
;
183 union algo_step step
;
185 step
.algo_step_reg
= 0;
186 intr_dest
.intr_dest_reg
= 0;
187 amo_dest
.dma_amo_dest_reg
= 0;
189 amo_dest
.dma_amo_sys_addr
= amoHostDest
;
190 amo_dest
.dma_amo_mod_type
= amoModType
;
191 MBCS_MMR_SET(mmr
, MBCS_ALG_AMO_DEST
, amo_dest
.dma_amo_dest_reg
);
193 intr_dest
.address
= intrHostDest
;
194 intr_dest
.int_vector
= intrVector
;
195 MBCS_MMR_SET(mmr
, MBCS_ALG_INT_DEST
, intr_dest
.intr_dest_reg
);
197 step
.alg_step_cnt
= algoStepCount
;
198 MBCS_MMR_SET(mmr
, MBCS_ALG_STEP
, step
.algo_step_reg
);
201 static inline int mbcs_getdma_start(struct mbcs_soft
*soft
)
206 union cm_control cm_control
;
208 mmr_base
= soft
->mmr_base
;
209 gdma
= &soft
->getdma
;
211 /* check that host address got setup */
216 (gdma
->bytes
+ (MBCS_CACHELINE_SIZE
- 1)) / MBCS_CACHELINE_SIZE
;
219 mbcs_getdma_set(mmr_base
, tiocx_dma_addr(gdma
->hostAddr
),
221 (gdma
->localAddr
< MB2
) ? 0 :
222 (gdma
->localAddr
< MB4
) ? 1 :
223 (gdma
->localAddr
< MB6
) ? 2 : 3,
230 gdma
->intrHostDest
, gdma
->intrVector
);
233 cm_control
.cm_control_reg
= MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
234 cm_control
.rd_dma_go
= 1;
235 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
, cm_control
.cm_control_reg
);
241 static inline int mbcs_putdma_start(struct mbcs_soft
*soft
)
246 union cm_control cm_control
;
248 mmr_base
= soft
->mmr_base
;
249 pdma
= &soft
->putdma
;
251 /* check that host address got setup */
256 (pdma
->bytes
+ (MBCS_CACHELINE_SIZE
- 1)) / MBCS_CACHELINE_SIZE
;
259 mbcs_putdma_set(mmr_base
, tiocx_dma_addr(pdma
->hostAddr
),
261 (pdma
->localAddr
< MB2
) ? 0 :
262 (pdma
->localAddr
< MB4
) ? 1 :
263 (pdma
->localAddr
< MB6
) ? 2 : 3,
270 pdma
->intrHostDest
, pdma
->intrVector
);
273 cm_control
.cm_control_reg
= MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
274 cm_control
.wr_dma_go
= 1;
275 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
, cm_control
.cm_control_reg
);
281 static inline int mbcs_algo_start(struct mbcs_soft
*soft
)
283 struct algoblock
*algo_soft
= &soft
->algo
;
284 void *mmr_base
= soft
->mmr_base
;
285 union cm_control cm_control
;
287 if (mutex_lock_interruptible(&soft
->algolock
))
290 atomic_set(&soft
->algo_done
, 0);
292 mbcs_algo_set(mmr_base
,
293 algo_soft
->amoHostDest
,
294 algo_soft
->amoModType
,
295 algo_soft
->intrHostDest
,
296 algo_soft
->intrVector
, algo_soft
->algoStepCount
);
298 /* start algorithm */
299 cm_control
.cm_control_reg
= MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
300 cm_control
.alg_done_int_en
= 1;
301 cm_control
.alg_go
= 1;
302 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
, cm_control
.cm_control_reg
);
304 mutex_unlock(&soft
->algolock
);
309 static inline ssize_t
310 do_mbcs_sram_dmawrite(struct mbcs_soft
*soft
, uint64_t hostAddr
,
311 size_t len
, loff_t
* off
)
315 if (mutex_lock_interruptible(&soft
->dmawritelock
))
318 atomic_set(&soft
->dmawrite_done
, 0);
320 soft
->putdma
.hostAddr
= hostAddr
;
321 soft
->putdma
.localAddr
= *off
;
322 soft
->putdma
.bytes
= len
;
324 if (mbcs_putdma_start(soft
) < 0) {
325 DBG(KERN_ALERT
"do_mbcs_sram_dmawrite: "
326 "mbcs_putdma_start failed\n");
331 if (wait_event_interruptible(soft
->dmawrite_queue
,
332 atomic_read(&soft
->dmawrite_done
))) {
341 mutex_unlock(&soft
->dmawritelock
);
346 static inline ssize_t
347 do_mbcs_sram_dmaread(struct mbcs_soft
*soft
, uint64_t hostAddr
,
348 size_t len
, loff_t
* off
)
352 if (mutex_lock_interruptible(&soft
->dmareadlock
))
355 atomic_set(&soft
->dmawrite_done
, 0);
357 soft
->getdma
.hostAddr
= hostAddr
;
358 soft
->getdma
.localAddr
= *off
;
359 soft
->getdma
.bytes
= len
;
361 if (mbcs_getdma_start(soft
) < 0) {
362 DBG(KERN_ALERT
"mbcs_strategy: mbcs_getdma_start failed\n");
367 if (wait_event_interruptible(soft
->dmaread_queue
,
368 atomic_read(&soft
->dmaread_done
))) {
377 mutex_unlock(&soft
->dmareadlock
);
382 static int mbcs_open(struct inode
*ip
, struct file
*fp
)
384 struct mbcs_soft
*soft
;
387 mutex_lock(&mbcs_mutex
);
390 /* Nothing protects access to this list... */
391 list_for_each_entry(soft
, &soft_list
, list
) {
392 if (soft
->nasid
== minor
) {
393 fp
->private_data
= soft
->cxdev
;
394 mutex_unlock(&mbcs_mutex
);
399 mutex_unlock(&mbcs_mutex
);
403 static ssize_t
mbcs_sram_read(struct file
* fp
, char __user
*buf
, size_t len
, loff_t
* off
)
405 struct cx_dev
*cx_dev
= fp
->private_data
;
406 struct mbcs_soft
*soft
= cx_dev
->soft
;
410 hostAddr
= __get_dma_pages(GFP_KERNEL
, get_order(len
));
414 rv
= do_mbcs_sram_dmawrite(soft
, hostAddr
, len
, off
);
418 if (copy_to_user(buf
, (void *)hostAddr
, len
))
422 free_pages(hostAddr
, get_order(len
));
428 mbcs_sram_write(struct file
* fp
, const char __user
*buf
, size_t len
, loff_t
* off
)
430 struct cx_dev
*cx_dev
= fp
->private_data
;
431 struct mbcs_soft
*soft
= cx_dev
->soft
;
435 hostAddr
= __get_dma_pages(GFP_KERNEL
, get_order(len
));
439 if (copy_from_user((void *)hostAddr
, buf
, len
)) {
444 rv
= do_mbcs_sram_dmaread(soft
, hostAddr
, len
, off
);
447 free_pages(hostAddr
, get_order(len
));
452 static loff_t
mbcs_sram_llseek(struct file
* filp
, loff_t off
, int whence
)
462 newpos
= filp
->f_pos
+ off
;
466 newpos
= MBCS_SRAM_SIZE
+ off
;
469 default: /* can't happen */
476 filp
->f_pos
= newpos
;
481 static uint64_t mbcs_pioaddr(struct mbcs_soft
*soft
, uint64_t offset
)
485 mmr_base
= (uint64_t) (soft
->mmr_base
+ offset
);
490 static void mbcs_debug_pioaddr_set(struct mbcs_soft
*soft
)
492 soft
->debug_addr
= mbcs_pioaddr(soft
, MBCS_DEBUG_START
);
495 static void mbcs_gscr_pioaddr_set(struct mbcs_soft
*soft
)
497 soft
->gscr_addr
= mbcs_pioaddr(soft
, MBCS_GSCR_START
);
500 static int mbcs_gscr_mmap(struct file
*fp
, struct vm_area_struct
*vma
)
502 struct cx_dev
*cx_dev
= fp
->private_data
;
503 struct mbcs_soft
*soft
= cx_dev
->soft
;
505 if (vma
->vm_pgoff
!= 0)
508 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
510 /* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
511 if (remap_pfn_range(vma
,
513 __pa(soft
->gscr_addr
) >> PAGE_SHIFT
,
522 * mbcs_completion_intr_handler - Primary completion handler.
524 * @arg: soft struct for device
528 mbcs_completion_intr_handler(int irq
, void *arg
)
530 struct mbcs_soft
*soft
= (struct mbcs_soft
*)arg
;
532 union cm_status cm_status
;
533 union cm_control cm_control
;
535 mmr_base
= soft
->mmr_base
;
536 cm_status
.cm_status_reg
= MBCS_MMR_GET(mmr_base
, MBCS_CM_STATUS
);
538 if (cm_status
.rd_dma_done
) {
539 /* stop dma-read engine, clear status */
540 cm_control
.cm_control_reg
=
541 MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
542 cm_control
.rd_dma_clr
= 1;
543 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
,
544 cm_control
.cm_control_reg
);
545 atomic_set(&soft
->dmaread_done
, 1);
546 wake_up(&soft
->dmaread_queue
);
548 if (cm_status
.wr_dma_done
) {
549 /* stop dma-write engine, clear status */
550 cm_control
.cm_control_reg
=
551 MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
552 cm_control
.wr_dma_clr
= 1;
553 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
,
554 cm_control
.cm_control_reg
);
555 atomic_set(&soft
->dmawrite_done
, 1);
556 wake_up(&soft
->dmawrite_queue
);
558 if (cm_status
.alg_done
) {
560 cm_control
.cm_control_reg
=
561 MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
562 cm_control
.alg_done_clr
= 1;
563 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
,
564 cm_control
.cm_control_reg
);
565 atomic_set(&soft
->algo_done
, 1);
566 wake_up(&soft
->algo_queue
);
573 * mbcs_intr_alloc - Allocate interrupts.
574 * @dev: device pointer
577 static int mbcs_intr_alloc(struct cx_dev
*dev
)
579 struct sn_irq_info
*sn_irq
;
580 struct mbcs_soft
*soft
;
581 struct getdma
*getdma
;
582 struct putdma
*putdma
;
583 struct algoblock
*algo
;
586 getdma
= &soft
->getdma
;
587 putdma
= &soft
->putdma
;
590 soft
->get_sn_irq
= NULL
;
591 soft
->put_sn_irq
= NULL
;
592 soft
->algo_sn_irq
= NULL
;
594 sn_irq
= tiocx_irq_alloc(dev
->cx_id
.nasid
, TIOCX_CORELET
, -1, -1, -1);
597 soft
->get_sn_irq
= sn_irq
;
598 getdma
->intrHostDest
= sn_irq
->irq_xtalkaddr
;
599 getdma
->intrVector
= sn_irq
->irq_irq
;
600 if (request_irq(sn_irq
->irq_irq
,
601 (void *)mbcs_completion_intr_handler
, IRQF_SHARED
,
602 "MBCS get intr", (void *)soft
)) {
603 tiocx_irq_free(soft
->get_sn_irq
);
607 sn_irq
= tiocx_irq_alloc(dev
->cx_id
.nasid
, TIOCX_CORELET
, -1, -1, -1);
608 if (sn_irq
== NULL
) {
609 free_irq(soft
->get_sn_irq
->irq_irq
, soft
);
610 tiocx_irq_free(soft
->get_sn_irq
);
613 soft
->put_sn_irq
= sn_irq
;
614 putdma
->intrHostDest
= sn_irq
->irq_xtalkaddr
;
615 putdma
->intrVector
= sn_irq
->irq_irq
;
616 if (request_irq(sn_irq
->irq_irq
,
617 (void *)mbcs_completion_intr_handler
, IRQF_SHARED
,
618 "MBCS put intr", (void *)soft
)) {
619 tiocx_irq_free(soft
->put_sn_irq
);
620 free_irq(soft
->get_sn_irq
->irq_irq
, soft
);
621 tiocx_irq_free(soft
->get_sn_irq
);
625 sn_irq
= tiocx_irq_alloc(dev
->cx_id
.nasid
, TIOCX_CORELET
, -1, -1, -1);
626 if (sn_irq
== NULL
) {
627 free_irq(soft
->put_sn_irq
->irq_irq
, soft
);
628 tiocx_irq_free(soft
->put_sn_irq
);
629 free_irq(soft
->get_sn_irq
->irq_irq
, soft
);
630 tiocx_irq_free(soft
->get_sn_irq
);
633 soft
->algo_sn_irq
= sn_irq
;
634 algo
->intrHostDest
= sn_irq
->irq_xtalkaddr
;
635 algo
->intrVector
= sn_irq
->irq_irq
;
636 if (request_irq(sn_irq
->irq_irq
,
637 (void *)mbcs_completion_intr_handler
, IRQF_SHARED
,
638 "MBCS algo intr", (void *)soft
)) {
639 tiocx_irq_free(soft
->algo_sn_irq
);
640 free_irq(soft
->put_sn_irq
->irq_irq
, soft
);
641 tiocx_irq_free(soft
->put_sn_irq
);
642 free_irq(soft
->get_sn_irq
->irq_irq
, soft
);
643 tiocx_irq_free(soft
->get_sn_irq
);
651 * mbcs_intr_dealloc - Remove interrupts.
652 * @dev: device pointer
655 static void mbcs_intr_dealloc(struct cx_dev
*dev
)
657 struct mbcs_soft
*soft
;
661 free_irq(soft
->get_sn_irq
->irq_irq
, soft
);
662 tiocx_irq_free(soft
->get_sn_irq
);
663 free_irq(soft
->put_sn_irq
->irq_irq
, soft
);
664 tiocx_irq_free(soft
->put_sn_irq
);
665 free_irq(soft
->algo_sn_irq
->irq_irq
, soft
);
666 tiocx_irq_free(soft
->algo_sn_irq
);
669 static inline int mbcs_hw_init(struct mbcs_soft
*soft
)
671 void *mmr_base
= soft
->mmr_base
;
672 union cm_control cm_control
;
673 union cm_req_timeout cm_req_timeout
;
676 cm_req_timeout
.cm_req_timeout_reg
=
677 MBCS_MMR_GET(mmr_base
, MBCS_CM_REQ_TOUT
);
679 cm_req_timeout
.time_out
= MBCS_CM_CONTROL_REQ_TOUT_MASK
;
680 MBCS_MMR_SET(mmr_base
, MBCS_CM_REQ_TOUT
,
681 cm_req_timeout
.cm_req_timeout_reg
);
683 mbcs_gscr_pioaddr_set(soft
);
684 mbcs_debug_pioaddr_set(soft
);
687 err_stat
= MBCS_MMR_GET(mmr_base
, MBCS_CM_ERR_STAT
);
688 MBCS_MMR_SET(mmr_base
, MBCS_CM_CLR_ERR_STAT
, err_stat
);
689 MBCS_MMR_ZERO(mmr_base
, MBCS_CM_ERROR_DETAIL1
);
691 /* enable interrupts */
692 /* turn off 2^23 (INT_EN_PIO_REQ_ADDR_INV) */
693 MBCS_MMR_SET(mmr_base
, MBCS_CM_ERR_INT_EN
, 0x3ffffff7e00ffUL
);
695 /* arm status regs and clear engines */
696 cm_control
.cm_control_reg
= MBCS_MMR_GET(mmr_base
, MBCS_CM_CONTROL
);
697 cm_control
.rearm_stat_regs
= 1;
698 cm_control
.alg_clr
= 1;
699 cm_control
.wr_dma_clr
= 1;
700 cm_control
.rd_dma_clr
= 1;
702 MBCS_MMR_SET(mmr_base
, MBCS_CM_CONTROL
, cm_control
.cm_control_reg
);
707 static ssize_t
show_algo(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
709 struct cx_dev
*cx_dev
= to_cx_dev(dev
);
710 struct mbcs_soft
*soft
= cx_dev
->soft
;
714 * By convention, the first debug register contains the
715 * algorithm number and revision.
717 debug0
= *(uint64_t *) soft
->debug_addr
;
719 return sprintf(buf
, "0x%x 0x%x\n",
720 upper_32_bits(debug0
), lower_32_bits(debug0
));
723 static ssize_t
store_algo(struct device
*dev
, struct device_attribute
*attr
, const char *buf
, size_t count
)
726 struct cx_dev
*cx_dev
= to_cx_dev(dev
);
727 struct mbcs_soft
*soft
= cx_dev
->soft
;
732 n
= simple_strtoul(buf
, NULL
, 0);
735 mbcs_algo_start(soft
);
736 if (wait_event_interruptible(soft
->algo_queue
,
737 atomic_read(&soft
->algo_done
)))
744 DEVICE_ATTR(algo
, 0644, show_algo
, store_algo
);
747 * mbcs_probe - Initialize for device
748 * @dev: device pointer
749 * @device_id: id table pointer
752 static int mbcs_probe(struct cx_dev
*dev
, const struct cx_device_id
*id
)
754 struct mbcs_soft
*soft
;
758 soft
= kzalloc(sizeof(struct mbcs_soft
), GFP_KERNEL
);
762 soft
->nasid
= dev
->cx_id
.nasid
;
763 list_add(&soft
->list
, &soft_list
);
764 soft
->mmr_base
= (void *)tiocx_swin_base(dev
->cx_id
.nasid
);
768 init_waitqueue_head(&soft
->dmawrite_queue
);
769 init_waitqueue_head(&soft
->dmaread_queue
);
770 init_waitqueue_head(&soft
->algo_queue
);
772 mutex_init(&soft
->dmawritelock
);
773 mutex_init(&soft
->dmareadlock
);
774 mutex_init(&soft
->algolock
);
776 mbcs_getdma_init(&soft
->getdma
);
777 mbcs_putdma_init(&soft
->putdma
);
778 mbcs_algo_init(&soft
->algo
);
782 /* Allocate interrupts */
783 mbcs_intr_alloc(dev
);
785 device_create_file(&dev
->dev
, &dev_attr_algo
);
790 static int mbcs_remove(struct cx_dev
*dev
)
793 mbcs_intr_dealloc(dev
);
797 device_remove_file(&dev
->dev
, &dev_attr_algo
);
802 static const struct cx_device_id __devinitconst mbcs_id_table
[] = {
804 .part_num
= MBCS_PART_NUM
,
805 .mfg_num
= MBCS_MFG_NUM
,
808 .part_num
= MBCS_PART_NUM_ALG0
,
809 .mfg_num
= MBCS_MFG_NUM
,
814 MODULE_DEVICE_TABLE(cx
, mbcs_id_table
);
816 static struct cx_drv mbcs_driver
= {
818 .id_table
= mbcs_id_table
,
820 .remove
= mbcs_remove
,
823 static void __exit
mbcs_exit(void)
825 unregister_chrdev(mbcs_major
, DEVICE_NAME
);
826 cx_driver_unregister(&mbcs_driver
);
829 static int __init
mbcs_init(void)
833 if (!ia64_platform_is("sn2"))
836 // Put driver into chrdevs[]. Get major number.
837 rv
= register_chrdev(mbcs_major
, DEVICE_NAME
, &mbcs_ops
);
839 DBG(KERN_ALERT
"mbcs_init: can't get major number. %d\n", rv
);
844 return cx_driver_register(&mbcs_driver
);
847 module_init(mbcs_init
);
848 module_exit(mbcs_exit
);
850 MODULE_AUTHOR("Bruce Losure <blosure@sgi.com>");
851 MODULE_DESCRIPTION("Driver for MOATB Core Services");
852 MODULE_LICENSE("GPL");