blob: 64b2047d19f0ff41ca3e7ea4b53e504bcdc409b6 [file] [log] [blame]
Olof Johanssonf5cd7872007-01-31 21:43:54 -06001/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Driver for the PA6T-1682M onchip 1G/10G Ethernet MACs, soft state and
5 * hardware register layouts.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef PASEMI_MAC_H
22#define PASEMI_MAC_H
23
24#include <linux/ethtool.h>
25#include <linux/netdevice.h>
26#include <linux/spinlock.h>
Olof Johanssonbb6e9592007-05-08 00:47:54 -050027#include <linux/phy.h>
Olof Johanssonf5cd7872007-01-31 21:43:54 -060028
29struct pasemi_mac_txring {
Olof Johansson34c20622007-11-28 20:56:32 -060030 struct pasemi_dmachan chan; /* Must be first */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060031 spinlock_t lock;
Olof Johanssonf5cd7872007-01-31 21:43:54 -060032 unsigned int size;
Olof Johansson021fa222007-08-22 09:13:11 -050033 unsigned int next_to_fill;
Olof Johanssonf5cd7872007-01-31 21:43:54 -060034 unsigned int next_to_clean;
Olof Johanssonfc9e4d22007-10-02 16:25:53 -050035 struct pasemi_mac_buffer *ring_info;
Olof Johansson72b05b92007-11-28 20:54:28 -060036 struct pasemi_mac *mac; /* Needed in intr handler */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060037};
38
39struct pasemi_mac_rxring {
Olof Johansson34c20622007-11-28 20:56:32 -060040 struct pasemi_dmachan chan; /* Must be first */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060041 spinlock_t lock;
Olof Johanssonf5cd7872007-01-31 21:43:54 -060042 u64 *buffers; /* RX interface buffer ring */
43 dma_addr_t buf_dma;
44 unsigned int size;
45 unsigned int next_to_fill;
46 unsigned int next_to_clean;
Olof Johanssonfc9e4d22007-10-02 16:25:53 -050047 struct pasemi_mac_buffer *ring_info;
Olof Johansson72b05b92007-11-28 20:54:28 -060048 struct pasemi_mac *mac; /* Needed in intr handler */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060049};
50
51struct pasemi_mac {
52 struct net_device *netdev;
53 struct pci_dev *pdev;
54 struct pci_dev *dma_pdev;
55 struct pci_dev *iob_pdev;
Olof Johanssonbb6e9592007-05-08 00:47:54 -050056 struct phy_device *phydev;
Stephen Hemmingerbea33482007-10-03 16:41:36 -070057 struct napi_struct napi;
Olof Johanssonf5cd7872007-01-31 21:43:54 -060058
Olof Johanssonf5cd7872007-01-31 21:43:54 -060059 u8 type;
60#define MAC_TYPE_GMAC 1
61#define MAC_TYPE_XAUI 2
Olof Johansson72b05b92007-11-28 20:54:28 -060062 u32 dma_if;
Olof Johanssonf5cd7872007-01-31 21:43:54 -060063
64 u8 mac_addr[6];
65
66 struct timer_list rxtimer;
67
68 struct pasemi_mac_txring *tx;
69 struct pasemi_mac_rxring *rx;
Olof Johansson72b05b92007-11-28 20:54:28 -060070 char tx_irq_name[10]; /* "eth%d tx" */
71 char rx_irq_name[10]; /* "eth%d rx" */
Olof Johanssonbb6e9592007-05-08 00:47:54 -050072 int link;
73 int speed;
74 int duplex;
Olof Johanssonceb51362007-05-08 00:47:49 -050075
76 unsigned int msg_enable;
Olof Johanssonbb6e9592007-05-08 00:47:54 -050077 char phy_id[BUS_ID_SIZE];
Olof Johanssonf5cd7872007-01-31 21:43:54 -060078};
79
Olof Johanssonfc9e4d22007-10-02 16:25:53 -050080/* Software status descriptor (ring_info) */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060081struct pasemi_mac_buffer {
82 struct sk_buff *skb;
83 dma_addr_t dma;
84};
85
86
Olof Johansson40afa532007-11-28 20:56:04 -060087/* PCI register offsets and formats */
88
Olof Johanssonf5cd7872007-01-31 21:43:54 -060089
Olof Johanssonf5cd7872007-01-31 21:43:54 -060090/* MAC CFG register offsets */
Olof Johanssonf5cd7872007-01-31 21:43:54 -060091enum {
92 PAS_MAC_CFG_PCFG = 0x80,
93 PAS_MAC_CFG_TXP = 0x98,
94 PAS_MAC_IPC_CHNL = 0x208,
95};
96
97/* MAC CFG register fields */
98#define PAS_MAC_CFG_PCFG_PE 0x80000000
99#define PAS_MAC_CFG_PCFG_CE 0x40000000
100#define PAS_MAC_CFG_PCFG_BU 0x20000000
101#define PAS_MAC_CFG_PCFG_TT 0x10000000
102#define PAS_MAC_CFG_PCFG_TSR_M 0x0c000000
103#define PAS_MAC_CFG_PCFG_TSR_10M 0x00000000
104#define PAS_MAC_CFG_PCFG_TSR_100M 0x04000000
105#define PAS_MAC_CFG_PCFG_TSR_1G 0x08000000
106#define PAS_MAC_CFG_PCFG_TSR_10G 0x0c000000
107#define PAS_MAC_CFG_PCFG_T24 0x02000000
108#define PAS_MAC_CFG_PCFG_PR 0x01000000
109#define PAS_MAC_CFG_PCFG_CRO_M 0x00ff0000
110#define PAS_MAC_CFG_PCFG_CRO_S 16
111#define PAS_MAC_CFG_PCFG_IPO_M 0x0000ff00
112#define PAS_MAC_CFG_PCFG_IPO_S 8
113#define PAS_MAC_CFG_PCFG_S1 0x00000080
114#define PAS_MAC_CFG_PCFG_IO_M 0x00000060
115#define PAS_MAC_CFG_PCFG_IO_MAC 0x00000000
116#define PAS_MAC_CFG_PCFG_IO_OFF 0x00000020
117#define PAS_MAC_CFG_PCFG_IO_IND_ETH 0x00000040
118#define PAS_MAC_CFG_PCFG_IO_IND_IP 0x00000060
119#define PAS_MAC_CFG_PCFG_LP 0x00000010
120#define PAS_MAC_CFG_PCFG_TS 0x00000008
121#define PAS_MAC_CFG_PCFG_HD 0x00000004
122#define PAS_MAC_CFG_PCFG_SPD_M 0x00000003
123#define PAS_MAC_CFG_PCFG_SPD_10M 0x00000000
124#define PAS_MAC_CFG_PCFG_SPD_100M 0x00000001
125#define PAS_MAC_CFG_PCFG_SPD_1G 0x00000002
126#define PAS_MAC_CFG_PCFG_SPD_10G 0x00000003
127#define PAS_MAC_CFG_TXP_FCF 0x01000000
128#define PAS_MAC_CFG_TXP_FCE 0x00800000
129#define PAS_MAC_CFG_TXP_FC 0x00400000
130#define PAS_MAC_CFG_TXP_FPC_M 0x00300000
131#define PAS_MAC_CFG_TXP_FPC_S 20
132#define PAS_MAC_CFG_TXP_FPC(x) (((x) << PAS_MAC_CFG_TXP_FPC_S) & \
133 PAS_MAC_CFG_TXP_FPC_M)
134#define PAS_MAC_CFG_TXP_RT 0x00080000
135#define PAS_MAC_CFG_TXP_BL 0x00040000
136#define PAS_MAC_CFG_TXP_SL_M 0x00030000
137#define PAS_MAC_CFG_TXP_SL_S 16
138#define PAS_MAC_CFG_TXP_SL(x) (((x) << PAS_MAC_CFG_TXP_SL_S) & \
139 PAS_MAC_CFG_TXP_SL_M)
140#define PAS_MAC_CFG_TXP_COB_M 0x0000f000
141#define PAS_MAC_CFG_TXP_COB_S 12
142#define PAS_MAC_CFG_TXP_COB(x) (((x) << PAS_MAC_CFG_TXP_COB_S) & \
143 PAS_MAC_CFG_TXP_COB_M)
144#define PAS_MAC_CFG_TXP_TIFT_M 0x00000f00
145#define PAS_MAC_CFG_TXP_TIFT_S 8
146#define PAS_MAC_CFG_TXP_TIFT(x) (((x) << PAS_MAC_CFG_TXP_TIFT_S) & \
147 PAS_MAC_CFG_TXP_TIFT_M)
148#define PAS_MAC_CFG_TXP_TIFG_M 0x000000ff
149#define PAS_MAC_CFG_TXP_TIFG_S 0
150#define PAS_MAC_CFG_TXP_TIFG(x) (((x) << PAS_MAC_CFG_TXP_TIFG_S) & \
151 PAS_MAC_CFG_TXP_TIFG_M)
152
153#define PAS_MAC_IPC_CHNL_DCHNO_M 0x003f0000
154#define PAS_MAC_IPC_CHNL_DCHNO_S 16
155#define PAS_MAC_IPC_CHNL_DCHNO(x) (((x) << PAS_MAC_IPC_CHNL_DCHNO_S) & \
156 PAS_MAC_IPC_CHNL_DCHNO_M)
157#define PAS_MAC_IPC_CHNL_BCH_M 0x0000003f
158#define PAS_MAC_IPC_CHNL_BCH_S 0
159#define PAS_MAC_IPC_CHNL_BCH(x) (((x) << PAS_MAC_IPC_CHNL_BCH_S) & \
160 PAS_MAC_IPC_CHNL_BCH_M)
161
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600162#endif /* PASEMI_MAC_H */