summaryrefslogtreecommitdiffstats
path: root/drivers/net/wan
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khc@pm.waw.pl>2008-07-09 23:13:49 +0200
committerKrzysztof Hałasa <khc@pm.waw.pl>2008-11-22 02:49:48 +0100
commit61e0a6a268947f7385282c6841f3e3d64b4c5cb9 (patch)
tree86a9ee7c3eb2028fe1589df5a94091b153fb273a /drivers/net/wan
parent967834361a4beb3bbd3069189c192dc6fdeef8a9 (diff)
downloadlinux-61e0a6a268947f7385282c6841f3e3d64b4c5cb9.tar.bz2
WAN: Simplify HD64572 drivers.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Diffstat (limited to 'drivers/net/wan')
-rw-r--r--drivers/net/wan/hd64572.c139
-rw-r--r--drivers/net/wan/pc300too.c51
-rw-r--r--drivers/net/wan/pci200syn.c55
3 files changed, 110 insertions, 135 deletions
diff --git a/drivers/net/wan/hd64572.c b/drivers/net/wan/hd64572.c
index 46a99a668e41..c7eff0a66a8e 100644
--- a/drivers/net/wan/hd64572.c
+++ b/drivers/net/wan/hd64572.c
@@ -11,13 +11,13 @@
*
* We use the following SCA memory map:
*
- * Packet buffer descriptor rings - starting from winbase or win0base:
+ * Packet buffer descriptor rings - starting from card->rambase:
* rx_ring_buffers * sizeof(pkt_desc) = logical channel #0 RX ring
* tx_ring_buffers * sizeof(pkt_desc) = logical channel #0 TX ring
* rx_ring_buffers * sizeof(pkt_desc) = logical channel #1 RX ring (if used)
* tx_ring_buffers * sizeof(pkt_desc) = logical channel #1 TX ring (if used)
*
- * Packet data buffers - starting from winbase + buff_offset:
+ * Packet data buffers - starting from card->rambase + buff_offset:
* rx_ring_buffers * HDLC_MAX_MRU = logical channel #0 RX buffers
* tx_ring_buffers * HDLC_MAX_MRU = logical channel #0 TX buffers
* rx_ring_buffers * HDLC_MAX_MRU = logical channel #0 RX buffers (if used)
@@ -47,16 +47,18 @@
#define NAPI_WEIGHT 16
-#define get_msci(port) (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET)
-#define get_dmac_rx(port) (phy_node(port) ? DMAC1RX_OFFSET : DMAC0RX_OFFSET)
-#define get_dmac_tx(port) (phy_node(port) ? DMAC1TX_OFFSET : DMAC0TX_OFFSET)
+#define get_msci(port) (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET)
+#define get_dmac_rx(port) (port->chan ? DMAC1RX_OFFSET : DMAC0RX_OFFSET)
+#define get_dmac_tx(port) (port->chan ? DMAC1TX_OFFSET : DMAC0TX_OFFSET)
-static int sca_poll(struct napi_struct *napi, int budget);
+#define sca_in(reg, card) readb(card->scabase + (reg))
+#define sca_out(value, reg, card) writeb(value, card->scabase + (reg))
+#define sca_inw(reg, card) readw(card->scabase + (reg))
+#define sca_outw(value, reg, card) writew(value, card->scabase + (reg))
+#define sca_inl(reg, card) readl(card->scabase + (reg))
+#define sca_outl(value, reg, card) writel(value, card->scabase + (reg))
-static inline struct net_device *port_to_dev(port_t *port)
-{
- return port->dev;
-}
+static int sca_poll(struct napi_struct *napi, int budget);
static inline port_t* dev_to_port(struct net_device *dev)
{
@@ -67,30 +69,29 @@ static inline void enable_intr(port_t *port)
{
/* enable DMIB and MSCI RXINTA interrupts */
sca_outl(sca_inl(IER0, port->card) |
- (phy_node(port) ? 0x08002200 : 0x00080022), IER0, port->card);
+ (port->chan ? 0x08002200 : 0x00080022), IER0, port->card);
}
static inline void disable_intr(port_t *port)
{
sca_outl(sca_inl(IER0, port->card) &
- (phy_node(port) ? 0x00FF00FF : 0xFF00FF00), IER0, port->card);
+ (port->chan ? 0x00FF00FF : 0xFF00FF00), IER0, port->card);
}
static inline u16 next_desc(port_t *port, u16 desc, int transmit)
{
- return (desc + 1) % (transmit ? port_to_card(port)->tx_ring_buffers
- : port_to_card(port)->rx_ring_buffers);
+ return (desc + 1) % (transmit ? port->card->tx_ring_buffers
+ : port->card->rx_ring_buffers);
}
static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
{
- u16 rx_buffs = port_to_card(port)->rx_ring_buffers;
- u16 tx_buffs = port_to_card(port)->tx_ring_buffers;
+ u16 rx_buffs = port->card->rx_ring_buffers;
+ u16 tx_buffs = port->card->tx_ring_buffers;
desc %= (transmit ? tx_buffs : rx_buffs); // called with "X + 1" etc.
- return log_node(port) * (rx_buffs + tx_buffs) +
- transmit * rx_buffs + desc;
+ return port->chan * (rx_buffs + tx_buffs) + transmit * rx_buffs + desc;
}
@@ -104,39 +105,39 @@ static inline u16 desc_offset(port_t *port, u16 desc, int transmit)
static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc,
int transmit)
{
- return (pkt_desc __iomem *)(winbase(port_to_card(port))
- + desc_offset(port, desc, transmit));
+ return (pkt_desc __iomem *)(port->card->rambase +
+ desc_offset(port, desc, transmit));
}
static inline u32 buffer_offset(port_t *port, u16 desc, int transmit)
{
- return port_to_card(port)->buff_offset +
+ return port->card->buff_offset +
desc_abs_number(port, desc, transmit) * (u32)HDLC_MAX_MRU;
}
static inline void sca_set_carrier(port_t *port)
{
- if (!(sca_in(get_msci(port) + ST3, port_to_card(port)) & ST3_DCD)) {
+ if (!(sca_in(get_msci(port) + ST3, port->card) & ST3_DCD)) {
#ifdef DEBUG_LINK
printk(KERN_DEBUG "%s: sca_set_carrier on\n",
- port_to_dev(port)->name);
+ port->netdev.name);
#endif
- netif_carrier_on(port_to_dev(port));
+ netif_carrier_on(port->netdev);
} else {
#ifdef DEBUG_LINK
printk(KERN_DEBUG "%s: sca_set_carrier off\n",
- port_to_dev(port)->name);
+ port->netdev.name);
#endif
- netif_carrier_off(port_to_dev(port));
+ netif_carrier_off(port->netdev);
}
}
static void sca_init_port(port_t *port)
{
- card_t *card = port_to_card(port);
+ card_t *card = port->card;
int transmit, i;
port->rxin = 0;
@@ -160,11 +161,11 @@ static void sca_init_port(port_t *port)
}
/* DMA disable - to halt state */
- sca_out(0, transmit ? DSR_TX(phy_node(port)) :
- DSR_RX(phy_node(port)), card);
+ sca_out(0, transmit ? DSR_TX(port->chan) :
+ DSR_RX(port->chan), card);
/* software ABORT - to initial state */
- sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
- DCR_RX(phy_node(port)), card);
+ sca_out(DCR_ABORT, transmit ? DCR_TX(port->chan) :
+ DCR_RX(port->chan), card);
/* current desc addr */
sca_outl(desc_offset(port, 0, transmit), dmac + CDAL, card);
@@ -176,26 +177,26 @@ static void sca_init_port(port_t *port)
card);
/* clear frame end interrupt counter */
- sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(phy_node(port)) :
- DCR_RX(phy_node(port)), card);
+ sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(port->chan) :
+ DCR_RX(port->chan), card);
if (!transmit) { /* Receive */
/* set buffer length */
sca_outw(HDLC_MAX_MRU, dmac + BFLL, card);
/* Chain mode, Multi-frame */
- sca_out(0x14, DMR_RX(phy_node(port)), card);
- sca_out(DIR_EOME, DIR_RX(phy_node(port)), card);
+ sca_out(0x14, DMR_RX(port->chan), card);
+ sca_out(DIR_EOME, DIR_RX(port->chan), card);
/* DMA enable */
- sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
+ sca_out(DSR_DE, DSR_RX(port->chan), card);
} else { /* Transmit */
/* Chain mode, Multi-frame */
- sca_out(0x14, DMR_TX(phy_node(port)), card);
+ sca_out(0x14, DMR_TX(port->chan), card);
/* enable underflow interrupts */
- sca_out(DIR_EOME, DIR_TX(phy_node(port)), card);
+ sca_out(DIR_EOME, DIR_TX(port->chan), card);
}
}
sca_set_carrier(port);
- netif_napi_add(port_to_dev(port), &port->napi, sca_poll, NAPI_WEIGHT);
+ netif_napi_add(port->netdev, &port->napi, sca_poll, NAPI_WEIGHT);
}
@@ -203,7 +204,7 @@ static void sca_init_port(port_t *port)
static inline void sca_msci_intr(port_t *port)
{
u16 msci = get_msci(port);
- card_t* card = port_to_card(port);
+ card_t* card = port->card;
if (sca_in(msci + ST1, card) & ST1_CDCD) {
/* Reset MSCI CDCD status bit */
@@ -216,7 +217,7 @@ static inline void sca_msci_intr(port_t *port)
static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
u16 rxin)
{
- struct net_device *dev = port_to_dev(port);
+ struct net_device *dev = port->netdev;
struct sk_buff *skb;
u16 len;
u32 buff;
@@ -229,7 +230,7 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
}
buff = buffer_offset(port, rxin, 0);
- memcpy_fromio(skb->data, winbase(card) + buff, len);
+ memcpy_fromio(skb->data, card->rambase + buff, len);
skb_put(skb, len);
#ifdef DEBUG_PKT
@@ -246,15 +247,15 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
/* Receive DMA service */
static inline int sca_rx_done(port_t *port, int budget)
{
- struct net_device *dev = port_to_dev(port);
+ struct net_device *dev = port->netdev;
u16 dmac = get_dmac_rx(port);
- card_t *card = port_to_card(port);
- u8 stat = sca_in(DSR_RX(phy_node(port)), card); /* read DMA Status */
+ card_t *card = port->card;
+ u8 stat = sca_in(DSR_RX(port->chan), card); /* read DMA Status */
int received = 0;
/* Reset DSR status bits */
sca_out((stat & (DSR_EOT | DSR_EOM | DSR_BOF | DSR_COF)) | DSR_DWE,
- DSR_RX(phy_node(port)), card);
+ DSR_RX(port->chan), card);
if (stat & DSR_BOF)
/* Dropped one or more frames */
@@ -294,7 +295,7 @@ static inline int sca_rx_done(port_t *port, int budget)
}
/* make sure RX DMA is enabled */
- sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
+ sca_out(DSR_DE, DSR_RX(port->chan), card);
return received;
}
@@ -302,17 +303,17 @@ static inline int sca_rx_done(port_t *port, int budget)
/* Transmit DMA service */
static inline void sca_tx_done(port_t *port)
{
- struct net_device *dev = port_to_dev(port);
- card_t* card = port_to_card(port);
+ struct net_device *dev = port->netdev;
+ card_t* card = port->card;
u8 stat;
spin_lock(&port->lock);
- stat = sca_in(DSR_TX(phy_node(port)), card); /* read DMA Status */
+ stat = sca_in(DSR_TX(port->chan), card); /* read DMA Status */
/* Reset DSR status bits */
sca_out((stat & (DSR_EOT | DSR_EOM | DSR_BOF | DSR_COF)) | DSR_DWE,
- DSR_TX(phy_node(port)), card);
+ DSR_TX(port->chan), card);
while (1) {
pkt_desc __iomem *desc = desc_address(port, port->txlast, 1);
@@ -342,17 +343,17 @@ static int sca_poll(struct napi_struct *napi, int budget)
u32 isr0 = sca_inl(ISR0, port->card);
int received = 0;
- if (isr0 & (port->phy_node ? 0x08000000 : 0x00080000))
+ if (isr0 & (port->chan ? 0x08000000 : 0x00080000))
sca_msci_intr(port);
- if (isr0 & (port->phy_node ? 0x00002000 : 0x00000020))
+ if (isr0 & (port->chan ? 0x00002000 : 0x00000020))
sca_tx_done(port);
- if (isr0 & (port->phy_node ? 0x00000200 : 0x00000002))
+ if (isr0 & (port->chan ? 0x00000200 : 0x00000002))
received = sca_rx_done(port, budget);
if (received < budget) {
- netif_rx_complete(port->dev, napi);
+ netif_rx_complete(port->netdev, napi);
enable_intr(port);
}
@@ -370,7 +371,7 @@ static irqreturn_t sca_intr(int irq, void *dev_id)
if (port && (isr0 & (i ? 0x08002200 : 0x00080022))) {
handled = 1;
disable_intr(port);
- netif_rx_schedule(port->dev, &port->napi);
+ netif_rx_schedule(port->netdev, &port->napi);
}
}
@@ -380,7 +381,7 @@ static irqreturn_t sca_intr(int irq, void *dev_id)
static void sca_set_port(port_t *port)
{
- card_t* card = port_to_card(port);
+ card_t* card = port->card;
u16 msci = get_msci(port);
u8 md2 = sca_in(msci + MD2, card);
unsigned int tmc, br = 10, brv = 1024;
@@ -435,7 +436,7 @@ static void sca_set_port(port_t *port)
static void sca_open(struct net_device *dev)
{
port_t *port = dev_to_port(dev);
- card_t* card = port_to_card(port);
+ card_t* card = port->card;
u16 msci = get_msci(port);
u8 md0, md2;
@@ -496,7 +497,7 @@ static void sca_close(struct net_device *dev)
port_t *port = dev_to_port(dev);
/* reset channel */
- sca_out(CMD_RESET, get_msci(port) + CMD, port_to_card(port));
+ sca_out(CMD_RESET, get_msci(port) + CMD, port->card);
disable_intr(port);
napi_disable(&port->napi);
netif_stop_queue(dev);
@@ -530,25 +531,25 @@ static int sca_attach(struct net_device *dev, unsigned short encoding,
static void sca_dump_rings(struct net_device *dev)
{
port_t *port = dev_to_port(dev);
- card_t *card = port_to_card(port);
+ card_t *card = port->card;
u16 cnt;
printk(KERN_DEBUG "RX ring: CDA=%u EDA=%u DSR=%02X in=%u %sactive",
sca_inl(get_dmac_rx(port) + CDAL, card),
sca_inl(get_dmac_rx(port) + EDAL, card),
- sca_in(DSR_RX(phy_node(port)), card), port->rxin,
- sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in");
- for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++)
+ sca_in(DSR_RX(port->chan), card), port->rxin,
+ sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in");
+ for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++)
printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat)));
printk("\n" KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u "
"last=%u %sactive",
sca_inl(get_dmac_tx(port) + CDAL, card),
sca_inl(get_dmac_tx(port) + EDAL, card),
- sca_in(DSR_TX(phy_node(port)), card), port->txin, port->txlast,
- sca_in(DSR_TX(phy_node(port)), card) & DSR_DE ? "" : "in");
+ sca_in(DSR_TX(port->chan), card), port->txin, port->txlast,
+ sca_in(DSR_TX(port->chan), card) & DSR_DE ? "" : "in");
- for (cnt = 0; cnt < port_to_card(port)->tx_ring_buffers; cnt++)
+ for (cnt = 0; cnt < port->card->tx_ring_buffers; cnt++)
printk(" %02X", readb(&(desc_address(port, cnt, 1)->stat)));
printk("\n");
@@ -575,7 +576,7 @@ static void sca_dump_rings(struct net_device *dev)
static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
{
port_t *port = dev_to_port(dev);
- card_t *card = port_to_card(port);
+ card_t *card = port->card;
pkt_desc __iomem *desc;
u32 buff, len;
@@ -592,7 +593,7 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
desc = desc_address(port, port->txin, 1);
buff = buffer_offset(port, port->txin, 1);
len = skb->len;
- memcpy_toio(winbase(card) + buff, skb->data, len);
+ memcpy_toio(card->rambase + buff, skb->data, len);
writew(len, &desc->len);
writeb(ST_TX_EOM, &desc->stat);
@@ -602,7 +603,7 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
sca_outl(desc_offset(port, port->txin, 1),
get_dmac_tx(port) + EDAL, card);
- sca_out(DSR_DE, DSR_TX(phy_node(port)), card); /* Enable TX DMA */
+ sca_out(DSR_DE, DSR_TX(port->chan), card); /* Enable TX DMA */
desc = desc_address(port, port->txin + 1, 1);
if (readb(&desc->stat)) /* allow 1 packet gap */
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 @@
/*
* Cyclades PC300 synchronous serial card driver for Linux
*
- * Copyright (C) 2000-2007 Krzysztof Halasa <khc@pm.waw.pl>
+ * Copyright (C) 2000-2008 Krzysztof Halasa <khc@pm.waw.pl>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License
@@ -11,7 +11,7 @@
*
* Sources of information:
* Hitachi HD64572 SCA-II User's Manual
- * Cyclades PC300 Linux driver
+ * Original Cyclades PC300 Linux driver
*
* This driver currently supports only PC300/RSV (V.24/V.35) and
* PC300/X21 cards.
@@ -76,7 +76,7 @@ typedef struct {
typedef struct port_s {
struct napi_struct napi;
- struct net_device *dev;
+ struct net_device *netdev;
struct card_s *card;
spinlock_t lock; /* TX lock */
sync_serial_settings settings;
@@ -88,7 +88,7 @@ typedef struct port_s {
u16 txin; /* tx ring buffer 'in' and 'last' pointers */
u16 txlast;
u8 rxs, txs, tmc; /* SCA registers */
- u8 phy_node; /* physical port # - 0 or 1 */
+ u8 chan; /* physical port # - 0 or 1 */
}port_t;
@@ -109,17 +109,6 @@ typedef struct card_s {
}card_t;
-#define sca_in(reg, card) readb(card->scabase + (reg))
-#define sca_out(value, reg, card) writeb(value, card->scabase + (reg))
-#define sca_inw(reg, card) readw(card->scabase + (reg))
-#define sca_outw(value, reg, card) writew(value, card->scabase + (reg))
-#define sca_inl(reg, card) readl(card->scabase + (reg))
-#define sca_outl(value, reg, card) writel(value, card->scabase + (reg))
-
-#define port_to_card(port) (port->card)
-#define log_node(port) (port->phy_node)
-#define phy_node(port) (port->phy_node)
-#define winbase(card) (card->rambase)
#define get_port(card, port) ((port) < (card)->n_ports ? \
(&(card)->ports[port]) : (NULL))
@@ -134,8 +123,8 @@ static void pc300_set_iface(port_t *port)
u8 rxs = port->rxs & CLK_BRG_MASK;
u8 txs = port->txs & CLK_BRG_MASK;
- sca_out(EXS_TES1, (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
- port_to_card(port));
+ sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
+ port->card);
switch(port->settings.clock_type) {
case CLOCK_INT:
rxs |= CLK_BRG; /* BRG output */
@@ -167,10 +156,10 @@ static void pc300_set_iface(port_t *port)
if (port->card->type == PC300_RSV) {
if (port->iface == IF_IFACE_V35)
writel(card->init_ctrl_value |
- PC300_CHMEDIA_MASK(port->phy_node), init_ctrl);
+ PC300_CHMEDIA_MASK(port->chan), init_ctrl);
else
writel(card->init_ctrl_value &
- ~PC300_CHMEDIA_MASK(port->phy_node), init_ctrl);
+ ~PC300_CHMEDIA_MASK(port->chan), init_ctrl);
}
}
@@ -275,10 +264,8 @@ static void pc300_pci_remove_one(struct pci_dev *pdev)
card_t *card = pci_get_drvdata(pdev);
for (i = 0; i < 2; i++)
- if (card->ports[i].card) {
- struct net_device *dev = port_to_dev(&card->ports[i]);
- unregister_hdlc_device(dev);
- }
+ if (card->ports[i].card)
+ unregister_hdlc_device(card->ports[i].netdev);
if (card->irq)
free_irq(card->irq, card);
@@ -293,10 +280,10 @@ static void pc300_pci_remove_one(struct pci_dev *pdev)
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
- if (card->ports[0].dev)
- free_netdev(card->ports[0].dev);
- if (card->ports[1].dev)
- free_netdev(card->ports[1].dev);
+ if (card->ports[0].netdev)
+ free_netdev(card->ports[0].netdev);
+ if (card->ports[1].netdev)
+ free_netdev(card->ports[1].netdev);
kfree(card);
}
@@ -347,7 +334,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
card->n_ports = 2;
for (i = 0; i < card->n_ports; i++)
- if (!(card->ports[i].dev = alloc_hdlcdev(&card->ports[i]))) {
+ if (!(card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]))) {
printk(KERN_ERR "pc300: unable to allocate memory\n");
pc300_pci_remove_one(pdev);
return -ENOMEM;
@@ -452,9 +439,9 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
for (i = 0; i < card->n_ports; i++) {
port_t *port = &card->ports[i];
- struct net_device *dev = port_to_dev(port);
+ struct net_device *dev = port->netdev;
hdlc_device *hdlc = dev_to_hdlc(dev);
- port->phy_node = i;
+ port->chan = i;
spin_lock_init(&port->lock);
dev->irq = card->irq;
@@ -482,8 +469,8 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
return -ENOBUFS;
}
- printk(KERN_INFO "%s: PC300 node %d\n",
- dev->name, port->phy_node);
+ printk(KERN_INFO "%s: PC300 channel %d\n",
+ dev->name, port->chan);
}
return 0;
}
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index a16311a79e9a..1104d3a692f7 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -1,7 +1,7 @@
/*
* Goramo PCI200SYN synchronous serial card driver for Linux
*
- * Copyright (C) 2002-2003 Krzysztof Halasa <khc@pm.waw.pl>
+ * Copyright (C) 2002-2008 Krzysztof Halasa <khc@pm.waw.pl>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License
@@ -63,7 +63,7 @@ typedef struct {
typedef struct port_s {
struct napi_struct napi;
- struct net_device *dev;
+ struct net_device *netdev;
struct card_s *card;
spinlock_t lock; /* TX lock */
sync_serial_settings settings;
@@ -74,7 +74,7 @@ typedef struct port_s {
u16 txin; /* tx ring buffer 'in' and 'last' pointers */
u16 txlast;
u8 rxs, txs, tmc; /* SCA registers */
- u8 phy_node; /* physical port # - 0 or 1 */
+ u8 chan; /* physical port # - 0 or 1 */
}port_t;
@@ -92,17 +92,6 @@ typedef struct card_s {
}card_t;
-#define sca_in(reg, card) readb(card->scabase + (reg))
-#define sca_out(value, reg, card) writeb(value, card->scabase + (reg))
-#define sca_inw(reg, card) readw(card->scabase + (reg))
-#define sca_outw(value, reg, card) writew(value, card->scabase + (reg))
-#define sca_inl(reg, card) readl(card->scabase + (reg))
-#define sca_outl(value, reg, card) writel(value, card->scabase + (reg))
-
-#define port_to_card(port) (port->card)
-#define log_node(port) (port->phy_node)
-#define phy_node(port) (port->phy_node)
-#define winbase(card) (card->rambase)
#define get_port(card, port) (&card->ports[port])
#define sca_flush(card) (sca_in(IER0, card));
@@ -132,8 +121,8 @@ static void pci200_set_iface(port_t *port)
u8 rxs = port->rxs & CLK_BRG_MASK;
u8 txs = port->txs & CLK_BRG_MASK;
- sca_out(EXS_TES1, (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
- port_to_card(port));
+ sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
+ port->card);
switch(port->settings.clock_type) {
case CLOCK_INT:
rxs |= CLK_BRG; /* BRG output */
@@ -175,7 +164,7 @@ static int pci200_open(struct net_device *dev)
sca_open(dev);
pci200_set_iface(port);
- sca_flush(port_to_card(port));
+ sca_flush(port->card);
return 0;
}
@@ -184,7 +173,7 @@ static int pci200_open(struct net_device *dev)
static int pci200_close(struct net_device *dev)
{
sca_close(dev);
- sca_flush(port_to_card(dev_to_port(dev)));
+ sca_flush(dev_to_port(dev)->card);
hdlc_close(dev);
return 0;
}
@@ -237,7 +226,7 @@ static int pci200_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
memcpy(&port->settings, &new_line, size); /* Update settings */
pci200_set_iface(port);
- sca_flush(port_to_card(port));
+ sca_flush(port->card);
return 0;
default:
@@ -253,10 +242,8 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
card_t *card = pci_get_drvdata(pdev);
for (i = 0; i < 2; i++)
- if (card->ports[i].card) {
- struct net_device *dev = port_to_dev(&card->ports[i]);
- unregister_hdlc_device(dev);
- }
+ if (card->ports[i].card)
+ unregister_hdlc_device(card->ports[i].netdev);
if (card->irq)
free_irq(card->irq, card);
@@ -271,10 +258,10 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
- if (card->ports[0].dev)
- free_netdev(card->ports[0].dev);
- if (card->ports[1].dev)
- free_netdev(card->ports[1].dev);
+ if (card->ports[0].netdev)
+ free_netdev(card->ports[0].netdev);
+ if (card->ports[1].netdev)
+ free_netdev(card->ports[1].netdev);
kfree(card);
}
@@ -309,9 +296,9 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
return -ENOBUFS;
}
pci_set_drvdata(pdev, card);
- card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
- card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
- if (!card->ports[0].dev || !card->ports[1].dev) {
+ card->ports[0].netdev = alloc_hdlcdev(&card->ports[0]);
+ card->ports[1].netdev = alloc_hdlcdev(&card->ports[1]);
+ if (!card->ports[0].netdev || !card->ports[1].netdev) {
printk(KERN_ERR "pci200syn: unable to allocate memory\n");
pci200_pci_remove_one(pdev);
return -ENOMEM;
@@ -399,9 +386,9 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
for (i = 0; i < 2; i++) {
port_t *port = &card->ports[i];
- struct net_device *dev = port_to_dev(port);
+ struct net_device *dev = port->netdev;
hdlc_device *hdlc = dev_to_hdlc(dev);
- port->phy_node = i;
+ port->chan = i;
spin_lock_init(&port->lock);
dev->irq = card->irq;
@@ -424,8 +411,8 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
return -ENOBUFS;
}
- printk(KERN_INFO "%s: PCI200SYN node %d\n",
- dev->name, port->phy_node);
+ printk(KERN_INFO "%s: PCI200SYN channel %d\n",
+ dev->name, port->chan);
}
sca_flush(card);