diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2009-02-24 19:39:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-02-24 19:39:03 -0500 |
commit | dbf64b10fa5b339d8b6e949f97c0d00750b08ca8 (patch) | |
tree | f3fe30e3d5f52d5a600ef10100e2de1670b54f86 /drivers/net/netxen/netxen_nic_init.c | |
parent | 4da129421f898147235a3e6b40234d789df208b7 (diff) |
netxen: cleanup unused code
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 360 |
1 files changed, 0 insertions, 360 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index ffd37bea1628..688f8807843f 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -55,15 +55,6 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; | |||
55 | static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, | 55 | static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, |
56 | uint32_t ctx, uint32_t ringid); | 56 | uint32_t ctx, uint32_t ringid); |
57 | 57 | ||
58 | #if 0 | ||
59 | static void netxen_nic_locked_write_reg(struct netxen_adapter *adapter, | ||
60 | unsigned long off, int *data) | ||
61 | { | ||
62 | void __iomem *addr = pci_base_offset(adapter, off); | ||
63 | writel(*data, addr); | ||
64 | } | ||
65 | #endif /* 0 */ | ||
66 | |||
67 | static void crb_addr_transform_setup(void) | 58 | static void crb_addr_transform_setup(void) |
68 | { | 59 | { |
69 | crb_addr_transform(XDMA); | 60 | crb_addr_transform(XDMA); |
@@ -399,9 +390,6 @@ static u32 netxen_decode_crb_addr(u32 addr) | |||
399 | 390 | ||
400 | static long rom_max_timeout = 100; | 391 | static long rom_max_timeout = 100; |
401 | static long rom_lock_timeout = 10000; | 392 | static long rom_lock_timeout = 10000; |
402 | #if 0 | ||
403 | static long rom_write_timeout = 700; | ||
404 | #endif | ||
405 | 393 | ||
406 | static int rom_lock(struct netxen_adapter *adapter) | 394 | static int rom_lock(struct netxen_adapter *adapter) |
407 | { | 395 | { |
@@ -452,38 +440,6 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter) | |||
452 | return 0; | 440 | return 0; |
453 | } | 441 | } |
454 | 442 | ||
455 | #if 0 | ||
456 | static int netxen_rom_wren(struct netxen_adapter *adapter) | ||
457 | { | ||
458 | /* Set write enable latch in ROM status register */ | ||
459 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); | ||
460 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, | ||
461 | M25P_INSTR_WREN); | ||
462 | if (netxen_wait_rom_done(adapter)) { | ||
463 | return -1; | ||
464 | } | ||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | static unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter, | ||
469 | unsigned int addr) | ||
470 | { | ||
471 | unsigned int data = 0xdeaddead; | ||
472 | data = netxen_nic_reg_read(adapter, addr); | ||
473 | return data; | ||
474 | } | ||
475 | |||
476 | static int netxen_do_rom_rdsr(struct netxen_adapter *adapter) | ||
477 | { | ||
478 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, | ||
479 | M25P_INSTR_RDSR); | ||
480 | if (netxen_wait_rom_done(adapter)) { | ||
481 | return -1; | ||
482 | } | ||
483 | return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA); | ||
484 | } | ||
485 | #endif | ||
486 | |||
487 | static void netxen_rom_unlock(struct netxen_adapter *adapter) | 443 | static void netxen_rom_unlock(struct netxen_adapter *adapter) |
488 | { | 444 | { |
489 | u32 val; | 445 | u32 val; |
@@ -493,44 +449,6 @@ static void netxen_rom_unlock(struct netxen_adapter *adapter) | |||
493 | 449 | ||
494 | } | 450 | } |
495 | 451 | ||
496 | #if 0 | ||
497 | static int netxen_rom_wip_poll(struct netxen_adapter *adapter) | ||
498 | { | ||
499 | long timeout = 0; | ||
500 | long wip = 1; | ||
501 | int val; | ||
502 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); | ||
503 | while (wip != 0) { | ||
504 | val = netxen_do_rom_rdsr(adapter); | ||
505 | wip = val & 1; | ||
506 | timeout++; | ||
507 | if (timeout > rom_max_timeout) { | ||
508 | return -1; | ||
509 | } | ||
510 | } | ||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static int do_rom_fast_write(struct netxen_adapter *adapter, int addr, | ||
515 | int data) | ||
516 | { | ||
517 | if (netxen_rom_wren(adapter)) { | ||
518 | return -1; | ||
519 | } | ||
520 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_WDATA, data); | ||
521 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); | ||
522 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3); | ||
523 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, | ||
524 | M25P_INSTR_PP); | ||
525 | if (netxen_wait_rom_done(adapter)) { | ||
526 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); | ||
527 | return -1; | ||
528 | } | ||
529 | |||
530 | return netxen_rom_wip_poll(adapter); | ||
531 | } | ||
532 | #endif | ||
533 | |||
534 | static int do_rom_fast_read(struct netxen_adapter *adapter, | 452 | static int do_rom_fast_read(struct netxen_adapter *adapter, |
535 | int addr, int *valp) | 453 | int addr, int *valp) |
536 | { | 454 | { |
@@ -597,284 +515,6 @@ int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) | |||
597 | return ret; | 515 | return ret; |
598 | } | 516 | } |
599 | 517 | ||
600 | #if 0 | ||
601 | int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data) | ||
602 | { | ||
603 | int ret = 0; | ||
604 | |||
605 | if (rom_lock(adapter) != 0) { | ||
606 | return -1; | ||
607 | } | ||
608 | ret = do_rom_fast_write(adapter, addr, data); | ||
609 | netxen_rom_unlock(adapter); | ||
610 | return ret; | ||
611 | } | ||
612 | |||
613 | static int do_rom_fast_write_words(struct netxen_adapter *adapter, | ||
614 | int addr, u8 *bytes, size_t size) | ||
615 | { | ||
616 | int addridx = addr; | ||
617 | int ret = 0; | ||
618 | |||
619 | while (addridx < (addr + size)) { | ||
620 | int last_attempt = 0; | ||
621 | int timeout = 0; | ||
622 | int data; | ||
623 | |||
624 | data = le32_to_cpu((*(__le32*)bytes)); | ||
625 | ret = do_rom_fast_write(adapter, addridx, data); | ||
626 | if (ret < 0) | ||
627 | return ret; | ||
628 | |||
629 | while(1) { | ||
630 | int data1; | ||
631 | |||
632 | ret = do_rom_fast_read(adapter, addridx, &data1); | ||
633 | if (ret < 0) | ||
634 | return ret; | ||
635 | |||
636 | if (data1 == data) | ||
637 | break; | ||
638 | |||
639 | if (timeout++ >= rom_write_timeout) { | ||
640 | if (last_attempt++ < 4) { | ||
641 | ret = do_rom_fast_write(adapter, | ||
642 | addridx, data); | ||
643 | if (ret < 0) | ||
644 | return ret; | ||
645 | } | ||
646 | else { | ||
647 | printk(KERN_INFO "Data write did not " | ||
648 | "succeed at address 0x%x\n", addridx); | ||
649 | break; | ||
650 | } | ||
651 | } | ||
652 | } | ||
653 | |||
654 | bytes += 4; | ||
655 | addridx += 4; | ||
656 | } | ||
657 | |||
658 | return ret; | ||
659 | } | ||
660 | |||
661 | int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, | ||
662 | u8 *bytes, size_t size) | ||
663 | { | ||
664 | int ret = 0; | ||
665 | |||
666 | ret = rom_lock(adapter); | ||
667 | if (ret < 0) | ||
668 | return ret; | ||
669 | |||
670 | ret = do_rom_fast_write_words(adapter, addr, bytes, size); | ||
671 | netxen_rom_unlock(adapter); | ||
672 | |||
673 | return ret; | ||
674 | } | ||
675 | |||
676 | static int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) | ||
677 | { | ||
678 | int ret; | ||
679 | |||
680 | ret = netxen_rom_wren(adapter); | ||
681 | if (ret < 0) | ||
682 | return ret; | ||
683 | |||
684 | netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_ROM_WDATA, data); | ||
685 | netxen_crb_writelit_adapter(adapter, | ||
686 | NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0x1); | ||
687 | |||
688 | ret = netxen_wait_rom_done(adapter); | ||
689 | if (ret < 0) | ||
690 | return ret; | ||
691 | |||
692 | return netxen_rom_wip_poll(adapter); | ||
693 | } | ||
694 | |||
695 | static int netxen_rom_rdsr(struct netxen_adapter *adapter) | ||
696 | { | ||
697 | int ret; | ||
698 | |||
699 | ret = rom_lock(adapter); | ||
700 | if (ret < 0) | ||
701 | return ret; | ||
702 | |||
703 | ret = netxen_do_rom_rdsr(adapter); | ||
704 | netxen_rom_unlock(adapter); | ||
705 | return ret; | ||
706 | } | ||
707 | |||
708 | int netxen_backup_crbinit(struct netxen_adapter *adapter) | ||
709 | { | ||
710 | int ret = FLASH_SUCCESS; | ||
711 | int val; | ||
712 | char *buffer = kmalloc(NETXEN_FLASH_SECTOR_SIZE, GFP_KERNEL); | ||
713 | |||
714 | if (!buffer) | ||
715 | return -ENOMEM; | ||
716 | /* unlock sector 63 */ | ||
717 | val = netxen_rom_rdsr(adapter); | ||
718 | val = val & 0xe3; | ||
719 | ret = netxen_rom_wrsr(adapter, val); | ||
720 | if (ret != FLASH_SUCCESS) | ||
721 | goto out_kfree; | ||
722 | |||
723 | ret = netxen_rom_wip_poll(adapter); | ||
724 | if (ret != FLASH_SUCCESS) | ||
725 | goto out_kfree; | ||
726 | |||
727 | /* copy sector 0 to sector 63 */ | ||
728 | ret = netxen_rom_fast_read_words(adapter, NETXEN_CRBINIT_START, | ||
729 | buffer, NETXEN_FLASH_SECTOR_SIZE); | ||
730 | if (ret != FLASH_SUCCESS) | ||
731 | goto out_kfree; | ||
732 | |||
733 | ret = netxen_rom_fast_write_words(adapter, NETXEN_FIXED_START, | ||
734 | buffer, NETXEN_FLASH_SECTOR_SIZE); | ||
735 | if (ret != FLASH_SUCCESS) | ||
736 | goto out_kfree; | ||
737 | |||
738 | /* lock sector 63 */ | ||
739 | val = netxen_rom_rdsr(adapter); | ||
740 | if (!(val & 0x8)) { | ||
741 | val |= (0x1 << 2); | ||
742 | /* lock sector 63 */ | ||
743 | if (netxen_rom_wrsr(adapter, val) == 0) { | ||
744 | ret = netxen_rom_wip_poll(adapter); | ||
745 | if (ret != FLASH_SUCCESS) | ||
746 | goto out_kfree; | ||
747 | |||
748 | /* lock SR writes */ | ||
749 | ret = netxen_rom_wip_poll(adapter); | ||
750 | if (ret != FLASH_SUCCESS) | ||
751 | goto out_kfree; | ||
752 | } | ||
753 | } | ||
754 | |||
755 | out_kfree: | ||
756 | kfree(buffer); | ||
757 | return ret; | ||
758 | } | ||
759 | |||
760 | static int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) | ||
761 | { | ||
762 | netxen_rom_wren(adapter); | ||
763 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); | ||
764 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3); | ||
765 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, | ||
766 | M25P_INSTR_SE); | ||
767 | if (netxen_wait_rom_done(adapter)) { | ||
768 | netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); | ||
769 | return -1; | ||
770 | } | ||
771 | return netxen_rom_wip_poll(adapter); | ||
772 | } | ||
773 | |||
774 | static void check_erased_flash(struct netxen_adapter *adapter, int addr) | ||
775 | { | ||
776 | int i; | ||
777 | int val; | ||
778 | int count = 0, erased_errors = 0; | ||
779 | int range; | ||
780 | |||
781 | range = (addr == NETXEN_USER_START) ? | ||
782 | NETXEN_FIXED_START : addr + NETXEN_FLASH_SECTOR_SIZE; | ||
783 | |||
784 | for (i = addr; i < range; i += 4) { | ||
785 | netxen_rom_fast_read(adapter, i, &val); | ||
786 | if (val != 0xffffffff) | ||
787 | erased_errors++; | ||
788 | count++; | ||
789 | } | ||
790 | |||
791 | if (erased_errors) | ||
792 | printk(KERN_INFO "0x%x out of 0x%x words fail to be erased " | ||
793 | "for sector address: %x\n", erased_errors, count, addr); | ||
794 | } | ||
795 | |||
796 | int netxen_rom_se(struct netxen_adapter *adapter, int addr) | ||
797 | { | ||
798 | int ret = 0; | ||
799 | if (rom_lock(adapter) != 0) { | ||
800 | return -1; | ||
801 | } | ||
802 | ret = netxen_do_rom_se(adapter, addr); | ||
803 | netxen_rom_unlock(adapter); | ||
804 | msleep(30); | ||
805 | check_erased_flash(adapter, addr); | ||
806 | |||
807 | return ret; | ||
808 | } | ||
809 | |||
810 | static int netxen_flash_erase_sections(struct netxen_adapter *adapter, | ||
811 | int start, int end) | ||
812 | { | ||
813 | int ret = FLASH_SUCCESS; | ||
814 | int i; | ||
815 | |||
816 | for (i = start; i < end; i++) { | ||
817 | ret = netxen_rom_se(adapter, i * NETXEN_FLASH_SECTOR_SIZE); | ||
818 | if (ret) | ||
819 | break; | ||
820 | ret = netxen_rom_wip_poll(adapter); | ||
821 | if (ret < 0) | ||
822 | return ret; | ||
823 | } | ||
824 | |||
825 | return ret; | ||
826 | } | ||
827 | |||
828 | int | ||
829 | netxen_flash_erase_secondary(struct netxen_adapter *adapter) | ||
830 | { | ||
831 | int ret = FLASH_SUCCESS; | ||
832 | int start, end; | ||
833 | |||
834 | start = NETXEN_SECONDARY_START / NETXEN_FLASH_SECTOR_SIZE; | ||
835 | end = NETXEN_USER_START / NETXEN_FLASH_SECTOR_SIZE; | ||
836 | ret = netxen_flash_erase_sections(adapter, start, end); | ||
837 | |||
838 | return ret; | ||
839 | } | ||
840 | |||
841 | int | ||
842 | netxen_flash_erase_primary(struct netxen_adapter *adapter) | ||
843 | { | ||
844 | int ret = FLASH_SUCCESS; | ||
845 | int start, end; | ||
846 | |||
847 | start = NETXEN_PRIMARY_START / NETXEN_FLASH_SECTOR_SIZE; | ||
848 | end = NETXEN_SECONDARY_START / NETXEN_FLASH_SECTOR_SIZE; | ||
849 | ret = netxen_flash_erase_sections(adapter, start, end); | ||
850 | |||
851 | return ret; | ||
852 | } | ||
853 | |||
854 | void netxen_halt_pegs(struct netxen_adapter *adapter) | ||
855 | { | ||
856 | netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x3c, 1); | ||
857 | netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x3c, 1); | ||
858 | netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x3c, 1); | ||
859 | netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x3c, 1); | ||
860 | } | ||
861 | |||
862 | int netxen_flash_unlock(struct netxen_adapter *adapter) | ||
863 | { | ||
864 | int ret = 0; | ||
865 | |||
866 | ret = netxen_rom_wrsr(adapter, 0); | ||
867 | if (ret < 0) | ||
868 | return ret; | ||
869 | |||
870 | ret = netxen_rom_wren(adapter); | ||
871 | if (ret < 0) | ||
872 | return ret; | ||
873 | |||
874 | return ret; | ||
875 | } | ||
876 | #endif /* 0 */ | ||
877 | |||
878 | #define NETXEN_BOARDTYPE 0x4008 | 518 | #define NETXEN_BOARDTYPE 0x4008 |
879 | #define NETXEN_BOARDNUM 0x400c | 519 | #define NETXEN_BOARDNUM 0x400c |
880 | #define NETXEN_CHIPNUM 0x4010 | 520 | #define NETXEN_CHIPNUM 0x4010 |