Commit b962ac794a26ff80269755c13c3e4fee65c3809e
Committed by
Wolfgang Denk
1 parent
29095f1a5c
Exists in
master
and in
55 other branches
altera_tse: Add support for dedicated descriptor memory
Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
Showing 3 changed files with 27 additions and 5 deletions Side-by-side Diff
board/altera/nios2-generic/nios2-generic.c
... | ... | @@ -74,7 +74,15 @@ |
74 | 74 | rc += altera_tse_initialize(0, |
75 | 75 | CONFIG_SYS_ALTERA_TSE_MAC_BASE, |
76 | 76 | CONFIG_SYS_ALTERA_TSE_SGDMA_RX_BASE, |
77 | - CONFIG_SYS_ALTERA_TSE_SGDMA_TX_BASE); | |
77 | + CONFIG_SYS_ALTERA_TSE_SGDMA_TX_BASE, | |
78 | +#if defined(CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE) && \ | |
79 | + (CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE > 0) | |
80 | + CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE, | |
81 | + CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE); | |
82 | +#else | |
83 | + 0, | |
84 | + 0); | |
85 | +#endif | |
78 | 86 | #endif |
79 | 87 | #ifdef CONFIG_ETHOC |
80 | 88 | rc += ethoc_initialize(0, CONFIG_SYS_ETHOC_BASE); |
drivers/net/altera_tse.c
... | ... | @@ -882,7 +882,8 @@ |
882 | 882 | |
883 | 883 | /* TSE init code */ |
884 | 884 | int altera_tse_initialize(u8 dev_num, int mac_base, |
885 | - int sgdma_rx_base, int sgdma_tx_base) | |
885 | + int sgdma_rx_base, int sgdma_tx_base, | |
886 | + u32 sgdma_desc_base, u32 sgdma_desc_size) | |
886 | 887 | { |
887 | 888 | struct altera_tse_priv *priv; |
888 | 889 | struct eth_device *dev; |
... | ... | @@ -903,8 +904,20 @@ |
903 | 904 | free(dev); |
904 | 905 | return 0; |
905 | 906 | } |
906 | - tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), | |
907 | - &dma_handle); | |
907 | + if (sgdma_desc_size) { | |
908 | + if (sgdma_desc_size < (sizeof(*tx_desc) * (3 + PKTBUFSRX))) { | |
909 | + printf("ALTERA_TSE-%hu: " | |
910 | + "descriptor memory is too small\n", dev_num); | |
911 | + free(priv); | |
912 | + free(dev); | |
913 | + return 0; | |
914 | + } | |
915 | + tx_desc = (struct alt_sgdma_descriptor *)sgdma_desc_base; | |
916 | + } else { | |
917 | + tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), | |
918 | + &dma_handle); | |
919 | + } | |
920 | + | |
908 | 921 | rx_desc = tx_desc + 2; |
909 | 922 | debug("tx desc: address = 0x%x\n", (unsigned int)tx_desc); |
910 | 923 | debug("rx desc: address = 0x%x\n", (unsigned int)rx_desc); |
include/netdev.h
... | ... | @@ -42,7 +42,8 @@ |
42 | 42 | |
43 | 43 | /* Driver initialization prototypes */ |
44 | 44 | int altera_tse_initialize(u8 dev_num, int mac_base, |
45 | - int sgdma_rx_base, int sgdma_tx_base); | |
45 | + int sgdma_rx_base, int sgdma_tx_base, | |
46 | + u32 sgdma_desc_base, u32 sgdma_desc_size); | |
46 | 47 | int at91emac_register(bd_t *bis, unsigned long iobase); |
47 | 48 | int au1x00_enet_initialize(bd_t*); |
48 | 49 | int ax88180_initialize(bd_t *bis); |