| 728 | } |
| 729 | |
| 730 | void |
| 731 | fman_finish(void) |
| 732 | { |
| 733 | struct __fman_if *__if, *tmpif; |
| 734 | |
| 735 | assert(fman_ccsr_map_fd != -1); |
| 736 | |
| 737 | list_for_each_entry_safe(__if, tmpif, &__ifs, __if.node) { |
| 738 | int _errno; |
| 739 | |
| 740 | /* disable Rx and Tx */ |
| 741 | if ((__if->__if.mac_type == fman_mac_1g) && |
| 742 | (!__if->__if.is_memac)) |
| 743 | out_be32(__if->ccsr_map + 0x100, |
| 744 | in_be32(__if->ccsr_map + 0x100) & ~(u32)0x5); |
| 745 | else |
| 746 | out_be32(__if->ccsr_map + 8, |
| 747 | in_be32(__if->ccsr_map + 8) & ~(u32)3); |
| 748 | /* release the mapping */ |
| 749 | _errno = munmap(__if->ccsr_map, __if->regs_size); |
| 750 | if (unlikely(_errno < 0)) |
| 751 | fprintf(stderr, "%s:%d:%s(): munmap() = %d (%s)\n", |
| 752 | __FILE__, __LINE__, __func__, |
| 753 | -errno, strerror(errno)); |
| 754 | printf("Tearing down %s\n", __if->node_path); |
| 755 | list_del(&__if->__if.node); |
| 756 | rte_free(__if); |
| 757 | } |
| 758 | |
| 759 | close(fman_ccsr_map_fd); |
| 760 | fman_ccsr_map_fd = -1; |
| 761 | } |