]> git.pld-linux.org Git - packages/kernel.git/blob - tahoe9xx-2.6.11.5.patch
- disbaled B43_PCMCIA and SSB_PCMCIAHOST, kills pcmcia dependency in ssb.ko
[packages/kernel.git] / tahoe9xx-2.6.11.5.patch
1 --- linux/drivers/net/wan/Makefile      2003-03-06 14:56:13.000000000 +0100
2 +++ linux/drivers/net/wan/Makefile      2003-03-30 22:37:04.000000000 +0200
3 @@ -58,6 +58,7 @@
4  endif
5  obj-$(CONFIG_N2)               += n2.o
6  obj-$(CONFIG_C101)             += c101.o
7 +obj-$(CONFIG_TAHOE9XX)         += tahoe9xx.o
8  obj-$(CONFIG_WANXL)            += wanxl.o
9  obj-$(CONFIG_PCI200SYN)                += pci200syn.o
10  
11 --- linux/drivers/net/wan/tahoe9xx.c    2003-04-07 14:18:45.000000000 +0200
12 +++ linux/drivers/net/wan/tahoe9xx.c    2003-04-07 13:47:45.000000000 +0200
13 @@ -0,0 +1,825 @@
14 +/*
15 + * Tahoe 9xx synchronous serial card driver for Linux
16 + *
17 + * Copyright (C) 2002-2003 Krzysztof Halasa <khc@pm.waw.pl>
18 + * Copyright (C) 2003 Piotr Kaczmarzyk <piotr@tahoe.pl>
19 + *
20 + * This program is free software; you can redistribute it and/or modify it
21 + * under the terms of version 2 of the GNU General Public License
22 + * as published by the Free Software Foundation.
23 + *
24 + * For information see http://hq.pm.waw.pl/hdlc/
25 + *
26 + * Sources of information:
27 + *    Hitachi HD64570 SCA User's Manual
28 + *    PLX Technology Inc. PCI9052 Data Book
29 + *    Dallas Semiconductor DS21554 Datasheet
30 + */
31 +
32 +#include <linux/module.h>
33 +#include <linux/kernel.h>
34 +#include <linux/slab.h>
35 +#include <linux/sched.h>
36 +#include <linux/types.h>
37 +#include <linux/fcntl.h>
38 +#include <linux/in.h>
39 +#include <linux/string.h>
40 +#include <linux/errno.h>
41 +#include <linux/init.h>
42 +#include <linux/ioport.h>
43 +#include <linux/moduleparam.h>
44 +#include <linux/netdevice.h>
45 +#include <linux/hdlc.h>
46 +#include <linux/pci.h>
47 +#include <asm/delay.h>
48 +#include <asm/io.h>
49 +
50 +#include "hd64570.h"
51 +
52 +static const char* version = "Tahoe 9xx driver version: 1.16t";
53 +static const char* devname = "TAHOE9XX";
54 +
55 +#define        TAHOE9XX_PLX_SIZE       0x80    /* PLX control window size (128b) */
56 +#define        TAHOE9XX_SCA_SIZE       0x100   /* SCA window size (256b) */
57 +#define ALL_PAGES_ALWAYS_MAPPED
58 +#define NEED_DETECT_RAM
59 +#define NEED_SCA_MSCI_INTR
60 +#define MAX_TX_BUFFERS         10
61 +
62 +#define CLOCK_BASE 9216000
63 +
64 +#define G703_AMI               0
65 +#define G703_HDB3              1
66 +
67 +#define DEFAULT_LICR    0x80
68 +
69 +#define PCI_VENDOR_ID_TAHOE            0x8246
70 +#define PCI_DEVICE_ID_TAHOE931 0x0931
71 +#define PCI_DEVICE_ID_TAHOE932 0x0932
72 +#define PCI_DEVICE_ID_TAHOE971 0x0971
73 +#define PCI_DEVICE_ID_TAHOE972 0x0972
74 +
75 +/*
76 + *      PLX PCI9052 local configuration and shared runtime registers.
77 + *     This structure can be used to access 9052 registers (memory mapped).
78 + */
79 +typedef struct {
80 +       u32 loc_addr_range[4];  /* 00-0Ch : Local Address Ranges */
81 +       u32 loc_rom_range;      /* 10h : Local ROM Range */
82 +       u32 loc_addr_base[4];   /* 14-20h : Local Address Base Addrs */
83 +       u32 loc_rom_base;       /* 24h : Local ROM Base */
84 +       u32 loc_bus_descr[4];   /* 28-34h : Local Bus Descriptors */
85 +       u32 rom_bus_descr;      /* 38h : ROM Bus Descriptor */
86 +       u32 cs_base[4];         /* 3C-48h : Chip Select Base Addrs */
87 +       u32 intr_ctrl_stat;     /* 4Ch : Interrupt Control/Status */
88 +       u32 init_ctrl;          /* 50h : EEPROM ctrl, Init Ctrl, etc */
89 +}plx9052;
90 +
91 +
92 +
93 +
94 +
95 +typedef struct ds21554_s {
96 +       u8      vcr1;           /* Counter:     Violation Error */
97 +       u8      vcr2;
98 +       u8      crccr1;         /* Counter:     CRC4 Error */
99 +       u8      crccr2;
100 +       u8      ebcr1;          /* Counter:     E-bit Error (FEBE) */
101 +       u8      ebcr2;
102 +       u8      sr1;            /* Status:      Status Register 1 */
103 +       u8      sr2;            /* Status:      Status Register 2 */
104 +       u8      rir;            /* Status:      Receive Information */
105 +       u8      reserved1[6];
106 +       u8      idr;            /* Misc:        Device Indentification */
107 +       u8      rcr1;           /* Control:     Receive Control 1 */
108 +       u8      rcr2;           /* Control:     Receive Control 2 */
109 +       u8      tcr1;           /* Control:     Transmit Control 1 */
110 +       u8      tcr2;           /* Control:     Transmit Control 2 */
111 +       u8      ccr1;           /* Control:     Common Control 1 */
112 +       u8      test1;
113 +       u8      imr1;           /* Interrupt Mask 1 */
114 +       u8      imr2;           /* Interrupt Mask 2 */
115 +       u8      licr;           /* Control: Line interface */
116 +       u8      test2;
117 +       u8      ccr2;           /* Control: Common Control 2 */
118 +       u8      ccr3;           /* Control: Common Control 3 */
119 +       u8      tsacr;          /* Control: Transmit Sa bit */
120 +       u8      ccr6;           /* Control: Common Control 6 */
121 +       u8      ssr;            /* Status:      Synchronizer Status */
122 +       u8      rnaf;           /* Receive non-align frame */
123 +       u8      taf;            /* Transmit align frame */
124 +       u8      tnaf;           /* Transmit non-align frame */
125 +       u8      tcbr1;          /* Transmit channel blocking */
126 +       u8      tcbr2;
127 +       u8      tcbr3;
128 +       u8      tcbr4;
129 +       u8      tir1;           /* Transmit idle */
130 +       u8      tir2;
131 +       u8      tir3;
132 +       u8      tir4;
133 +       u8      tidr;           /* Transmit idle definition */
134 +       u8      rcbr1;          /* Receive channel blocking */
135 +       u8      rcbr2;
136 +       u8      rcbr3;
137 +       u8      rcbr4;
138 +       u8      raf;            /* Receive align frame */
139 +       u8      rs1;            /* Receive signalling */
140 +       u8      rs2;
141 +       u8      rs3;
142 +       u8      rs4;
143 +       u8      rs5;
144 +       u8      rs6;
145 +       u8      rs7;
146 +       u8      rs8;
147 +       u8      rs9;
148 +       u8      rs10;
149 +       u8      rs11;
150 +       u8      rs12;
151 +       u8      rs13;
152 +       u8      rs14;
153 +       u8      rs15;
154 +       u8      rs16;
155 +       u8      ts1;            /* Transmit signaling */
156 +       u8      ts2;
157 +       u8      ts3;
158 +       u8      ts4;
159 +       u8      ts5;
160 +       u8      ts6;
161 +       u8      ts7;
162 +       u8      ts8;
163 +       u8      ts9;
164 +       u8      ts10;
165 +       u8      ts11;
166 +       u8      ts12;
167 +       u8      ts13;
168 +       u8      ts14;
169 +       u8      ts15;
170 +       u8      ts16;
171 +       u8      tsiaf;          /* Transmit Si Bits Align Frame */
172 +       u8      tsinaf;         /* Transmit Si Bits Non-align Frame */
173 +       u8      tra;            /* Transmit Remote Alarm Bits */
174 +       u8      tsa4;           /* Transmit Sa Bits */
175 +       u8      tsa5;
176 +       u8      tsa6;
177 +       u8      tsa7;
178 +       u8      tsa8;
179 +       u8      rsiaf;          /* Receive Si Bits Align Frame */
180 +       u8      rsinaf;         /* Receive Si Bits Non-Align Frame */
181 +       u8      rra;            /* Receive Remote Alarm Bits */
182 +       u8      rsa4;           /* Receive Sa Bits */
183 +       u8      rsa5;
184 +       u8      rsa6;
185 +       u8      rsa7;
186 +       u8      rsa8;
187 +       u8      tc1;            /* Transmit channel */
188 +       u8      tc2;
189 +       u8      tc3;
190 +       u8      tc4;
191 +       u8      tc5;
192 +       u8      tc6;
193 +       u8      tc7;
194 +       u8      tc8;
195 +       u8      tc9;
196 +       u8      tc10;
197 +       u8      tc11;
198 +       u8      tc12;
199 +       u8      tc13;
200 +       u8      tc14;
201 +       u8      tc15;
202 +       u8      tc16;
203 +       u8      tc17;
204 +       u8      tc18;
205 +       u8      tc19;
206 +       u8      tc20;
207 +       u8      tc21;
208 +       u8      tc22;
209 +       u8      tc23;
210 +       u8      tc24;
211 +       u8      tc25;
212 +       u8      tc26;
213 +       u8      tc27;
214 +       u8      tc28;
215 +       u8      tc29;
216 +       u8      tc30;
217 +       u8      tc31;
218 +       u8      tc32;
219 +       u8      rc1;            /* Receive channel */
220 +       u8      rc2;
221 +       u8      rc3;
222 +       u8      rc4;
223 +       u8      rc5;
224 +       u8      rc6;
225 +       u8      rc7;
226 +       u8      rc8;
227 +       u8      rc9;
228 +       u8      rc10;
229 +       u8      rc11;
230 +       u8      rc12;
231 +       u8      rc13;
232 +       u8      rc14;
233 +       u8      rc15;
234 +       u8      rc16;
235 +       u8      rc17;
236 +       u8      rc18;
237 +       u8      rc19;
238 +       u8      rc20;
239 +       u8      rc21;
240 +       u8      rc22;
241 +       u8      rc23;
242 +       u8      rc24;
243 +       u8      rc25;
244 +       u8      rc26;
245 +       u8      rc27;
246 +       u8      rc28;
247 +       u8      rc29;
248 +       u8      rc30;
249 +       u8      rc31;
250 +       u8      rc32;
251 +       u8      tcc1;           /* Transmit channel control */
252 +       u8      tcc2;
253 +       u8      tcc3;
254 +       u8      tcc4;
255 +       u8      rcc1;           /* Receive channel control */
256 +       u8      rcc2;
257 +       u8      rcc3;
258 +       u8      rcc4;
259 +       u8      ccr4;           /* Control:     Common Control 4 */
260 +       u8      tds0m;          /* Transmit DS0 Monitor */
261 +       u8      ccr5;           /* Control:     Common Control 5 */
262 +       u8      rds0m;          /* Receive DS0 Monitor */
263 +       u8      test3;
264 +       u8      reserved2[3];
265 +       u8      hcr;            /* HDLC Control */
266 +       u8      hsr;            /* HDLC Status */
267 +       u8      himr;           /* HDLC Interrupt Mask */
268 +       u8      rhir;           /* Receive HDLC Information */
269 +       u8      rhfr;           /* Receive HDLC FIFO */
270 +       u8      ibo;            /* Interleave Bus Operation */
271 +       u8      thir;           /* Transmit HDLC Information */
272 +       u8      thfr;           /* Transmit HDLC FIFO */
273 +       u8      rdc1;           /* Receive HDLC DS0 Control 1 */
274 +       u8      rdc2;           /* Receive HDLC DS0 Control 2 */
275 +       u8      tdc1;           /* Transmit HDLC DS0 Control 1 */
276 +       u8      tdc2;           /* Transmit HDLC DS0 Control 2 */
277 +       u8      reserved3[4];
278 +} ds21554_t;
279 +
280 +typedef struct port_s {
281 +       struct net_device *dev;
282 +    struct card_s *card;
283 +       spinlock_t lock;        /* TX lock */
284 +       te1_settings settings;
285 +       int rxpart;             /* partial frame received, next frame invalid*/
286 +       unsigned short encoding;
287 +       unsigned short parity;
288 +       u16 rxin;               /* rx ring buffer 'in' pointer */
289 +       u16 txin;               /* tx ring buffer 'in' and 'last' pointers */
290 +       u16 txlast;
291 +       u8 rxs, txs, tmc;       /* SCA registers */
292 +       u8 phy_node;            /* physical port # - 0 or 1 */
293 +       u32 dsphys;                     /* DS21544 memory base (physical) */
294 +       ds21554_t* dsbase;      /* DS21544 memory base (virtual) */
295 +       u8      g703_on;                /* Enable/disable G.703 transceiver */
296 +       u8      g703_coding;    /* G.703 line coding */
297 +       u8      g703_idlecode;  /* G.703 idle timeslots contents */
298 +}port_t;
299 +
300 +typedef struct card_s {
301 +       u8* __iomem rambase;            /* buffer memory base (virtual) */
302 +       u8* __iomem scabase;            /* SCA memory base (virtual) */
303 +       plx9052* __iomem plxbase;       /* PLX registers memory base (virtual) */
304 +       u16 rx_ring_buffers;    /* number of buffers in a ring */
305 +       u16 tx_ring_buffers;
306 +       u16 buff_offset;        /* offset of first buffer of first channel */
307 +       u8 irq;                         /* interrupt request level */
308 +       u8 no_ports;            /* number of ports */
309 +       char dev_name[10];      /* device name */
310 +       port_t ports[2];
311 +}card_t;
312 +
313 +#define sca_in(reg, card)           readb(card->scabase + (reg))
314 +#define sca_out(value, reg, card)    writeb(value, card->scabase + (reg))
315 +#define sca_inw(reg, card)          readw(card->scabase + (reg))
316 +#define sca_outw(value, reg, card)   writew(value, card->scabase + (reg))
317 +#define sca_inl(reg, card)          readl(card->scabase + (reg))
318 +#define sca_outl(value, reg, card)   writel(value, card->scabase + (reg))
319 +
320 +#define port_to_card(port)          (port->card)
321 +#define log_node(port)              (port->phy_node)
322 +#define phy_node(port)              (port->phy_node)
323 +#define winbase(card)               (card->rambase)
324 +#define get_port(card, port)        (&card->ports[port])
325 +#define sca_flush(card)                     (sca_in(IER0, card));
326 +
327 +static inline void new_memcpy_toio(char __iomem *dest, char *src, int length)
328 +{
329 +       int len;
330 +       
331 +       do {
332 +               len = length > 64 ? 64 : length; /* 32 */
333 +               memcpy_toio(dest, src, len);
334 +               dest += len;
335 +               src += len;
336 +               length -= len;
337 +               readb(dest);
338 +       } while (len);
339 +}
340 +
341 +#undef memcpy_toio
342 +#define memcpy_toio new_memcpy_toio
343 +
344 +#include "hd6457x.c"
345 +
346 +void init_ds21554(port_t *port);
347 +
348 +static void t9xx_set_iface(port_t *port)
349 +{
350 +       card_t *card = port->card;
351 +       u8 msci = get_msci(port);
352 +       u8 rxs = port->rxs & CLK_BRG_MASK;
353 +       u8 txs = port->txs & CLK_BRG_MASK;
354 +       
355 +       if (port->dsbase) {
356 +               init_ds21554(port);
357 +       }
358 +       
359 +       rxs |= CLK_LINE_RX; /* RXC input */
360 +       txs |= CLK_LINE_TX; /* TXC input */
361 +
362 +       port->rxs = rxs;
363 +       port->txs = txs;
364 +       sca_out(rxs, msci + RXS, card);
365 +       sca_out(txs, msci + TXS, card);
366 +       sca_set_port(port);
367 +}
368 +
369 +
370 +
371 +static int t9xx_open(struct net_device *dev)
372 +{
373 +       port_t *port = dev_to_port(dev);
374 +
375 +       int result = hdlc_open(dev);
376 +       if (result)
377 +               return result;
378 +
379 +       sca_open(dev);
380 +       t9xx_set_iface(port);
381 +       sca_flush(port_to_card(port));
382 +       return 0;
383 +}
384 +
385 +
386 +
387 +static int t9xx_close(struct net_device *dev)
388 +{
389 +       sca_close(dev);
390 +       sca_flush(port_to_card(dev_to_port(dev)));
391 +       hdlc_close(dev);
392 +       return 0;
393 +}
394 +
395 +
396 +
397 +static int t9xx_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
398 +{
399 +       const size_t size = sizeof(te1_settings);
400 +       te1_settings new_line;
401 +       te1_settings __user *line = ifr->ifr_settings.ifs_ifsu.te1;
402 +       port_t *port = dev_to_port(dev);
403 +
404 +#ifdef DEBUG_RINGS
405 +       if (cmd == SIOCDEVPRIVATE) {
406 +               sca_dump_rings(dev);
407 +               return 0;
408 +       }
409 +#endif
410 +       if (cmd != SIOCWANDEV)
411 +               return hdlc_ioctl(dev, ifr, cmd);
412 +
413 +       switch(ifr->ifr_settings.type) {
414 +       case IF_GET_IFACE:
415 +               if (port->dsbase)
416 +                       ifr->ifr_settings.type = IF_IFACE_E1;
417 +               else
418 +                       ifr->ifr_settings.type = IF_IFACE_V35;
419 +               if (ifr->ifr_settings.size < size) {
420 +                       ifr->ifr_settings.size = size; /* data size wanted */
421 +                       return -ENOBUFS;
422 +               }
423 +               if (copy_to_user(line, &port->settings, size))
424 +                       return -EFAULT;
425 +               return 0;
426 +
427 +       case IF_IFACE_E1:
428 +       case IF_IFACE_V35:
429 +               if (!capable(CAP_NET_ADMIN))
430 +                       return -EPERM;
431 +
432 +               if (copy_from_user(&new_line, line, size))
433 +                       return -EFAULT;
434 +
435 +               if (new_line.clock_type != CLOCK_EXT)
436 +                       return -EINVAL; /* No such clock setting */
437 +
438 +               if (new_line.loopback > 3)
439 +                       return -EINVAL;
440 +
441 +               memcpy(&port->settings, &new_line, size); /* Update settings */
442 +               t9xx_set_iface(port);
443 +               sca_flush(port_to_card(port));
444 +               return 0;
445 +
446 +       default:
447 +               return hdlc_ioctl(dev, ifr, cmd);
448 +       }
449 +}
450 +
451 +
452 +
453 +static void t9xx_pci_remove_one(struct pci_dev *pdev)
454 +{
455 +       int i, ports;
456 +       card_t *card = pci_get_drvdata(pdev);
457 +
458 +       if ((pdev->subsystem_device == PCI_DEVICE_ID_TAHOE932) ||
459 +           (pdev->subsystem_device == PCI_DEVICE_ID_TAHOE972))
460 +               ports = 2;
461 +       else
462 +               ports = 1;
463 +       for(i = 0; i < ports; i++)
464 +               if (card->ports[i].card) {
465 +                       struct net_device *dev = port_to_dev(&card->ports[i]);
466 +                       unregister_hdlc_device(dev);
467 +               }
468 +
469 +       if (card->rambase)
470 +               iounmap(card->rambase);
471 +       if (card->scabase)
472 +               iounmap(card->scabase);
473 +       if (card->plxbase)
474 +               iounmap(card->plxbase);
475 +
476 +       pci_release_regions(pdev);
477 +       pci_disable_device(pdev);
478 +       pci_set_drvdata(pdev, NULL);
479 +       if (card->ports[0].dev)
480 +               free_netdev(card->ports[0].dev);
481 +       if ((ports == 2) && (card->ports[1].dev))
482 +               free_netdev(card->ports[1].dev);
483 +       kfree(card);
484 +}
485 +
486 +static void ds21554_update_licr(port_t *port)
487 +{
488 +       port->dsbase->licr = DEFAULT_LICR | (port->settings.egl << 4) | (port->g703_on == 0);
489 +}
490 +
491 +static void ds21554_update_registers(port_t *port)
492 +{
493 +       ds21554_t       *ds = port->dsbase;
494 +
495 +       if (port->settings.slot_map == 0xffffffff) {
496 +               /* Unframed */
497 +               ds->ccr1 = 0x08 | (port->g703_coding << 6) | (port->g703_coding << 2);
498 +               ds->tcr1 = 0x40;
499 +               ds->tcr2 = 0x00;
500 +               ds->ccr2 = 0x80; //84
501 +               ds->tir1 = 0; ds->tir2 = 0; ds->tir3 = 0; ds->tir4 = 0;
502 +               ds->tcc1 = 0; ds->tcc2 = 0; ds->tcc3 = 0; ds->tcc4 = 0;
503 +               ds->rcc1 = 0; ds->rcc2 = 0; ds->rcc3 = 0; ds->rcc4 = 0;
504 +               ds->rcbr1 = 0xff; ds->rcbr2 = 0xff; 
505 +               ds->rcbr3 = 0xff; ds->rcbr4 = 0xff; 
506 +               ds->tcbr1 = 0xff; ds->tcbr2 = 0xff; 
507 +               ds->tcbr3 = 0xff; ds->tcbr4 = 0xff; 
508 +               ds->tsacr = 0x00;
509 +               ds->tdc1 = 0x00;
510 +
511 +               ds->rcr2 = 0x04;
512 +               ds->ccr3 = 0x02;
513 +
514 +               ds->ccr6 = 0x03;        /* elastic buffers reset */
515 +               udelay(1000);
516 +               ds->ccr6 = 0x00;        /* elastic buffers reset */
517 +
518 +               ds->ccr5 = 0x60;        /* elastic buffers align */
519 +               udelay(1000);
520 +               ds->ccr5 = 0x00;
521 +       } else {
522 +               ds->ccr1 = 0x08 | (port->g703_coding << 6) | (port->g703_coding << 2)
523 +                               | (port->settings.crc4 << 4) | (port->settings.crc4);
524 +               ds->tcr1 = 0x00;
525 +               ds->ccr2 = 0x94;        /* Automatic alarm generation */
526 +
527 +               /* Receive channels */
528 +               ds->rcbr1 = port->settings.slot_map & 0xff;
529 +               ds->rcbr2 = (port->settings.slot_map >> 8) & 0xff;
530 +               ds->rcbr3 = (port->settings.slot_map >> 16) & 0xff;
531 +               ds->rcbr4 = (port->settings.slot_map >> 24) & 0xff;
532 +       
533 +               /* Transmit channels */
534 +               ds->tcbr1 = port->settings.slot_map & 0xff;
535 +               ds->tcbr2 = (port->settings.slot_map >> 8) & 0xff;
536 +               ds->tcbr3 = (port->settings.slot_map >> 16) & 0xff;
537 +               ds->tcbr4 = (port->settings.slot_map >> 24) & 0xff;
538 +
539 +               /* Transmit idle */
540 +               /* (remaining timeslots are filled with idle code) */
541 +               ds->tir1 = ~port->settings.slot_map & 0xfe;     /* Slot 0 is never idle */
542 +               ds->tir2 = (~port->settings.slot_map >> 8) & 0xff;
543 +               ds->tir3 = (~port->settings.slot_map >> 16) & 0xff;
544 +               ds->tir4 = (~port->settings.slot_map >> 24) & 0xff;
545 +               ds->rcr2 = 0x06;        /* RSYSCLK = 2048, rx elastic store enabled */
546 +               ds->ccr3 = 0x82;        /* TSYSCLK = 2048, tx elastic store enabled */
547 +
548 +               ds->ccr6 = 0x07;        /* elastic buffers reset */
549 +               udelay(1000);
550 +               ds->ccr6 = 0x04;        /* elastic buffers reset */
551 +
552 +               ds->ccr5 = 0x60;        /* elastic buffers align */
553 +               udelay(1000);
554 +               ds->ccr5 = 0x00;
555 +       }
556 +}
557 +
558 +void init_ds21554(port_t *port)
559 +{
560 +       ds21554_t       *ds = port->dsbase;
561 +       
562 +       ds->ccr2 = 0x04;
563 +       udelay(1000);
564 +       ds->ccr5 = 0x80;        /* Line Interface Reset */
565 +       udelay(1000);
566 +
567 +       ds->ccr5 = 0xe0;        /* Elastic Buffers Reset */
568 +       udelay(1000);
569 +       ds->ccr5 = 0x00;
570 +       ds->ccr6 = 0x04;        /* TCLK from RCLK */
571 +       ds->tcr2 = 0x00;
572 +       ds21554_update_licr(port);
573 +
574 +       /* Setup HDB3, CRC4, CAS/CCS, G.802 */
575 +       ds21554_update_registers(port);
576 +
577 +       ds->ccr2 = 0x94;        /* Automatic alarm generation */
578 +
579 +       ds->taf = 0x1b;
580 +       ds->tnaf = 0x40;
581 +
582 +       ds21554_update_registers(port);
583 +
584 +       ds->tidr = port->g703_idlecode;
585 +
586 +//     ds->ccr4 |= 0x40;
587 +}
588 +
589 +
590 +static int __devinit t9xx_pci_init_one(struct pci_dev *pdev,
591 +                                        const struct pci_device_id *ent)
592 +{
593 +       card_t *card;
594 +       u8 rev_id, tahoe97x = 0;
595 +       u32 __iomem *p;
596 +       int i;
597 +       u32 ramsize;
598 +       u32 ramphys;            /* buffer memory base */
599 +       u32 scaphys;            /* SCA memory base */
600 +       u32 plxphys;            /* PLX registers memory base */
601 +
602 +#ifndef MODULE
603 +        static int printed_version;
604 +        if (!printed_version++)
605 +                printk(KERN_INFO "%s\n", version);
606 +#endif
607 +
608 +       i = pci_enable_device(pdev);
609 +       if (i)
610 +               return i;
611 +
612 +       i = pci_request_regions(pdev, "Tahoe9xx");
613 +       if (i) {
614 +               pci_disable_device(pdev);
615 +               return i;
616 +       }
617 +
618 +       card = kmalloc(sizeof(card_t), GFP_KERNEL);
619 +       if (card == NULL) {
620 +               printk(KERN_ERR "%s: unable to allocate memory\n", card->dev_name);
621 +               pci_release_regions(pdev);
622 +               pci_disable_device(pdev);
623 +               return -ENOBUFS;
624 +       }
625 +       memset(card, 0, sizeof(card_t));
626 +       pci_set_drvdata(pdev, card);
627 +       card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
628 +       card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
629 +       if (!card->ports[0].dev || !card->ports[1].dev) {
630 +               printk(KERN_ERR "tahoe9xx: unable to allocate memory\n");
631 +               t9xx_pci_remove_one(pdev);
632 +               return -ENOMEM;
633 +       }
634 +
635 +       sprintf(card->dev_name, "Tahoe");
636 +       switch (pdev->subsystem_device) {
637 +               case PCI_DEVICE_ID_TAHOE931:
638 +                       strcat(card->dev_name, "931");
639 +                       card->no_ports = 1;
640 +                       break;
641 +               case PCI_DEVICE_ID_TAHOE932:
642 +                       strcat(card->dev_name, "932");
643 +                       card->no_ports = 2;
644 +                       break;
645 +               case PCI_DEVICE_ID_TAHOE971:
646 +                       strcat(card->dev_name, "971");
647 +                       tahoe97x = 1;
648 +                       card->no_ports = 1;
649 +                       break;
650 +               case PCI_DEVICE_ID_TAHOE972:
651 +                       strcat(card->dev_name, "972");
652 +                       tahoe97x = 1;
653 +                       card->no_ports = 2;
654 +                       break;
655 +               default:
656 +                       strcat(card->dev_name, "9xx");
657 +                       card->no_ports = 0;
658 +                       break;
659 +       }
660 +
661 +       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
662 +       if (pci_resource_len(pdev, 0) != TAHOE9XX_PLX_SIZE ||
663 +           pci_resource_len(pdev, 2) != TAHOE9XX_SCA_SIZE ||
664 +           pci_resource_len(pdev, 3) < 16384) {
665 +               printk(KERN_ERR "%s: invalid card EEPROM parameters\n", card->dev_name);
666 +               t9xx_pci_remove_one(pdev);
667 +               return -EFAULT;
668 +       }
669 +
670 +       plxphys = pci_resource_start(pdev,0) & PCI_BASE_ADDRESS_MEM_MASK;
671 +       card->plxbase = ioremap(plxphys, TAHOE9XX_PLX_SIZE);
672 +
673 +       scaphys = pci_resource_start(pdev,2) & PCI_BASE_ADDRESS_MEM_MASK;
674 +       card->scabase = ioremap(scaphys, TAHOE9XX_SCA_SIZE);
675 +
676 +       ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
677 +       card->rambase = ioremap(ramphys, pci_resource_len(pdev,3));
678 +
679 +       if (tahoe97x) {
680 +               for (i=0; i < card->no_ports; i++) {
681 +                       card->ports[i].dsphys = pci_resource_start(pdev,4+i) & PCI_BASE_ADDRESS_MEM_MASK;
682 +                       card->ports[i].dsbase = (ds21554_t *)ioremap(card->ports[i].dsphys, pci_resource_len(pdev,4+i));
683 +               }
684 +       } else {
685 +               for (i=0; i < card->no_ports; i++)
686 +                       card->ports[i].dsbase = (ds21554_t *)0;
687 +       }
688 +
689 +       if (card->plxbase == NULL ||
690 +           card->scabase == NULL ||
691 +           card->rambase == NULL) {
692 +               printk(KERN_ERR "tahoe9xx: ioremap() failed\n");
693 +               t9xx_pci_remove_one(pdev);
694 +       }
695 +
696 +       /* Reset PLX */
697 +       p = &card->plxbase->init_ctrl;
698 +       writel(readl(p) | 0x40000000, p);
699 +       readl(p);               /* Flush the write - do not use sca_flush */
700 +       udelay(1);
701 +
702 +       writel(readl(p) & ~0x40000000, p);
703 +       readl(p);               /* Flush the write - do not use sca_flush */
704 +       udelay(1);
705 +
706 +       ramsize = sca_detect_ram(card, card->rambase,
707 +                               pci_resource_len(pdev,3));
708 +
709 +       /* number of TX + RX buffers for one port - this is dual port card */
710 +       i = ramsize / (2 * (sizeof(pkt_desc) + HDLC_MAX_MRU));
711 +       card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS);
712 +       card->rx_ring_buffers = i - card->tx_ring_buffers;
713 +
714 +       card->buff_offset = 2 * sizeof(pkt_desc) * (card->tx_ring_buffers +
715 +                                                   card->rx_ring_buffers);
716 +
717 +       printk(KERN_INFO "%s: %u KB RAM at 0x%x, IRQ%u, using %u TX +"
718 +              " %u RX packets rings\n", card->dev_name, ramsize / 1024,
719 +              ramphys, pdev->irq,
720 +              card->tx_ring_buffers, card->rx_ring_buffers);
721 +       if (tahoe97x) {
722 +               for (i=0; i < card->no_ports; i++) {
723 +                       /* Make sure DS21554 is there */
724 +                       card->ports[i].dsbase->idr = 0x00;
725 +                       card->ports[i].dsbase->tc1 = 0xaa;
726 +                       card->ports[i].dsbase->rc1 = 0x55;
727 +                       if (((card->ports[i].dsbase->idr & 0xf0) == 0xa0) && (card->ports[i].dsbase->tc1 == 0xaa) && (card->ports[i].dsbase->rc1 == 0x55)) {
728 +                               printk(KERN_INFO "%s: DS21554 (port %d) detected at 0x%x\n", card->dev_name, i, card->ports[i].dsphys);
729 +                               /* Clear registers */
730 +                               memset(card->ports[i].dsbase, 0, 256);
731 +                               /* Default settings */
732 +                               card->ports[i].g703_on = 1;
733 +                               card->ports[i].settings.egl = 0;
734 +                               card->ports[i].g703_coding = G703_HDB3;
735 +                               card->ports[i].g703_idlecode = 0x54;
736 +                               card->ports[i].settings.crc4 = 1;
737 +                               /* Unframed */
738 +                               card->ports[i].settings.slot_map = 0xffffffff;
739 +                               init_ds21554(&card->ports[i]);
740 +                       } else
741 +                               printk(KERN_INFO "%s: DS21554 (port %d) test failed!\n", card->dev_name, i);
742 +               }
743 +       }
744 +
745 +       if (card->tx_ring_buffers < 1) {
746 +               printk(KERN_ERR "%s: RAM test failed\n", card->dev_name);
747 +               t9xx_pci_remove_one(pdev);
748 +               return -EFAULT;
749 +       }
750 +
751 +       /* Enable interrupts on the PCI bridge */
752 +       p = &card->plxbase->intr_ctrl_stat;
753 +       writew(readw(p) | 0x0040, p);
754 +
755 +       /* Allocate IRQ */
756 +       if(request_irq(pdev->irq, sca_intr, IRQF_SHARED, devname, card)) {
757 +               printk(KERN_WARNING "%s: could not allocate IRQ%d.\n", card->dev_name,
758 +                      pdev->irq);
759 +               t9xx_pci_remove_one(pdev);
760 +               return -EBUSY;
761 +       }
762 +       card->irq = pdev->irq;
763 +
764 +       sca_init(card, 0);
765 +
766 +       for(i = 0; i < card->no_ports; i++) {
767 +               port_t *port = &card->ports[i];
768 +               struct net_device *dev = port_to_dev(port);
769 +               hdlc_device *hdlc = dev_to_hdlc(dev);
770 +               port->phy_node = i;
771 +
772 +               spin_lock_init(&port->lock);
773 +               
774 +               dev->irq = card->irq;
775 +               dev->mem_start = ramphys;
776 +               dev->mem_end = ramphys + ramsize - 1;
777 +               dev->tx_queue_len = 50;
778 +               dev->do_ioctl = t9xx_ioctl;
779 +               dev->open = t9xx_open;
780 +               dev->stop = t9xx_close;
781 +               hdlc->attach = sca_attach;
782 +               hdlc->xmit = sca_xmit;
783 +               port->settings.clock_type = CLOCK_EXT;
784 +               port->card = card;
785 +               if(register_hdlc_device(dev)) {
786 +                       printk(KERN_ERR "%s: unable to register hdlc "
787 +                              "device\n", card->dev_name);
788 +                       port->card = NULL;
789 +                       t9xx_pci_remove_one(pdev);
790 +                       return -ENOBUFS;
791 +               }
792 +               sca_init_sync_port(port);       /* Set up SCA memory */
793 +
794 +               printk(KERN_INFO "%s: %s node %d\n",
795 +                      dev->name, card->dev_name, port->phy_node);
796 +       }
797 +
798 +       sca_flush(card);
799 +       return 0;
800 +}
801 +
802 +
803 +
804 +static struct pci_device_id t9xx_pci_tbl[] __devinitdata = {
805 +        { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, 
806 +          PCI_VENDOR_ID_TAHOE, PCI_ANY_ID,
807 +          0, 0, 0 },
808 +        { 0, }
809 +};
810 +
811 +static struct pci_driver t9xx_pci_driver = {
812 +        name:           "Tahoe9xx",
813 +        id_table:       t9xx_pci_tbl,
814 +        probe:          t9xx_pci_init_one,
815 +        remove:         t9xx_pci_remove_one,
816 +};
817 +
818 +static int __init t9xx_init_module(void)
819 +{
820 +#ifdef MODULE
821 +        printk(KERN_INFO "%s\n", version);
822 +#endif
823 +       return pci_register_driver(&t9xx_pci_driver);
824 +}
825 +
826 +
827 +
828 +static void __exit t9xx_cleanup_module(void)
829 +{
830 +       pci_unregister_driver(&t9xx_pci_driver);
831 +}
832 +
833 +MODULE_AUTHOR("Piotr Kaczmarzyk <piotr@tahoe.pl>");
834 +MODULE_DESCRIPTION("Tahoe 9xx serial port driver");
835 +MODULE_LICENSE("GPL v2");
836 +MODULE_DEVICE_TABLE(pci, t9xx_pci_tbl);
837 +module_init(t9xx_init_module);
838 +module_exit(t9xx_cleanup_module);
839 --- linux/drivers/net/wan/Kconfig       2003-03-06 14:56:13.000000000 +0100
840 +++ linux/drivers/net/wan/Kconfig       2003-03-30 22:37:04.000000000 +0200
841 @@ -218,6 +218,21 @@
842  comment "X.25/LAPB support is disabled"
843         depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y
844  
845 +config TAHOE9XX
846 +       tristate "Tahoe 9xx support"
847 +       depends on HDLC && PCI
848 +       help
849 +         This driver is for Tahoe 931/932/971/972 cards
850 +         If you have such a card, say Y or M here and see
851 +         <http://www.tahoe.pl/>
852 +
853 +         If you want to compile the driver as a module ( = code which can be
854 +         inserted in and removed from the running kernel whenever you want),
855 +         say M here and read <file:Documentation/modules.txt>.  The module
856 +         will be called tahoe9xx.o.
857 +
858 +         If unsure, say N here.
859 +
860  config PCI200SYN
861         tristate "Goramo PCI200SYN support"
862         depends on HDLC && PCI
863 --- linux/include/linux/hdlc/ioctl.h    1970-01-01 01:00:00.000000000 +0100
864 +++ linux/include/linux/hdlc/ioctl.h    2003-07-31 14:46:58.000000000 +0200
865 @@ -12,6 +12,8 @@
866         unsigned int clock_type; /* internal, external, TX-internal etc. */
867         unsigned short loopback;
868         unsigned int slot_map;
869 +       unsigned short crc4;
870 +       unsigned short egl;
871  } te1_settings;                  /* T1, E1 */
872  
873  typedef struct {
This page took 0.087483 seconds and 3 git commands to generate.