diff options
Diffstat (limited to 'drivers/net/wan/pc300too.c')
-rw-r--r-- | drivers/net/wan/pc300too.c | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index 9b42199d4f83..ac8b0a20a0d8 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Cyclades PC300 synchronous serial card driver for Linux | 2 | * Cyclades PC300 synchronous serial card driver for Linux |
3 | * | 3 | * |
4 | * Copyright (C) 2000-2007 Krzysztof Halasa <khc@pm.waw.pl> | 4 | * Copyright (C) 2000-2008 Krzysztof Halasa <khc@pm.waw.pl> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of version 2 of the GNU General Public License | 7 | * under the terms of version 2 of the GNU General Public License |
@@ -11,7 +11,7 @@ | |||
11 | * | 11 | * |
12 | * Sources of information: | 12 | * Sources of information: |
13 | * Hitachi HD64572 SCA-II User's Manual | 13 | * Hitachi HD64572 SCA-II User's Manual |
14 | * Cyclades PC300 Linux driver | 14 | * Original Cyclades PC300 Linux driver |
15 | * | 15 | * |
16 | * This driver currently supports only PC300/RSV (V.24/V.35) and | 16 | * This driver currently supports only PC300/RSV (V.24/V.35) and |
17 | * PC300/X21 cards. | 17 | * PC300/X21 cards. |
@@ -76,7 +76,7 @@ typedef struct { | |||
76 | 76 | ||
77 | typedef struct port_s { | 77 | typedef struct port_s { |
78 | struct napi_struct napi; | 78 | struct napi_struct napi; |
79 | struct net_device *dev; | 79 | struct net_device *netdev; |
80 | struct card_s *card; | 80 | struct card_s *card; |
81 | spinlock_t lock; /* TX lock */ | 81 | spinlock_t lock; /* TX lock */ |
82 | sync_serial_settings settings; | 82 | sync_serial_settings settings; |
@@ -88,7 +88,7 @@ typedef struct port_s { | |||
88 | u16 txin; /* tx ring buffer 'in' and 'last' pointers */ | 88 | u16 txin; /* tx ring buffer 'in' and 'last' pointers */ |
89 | u16 txlast; | 89 | u16 txlast; |
90 | u8 rxs, txs, tmc; /* SCA registers */ | 90 | u8 rxs, txs, tmc; /* SCA registers */ |
91 | u8 phy_node; /* physical port # - 0 or 1 */ | 91 | u8 chan; /* physical port # - 0 or 1 */ |
92 | }port_t; | 92 | }port_t; |
93 | 93 | ||
94 | 94 | ||
@@ -109,17 +109,6 @@ typedef struct card_s { | |||
109 | }card_t; | 109 | }card_t; |
110 | 110 | ||
111 | 111 | ||
112 | #define sca_in(reg, card) readb(card->scabase + (reg)) | ||
113 | #define sca_out(value, reg, card) writeb(value, card->scabase + (reg)) | ||
114 | #define sca_inw(reg, card) readw(card->scabase + (reg)) | ||
115 | #define sca_outw(value, reg, card) writew(value, card->scabase + (reg)) | ||
116 | #define sca_inl(reg, card) readl(card->scabase + (reg)) | ||
117 | #define sca_outl(value, reg, card) writel(value, card->scabase + (reg)) | ||
118 | |||
119 | #define port_to_card(port) (port->card) | ||
120 | #define log_node(port) (port->phy_node) | ||
121 | #define phy_node(port) (port->phy_node) | ||
122 | #define winbase(card) (card->rambase) | ||
123 | #define get_port(card, port) ((port) < (card)->n_ports ? \ | 112 | #define get_port(card, port) ((port) < (card)->n_ports ? \ |
124 | (&(card)->ports[port]) : (NULL)) | 113 | (&(card)->ports[port]) : (NULL)) |
125 | 114 | ||
@@ -134,8 +123,8 @@ static void pc300_set_iface(port_t *port) | |||
134 | u8 rxs = port->rxs & CLK_BRG_MASK; | 123 | u8 rxs = port->rxs & CLK_BRG_MASK; |
135 | u8 txs = port->txs & CLK_BRG_MASK; | 124 | u8 txs = port->txs & CLK_BRG_MASK; |
136 | 125 | ||
137 | sca_out(EXS_TES1, (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS, | 126 | sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS, |
138 | port_to_card(port)); | 127 | port->card); |
139 | switch(port->settings.clock_type) { | 128 | switch(port->settings.clock_type) { |
140 | case CLOCK_INT: | 129 | case CLOCK_INT: |
141 | rxs |= CLK_BRG; /* BRG output */ | 130 | rxs |= CLK_BRG; /* BRG output */ |
@@ -167,10 +156,10 @@ static void pc300_set_iface(port_t *port) | |||
167 | if (port->card->type == PC300_RSV) { | 156 | if (port->card->type == PC300_RSV) { |
168 | if (port->iface == IF_IFACE_V35) | 157 | if (port->iface == IF_IFACE_V35) |
169 | writel(card->init_ctrl_value | | 158 | writel(card->init_ctrl_value | |
170 | PC300_CHMEDIA_MASK(port->phy_node), init_ctrl); | 159 | PC300_CHMEDIA_MASK(port->chan), init_ctrl); |
171 | else | 160 | else |
172 | writel(card->init_ctrl_value & | 161 | writel(card->init_ctrl_value & |
173 | ~PC300_CHMEDIA_MASK(port->phy_node), init_ctrl); | 162 | ~PC300_CHMEDIA_MASK(port->chan), init_ctrl); |
174 | } | 163 | } |
175 | } | 164 | } |
176 | 165 | ||
@@ -275,10 +264,8 @@ static void pc300_pci_remove_one(struct pci_dev *pdev) | |||
275 | card_t *card = pci_get_drvdata(pdev); | 264 | card_t *card = pci_get_drvdata(pdev); |
276 | 265 | ||
277 | for (i = 0; i < 2; i++) | 266 | for (i = 0; i < 2; i++) |
278 | if (card->ports[i].card) { | 267 | if (card->ports[i].card) |
279 | struct net_device *dev = port_to_dev(&card->ports[i]); | 268 | unregister_hdlc_device(card->ports[i].netdev); |
280 | unregister_hdlc_device(dev); | ||
281 | } | ||
282 | 269 | ||
283 | if (card->irq) | 270 | if (card->irq) |
284 | free_irq(card->irq, card); | 271 | free_irq(card->irq, card); |
@@ -293,10 +280,10 @@ static void pc300_pci_remove_one(struct pci_dev *pdev) | |||
293 | pci_release_regions(pdev); | 280 | pci_release_regions(pdev); |
294 | pci_disable_device(pdev); | 281 | pci_disable_device(pdev); |
295 | pci_set_drvdata(pdev, NULL); | 282 | pci_set_drvdata(pdev, NULL); |
296 | if (card->ports[0].dev) | 283 | if (card->ports[0].netdev) |
297 | free_netdev(card->ports[0].dev); | 284 | free_netdev(card->ports[0].netdev); |
298 | if (card->ports[1].dev) | 285 | if (card->ports[1].netdev) |
299 | free_netdev(card->ports[1].dev); | 286 | free_netdev(card->ports[1].netdev); |
300 | kfree(card); | 287 | kfree(card); |
301 | } | 288 | } |
302 | 289 | ||
@@ -347,7 +334,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, | |||
347 | card->n_ports = 2; | 334 | card->n_ports = 2; |
348 | 335 | ||
349 | for (i = 0; i < card->n_ports; i++) | 336 | for (i = 0; i < card->n_ports; i++) |
350 | if (!(card->ports[i].dev = alloc_hdlcdev(&card->ports[i]))) { | 337 | if (!(card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]))) { |
351 | printk(KERN_ERR "pc300: unable to allocate memory\n"); | 338 | printk(KERN_ERR "pc300: unable to allocate memory\n"); |
352 | pc300_pci_remove_one(pdev); | 339 | pc300_pci_remove_one(pdev); |
353 | return -ENOMEM; | 340 | return -ENOMEM; |
@@ -452,9 +439,9 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, | |||
452 | 439 | ||
453 | for (i = 0; i < card->n_ports; i++) { | 440 | for (i = 0; i < card->n_ports; i++) { |
454 | port_t *port = &card->ports[i]; | 441 | port_t *port = &card->ports[i]; |
455 | struct net_device *dev = port_to_dev(port); | 442 | struct net_device *dev = port->netdev; |
456 | hdlc_device *hdlc = dev_to_hdlc(dev); | 443 | hdlc_device *hdlc = dev_to_hdlc(dev); |
457 | port->phy_node = i; | 444 | port->chan = i; |
458 | 445 | ||
459 | spin_lock_init(&port->lock); | 446 | spin_lock_init(&port->lock); |
460 | dev->irq = card->irq; | 447 | dev->irq = card->irq; |
@@ -482,8 +469,8 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, | |||
482 | return -ENOBUFS; | 469 | return -ENOBUFS; |
483 | } | 470 | } |
484 | 471 | ||
485 | printk(KERN_INFO "%s: PC300 node %d\n", | 472 | printk(KERN_INFO "%s: PC300 channel %d\n", |
486 | dev->name, port->phy_node); | 473 | dev->name, port->chan); |
487 | } | 474 | } |
488 | return 0; | 475 | return 0; |
489 | } | 476 | } |