1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71#include <linux/module.h>
72#include <linux/kernel.h>
73#include <linux/string.h>
74#include <linux/ptrace.h>
75#include <linux/errno.h>
76#include <linux/ioport.h>
77#include <linux/interrupt.h>
78#include <linux/delay.h>
79#include <linux/netdevice.h>
80#include <linux/etherdevice.h>
81#include <linux/skbuff.h>
82#include <linux/types.h>
83#include <linux/bitops.h>
84#include <linux/dma-mapping.h>
85
86#include <asm/io.h>
87#include <asm/irq.h>
88#include <asm/pdc.h>
89#include <asm/parisc-device.h>
90
91#define LASI_82596_DRIVER_VERSION "LASI 82596 driver - Revision: 1.30"
92
93#define PA_I82596_RESET 0
94#define PA_CPU_PORT_L_ACCESS 4
95#define PA_CHANNEL_ATTENTION 8
96
97#define OPT_SWAP_PORT 0x0001
98
99#define DMA_ALLOC dma_alloc_noncoherent
100#define DMA_FREE dma_free_noncoherent
101#define DMA_WBACK(ndev, addr, len) \
102 do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, DMA_TO_DEVICE); } while (0)
103
104#define DMA_INV(ndev, addr, len) \
105 do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, DMA_FROM_DEVICE); } while (0)
106
107#define DMA_WBACK_INV(ndev, addr, len) \
108 do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
109
110#define SYSBUS 0x0000006c;
111
112
113#define SWAP32(x) (((u32)(x)<<16) | ((((u32)(x)))>>16))
114#define SWAP16(x) (x)
115
116#include "lib82596.c"
117
118MODULE_AUTHOR("Richard Hirst");
119MODULE_DESCRIPTION("i82596 driver");
120MODULE_LICENSE("GPL");
121module_param(i596_debug, int, 0);
122MODULE_PARM_DESC(i596_debug, "lasi_82596 debug mask");
123
124static inline void ca(struct net_device *dev)
125{
126 gsc_writel(0, dev->base_addr + PA_CHANNEL_ATTENTION);
127}
128
129
130static void mpu_port(struct net_device *dev, int c, dma_addr_t x)
131{
132 struct i596_private *lp = netdev_priv(dev);
133
134 u32 v = (u32) (c) | (u32) (x);
135 u16 a, b;
136
137 if (lp->options & OPT_SWAP_PORT) {
138 a = v >> 16;
139 b = v & 0xffff;
140 } else {
141 a = v & 0xffff;
142 b = v >> 16;
143 }
144
145 gsc_writel(a, dev->base_addr + PA_CPU_PORT_L_ACCESS);
146 udelay(1);
147 gsc_writel(b, dev->base_addr + PA_CPU_PORT_L_ACCESS);
148}
149
150#define LAN_PROM_ADDR 0xF0810000
151
152static int
153lan_init_chip(struct parisc_device *dev)
154{
155 struct net_device *netdevice;
156 struct i596_private *lp;
157 int retval;
158 int i;
159
160 if (!dev->irq) {
161 printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
162 __FILE__, (unsigned long)dev->hpa.start);
163 return -ENODEV;
164 }
165
166 printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n",
167 (unsigned long)dev->hpa.start, dev->irq);
168
169 netdevice = alloc_etherdev(sizeof(struct i596_private));
170 if (!netdevice)
171 return -ENOMEM;
172 SET_NETDEV_DEV(netdevice, &dev->dev);
173 parisc_set_drvdata (dev, netdevice);
174
175 netdevice->base_addr = dev->hpa.start;
176 netdevice->irq = dev->irq;
177
178 if (pdc_lan_station_id(netdevice->dev_addr, netdevice->base_addr)) {
179 for (i = 0; i < 6; i++) {
180 netdevice->dev_addr[i] = gsc_readb(LAN_PROM_ADDR + i);
181 }
182 printk(KERN_INFO
183 "%s: MAC of HP700 LAN read from EEPROM\n", __FILE__);
184 }
185
186 lp = netdev_priv(netdevice);
187 lp->options = dev->id.sversion == 0x72 ? OPT_SWAP_PORT : 0;
188
189 retval = i82596_probe(netdevice);
190 if (retval) {
191 free_netdev(netdevice);
192 return -ENODEV;
193 }
194 return retval;
195}
196
197static int lan_remove_chip(struct parisc_device *pdev)
198{
199 struct net_device *dev = parisc_get_drvdata(pdev);
200 struct i596_private *lp = netdev_priv(dev);
201
202 unregister_netdev (dev);
203 DMA_FREE(&pdev->dev, sizeof(struct i596_private),
204 (void *)lp->dma, lp->dma_addr);
205 free_netdev (dev);
206 return 0;
207}
208
209static struct parisc_device_id lan_tbl[] = {
210 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008a },
211 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00072 },
212 { 0, }
213};
214
215MODULE_DEVICE_TABLE(parisc, lan_tbl);
216
217static struct parisc_driver lan_driver = {
218 .name = "lasi_82596",
219 .id_table = lan_tbl,
220 .probe = lan_init_chip,
221 .remove = lan_remove_chip,
222};
223
224static int lasi_82596_init(void)
225{
226 printk(KERN_INFO LASI_82596_DRIVER_VERSION "\n");
227 return register_parisc_driver(&lan_driver);
228}
229
230module_init(lasi_82596_init);
231
232static void __exit lasi_82596_exit(void)
233{
234 unregister_parisc_driver(&lan_driver);
235}
236
237module_exit(lasi_82596_exit);
238