14 #include <linux/module.h>
16 #include <linux/types.h>
18 #include <linux/kernel.h>
20 #include <linux/reboot.h>
24 #include <linux/device.h>
26 #include <linux/uio.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>
39 #define DBG(fmt...) printk(KERN_ALERT fmt)
44 static int mbcs_major;
53 .llseek = mbcs_sram_llseek,
54 .read = mbcs_sram_read,
55 .write = mbcs_sram_write,
56 .mmap = mbcs_gscr_mmap,
64 static inline void mbcs_getdma_init(
struct getdma *gdma)
70 static inline void mbcs_putdma_init(
struct putdma *pdma)
76 static inline void mbcs_algo_init(
struct algoblock *algo_soft)
81 static inline void mbcs_getdma_set(
void *mmr,
99 rdma_control.dma_control_reg = 0;
100 amo_dest.dma_amo_dest_reg = 0;
103 host_addr.dma_hostaddr_reg = 0;
105 host_addr.dma_sys_addr = hostAddr;
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;
118 amo_dest.dma_amo_sys_addr = amoHostDest;
119 amo_dest.dma_amo_mod_type = amoModType;
128 static inline void mbcs_putdma_set(
void *mmr,
146 wdma_control.dma_control_reg = 0;
147 amo_dest.dma_amo_dest_reg = 0;
150 host_addr.dma_hostaddr_reg = 0;
152 host_addr.dma_sys_addr = hostAddr;
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;
165 amo_dest.dma_amo_sys_addr = amoHostDest;
166 amo_dest.dma_amo_mod_type = amoModType;
175 static inline void mbcs_algo_set(
void *mmr,
185 step.algo_step_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;
197 step.alg_step_cnt = algoStepCount;
241 static inline int mbcs_putdma_start(
struct mbcs_soft *soft)
281 static inline int mbcs_algo_start(
struct mbcs_soft *soft)
292 mbcs_algo_set(mmr_base,
311 size_t len, loff_t * off)
320 soft->
putdma.hostAddr = hostAddr;
321 soft->
putdma.localAddr = *off;
324 if (mbcs_putdma_start(soft) < 0) {
326 "mbcs_putdma_start failed\n");
348 size_t len, loff_t * off)
357 soft->
getdma.hostAddr = hostAddr;
358 soft->
getdma.localAddr = *off;
361 if (mbcs_getdma_start(soft) < 0) {
392 if (soft->
nasid == minor) {
403 static ssize_t mbcs_sram_read(
struct file * fp,
char __user *
buf,
size_t len, loff_t * off)
414 rv = do_mbcs_sram_dmawrite(soft, hostAddr, len, off);
428 mbcs_sram_write(
struct file * fp,
const char __user *buf,
size_t len, loff_t * off)
444 rv = do_mbcs_sram_dmaread(soft, hostAddr, len, off);
452 static loff_t mbcs_sram_llseek(
struct file * filp, loff_t off,
int whence)
462 newpos = filp->
f_pos + off;
476 filp->
f_pos = newpos;
490 static void mbcs_debug_pioaddr_set(
struct mbcs_soft *soft)
495 static void mbcs_gscr_pioaddr_set(
struct mbcs_soft *soft)
528 mbcs_completion_intr_handler(
int irq,
void *
arg)
577 static int mbcs_intr_alloc(
struct cx_dev *
dev)
602 "MBCS get intr", (
void *)soft)) {
608 if (sn_irq ==
NULL) {
618 "MBCS put intr", (
void *)soft)) {
626 if (sn_irq ==
NULL) {
638 "MBCS algo intr", (
void *)soft)) {
655 static void mbcs_intr_dealloc(
struct cx_dev *dev)
669 static inline int mbcs_hw_init(
struct mbcs_soft *soft)
683 mbcs_gscr_pioaddr_set(soft);
684 mbcs_debug_pioaddr_set(soft);
709 struct cx_dev *cx_dev = to_cx_dev(dev);
719 return sprintf(buf,
"0x%x 0x%x\n",
726 struct cx_dev *cx_dev = to_cx_dev(dev);
735 mbcs_algo_start(soft);
752 static int mbcs_probe(
struct cx_dev *dev,
const struct cx_device_id *
id)
762 soft->
nasid = dev->cx_id.nasid;
763 list_add(&soft->
list, &soft_list);
776 mbcs_getdma_init(&soft->
getdma);
777 mbcs_putdma_init(&soft->
putdma);
778 mbcs_algo_init(&soft->
algo);
783 mbcs_intr_alloc(dev);
790 static int mbcs_remove(
struct cx_dev *dev)
793 mbcs_intr_dealloc(dev);
802 static const struct cx_device_id
__devinitconst 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)
829 static int __init mbcs_init(
void)
837 rv = register_chrdev(mbcs_major,
DEVICE_NAME, &mbcs_ops);
839 DBG(
KERN_ALERT "mbcs_init: can't get major number. %d\n", rv);