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