Lines Matching full:card
31 static inline void softing_set_reset_dpram(struct softing *card) in softing_set_reset_dpram() argument
33 if (card->pdat->generation >= 2) { in softing_set_reset_dpram()
34 spin_lock_bh(&card->spin); in softing_set_reset_dpram()
35 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) & ~1, in softing_set_reset_dpram()
36 &card->dpram[DPRAM_V2_RESET]); in softing_set_reset_dpram()
37 spin_unlock_bh(&card->spin); in softing_set_reset_dpram()
41 static inline void softing_clr_reset_dpram(struct softing *card) in softing_clr_reset_dpram() argument
43 if (card->pdat->generation >= 2) { in softing_clr_reset_dpram()
44 spin_lock_bh(&card->spin); in softing_clr_reset_dpram()
45 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) | 1, in softing_clr_reset_dpram()
46 &card->dpram[DPRAM_V2_RESET]); in softing_clr_reset_dpram()
47 spin_unlock_bh(&card->spin); in softing_clr_reset_dpram()
56 struct softing *card = priv->card; in softing_netdev_start_xmit() local
66 spin_lock(&card->spin); in softing_netdev_start_xmit()
69 if (!card->fw.up || in softing_netdev_start_xmit()
70 (card->tx.pending >= TXMAX) || in softing_netdev_start_xmit()
73 fifo_wr = ioread8(&card->dpram[DPRAM_TX_WR]); in softing_netdev_start_xmit()
74 fifo_rd = ioread8(&card->dpram[DPRAM_TX_RD]); in softing_netdev_start_xmit()
100 memcpy_toio(&card->dpram[DPRAM_TX + DPRAM_TX_SIZE * fifo_wr], in softing_netdev_start_xmit()
104 iowrite8(fifo_wr, &card->dpram[DPRAM_TX_WR]); in softing_netdev_start_xmit()
105 card->tx.last_bus = priv->index; in softing_netdev_start_xmit()
106 ++card->tx.pending; in softing_netdev_start_xmit()
115 spin_unlock(&card->spin); in softing_netdev_start_xmit()
116 if (card->tx.pending >= TXMAX) { in softing_netdev_start_xmit()
118 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_netdev_start_xmit()
119 if (card->net[j]) in softing_netdev_start_xmit()
120 netif_stop_queue(card->net[j]); in softing_netdev_start_xmit()
150 static int softing_handle_1(struct softing *card) in softing_handle_1() argument
164 lost_msg = ioread8(&card->dpram[DPRAM_RX_LOST]); in softing_handle_1()
168 iowrite8(0, &card->dpram[DPRAM_RX_LOST]); in softing_handle_1()
177 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_handle_1()
178 netdev = card->net[j]; in softing_handle_1()
192 fifo_rd = ioread8(&card->dpram[DPRAM_RX_RD]); in softing_handle_1()
193 fifo_wr = ioread8(&card->dpram[DPRAM_RX_WR]); in softing_handle_1()
200 memcpy_fromio(buf, &card->dpram[DPRAM_RX + DPRAM_RX_SIZE*fifo_rd], in softing_handle_1()
204 iowrite8(fifo_rd, &card->dpram[DPRAM_RX_RD]); in softing_handle_1()
209 /* not quite useful, probably the card has got out */ in softing_handle_1()
211 netdev = card->net[0]; in softing_handle_1()
213 netdev = card->net[1]; in softing_handle_1()
239 iowrite8(state, &card->dpram[priv->index ? in softing_handle_1()
243 ktime = softing_raw2ktime(card, tmp_u32); in softing_handle_1()
276 ktime = softing_raw2ktime(card, tmp_u32); in softing_handle_1()
295 if (card->tx.pending) in softing_handle_1()
296 --card->tx.pending; in softing_handle_1()
319 struct softing *card = (struct softing *)dev_id; in softing_irq_thread() local
325 spin_lock_bh(&card->spin); in softing_irq_thread()
326 while (softing_handle_1(card) > 0) { in softing_irq_thread()
327 ++card->irq.svc_count; in softing_irq_thread()
330 spin_unlock_bh(&card->spin); in softing_irq_thread()
332 offset = card->tx.last_bus; in softing_irq_thread()
333 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_irq_thread()
334 if (card->tx.pending >= TXMAX) in softing_irq_thread()
336 netdev = card->net[(j + offset + 1) % card->pdat->nbus]; in softing_irq_thread()
357 struct softing *card = (struct softing *)dev_id; in softing_irq_v2() local
360 ir = ioread8(&card->dpram[DPRAM_V2_IRQ_TOHOST]); in softing_irq_v2()
361 iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]); in softing_irq_v2()
367 struct softing *card = (struct softing *)dev_id; in softing_irq_v1() local
370 ir = ioread8(&card->dpram[DPRAM_IRQ_TOHOST]); in softing_irq_v1()
371 iowrite8(0, &card->dpram[DPRAM_IRQ_TOHOST]); in softing_irq_v1()
421 int softing_enable_irq(struct softing *card, int enable) in softing_enable_irq() argument
425 if (!card->irq.nr) { in softing_enable_irq()
427 } else if (card->irq.requested && !enable) { in softing_enable_irq()
428 free_irq(card->irq.nr, card); in softing_enable_irq()
429 card->irq.requested = 0; in softing_enable_irq()
430 } else if (!card->irq.requested && enable) { in softing_enable_irq()
431 ret = request_threaded_irq(card->irq.nr, in softing_enable_irq()
432 (card->pdat->generation >= 2) ? in softing_enable_irq()
435 dev_name(&card->pdev->dev), card); in softing_enable_irq()
437 dev_alert(&card->pdev->dev, in softing_enable_irq()
439 card->irq.nr); in softing_enable_irq()
442 card->irq.requested = 1; in softing_enable_irq()
447 static void softing_card_shutdown(struct softing *card) in softing_card_shutdown() argument
451 if (mutex_lock_interruptible(&card->fw.lock)) { in softing_card_shutdown()
454 fw_up = card->fw.up; in softing_card_shutdown()
455 card->fw.up = 0; in softing_card_shutdown()
457 if (card->irq.requested && card->irq.nr) { in softing_card_shutdown()
458 free_irq(card->irq.nr, card); in softing_card_shutdown()
459 card->irq.requested = 0; in softing_card_shutdown()
462 if (card->pdat->enable_irq) in softing_card_shutdown()
463 card->pdat->enable_irq(card->pdev, 0); in softing_card_shutdown()
464 softing_set_reset_dpram(card); in softing_card_shutdown()
465 if (card->pdat->reset) in softing_card_shutdown()
466 card->pdat->reset(card->pdev, 1); in softing_card_shutdown()
468 mutex_unlock(&card->fw.lock); in softing_card_shutdown()
471 static int softing_card_boot(struct softing *card) in softing_card_boot() argument
478 if (mutex_lock_interruptible(&card->fw.lock)) in softing_card_boot()
480 if (card->fw.up) { in softing_card_boot()
481 mutex_unlock(&card->fw.lock); in softing_card_boot()
485 if (card->pdat->enable_irq) in softing_card_boot()
486 card->pdat->enable_irq(card->pdev, 1); in softing_card_boot()
487 /* boot card */ in softing_card_boot()
488 softing_set_reset_dpram(card); in softing_card_boot()
489 if (card->pdat->reset) in softing_card_boot()
490 card->pdat->reset(card->pdev, 1); in softing_card_boot()
491 for (j = 0; (j + sizeof(stream)) < card->dpram_size; in softing_card_boot()
494 memcpy_toio(&card->dpram[j], stream, sizeof(stream)); in softing_card_boot()
497 memcpy_fromio(back, &card->dpram[j], sizeof(stream)); in softing_card_boot()
502 dev_alert(&card->pdev->dev, "dpram failed at 0x%04x\n", j); in softing_card_boot()
508 ret = softing_load_fw(card->pdat->boot.fw, card, card->dpram, in softing_card_boot()
509 card->dpram_size, in softing_card_boot()
510 card->pdat->boot.offs - card->pdat->boot.addr); in softing_card_boot()
514 ret = softing_load_fw(card->pdat->load.fw, card, card->dpram, in softing_card_boot()
515 card->dpram_size, in softing_card_boot()
516 card->pdat->load.offs - card->pdat->load.addr); in softing_card_boot()
520 if (card->pdat->reset) in softing_card_boot()
521 card->pdat->reset(card->pdev, 0); in softing_card_boot()
522 softing_clr_reset_dpram(card); in softing_card_boot()
523 ret = softing_bootloader_command(card, 0, "card boot"); in softing_card_boot()
526 ret = softing_load_app_fw(card->pdat->app.fw, card); in softing_card_boot()
530 ret = softing_chip_poweron(card); in softing_card_boot()
534 card->fw.up = 1; in softing_card_boot()
535 mutex_unlock(&card->fw.lock); in softing_card_boot()
538 card->fw.up = 0; in softing_card_boot()
539 if (card->pdat->enable_irq) in softing_card_boot()
540 card->pdat->enable_irq(card->pdev, 0); in softing_card_boot()
541 softing_set_reset_dpram(card); in softing_card_boot()
542 if (card->pdat->reset) in softing_card_boot()
543 card->pdat->reset(card->pdev, 1); in softing_card_boot()
544 mutex_unlock(&card->fw.lock); in softing_card_boot()
574 struct softing *card = priv->card; in store_output() local
583 ret = mutex_lock_interruptible(&card->fw.lock); in store_output()
587 mutex_unlock(&card->fw.lock); in store_output()
591 mutex_unlock(&card->fw.lock); in store_output()
632 static struct net_device *softing_netdev_create(struct softing *card, in softing_netdev_create() argument
640 dev_alert(&card->pdev->dev, "alloc_candev failed\n"); in softing_netdev_create()
645 priv->card = card; in softing_netdev_create()
647 priv->btr_const.brp_max = card->pdat->max_brp; in softing_netdev_create()
648 priv->btr_const.sjw_max = card->pdat->max_sjw; in softing_netdev_create()
653 SET_NETDEV_DEV(netdev, &card->pdev->dev); in softing_netdev_create()
693 struct softing *card = dev_get_drvdata(dev); \
694 return sprintf(buf, "%u\n", card->member); \
702 struct softing *card = dev_get_drvdata(dev); \
703 return sprintf(buf, "%s\n", card->member); \
734 struct softing *card = platform_get_drvdata(pdev); in softing_pdev_remove() local
737 /* first, disable card*/ in softing_pdev_remove()
738 softing_card_shutdown(card); in softing_pdev_remove()
740 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_pdev_remove()
741 if (!card->net[j]) in softing_pdev_remove()
743 softing_netdev_cleanup(card->net[j]); in softing_pdev_remove()
744 card->net[j] = NULL; in softing_pdev_remove()
748 iounmap(card->dpram); in softing_pdev_remove()
749 kfree(card); in softing_pdev_remove()
755 struct softing *card; in softing_pdev_probe() local
766 if (pdat->nbus > ARRAY_SIZE(card->net)) { in softing_pdev_probe()
771 card = kzalloc(sizeof(*card), GFP_KERNEL); in softing_pdev_probe()
772 if (!card) in softing_pdev_probe()
774 card->pdat = pdat; in softing_pdev_probe()
775 card->pdev = pdev; in softing_pdev_probe()
776 platform_set_drvdata(pdev, card); in softing_pdev_probe()
777 mutex_init(&card->fw.lock); in softing_pdev_probe()
778 spin_lock_init(&card->spin); in softing_pdev_probe()
784 card->dpram_phys = pres->start; in softing_pdev_probe()
785 card->dpram_size = resource_size(pres); in softing_pdev_probe()
786 card->dpram = ioremap(card->dpram_phys, card->dpram_size); in softing_pdev_probe()
787 if (!card->dpram) { in softing_pdev_probe()
788 dev_alert(&card->pdev->dev, "dpram ioremap failed\n"); in softing_pdev_probe()
794 card->irq.nr = pres->start; in softing_pdev_probe()
796 /* reset card */ in softing_pdev_probe()
797 ret = softing_card_boot(card); in softing_pdev_probe()
804 card->id.freq = card->pdat->freq; in softing_pdev_probe()
808 dev_alert(&card->pdev->dev, "sysfs failed\n"); in softing_pdev_probe()
812 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_pdev_probe()
813 card->net[j] = netdev = in softing_pdev_probe()
814 softing_netdev_create(card, card->id.chip[j]); in softing_pdev_probe()
821 priv = netdev_priv(card->net[j]); in softing_pdev_probe()
826 card->net[j] = NULL; in softing_pdev_probe()
827 dev_alert(&card->pdev->dev, in softing_pdev_probe()
832 dev_info(&card->pdev->dev, "%s ready.\n", card->pdat->name); in softing_pdev_probe()
836 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { in softing_pdev_probe()
837 if (!card->net[j]) in softing_pdev_probe()
839 softing_netdev_cleanup(card->net[j]); in softing_pdev_probe()
843 softing_card_shutdown(card); in softing_pdev_probe()
845 iounmap(card->dpram); in softing_pdev_probe()
848 kfree(card); in softing_pdev_probe()