Searched refs:cosa (Results 1 - 12 of 12) sorted by relevance

/linux-4.1.27/drivers/net/wan/
H A Dcosa.c1 /* $Id: cosa.c,v 1.31 2000/03/08 17:47:16 kas Exp $ */
31 * http://www.pavoucek.cz/cosa.html. The card documentation, firmwares
32 * and other goods can be downloaded from ftp://ftp.ics.muni.cz/pub/cosa/.
51 * The homepage of the Linux driver is at http://www.fi.muni.cz/~kas/cosa/.
100 #include "cosa.h"
113 struct cosa_data *cosa; /* Pointer to the per-card structure */ member in struct:channel_data
139 /* cosa->firmware_status bits */
201 * for cosa->rxtx - indicates whether either transmit or receive is
260 #define is_8bit(cosa) (!(cosa->datareg & 0x08))
262 #define cosa_getstatus(cosa) (cosa_inb(cosa->statusreg))
263 #define cosa_putstatus(cosa, stat) (cosa_outb(stat, cosa->statusreg))
264 #define cosa_getdata16(cosa) (cosa_inw(cosa->datareg))
265 #define cosa_getdata8(cosa) (cosa_inb(cosa->datareg))
266 #define cosa_putdata16(cosa, dt) (cosa_outw(dt, cosa->datareg))
267 #define cosa_putdata8(cosa, dt) (cosa_outb(dt, cosa->datareg))
276 static void cosa_kick(struct cosa_data *cosa);
323 static int cosa_start(struct cosa_data *cosa, int address);
324 static int cosa_reset(struct cosa_data *cosa);
325 static int cosa_download(struct cosa_data *cosa, void __user *a);
326 static int cosa_readmem(struct cosa_data *cosa, void __user *a);
329 static int download(struct cosa_data *cosa, const char __user *data, int addr, int len);
330 static int startmicrocode(struct cosa_data *cosa, int address);
331 static int readmem(struct cosa_data *cosa, char __user *data, int addr, int len);
332 static int cosa_reset_and_read_id(struct cosa_data *cosa, char *id);
335 static int get_wait_data(struct cosa_data *cosa);
336 static int put_wait_data(struct cosa_data *cosa, int data);
337 static int puthexnumber(struct cosa_data *cosa, int number);
338 static void put_driver_status(struct cosa_data *cosa);
339 static void put_driver_status_nolock(struct cosa_data *cosa);
342 static irqreturn_t cosa_interrupt(int irq, void *cosa);
346 static void debug_data_in(struct cosa_data *cosa, int data);
347 static void debug_data_out(struct cosa_data *cosa, int data);
348 static void debug_data_cmd(struct cosa_data *cosa, int data);
349 static void debug_status_in(struct cosa_data *cosa, int status);
350 static void debug_status_out(struct cosa_data *cosa, int status);
365 if (register_chrdev(cosa_major, "cosa", &cosa_fops)) { cosa_init()
371 if (!(cosa_major=register_chrdev(0, "cosa", &cosa_fops))) { cosa_init()
383 unregister_chrdev(cosa_major, "cosa"); cosa_init()
387 cosa_class = class_create(THIS_MODULE, "cosa"); cosa_init()
394 "cosa%d", i); cosa_init()
399 unregister_chrdev(cosa_major, "cosa"); cosa_init()
407 struct cosa_data *cosa; cosa_exit() local
414 for (cosa = cosa_cards; nr_cards--; cosa++) { cosa_exit()
416 for (i = 0; i < cosa->nchannels; i++) { cosa_exit()
418 unregister_hdlc_device(cosa->chan[i].netdev); cosa_exit()
419 free_netdev(cosa->chan[i].netdev); cosa_exit()
422 kfree(cosa->chan); cosa_exit()
423 kfree(cosa->bouncebuf); cosa_exit()
424 free_irq(cosa->irq, cosa); cosa_exit()
425 free_dma(cosa->dma); cosa_exit()
426 release_region(cosa->datareg, is_8bit(cosa) ? 2 : 4); cosa_exit()
428 unregister_chrdev(cosa_major, "cosa"); cosa_exit()
443 struct cosa_data *cosa = cosa_cards+nr_cards; cosa_probe() local
446 memset(cosa, 0, sizeof(struct cosa_data)); cosa_probe()
473 cosa->dma = dma; cosa_probe()
474 cosa->datareg = base; cosa_probe()
475 cosa->statusreg = is_8bit(cosa)?base+1:base+2; cosa_probe()
476 spin_lock_init(&cosa->lock); cosa_probe()
478 if (!request_region(base, is_8bit(cosa)?2:4,"cosa")) cosa_probe()
481 if (cosa_reset_and_read_id(cosa, cosa->id_string) < 0) { cosa_probe()
488 if (!strncmp(cosa->id_string, "SRP", 3)) cosa_probe()
489 cosa->type = "srp"; cosa_probe()
490 else if (!strncmp(cosa->id_string, "COSA", 4)) cosa_probe()
491 cosa->type = is_8bit(cosa)? "cosa8": "cosa16"; cosa_probe()
501 release_region(base, is_8bit(cosa)?2:4); cosa_probe()
502 if (!request_region(base, is_8bit(cosa)?2:4, cosa->type)) { cosa_probe()
519 cosa_putstatus(cosa, SR_TX_INT_ENA); cosa_probe()
523 cosa_putstatus(cosa, 0); cosa_probe()
525 cosa_getdata8(cosa); cosa_probe()
529 irq, cosa->datareg); cosa_probe()
535 cosa->datareg); cosa_probe()
540 cosa->irq = irq; cosa_probe()
541 cosa->num = nr_cards; cosa_probe()
542 cosa->usage = 0; cosa_probe()
543 cosa->nchannels = 2; /* FIXME: how to determine this? */ cosa_probe()
545 if (request_irq(cosa->irq, cosa_interrupt, 0, cosa->type, cosa)) { cosa_probe()
549 if (request_dma(cosa->dma, cosa->type)) { cosa_probe()
554 cosa->bouncebuf = kmalloc(COSA_MTU, GFP_KERNEL|GFP_DMA); cosa_probe()
555 if (!cosa->bouncebuf) { cosa_probe()
559 sprintf(cosa->name, "cosa%d", cosa->num); cosa_probe()
562 cosa->chan = kcalloc(cosa->nchannels, sizeof(struct channel_data), GFP_KERNEL); cosa_probe()
563 if (!cosa->chan) { cosa_probe()
568 for (i = 0; i < cosa->nchannels; i++) { cosa_probe()
569 struct channel_data *chan = &cosa->chan[i]; cosa_probe()
571 chan->cosa = cosa; cosa_probe()
573 sprintf(chan->name, "cosa%dc%d", chan->cosa->num, i); cosa_probe()
589 chan->netdev->base_addr = chan->cosa->datareg; cosa_probe()
590 chan->netdev->irq = chan->cosa->irq; cosa_probe()
591 chan->netdev->dma = chan->cosa->dma; cosa_probe()
600 pr_info("cosa%d: %s (%s at 0x%x irq %d dma %d), %d channels\n", cosa_probe()
601 cosa->num, cosa->id_string, cosa->type, cosa_probe()
602 cosa->datareg, cosa->irq, cosa->dma, cosa->nchannels); cosa_probe()
608 unregister_hdlc_device(cosa->chan[i].netdev); cosa_probe()
609 free_netdev(cosa->chan[i].netdev); cosa_probe()
611 kfree(cosa->chan); cosa_probe()
613 kfree(cosa->bouncebuf); cosa_probe()
615 free_dma(cosa->dma); cosa_probe()
617 free_irq(cosa->irq, cosa); cosa_probe()
619 release_region(cosa->datareg,is_8bit(cosa)?2:4); cosa_probe()
620 pr_notice("cosa%d: allocating resources failed\n", cosa->num); cosa_probe()
642 if (!(chan->cosa->firmware_status & COSA_FW_START)) { cosa_net_open()
644 chan->cosa->name, chan->cosa->firmware_status); cosa_net_open()
647 spin_lock_irqsave(&chan->cosa->lock, flags); cosa_net_open()
651 spin_unlock_irqrestore(&chan->cosa->lock, flags); cosa_net_open()
658 chan->cosa->usage++; cosa_net_open()
659 spin_unlock_irqrestore(&chan->cosa->lock, flags); cosa_net_open()
663 spin_lock_irqsave(&chan->cosa->lock, flags); cosa_net_open()
665 chan->cosa->usage--; cosa_net_open()
666 spin_unlock_irqrestore(&chan->cosa->lock, flags); cosa_net_open()
691 if (test_bit(RXBIT, &chan->cosa->rxtx)) { cosa_net_timeout()
698 cosa_kick(chan->cosa); cosa_net_timeout()
714 spin_lock_irqsave(&chan->cosa->lock, flags); cosa_net_close()
724 chan->cosa->usage--; cosa_net_close()
725 spin_unlock_irqrestore(&chan->cosa->lock, flags); cosa_net_close()
733 * the cosa->bouncebuf pre-allocated. cosa_net_setup_rx()
758 chan->netdev->stats.rx_bytes += chan->cosa->rxsize; cosa_net_rx_done()
789 struct cosa_data *cosa = chan->cosa; cosa_read()
792 if (!(cosa->firmware_status & COSA_FW_START)) { cosa_read()
794 cosa->name, cosa->firmware_status); cosa_read()
808 spin_lock_irqsave(&cosa->lock, flags); cosa_read()
812 spin_unlock_irqrestore(&cosa->lock, flags); cosa_read()
814 spin_lock_irqsave(&cosa->lock, flags); cosa_read()
819 spin_unlock_irqrestore(&cosa->lock, flags); cosa_read()
828 spin_unlock_irqrestore(&cosa->lock, flags); cosa_read()
863 struct cosa_data *cosa = chan->cosa; cosa_write()
867 if (!(cosa->firmware_status & COSA_FW_START)) { cosa_write()
869 cosa->name, cosa->firmware_status); cosa_write()
892 spin_lock_irqsave(&cosa->lock, flags); cosa_write()
896 spin_unlock_irqrestore(&cosa->lock, flags); cosa_write()
898 spin_lock_irqsave(&cosa->lock, flags); cosa_write()
904 spin_unlock_irqrestore(&cosa->lock, flags); cosa_write()
912 spin_unlock_irqrestore(&cosa->lock, flags); cosa_write()
936 struct cosa_data *cosa; cosa_open()
948 cosa = cosa_cards+n; cosa_open()
951 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) { cosa_open()
955 chan = cosa->chan + n; cosa_open()
959 spin_lock_irqsave(&cosa->lock, flags); cosa_open()
962 spin_unlock_irqrestore(&cosa->lock, flags); cosa_open()
966 cosa->usage++; cosa_open()
972 spin_unlock_irqrestore(&cosa->lock, flags); cosa_open()
981 struct cosa_data *cosa; cosa_release()
984 cosa = channel->cosa; cosa_release()
985 spin_lock_irqsave(&cosa->lock, flags); cosa_release()
986 cosa->usage--; cosa_release()
988 spin_unlock_irqrestore(&cosa->lock, flags); cosa_release()
1012 static inline int cosa_reset(struct cosa_data *cosa) cosa_reset()
1015 if (cosa->usage > 1) cosa_reset()
1016 pr_info("cosa%d: WARNING: reset requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa_reset()
1017 cosa->num, cosa->usage); cosa_reset()
1018 cosa->firmware_status &= ~(COSA_FW_RESET|COSA_FW_START); cosa_reset()
1019 if (cosa_reset_and_read_id(cosa, idstring) < 0) { cosa_reset()
1020 pr_notice("cosa%d: reset failed\n", cosa->num); cosa_reset()
1023 pr_info("cosa%d: resetting device: %s\n", cosa->num, idstring); cosa_reset()
1024 cosa->firmware_status |= COSA_FW_RESET;
1029 static inline int cosa_download(struct cosa_data *cosa, void __user *arg) cosa_download()
1034 if (cosa->usage > 1) cosa_download()
1035 pr_info("%s: WARNING: download of microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa_download()
1036 cosa->name, cosa->usage); cosa_download()
1037 if (!(cosa->firmware_status & COSA_FW_RESET)) { cosa_download()
1039 cosa->name, cosa->firmware_status); cosa_download()
1053 cosa->firmware_status &= ~(COSA_FW_RESET|COSA_FW_DOWNLOAD); cosa_download()
1055 i = download(cosa, d.code, d.len, d.addr); cosa_download()
1057 pr_notice("cosa%d: microcode download failed: %d\n", cosa_download()
1058 cosa->num, i); cosa_download()
1061 pr_info("cosa%d: downloading microcode - 0x%04x bytes at 0x%04x\n", cosa_download()
1062 cosa->num, d.len, d.addr); cosa_download()
1063 cosa->firmware_status |= COSA_FW_RESET|COSA_FW_DOWNLOAD;
1068 static inline int cosa_readmem(struct cosa_data *cosa, void __user *arg) cosa_readmem()
1073 if (cosa->usage > 1) cosa_readmem()
1074 pr_info("cosa%d: WARNING: readmem requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa_readmem()
1075 cosa->num, cosa->usage); cosa_readmem()
1076 if (!(cosa->firmware_status & COSA_FW_RESET)) { cosa_readmem()
1078 cosa->name, cosa->firmware_status); cosa_readmem()
1086 cosa->firmware_status &= ~COSA_FW_RESET; cosa_readmem()
1088 i = readmem(cosa, d.code, d.len, d.addr); cosa_readmem()
1090 pr_notice("cosa%d: reading memory failed: %d\n", cosa->num, i); cosa_readmem()
1093 pr_info("cosa%d: reading card memory - 0x%04x bytes at 0x%04x\n", cosa_readmem()
1094 cosa->num, d.len, d.addr); cosa_readmem()
1095 cosa->firmware_status |= COSA_FW_RESET;
1100 static inline int cosa_start(struct cosa_data *cosa, int address) cosa_start()
1104 if (cosa->usage > 1) cosa_start()
1105 pr_info("cosa%d: WARNING: start microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa_start()
1106 cosa->num, cosa->usage); cosa_start()
1108 if ((cosa->firmware_status & (COSA_FW_RESET|COSA_FW_DOWNLOAD)) cosa_start()
1111 cosa->name, cosa->firmware_status); cosa_start()
1114 cosa->firmware_status &= ~COSA_FW_RESET; cosa_start()
1115 if ((i=startmicrocode(cosa, address)) < 0) { cosa_start()
1116 pr_notice("cosa%d: start microcode at 0x%04x failed: %d\n", cosa_start()
1117 cosa->num, address, i); cosa_start()
1120 pr_info("cosa%d: starting microcode at 0x%04x\n", cosa->num, address); cosa_start()
1121 cosa->startaddr = address; cosa_start()
1122 cosa->firmware_status |= COSA_FW_START;
1127 static inline int cosa_getidstr(struct cosa_data *cosa, char __user *string) cosa_getidstr()
1129 int l = strlen(cosa->id_string)+1; cosa_getidstr()
1130 if (copy_to_user(string, cosa->id_string, l)) cosa_getidstr()
1136 static inline int cosa_gettype(struct cosa_data *cosa, char __user *string) cosa_gettype()
1138 int l = strlen(cosa->type)+1; cosa_gettype()
1139 if (copy_to_user(string, cosa->type, l)) cosa_gettype()
1144 static int cosa_ioctl_common(struct cosa_data *cosa, cosa_ioctl_common()
1152 return cosa_reset(cosa); cosa_ioctl_common()
1156 return cosa_start(cosa, arg); cosa_ioctl_common()
1161 return cosa_download(cosa, argp); cosa_ioctl_common()
1165 return cosa_readmem(cosa, argp); cosa_ioctl_common()
1167 return cosa_gettype(cosa, argp); cosa_ioctl_common()
1169 return cosa_getidstr(cosa, argp); cosa_ioctl_common()
1173 return cosa->nchannels; cosa_ioctl_common()
1177 if (is_8bit(cosa)) cosa_ioctl_common()
1181 cosa->busmaster = arg; cosa_ioctl_common()
1184 return cosa->busmaster; cosa_ioctl_common()
1193 rv = cosa_ioctl_common(chan->cosa, chan, cmd, cosa_net_ioctl()
1204 struct cosa_data *cosa; cosa_chardev_ioctl()
1208 cosa = channel->cosa; cosa_chardev_ioctl()
1209 ret = cosa_ioctl_common(cosa, channel, cmd, arg); cosa_chardev_ioctl()
1224 struct cosa_data *cosa = chan->cosa; cosa_enable_rx()
1226 if (!test_and_set_bit(chan->num, &cosa->rxbitmap)) cosa_disable_rx()
1227 put_driver_status(cosa); cosa_disable_rx()
1232 struct cosa_data *cosa = chan->cosa; cosa_disable_rx()
1234 if (test_and_clear_bit(chan->num, &cosa->rxbitmap))
1235 put_driver_status(cosa);
1246 struct cosa_data *cosa = chan->cosa; cosa_start_tx()
1251 pr_info("cosa%dc%d: starting tx(0x%x)", cosa_start_tx()
1252 chan->cosa->num, chan->num, len); cosa_start_tx()
1257 spin_lock_irqsave(&cosa->lock, flags); cosa_start_tx()
1262 spin_unlock_irqrestore(&cosa->lock, flags); cosa_start_tx()
1265 set_bit(chan->num, &cosa->txbitmap); cosa_start_tx()
1266 put_driver_status(cosa);
1271 static void put_driver_status(struct cosa_data *cosa) put_driver_status()
1276 spin_lock_irqsave(&cosa->lock, flags); put_driver_status()
1278 status = (cosa->rxbitmap ? DRIVER_RX_READY : 0) put_driver_status()
1279 | (cosa->txbitmap ? DRIVER_TX_READY : 0) put_driver_status()
1280 | (cosa->txbitmap? ~(cosa->txbitmap<<DRIVER_TXMAP_SHIFT) put_driver_status()
1282 if (!cosa->rxtx) { put_driver_status()
1283 if (cosa->rxbitmap|cosa->txbitmap) { put_driver_status()
1284 if (!cosa->enabled) { put_driver_status()
1285 cosa_putstatus(cosa, SR_RX_INT_ENA); put_driver_status()
1287 debug_status_out(cosa, SR_RX_INT_ENA); put_driver_status()
1289 cosa->enabled = 1; put_driver_status()
1291 } else if (cosa->enabled) { put_driver_status()
1292 cosa->enabled = 0; put_driver_status()
1293 cosa_putstatus(cosa, 0); put_driver_status()
1295 debug_status_out(cosa, 0); put_driver_status()
1298 cosa_putdata8(cosa, status); put_driver_status()
1300 debug_data_cmd(cosa, status); put_driver_status()
1303 spin_unlock_irqrestore(&cosa->lock, flags); put_driver_status_nolock() argument
1306 static void put_driver_status_nolock(struct cosa_data *cosa) put_driver_status_nolock()
1310 status = (cosa->rxbitmap ? DRIVER_RX_READY : 0) put_driver_status_nolock()
1311 | (cosa->txbitmap ? DRIVER_TX_READY : 0) put_driver_status_nolock()
1312 | (cosa->txbitmap? ~(cosa->txbitmap<<DRIVER_TXMAP_SHIFT) put_driver_status_nolock()
1315 if (cosa->rxbitmap|cosa->txbitmap) { put_driver_status_nolock()
1316 cosa_putstatus(cosa, SR_RX_INT_ENA); put_driver_status_nolock()
1318 debug_status_out(cosa, SR_RX_INT_ENA); put_driver_status_nolock()
1320 cosa->enabled = 1; put_driver_status_nolock()
1322 cosa_putstatus(cosa, 0); put_driver_status_nolock()
1324 debug_status_out(cosa, 0); put_driver_status_nolock()
1326 cosa->enabled = 0; put_driver_status_nolock()
1328 cosa_putdata8(cosa, status); put_driver_status_nolock()
1330 debug_data_cmd(cosa, status);
1339 static void cosa_kick(struct cosa_data *cosa) cosa_kick()
1344 if (test_bit(RXBIT, &cosa->rxtx)) cosa_kick()
1346 if (test_bit(TXBIT, &cosa->rxtx)) cosa_kick()
1349 pr_info("%s: %s timeout - restarting\n", cosa->name, s); cosa_kick()
1350 spin_lock_irqsave(&cosa->lock, flags); cosa_kick()
1351 cosa->rxtx = 0; cosa_kick()
1354 disable_dma(cosa->dma); cosa_kick()
1355 clear_dma_ff(cosa->dma); cosa_kick()
1360 cosa_putstatus(cosa, 0); cosa_kick()
1362 (void) cosa_getdata8(cosa); cosa_kick()
1364 cosa_putdata8(cosa, 0); cosa_kick()
1366 put_driver_status_nolock(cosa);
1367 spin_unlock_irqrestore(&cosa->lock, flags);
1402 static int download(struct cosa_data *cosa, const char __user *microcode, int length, int address) download()
1406 if (put_wait_data(cosa, 'w') == -1) return -1; download()
1407 if ((i=get_wait_data(cosa)) != 'w') { printk("dnld: 0x%04x\n",i); return -2;} download()
1408 if (get_wait_data(cosa) != '=') return -3; download()
1410 if (puthexnumber(cosa, address) < 0) return -4; download()
1411 if (put_wait_data(cosa, ' ') == -1) return -10; download()
1412 if (get_wait_data(cosa) != ' ') return -11; download()
1413 if (get_wait_data(cosa) != '=') return -12; download()
1415 if (puthexnumber(cosa, address+length-1) < 0) return -13; download()
1416 if (put_wait_data(cosa, ' ') == -1) return -18; download()
1417 if (get_wait_data(cosa) != ' ') return -19; download()
1427 if (put_wait_data(cosa, c) == -1) download()
1432 if (get_wait_data(cosa) != '\r') return -21; download()
1433 if (get_wait_data(cosa) != '\n') return -22; download()
1434 if (get_wait_data(cosa) != '.') return -23; download()
1436 printk(KERN_DEBUG "cosa%d: download completed.\n", cosa->num);
1447 static int startmicrocode(struct cosa_data *cosa, int address) startmicrocode()
1449 if (put_wait_data(cosa, 'g') == -1) return -1; startmicrocode()
1450 if (get_wait_data(cosa) != 'g') return -2; startmicrocode()
1451 if (get_wait_data(cosa) != '=') return -3; startmicrocode()
1453 if (puthexnumber(cosa, address) < 0) return -4; startmicrocode()
1454 if (put_wait_data(cosa, '\r') == -1) return -5; startmicrocode()
1456 if (get_wait_data(cosa) != '\r') return -6; startmicrocode()
1457 if (get_wait_data(cosa) != '\r') return -7; startmicrocode()
1458 if (get_wait_data(cosa) != '\n') return -8; startmicrocode()
1459 if (get_wait_data(cosa) != '\r') return -9; startmicrocode()
1460 if (get_wait_data(cosa) != '\n') return -10; startmicrocode()
1462 printk(KERN_DEBUG "cosa%d: microcode started\n", cosa->num);
1476 static int readmem(struct cosa_data *cosa, char __user *microcode, int length, int address) readmem()
1478 if (put_wait_data(cosa, 'r') == -1) return -1; readmem()
1479 if ((get_wait_data(cosa)) != 'r') return -2; readmem()
1480 if ((get_wait_data(cosa)) != '=') return -3; readmem()
1482 if (puthexnumber(cosa, address) < 0) return -4; readmem()
1483 if (put_wait_data(cosa, ' ') == -1) return -5; readmem()
1484 if (get_wait_data(cosa) != ' ') return -6; readmem()
1485 if (get_wait_data(cosa) != '=') return -7; readmem()
1487 if (puthexnumber(cosa, address+length-1) < 0) return -8; readmem()
1488 if (put_wait_data(cosa, ' ') == -1) return -9; readmem()
1489 if (get_wait_data(cosa) != ' ') return -10; readmem()
1494 if ((i=get_wait_data(cosa)) == -1) { readmem()
1508 if (get_wait_data(cosa) != '\r') return -21; readmem()
1509 if (get_wait_data(cosa) != '\n') return -22; readmem()
1510 if (get_wait_data(cosa) != '.') return -23; readmem()
1512 printk(KERN_DEBUG "cosa%d: readmem completed.\n", cosa->num);
1521 static int cosa_reset_and_read_id(struct cosa_data *cosa, char *idstring) cosa_reset_and_read_id()
1526 cosa_putstatus(cosa, 0); cosa_reset_and_read_id()
1527 cosa_getdata8(cosa); cosa_reset_and_read_id()
1528 cosa_putstatus(cosa, SR_RST); cosa_reset_and_read_id()
1531 cosa_putstatus(cosa, 0); cosa_reset_and_read_id()
1542 if ((curr = get_wait_data(cosa)) == -1) { cosa_reset_and_read_id()
1565 static int get_wait_data(struct cosa_data *cosa) get_wait_data()
1571 if (cosa_getstatus(cosa) & SR_RX_RDY) { get_wait_data()
1573 r = cosa_getdata8(cosa); get_wait_data()
1584 cosa_getstatus(cosa));
1593 static int put_wait_data(struct cosa_data *cosa, int data) put_wait_data()
1598 if (cosa_getstatus(cosa) & SR_TX_RDY) { put_wait_data()
1599 cosa_putdata8(cosa, data); put_wait_data()
1610 pr_info("cosa%d: timeout in put_wait_data (status 0x%x)\n",
1611 cosa->num, cosa_getstatus(cosa));
1621 static int puthexnumber(struct cosa_data *cosa, int number) puthexnumber()
1629 if (put_wait_data(cosa, temp[i]) == -1) { puthexnumber()
1630 pr_notice("cosa%d: puthexnumber failed to write byte %d\n", puthexnumber()
1631 cosa->num, i); puthexnumber()
1634 if (get_wait_data(cosa) != temp[i]) { puthexnumber()
1635 pr_notice("cosa%d: puthexhumber failed to read echo of byte %d\n", puthexnumber()
1636 cosa->num, i);
1678 static inline void tx_interrupt(struct cosa_data *cosa, int status) tx_interrupt()
1682 pr_info("cosa%d: SR_DOWN_REQUEST status=0x%04x\n", cosa->num, status); tx_interrupt()
1684 spin_lock_irqsave(&cosa->lock, flags); tx_interrupt()
1685 set_bit(TXBIT, &cosa->rxtx); tx_interrupt()
1686 if (!test_bit(IRQBIT, &cosa->rxtx)) { tx_interrupt()
1689 if (!cosa->txbitmap) { tx_interrupt()
1691 cosa->name); tx_interrupt()
1692 put_driver_status_nolock(cosa); tx_interrupt()
1693 clear_bit(TXBIT, &cosa->rxtx); tx_interrupt()
1694 spin_unlock_irqrestore(&cosa->lock, flags); tx_interrupt()
1698 cosa->txchan++; tx_interrupt()
1700 if (cosa->txchan >= cosa->nchannels) tx_interrupt()
1701 cosa->txchan = 0; tx_interrupt()
1702 if (!(cosa->txbitmap & (1<<cosa->txchan))) tx_interrupt()
1704 if (~status & (1 << (cosa->txchan+DRIVER_TXMAP_SHIFT))) tx_interrupt()
1707 if (i > cosa->nchannels) { tx_interrupt()
1712 cosa->name, cosa->txchan); tx_interrupt()
1718 cosa->txsize = cosa->chan[cosa->txchan].txsize; tx_interrupt()
1719 if (cosa_dma_able(cosa->chan+cosa->txchan, tx_interrupt()
1720 cosa->chan[cosa->txchan].txbuf, cosa->txsize)) { tx_interrupt()
1721 cosa->txbuf = cosa->chan[cosa->txchan].txbuf; tx_interrupt()
1723 memcpy(cosa->bouncebuf, cosa->chan[cosa->txchan].txbuf, tx_interrupt()
1724 cosa->txsize); tx_interrupt()
1725 cosa->txbuf = cosa->bouncebuf; tx_interrupt()
1729 if (is_8bit(cosa)) { tx_interrupt()
1730 if (!test_bit(IRQBIT, &cosa->rxtx)) { tx_interrupt()
1731 cosa_putstatus(cosa, SR_TX_INT_ENA); tx_interrupt()
1732 cosa_putdata8(cosa, ((cosa->txchan << 5) & 0xe0)| tx_interrupt()
1733 ((cosa->txsize >> 8) & 0x1f)); tx_interrupt()
1735 debug_status_out(cosa, SR_TX_INT_ENA); tx_interrupt()
1736 debug_data_out(cosa, ((cosa->txchan << 5) & 0xe0)| tx_interrupt()
1737 ((cosa->txsize >> 8) & 0x1f)); tx_interrupt()
1738 debug_data_in(cosa, cosa_getdata8(cosa)); tx_interrupt()
1740 cosa_getdata8(cosa); tx_interrupt()
1742 set_bit(IRQBIT, &cosa->rxtx); tx_interrupt()
1743 spin_unlock_irqrestore(&cosa->lock, flags); tx_interrupt()
1746 clear_bit(IRQBIT, &cosa->rxtx); tx_interrupt()
1747 cosa_putstatus(cosa, 0); tx_interrupt()
1748 cosa_putdata8(cosa, cosa->txsize&0xff); tx_interrupt()
1750 debug_status_out(cosa, 0); tx_interrupt()
1751 debug_data_out(cosa, cosa->txsize&0xff); tx_interrupt()
1755 cosa_putstatus(cosa, SR_TX_INT_ENA); tx_interrupt()
1756 cosa_putdata16(cosa, ((cosa->txchan<<13) & 0xe000) tx_interrupt()
1757 | (cosa->txsize & 0x1fff)); tx_interrupt()
1759 debug_status_out(cosa, SR_TX_INT_ENA); tx_interrupt()
1760 debug_data_out(cosa, ((cosa->txchan<<13) & 0xe000) tx_interrupt()
1761 | (cosa->txsize & 0x1fff)); tx_interrupt()
1762 debug_data_in(cosa, cosa_getdata8(cosa)); tx_interrupt()
1763 debug_status_out(cosa, 0); tx_interrupt()
1765 cosa_getdata8(cosa); tx_interrupt()
1767 cosa_putstatus(cosa, 0); tx_interrupt()
1770 if (cosa->busmaster) { tx_interrupt()
1771 unsigned long addr = virt_to_bus(cosa->txbuf); tx_interrupt()
1774 while (!(cosa_getstatus(cosa)&SR_TX_RDY)) { tx_interrupt()
1779 pr_info("status %x\n", cosa_getstatus(cosa)); tx_interrupt()
1781 cosa_putdata16(cosa, (addr >> 16)&0xffff); tx_interrupt()
1784 while (!(cosa_getstatus(cosa)&SR_TX_RDY)) { tx_interrupt()
1790 cosa_putdata16(cosa, addr &0xffff); tx_interrupt()
1792 set_dma_mode(cosa->dma, DMA_MODE_CASCADE); tx_interrupt()
1793 enable_dma(cosa->dma); tx_interrupt()
1798 disable_dma(cosa->dma); tx_interrupt()
1799 clear_dma_ff(cosa->dma); tx_interrupt()
1800 set_dma_mode(cosa->dma, DMA_MODE_WRITE); tx_interrupt()
1801 set_dma_addr(cosa->dma, virt_to_bus(cosa->txbuf)); tx_interrupt()
1802 set_dma_count(cosa->dma, cosa->txsize); tx_interrupt()
1803 enable_dma(cosa->dma); tx_interrupt()
1806 cosa_putstatus(cosa, SR_TX_DMA_ENA|SR_USR_INT_ENA); rx_interrupt()
1808 debug_status_out(cosa, SR_TX_DMA_ENA|SR_USR_INT_ENA); rx_interrupt()
1810 spin_unlock_irqrestore(&cosa->lock, flags); rx_interrupt()
1813 static inline void rx_interrupt(struct cosa_data *cosa, int status) rx_interrupt()
1817 pr_info("cosa%d: SR_UP_REQUEST\n", cosa->num); rx_interrupt()
1820 spin_lock_irqsave(&cosa->lock, flags); rx_interrupt()
1821 set_bit(RXBIT, &cosa->rxtx); rx_interrupt()
1823 if (is_8bit(cosa)) { rx_interrupt()
1824 if (!test_bit(IRQBIT, &cosa->rxtx)) { rx_interrupt()
1825 set_bit(IRQBIT, &cosa->rxtx); rx_interrupt()
1826 put_driver_status_nolock(cosa); rx_interrupt()
1827 cosa->rxsize = cosa_getdata8(cosa) <<8; rx_interrupt()
1829 debug_data_in(cosa, cosa->rxsize >> 8); rx_interrupt()
1831 spin_unlock_irqrestore(&cosa->lock, flags); rx_interrupt()
1834 clear_bit(IRQBIT, &cosa->rxtx); rx_interrupt()
1835 cosa->rxsize |= cosa_getdata8(cosa) & 0xff; rx_interrupt()
1837 debug_data_in(cosa, cosa->rxsize & 0xff); rx_interrupt()
1840 pr_info("cosa%d: receive rxsize = (0x%04x)\n", rx_interrupt()
1841 cosa->num, cosa->rxsize); rx_interrupt()
1845 cosa->rxsize = cosa_getdata16(cosa); rx_interrupt()
1847 debug_data_in(cosa, cosa->rxsize); rx_interrupt()
1850 pr_info("cosa%d: receive rxsize = (0x%04x)\n", rx_interrupt()
1851 cosa->num, cosa->rxsize); rx_interrupt()
1854 if (((cosa->rxsize & 0xe000) >> 13) >= cosa->nchannels) { rx_interrupt()
1856 cosa->name, cosa->rxsize); rx_interrupt()
1857 spin_unlock_irqrestore(&cosa->lock, flags); rx_interrupt()
1860 cosa->rxchan = cosa->chan + ((cosa->rxsize & 0xe000) >> 13); rx_interrupt()
1861 cosa->rxsize &= 0x1fff; rx_interrupt()
1862 spin_unlock_irqrestore(&cosa->lock, flags); rx_interrupt()
1864 cosa->rxbuf = NULL; rx_interrupt()
1865 if (cosa->rxchan->setup_rx) rx_interrupt()
1866 cosa->rxbuf = cosa->rxchan->setup_rx(cosa->rxchan, cosa->rxsize); rx_interrupt()
1868 if (!cosa->rxbuf) { rx_interrupt()
1870 pr_info("cosa%d: rejecting packet on channel %d\n", rx_interrupt()
1871 cosa->num, cosa->rxchan->num); rx_interrupt()
1872 cosa->rxbuf = cosa->bouncebuf; rx_interrupt()
1877 disable_dma(cosa->dma); rx_interrupt()
1878 clear_dma_ff(cosa->dma); rx_interrupt()
1879 set_dma_mode(cosa->dma, DMA_MODE_READ); rx_interrupt()
1880 if (cosa_dma_able(cosa->rxchan, cosa->rxbuf, cosa->rxsize & 0x1fff)) { rx_interrupt()
1881 set_dma_addr(cosa->dma, virt_to_bus(cosa->rxbuf)); rx_interrupt()
1883 set_dma_addr(cosa->dma, virt_to_bus(cosa->bouncebuf)); rx_interrupt()
1885 set_dma_count(cosa->dma, (cosa->rxsize&0x1fff)); rx_interrupt()
1886 enable_dma(cosa->dma); rx_interrupt()
1888 spin_lock_irqsave(&cosa->lock, flags); rx_interrupt()
1889 cosa_putstatus(cosa, SR_RX_DMA_ENA|SR_USR_INT_ENA); rx_interrupt()
1890 if (!is_8bit(cosa) && (status & SR_TX_RDY)) rx_interrupt()
1891 cosa_putdata8(cosa, DRIVER_RX_READY); rx_interrupt()
1893 debug_status_out(cosa, SR_RX_DMA_ENA|SR_USR_INT_ENA); eot_interrupt()
1894 if (!is_8bit(cosa) && (status & SR_TX_RDY)) eot_interrupt() argument
1895 debug_data_cmd(cosa, DRIVER_RX_READY); eot_interrupt()
1897 spin_unlock_irqrestore(&cosa->lock, flags); eot_interrupt()
1900 static inline void eot_interrupt(struct cosa_data *cosa, int status) eot_interrupt()
1903 spin_lock_irqsave(&cosa->lock, flags); eot_interrupt()
1905 disable_dma(cosa->dma); eot_interrupt()
1906 clear_dma_ff(cosa->dma); eot_interrupt()
1908 if (test_bit(TXBIT, &cosa->rxtx)) { eot_interrupt()
1909 struct channel_data *chan = cosa->chan+cosa->txchan; eot_interrupt()
1911 if (chan->tx_done(chan, cosa->txsize)) eot_interrupt()
1912 clear_bit(chan->num, &cosa->txbitmap); eot_interrupt()
1913 } else if (test_bit(RXBIT, &cosa->rxtx)) { eot_interrupt()
1917 pr_info("cosa%dc%d: done rx(0x%x)", eot_interrupt()
1918 cosa->num, cosa->rxchan->num, cosa->rxsize); eot_interrupt()
1919 for (i=0; i<cosa->rxsize; i++) eot_interrupt()
1920 pr_cont(" %02x", cosa->rxbuf[i]&0xff); eot_interrupt()
1925 if (cosa->rxbuf == cosa->bouncebuf) eot_interrupt()
1927 if (!cosa_dma_able(cosa->rxchan, cosa->rxbuf, cosa->rxsize)) eot_interrupt()
1928 memcpy(cosa->rxbuf, cosa->bouncebuf, cosa->rxsize); eot_interrupt()
1929 if (cosa->rxchan->rx_done) eot_interrupt()
1930 if (cosa->rxchan->rx_done(cosa->rxchan)) eot_interrupt()
1931 clear_bit(cosa->rxchan->num, &cosa->rxbitmap); eot_interrupt()
1933 pr_notice("cosa%d: unexpected EOT interrupt\n", cosa->num); eot_interrupt()
1942 cosa->rxtx = 0; cosa_interrupt()
1943 put_driver_status_nolock(cosa); cosa_interrupt()
1944 spin_unlock_irqrestore(&cosa->lock, flags); cosa_interrupt()
1951 struct cosa_data *cosa = cosa_; cosa_interrupt()
1953 status = cosa_getstatus(cosa); cosa_interrupt()
1955 pr_info("cosa%d: got IRQ, status 0x%02x\n", cosa->num, status & 0xff); cosa_interrupt()
1958 debug_status_in(cosa, status); cosa_interrupt()
1962 tx_interrupt(cosa, status); cosa_interrupt()
1965 rx_interrupt(cosa, status); cosa_interrupt()
1968 eot_interrupt(cosa, status); cosa_interrupt()
1976 pr_info("cosa%d: unknown status 0x%02x in IRQ after %d retries\n", cosa_interrupt()
1977 cosa->num, status & 0xff, count); cosa_interrupt()
1982 cosa->name, count);
1984 pr_info("%s: returning from IRQ\n", cosa->name);
1999 static void debug_status_in(struct cosa_data *cosa, int status) debug_status_in()
2017 cosa->name, debug_status_out()
2025 static void debug_status_out(struct cosa_data *cosa, int status) debug_status_out()
2028 cosa->name, debug_status_out()
2038 static void debug_data_in(struct cosa_data *cosa, int data) debug_data_out()
2040 pr_info("%s: IO: data -> 0x%04x\n", cosa->name, data); debug_data_cmd()
2043 static void debug_data_out(struct cosa_data *cosa, int data) debug_data_cmd()
2045 pr_info("%s: IO: data <- 0x%04x\n", cosa->name, data); debug_data_cmd()
2048 static void debug_data_cmd(struct cosa_data *cosa, int data)
2051 cosa->name, data,
788 struct cosa_data *cosa = chan->cosa; cosa_read() local
862 struct cosa_data *cosa = chan->cosa; cosa_write() local
935 struct cosa_data *cosa; cosa_open() local
980 struct cosa_data *cosa; cosa_release() local
1010 cosa_reset(struct cosa_data *cosa) cosa_reset() argument
1027 cosa_download(struct cosa_data *cosa, void __user *arg) cosa_download() argument
1066 cosa_readmem(struct cosa_data *cosa, void __user *arg) cosa_readmem() argument
1098 cosa_start(struct cosa_data *cosa, int address) cosa_start() argument
1125 cosa_getidstr(struct cosa_data *cosa, char __user *string) cosa_getidstr() argument
1134 cosa_gettype(struct cosa_data *cosa, char __user *string) cosa_gettype() argument
1142 cosa_ioctl_common(struct cosa_data *cosa, struct channel_data *channel, unsigned int cmd, unsigned long arg) cosa_ioctl_common() argument
1202 struct cosa_data *cosa; cosa_chardev_ioctl() local
1221 struct cosa_data *cosa = chan->cosa; cosa_enable_rx() local
1229 struct cosa_data *cosa = chan->cosa; cosa_disable_rx() local
1243 struct cosa_data *cosa = chan->cosa; cosa_start_tx() local
1268 put_driver_status(struct cosa_data *cosa) put_driver_status() argument
1336 cosa_kick(struct cosa_data *cosa) cosa_kick() argument
1398 download(struct cosa_data *cosa, const char __user *microcode, int length, int address) download() argument
1443 startmicrocode(struct cosa_data *cosa, int address) startmicrocode() argument
1472 readmem(struct cosa_data *cosa, char __user *microcode, int length, int address) readmem() argument
1517 cosa_reset_and_read_id(struct cosa_data *cosa, char *idstring) cosa_reset_and_read_id() argument
1560 get_wait_data(struct cosa_data *cosa) get_wait_data() argument
1588 put_wait_data(struct cosa_data *cosa, int data) put_wait_data() argument
1616 puthexnumber(struct cosa_data *cosa, int number) puthexnumber() argument
1672 tx_interrupt(struct cosa_data *cosa, int status) tx_interrupt() argument
1807 rx_interrupt(struct cosa_data *cosa, int status) rx_interrupt() argument
1945 struct cosa_data *cosa = cosa_; cosa_interrupt() local
1992 debug_status_in(struct cosa_data *cosa, int status) debug_status_in() argument
2018 debug_status_out(struct cosa_data *cosa, int status) debug_status_out() argument
2031 debug_data_in(struct cosa_data *cosa, int data) debug_data_in() argument
2036 debug_data_out(struct cosa_data *cosa, int data) debug_data_out() argument
2041 debug_data_cmd(struct cosa_data *cosa, int data) debug_data_cmd() argument
H A DMakefile18 obj-$(CONFIG_COSA) += cosa.o
H A Dcosa.h1 /* $Id: cosa.h,v 1.6 1999/01/06 14:02:44 kas Exp $ */
90 /* Read the device type (one of "srp", "cosa", and "cosa8" for now) */
/linux-4.1.27/drivers/staging/rtl8723au/include/
H A Drtl8723a_dm.h115 u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */
H A Dodm.h488 u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */
/linux-4.1.27/drivers/staging/rtl8192u/
H A Dr8192U_dm.c269 pra->ping_rssi_ratr = 0x0000000d;/* cosa add for test */ init_rate_adaptive()
276 pra->ping_rssi_ratr = 0x0000000d;/* cosa add for test */ init_rate_adaptive()
340 /* cosa add for test */ dm_check_rate_adaptive()
377 /* cosa add for test */ dm_check_rate_adaptive()
1440 /*priv->CCKTxPowerAdjustCntNotCh14++; cosa add for debug.*/ dm_CCKTxPowerAdjust_ThermalMeter()
1526 /*cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);*/ dm_restore_dynamic_mechanism_state()
H A Dr8192U_core.c3721 //cosa add 04292008 to record the sequence number rtl8192_process_phyinfo()
3859 //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. rtl8192_process_phyinfo()
3926 // 2007/7/19 01:09, by cosa.
/linux-4.1.27/drivers/staging/rtl8192u/ieee80211/
H A Dieee80211.h884 bool bPacketBeacon; //cosa add for rssi
885 bool bToSelfBA; //cosa add for rssi
886 char cck_adc_pwdb[4]; //cosa add for rx path selection
H A Drtl819x_HTProc.c36 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; //cosa 03202008
/linux-4.1.27/drivers/staging/rtl8188eu/include/
H A Dodm.h645 u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */
/linux-4.1.27/drivers/staging/rtl8723au/hal/
H A DHalDMOutSrc8723A_CE.c47 pdmpriv->TXPowerTrackingCallbackCnt++; /* cosa add for debug */ odm_TXPowerTrackingCallback_ThermalMeter_92C()
/linux-4.1.27/drivers/net/wireless/rtlwifi/rtl8192de/
H A Dphy.c1386 "cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", _rtl92d_phy_switch_rf_setting()
2683 RTPRINT(rtlpriv, FINIT, INIT_IQK, "cosa PHY_LCK ver=2\n"); _rtl92d_phy_lc_calibrate()

Completed in 992 milliseconds