Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Alchemy Au1x00 ethernet driver include file |
| 4 | * |
| 5 | * Author: Pete Popov <ppopov@mvista.com> |
| 6 | * |
| 7 | * Copyright 2001 MontaVista Software Inc. |
| 8 | * |
| 9 | * ######################################################################## |
| 10 | * |
| 11 | * This program is free software; you can distribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License (Version 2) as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 18 | * for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License along |
Jeff Kirsher | 0ab75ae | 2013-12-06 06:28:43 -0800 | [diff] [blame] | 21 | * with this program; if not, see <http://www.gnu.org/licenses/>. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * |
| 23 | * ######################################################################## |
| 24 | * |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 25 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | |
| 29 | #define MAC_IOSIZE 0x10000 |
| 30 | #define NUM_RX_DMA 4 /* Au1x00 has 4 rx hardware descriptors */ |
| 31 | #define NUM_TX_DMA 4 /* Au1x00 has 4 tx hardware descriptors */ |
| 32 | |
| 33 | #define NUM_RX_BUFFS 4 |
| 34 | #define NUM_TX_BUFFS 4 |
| 35 | #define MAX_BUF_SIZE 2048 |
| 36 | |
Florian Fainelli | 2cc3c6b | 2010-04-06 22:09:06 +0000 | [diff] [blame] | 37 | #define ETH_TX_TIMEOUT (HZ/4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define MAC_MIN_PKT_SIZE 64 |
| 39 | |
| 40 | #define MULTICAST_FILTER_LIMIT 64 |
| 41 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 42 | /* |
| 43 | * Data Buffer Descriptor. Data buffers must be aligned on 32 byte |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | * boundary for both, receive and transmit. |
| 45 | */ |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 46 | struct db_dest { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | struct db_dest *pnext; |
Florian Fainelli | d0e7cb5 | 2010-09-08 11:15:13 +0000 | [diff] [blame] | 48 | u32 *vaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | dma_addr_t dma_addr; |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 50 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 53 | * The transmit and receive descriptors are memory |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | * mapped registers. |
| 55 | */ |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 56 | struct tx_dma { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | u32 status; |
| 58 | u32 buff_stat; |
| 59 | u32 len; |
| 60 | u32 pad; |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 61 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 63 | struct rx_dma { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | u32 status; |
| 65 | u32 buff_stat; |
| 66 | u32 pad[2]; |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 67 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | |
| 70 | /* |
| 71 | * MAC control registers, memory mapped. |
| 72 | */ |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 73 | struct mac_reg { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | u32 control; |
| 75 | u32 mac_addr_high; |
| 76 | u32 mac_addr_low; |
| 77 | u32 multi_hash_high; |
| 78 | u32 multi_hash_low; |
| 79 | u32 mii_control; |
| 80 | u32 mii_data; |
| 81 | u32 flow_control; |
| 82 | u32 vlan1_tag; |
| 83 | u32 vlan2_tag; |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 84 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | |
| 87 | struct au1000_private { |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 88 | struct db_dest *pDBfree; |
| 89 | struct db_dest db[NUM_RX_BUFFS+NUM_TX_BUFFS]; |
Florian Fainelli | d0e7cb5 | 2010-09-08 11:15:13 +0000 | [diff] [blame] | 90 | struct rx_dma *rx_dma_ring[NUM_RX_DMA]; |
| 91 | struct tx_dma *tx_dma_ring[NUM_TX_DMA]; |
Florian Fainelli | 3441592 | 2010-09-08 11:11:25 +0000 | [diff] [blame] | 92 | struct db_dest *rx_db_inuse[NUM_RX_DMA]; |
| 93 | struct db_dest *tx_db_inuse[NUM_TX_DMA]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | u32 rx_head; |
| 95 | u32 tx_head; |
| 96 | u32 tx_tail; |
| 97 | u32 tx_full; |
| 98 | |
| 99 | int mac_id; |
Herbert Valerio Riedel | 0638dec | 2006-06-01 09:41:04 +0200 | [diff] [blame] | 100 | |
Florian Fainelli | 18b8e15 | 2010-09-08 11:11:40 +0000 | [diff] [blame] | 101 | int mac_enabled; /* whether MAC is currently enabled and running |
Florian Fainelli | dc99839 | 2010-09-08 11:11:59 +0000 | [diff] [blame] | 102 | * (req. for mdio) |
| 103 | */ |
Herbert Valerio Riedel | 0638dec | 2006-06-01 09:41:04 +0200 | [diff] [blame] | 104 | |
| 105 | int old_link; /* used by au1000_adjust_link */ |
| 106 | int old_speed; |
| 107 | int old_duplex; |
| 108 | |
| 109 | struct phy_device *phy_dev; |
Lennert Buytenhek | 298cf9b | 2008-10-08 16:29:57 -0700 | [diff] [blame] | 110 | struct mii_bus *mii_bus; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 111 | |
Florian Fainelli | bd2302c | 2009-11-10 01:13:38 +0100 | [diff] [blame] | 112 | /* PHY configuration */ |
| 113 | int phy_static_config; |
| 114 | int phy_search_highest_addr; |
| 115 | int phy1_search_mac0; |
| 116 | |
| 117 | int phy_addr; |
| 118 | int phy_busid; |
| 119 | int phy_irq; |
| 120 | |
Florian Fainelli | 18b8e15 | 2010-09-08 11:11:40 +0000 | [diff] [blame] | 121 | /* These variables are just for quick access |
Florian Fainelli | dc99839 | 2010-09-08 11:11:59 +0000 | [diff] [blame] | 122 | * to certain regs addresses. |
| 123 | */ |
Florian Fainelli | d0e7cb5 | 2010-09-08 11:15:13 +0000 | [diff] [blame] | 124 | struct mac_reg *mac; /* mac registers */ |
| 125 | u32 *enable; /* address of MAC Enable Register */ |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 126 | void __iomem *macdma; /* base of MAC DMA port */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | u32 vaddr; /* virtual address of rx/tx buffers */ |
| 128 | dma_addr_t dma_addr; /* dma address of rx/tx buffers */ |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | spinlock_t lock; /* Serialise access to device */ |
Florian Fainelli | 7cd2e6e | 2010-04-06 22:09:09 +0000 | [diff] [blame] | 131 | |
| 132 | u32 msg_enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | }; |