Commit 88597364 authored by Krzysztof Hałasa's avatar Krzysztof Hałasa

WAN: remove SCA II support from SCA drivers

Signed-off-by: default avatarKrzysztof Hałasa <khc@pm.waw.pl>
parent 6b40aba3
...@@ -88,7 +88,7 @@ static card_t **new_card = &first_card; ...@@ -88,7 +88,7 @@ static card_t **new_card = &first_card;
/* EDA address register must be set in EDAL, EDAH order - 8 bit ISA bus */ /* EDA address register must be set in EDAL, EDAH order - 8 bit ISA bus */
#define sca_outw(value, reg, card) do { \ #define sca_outw(value, reg, card) do { \
writeb(value & 0xFF, (card)->win0base + C101_SCA + (reg)); \ writeb(value & 0xFF, (card)->win0base + C101_SCA + (reg)); \
writeb((value >> 8 ) & 0xFF, (card)->win0base + C101_SCA + (reg+1));\ writeb((value >> 8 ) & 0xFF, (card)->win0base + C101_SCA + (reg + 1));\
} while(0) } while(0)
#define port_to_card(port) (port) #define port_to_card(port) (port)
...@@ -381,7 +381,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) ...@@ -381,7 +381,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
return result; return result;
} }
sca_init_sync_port(card); /* Set up C101 memory */ sca_init_port(card); /* Set up C101 memory */
set_carrier(card); set_carrier(card);
printk(KERN_INFO "%s: Moxa C101 on IRQ%u," printk(KERN_INFO "%s: Moxa C101 on IRQ%u,"
......
/* /*
* Hitachi SCA HD64570 and HD64572 common driver for Linux * Hitachi SCA HD64570 driver for Linux
* *
* Copyright (C) 1998-2003 Krzysztof Halasa <khc@pm.waw.pl> * Copyright (C) 1998-2003 Krzysztof Halasa <khc@pm.waw.pl>
* *
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
* under the terms of version 2 of the GNU General Public License * under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation. * as published by the Free Software Foundation.
* *
* Sources of information: * Source of information: Hitachi HD64570 SCA User's Manual
* Hitachi HD64570 SCA User's Manual
* Hitachi HD64572 SCA-II User's Manual
* *
* We use the following SCA memory map: * We use the following SCA memory map:
* *
...@@ -26,33 +24,26 @@ ...@@ -26,33 +24,26 @@
* tx_ring_buffers * HDLC_MAX_MRU = logical channel #0 TX buffers (if used) * tx_ring_buffers * HDLC_MAX_MRU = logical channel #0 TX buffers (if used)
*/ */
#include <linux/module.h> #include <linux/bitops.h>
#include <linux/kernel.h> #include <linux/errno.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/types.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/interrupt.h> #include <linux/hdlc.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/bitops.h> #include <linux/jiffies.h>
#include <linux/kernel.h>
#include <asm/system.h> #include <linux/module.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/hdlc.h> #include <linux/string.h>
#include <linux/types.h>
#if (!defined (__HD64570_H) && !defined (__HD64572_H)) || \ #include <asm/io.h>
(defined (__HD64570_H) && defined (__HD64572_H)) #include <asm/system.h>
#error Either hd64570.h or hd64572.h must be included #include <asm/uaccess.h>
#endif #include "hd64570.h"
#define get_msci(port) (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) #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_rx(port) (phy_node(port) ? DMAC1RX_OFFSET : DMAC0RX_OFFSET)
...@@ -62,16 +53,6 @@ ...@@ -62,16 +53,6 @@
#define SCA_INTR_DMAC_RX(node) (node ? 0x20 : 0x02) #define SCA_INTR_DMAC_RX(node) (node ? 0x20 : 0x02)
#define SCA_INTR_DMAC_TX(node) (node ? 0x40 : 0x04) #define SCA_INTR_DMAC_TX(node) (node ? 0x40 : 0x04)
#ifdef __HD64570_H /* HD64570 */
#define sca_outa(value, reg, card) sca_outw(value, reg, card)
#define sca_ina(reg, card) sca_inw(reg, card)
#define writea(value, ptr) writew(value, ptr)
#else /* HD64572 */
#define sca_outa(value, reg, card) sca_outl(value, reg, card)
#define sca_ina(reg, card) sca_inl(reg, card)
#define writea(value, ptr) writel(value, ptr)
#endif
static inline struct net_device *port_to_dev(port_t *port) static inline struct net_device *port_to_dev(port_t *port)
{ {
...@@ -81,8 +62,6 @@ static inline struct net_device *port_to_dev(port_t *port) ...@@ -81,8 +62,6 @@ static inline struct net_device *port_to_dev(port_t *port)
static inline int sca_intr_status(card_t *card) static inline int sca_intr_status(card_t *card)
{ {
u8 result = 0; u8 result = 0;
#ifdef __HD64570_H /* HD64570 */
u8 isr0 = sca_in(ISR0, card); u8 isr0 = sca_in(ISR0, card);
u8 isr1 = sca_in(ISR1, card); u8 isr1 = sca_in(ISR1, card);
...@@ -93,18 +72,6 @@ static inline int sca_intr_status(card_t *card) ...@@ -93,18 +72,6 @@ static inline int sca_intr_status(card_t *card)
if (isr0 & 0x0F) result |= SCA_INTR_MSCI(0); if (isr0 & 0x0F) result |= SCA_INTR_MSCI(0);
if (isr0 & 0xF0) result |= SCA_INTR_MSCI(1); if (isr0 & 0xF0) result |= SCA_INTR_MSCI(1);
#else /* HD64572 */
u32 isr0 = sca_inl(ISR0, card);
if (isr0 & 0x0000000F) result |= SCA_INTR_DMAC_RX(0);
if (isr0 & 0x000000F0) result |= SCA_INTR_DMAC_TX(0);
if (isr0 & 0x00000F00) result |= SCA_INTR_DMAC_RX(1);
if (isr0 & 0x0000F000) result |= SCA_INTR_DMAC_TX(1);
if (isr0 & 0x003E0000) result |= SCA_INTR_MSCI(0);
if (isr0 & 0x3E000000) result |= SCA_INTR_MSCI(1);
#endif /* HD64570 vs HD64572 */
if (!(result & SCA_INTR_DMAC_TX(0))) if (!(result & SCA_INTR_DMAC_TX(0)))
if (sca_in(DSR_TX(0), card) & DSR_EOM) if (sca_in(DSR_TX(0), card) & DSR_EOM)
result |= SCA_INTR_DMAC_TX(0); result |= SCA_INTR_DMAC_TX(0);
...@@ -127,7 +94,6 @@ static inline u16 next_desc(port_t *port, u16 desc, int transmit) ...@@ -127,7 +94,6 @@ static inline u16 next_desc(port_t *port, u16 desc, int transmit)
} }
static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
{ {
u16 rx_buffs = port_to_card(port)->rx_ring_buffers; u16 rx_buffs = port_to_card(port)->rx_ring_buffers;
...@@ -139,7 +105,6 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit) ...@@ -139,7 +105,6 @@ static inline u16 desc_abs_number(port_t *port, u16 desc, int transmit)
} }
static inline u16 desc_offset(port_t *port, u16 desc, int transmit) static inline u16 desc_offset(port_t *port, u16 desc, int transmit)
{ {
/* Descriptor offset always fits in 16 bytes */ /* Descriptor offset always fits in 16 bytes */
...@@ -147,20 +112,19 @@ static inline u16 desc_offset(port_t *port, u16 desc, int transmit) ...@@ -147,20 +112,19 @@ static inline u16 desc_offset(port_t *port, u16 desc, int transmit)
} }
static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc,
static inline pkt_desc __iomem *desc_address(port_t *port, u16 desc, int transmit) int transmit)
{ {
#ifdef PAGE0_ALWAYS_MAPPED #ifdef PAGE0_ALWAYS_MAPPED
return (pkt_desc __iomem *)(win0base(port_to_card(port)) return (pkt_desc __iomem *)(win0base(port_to_card(port))
+ desc_offset(port, desc, transmit)); + desc_offset(port, desc, transmit));
#else #else
return (pkt_desc __iomem *)(winbase(port_to_card(port)) return (pkt_desc __iomem *)(winbase(port_to_card(port))
+ desc_offset(port, desc, transmit)); + desc_offset(port, desc, transmit));
#endif #endif
} }
static inline u32 buffer_offset(port_t *port, u16 desc, int transmit) static inline u32 buffer_offset(port_t *port, u16 desc, int transmit)
{ {
return port_to_card(port)->buff_offset + return port_to_card(port)->buff_offset +
...@@ -186,7 +150,7 @@ static inline void sca_set_carrier(port_t *port) ...@@ -186,7 +150,7 @@ static inline void sca_set_carrier(port_t *port)
} }
static void sca_init_sync_port(port_t *port) static void sca_init_port(port_t *port)
{ {
card_t *card = port_to_card(port); card_t *card = port_to_card(port);
int transmit, i; int transmit, i;
...@@ -195,7 +159,7 @@ static void sca_init_sync_port(port_t *port) ...@@ -195,7 +159,7 @@ static void sca_init_sync_port(port_t *port)
port->txin = 0; port->txin = 0;
port->txlast = 0; port->txlast = 0;
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED) #ifndef PAGE0_ALWAYS_MAPPED
openwin(card, 0); openwin(card, 0);
#endif #endif
...@@ -209,7 +173,7 @@ static void sca_init_sync_port(port_t *port) ...@@ -209,7 +173,7 @@ static void sca_init_sync_port(port_t *port)
u16 chain_off = desc_offset(port, i + 1, transmit); u16 chain_off = desc_offset(port, i + 1, transmit);
u32 buff_off = buffer_offset(port, i, transmit); u32 buff_off = buffer_offset(port, i, transmit);
writea(chain_off, &desc->cp); writew(chain_off, &desc->cp);
writel(buff_off, &desc->bp); writel(buff_off, &desc->bp);
writew(0, &desc->len); writew(0, &desc->len);
writeb(0, &desc->stat); writeb(0, &desc->stat);
...@@ -222,16 +186,14 @@ static void sca_init_sync_port(port_t *port) ...@@ -222,16 +186,14 @@ static void sca_init_sync_port(port_t *port)
sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) : sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
DCR_RX(phy_node(port)), card); DCR_RX(phy_node(port)), card);
#ifdef __HD64570_H
sca_out(0, dmac + CPB, card); /* pointer base */
#endif
/* current desc addr */ /* current desc addr */
sca_outa(desc_offset(port, 0, transmit), dmac + CDAL, card); sca_out(0, dmac + CPB, card); /* pointer base */
sca_outw(desc_offset(port, 0, transmit), dmac + CDAL, card);
if (!transmit) if (!transmit)
sca_outa(desc_offset(port, buffs - 1, transmit), sca_outw(desc_offset(port, buffs - 1, transmit),
dmac + EDAL, card); dmac + EDAL, card);
else else
sca_outa(desc_offset(port, 0, transmit), dmac + EDAL, sca_outw(desc_offset(port, 0, transmit), dmac + EDAL,
card); card);
/* clear frame end interrupt counter */ /* clear frame end interrupt counter */
...@@ -258,7 +220,6 @@ static void sca_init_sync_port(port_t *port) ...@@ -258,7 +220,6 @@ static void sca_init_sync_port(port_t *port)
} }
#ifdef NEED_SCA_MSCI_INTR #ifdef NEED_SCA_MSCI_INTR
/* MSCI interrupt service */ /* MSCI interrupt service */
static inline void sca_msci_intr(port_t *port) static inline void sca_msci_intr(port_t *port)
...@@ -282,17 +243,15 @@ static inline void sca_msci_intr(port_t *port) ...@@ -282,17 +243,15 @@ static inline void sca_msci_intr(port_t *port)
#endif #endif
static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u16 rxin) u16 rxin)
{ {
struct net_device *dev = port_to_dev(port); struct net_device *dev = port_to_dev(port);
struct sk_buff *skb; struct sk_buff *skb;
u16 len; u16 len;
u32 buff; u32 buff;
#ifndef ALL_PAGES_ALWAYS_MAPPED
u32 maxlen; u32 maxlen;
u8 page; u8 page;
#endif
len = readw(&desc->len); len = readw(&desc->len);
skb = dev_alloc_skb(len); skb = dev_alloc_skb(len);
...@@ -302,7 +261,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1 ...@@ -302,7 +261,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1
} }
buff = buffer_offset(port, rxin, 0); buff = buffer_offset(port, rxin, 0);
#ifndef ALL_PAGES_ALWAYS_MAPPED
page = buff / winsize(card); page = buff / winsize(card);
buff = buff % winsize(card); buff = buff % winsize(card);
maxlen = winsize(card) - buff; maxlen = winsize(card) - buff;
...@@ -314,12 +272,10 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1 ...@@ -314,12 +272,10 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1
openwin(card, page + 1); openwin(card, page + 1);
memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen); memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen);
} else } else
#endif memcpy_fromio(skb->data, winbase(card) + buff, len);
memcpy_fromio(skb->data, winbase(card) + buff, len);
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED) #ifndef PAGE0_ALWAYS_MAPPED
/* select pkt_desc table page back */ openwin(card, 0); /* select pkt_desc table page back */
openwin(card, 0);
#endif #endif
skb_put(skb, len); skb_put(skb, len);
#ifdef DEBUG_PKT #ifdef DEBUG_PKT
...@@ -333,7 +289,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1 ...@@ -333,7 +289,6 @@ static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, u1
} }
/* Receive DMA interrupt service */ /* Receive DMA interrupt service */
static inline void sca_rx_intr(port_t *port) static inline void sca_rx_intr(port_t *port)
{ {
...@@ -353,7 +308,7 @@ static inline void sca_rx_intr(port_t *port) ...@@ -353,7 +308,7 @@ static inline void sca_rx_intr(port_t *port)
while (1) { while (1) {
u32 desc_off = desc_offset(port, port->rxin, 0); u32 desc_off = desc_offset(port, port->rxin, 0);
pkt_desc __iomem *desc; pkt_desc __iomem *desc;
u32 cda = sca_ina(dmac + CDAL, card); u32 cda = sca_inw(dmac + CDAL, card);
if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc))) if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc)))
break; /* No frame received */ break; /* No frame received */
...@@ -377,7 +332,7 @@ static inline void sca_rx_intr(port_t *port) ...@@ -377,7 +332,7 @@ static inline void sca_rx_intr(port_t *port)
sca_rx(card, port, desc, port->rxin); sca_rx(card, port, desc, port->rxin);
/* Set new error descriptor address */ /* Set new error descriptor address */
sca_outa(desc_off, dmac + EDAL, card); sca_outw(desc_off, dmac + EDAL, card);
port->rxin = next_desc(port, port->rxin, 0); port->rxin = next_desc(port, port->rxin, 0);
} }
...@@ -386,7 +341,6 @@ static inline void sca_rx_intr(port_t *port) ...@@ -386,7 +341,6 @@ static inline void sca_rx_intr(port_t *port)
} }
/* Transmit DMA interrupt service */ /* Transmit DMA interrupt service */
static inline void sca_tx_intr(port_t *port) static inline void sca_tx_intr(port_t *port)
{ {
...@@ -407,7 +361,7 @@ static inline void sca_tx_intr(port_t *port) ...@@ -407,7 +361,7 @@ static inline void sca_tx_intr(port_t *port)
pkt_desc __iomem *desc; pkt_desc __iomem *desc;
u32 desc_off = desc_offset(port, port->txlast, 1); u32 desc_off = desc_offset(port, port->txlast, 1);
u32 cda = sca_ina(dmac + CDAL, card); u32 cda = sca_inw(dmac + CDAL, card);
if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc))) if ((cda >= desc_off) && (cda < desc_off + sizeof(pkt_desc)))
break; /* Transmitter is/will_be sending this frame */ break; /* Transmitter is/will_be sending this frame */
...@@ -423,17 +377,13 @@ static inline void sca_tx_intr(port_t *port) ...@@ -423,17 +377,13 @@ static inline void sca_tx_intr(port_t *port)
} }
static irqreturn_t sca_intr(int irq, void* dev_id) static irqreturn_t sca_intr(int irq, void* dev_id)
{ {
card_t *card = dev_id; card_t *card = dev_id;
int i; int i;
u8 stat; u8 stat;
int handled = 0; int handled = 0;
#ifndef ALL_PAGES_ALWAYS_MAPPED
u8 page = sca_get_page(card); u8 page = sca_get_page(card);
#endif
while((stat = sca_intr_status(card)) != 0) { while((stat = sca_intr_status(card)) != 0) {
handled = 1; handled = 1;
...@@ -452,14 +402,11 @@ static irqreturn_t sca_intr(int irq, void* dev_id) ...@@ -452,14 +402,11 @@ static irqreturn_t sca_intr(int irq, void* dev_id)
} }
} }
#ifndef ALL_PAGES_ALWAYS_MAPPED
openwin(card, page); /* Restore original page */ openwin(card, page); /* Restore original page */
#endif
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static void sca_set_port(port_t *port) static void sca_set_port(port_t *port)
{ {
card_t* card = port_to_card(port); card_t* card = port_to_card(port);
...@@ -497,12 +444,7 @@ static void sca_set_port(port_t *port) ...@@ -497,12 +444,7 @@ static void sca_set_port(port_t *port)
port->tmc = tmc; port->tmc = tmc;
/* baud divisor - time constant*/ /* baud divisor - time constant*/
#ifdef __HD64570_H
sca_out(port->tmc, msci + TMC, card); sca_out(port->tmc, msci + TMC, card);
#else
sca_out(port->tmc, msci + TMCR, card);
sca_out(port->tmc, msci + TMCT, card);
#endif
/* Set BRG bits */ /* Set BRG bits */
sca_out(port->rxs, msci + RXS, card); sca_out(port->rxs, msci + RXS, card);
...@@ -518,7 +460,6 @@ static void sca_set_port(port_t *port) ...@@ -518,7 +460,6 @@ static void sca_set_port(port_t *port)
} }
static void sca_open(struct net_device *dev) static void sca_open(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
...@@ -540,11 +481,7 @@ static void sca_open(struct net_device *dev) ...@@ -540,11 +481,7 @@ static void sca_open(struct net_device *dev)
switch(port->parity) { switch(port->parity) {
case PARITY_CRC16_PR0: md0 = MD0_HDLC | MD0_CRC_16_0; break; case PARITY_CRC16_PR0: md0 = MD0_HDLC | MD0_CRC_16_0; break;
case PARITY_CRC16_PR1: md0 = MD0_HDLC | MD0_CRC_16; break; case PARITY_CRC16_PR1: md0 = MD0_HDLC | MD0_CRC_16; break;
#ifdef __HD64570_H
case PARITY_CRC16_PR0_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU_0; break; case PARITY_CRC16_PR0_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU_0; break;
#else
case PARITY_CRC32_PR1_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU32; break;
#endif
case PARITY_CRC16_PR1_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU; break; case PARITY_CRC16_PR1_CCITT: md0 = MD0_HDLC | MD0_CRC_ITU; break;
default: md0 = MD0_HDLC | MD0_CRC_NONE; default: md0 = MD0_HDLC | MD0_CRC_NONE;
} }
...@@ -554,35 +491,20 @@ static void sca_open(struct net_device *dev) ...@@ -554,35 +491,20 @@ static void sca_open(struct net_device *dev)
sca_out(0x00, msci + MD1, card); /* no address field check */ sca_out(0x00, msci + MD1, card); /* no address field check */
sca_out(md2, msci + MD2, card); sca_out(md2, msci + MD2, card);
sca_out(0x7E, msci + IDL, card); /* flag character 0x7E */ sca_out(0x7E, msci + IDL, card); /* flag character 0x7E */
#ifdef __HD64570_H
sca_out(CTL_IDLE, msci + CTL, card); sca_out(CTL_IDLE, msci + CTL, card);
#else
/* Skip the rest of underrun frame */
sca_out(CTL_IDLE | CTL_URCT | CTL_URSKP, msci + CTL, card);
#endif
#ifdef __HD64570_H
/* Allow at least 8 bytes before requesting RX DMA operation */ /* Allow at least 8 bytes before requesting RX DMA operation */
/* TX with higher priority and possibly with shorter transfers */ /* TX with higher priority and possibly with shorter transfers */
sca_out(0x07, msci + RRC, card); /* +1=RXRDY/DMA activation condition*/ sca_out(0x07, msci + RRC, card); /* +1=RXRDY/DMA activation condition*/
sca_out(0x10, msci + TRC0, card); /* = TXRDY/DMA activation condition*/ sca_out(0x10, msci + TRC0, card); /* = TXRDY/DMA activation condition*/
sca_out(0x14, msci + TRC1, card); /* +1=TXRDY/DMA deactiv condition */ sca_out(0x14, msci + TRC1, card); /* +1=TXRDY/DMA deactiv condition */
#else
sca_out(0x0F, msci + RNR, card); /* +1=RX DMA activation condition */
sca_out(0x3C, msci + TFS, card); /* +1 = TX start */
sca_out(0x38, msci + TCR, card); /* =Critical TX DMA activ condition */
sca_out(0x38, msci + TNR0, card); /* =TX DMA activation condition */
sca_out(0x3F, msci + TNR1, card); /* +1=TX DMA deactivation condition*/
#endif
/* We're using the following interrupts: /* We're using the following interrupts:
- TXINT (DMAC completed all transmisions, underrun or DCD change) - TXINT (DMAC completed all transmisions, underrun or DCD change)
- all DMA interrupts - all DMA interrupts
*/ */
sca_set_carrier(port); sca_set_carrier(port);
#ifdef __HD64570_H
/* MSCI TX INT and RX INT A IRQ enable */ /* MSCI TX INT and RX INT A IRQ enable */
sca_out(IE0_TXINT | IE0_RXINTA, msci + IE0, card); sca_out(IE0_TXINT | IE0_RXINTA, msci + IE0, card);
sca_out(IE1_UDRN | IE1_CDCD, msci + IE1, card); sca_out(IE1_UDRN | IE1_CDCD, msci + IE1, card);
...@@ -591,21 +513,8 @@ static void sca_open(struct net_device *dev) ...@@ -591,21 +513,8 @@ static void sca_open(struct net_device *dev)
/* enable DMA IRQ */ /* enable DMA IRQ */
sca_out(sca_in(IER1, card) | (phy_node(port) ? 0xF0 : 0x0F), sca_out(sca_in(IER1, card) | (phy_node(port) ? 0xF0 : 0x0F),
IER1, card); IER1, card);
#else
/* MSCI TXINT and RXINTA interrupt enable */
sca_outl(IE0_TXINT | IE0_RXINTA | IE0_UDRN | IE0_CDCD, msci + IE0,
card);
/* DMA & MSCI IRQ enable */
sca_outl(sca_inl(IER0, card) |
(phy_node(port) ? 0x0A006600 : 0x000A0066), IER0, card);
#endif
#ifdef __HD64570_H
sca_out(port->tmc, msci + TMC, card); /* Restore registers */ sca_out(port->tmc, msci + TMC, card); /* Restore registers */
#else
sca_out(port->tmc, msci + TMCR, card);
sca_out(port->tmc, msci + TMCT, card);
#endif
sca_out(port->rxs, msci + RXS, card); sca_out(port->rxs, msci + RXS, card);
sca_out(port->txs, msci + TXS, card); sca_out(port->txs, msci + TXS, card);
sca_out(CMD_TX_ENABLE, msci + CMD, card); sca_out(CMD_TX_ENABLE, msci + CMD, card);
...@@ -615,7 +524,6 @@ static void sca_open(struct net_device *dev) ...@@ -615,7 +524,6 @@ static void sca_open(struct net_device *dev)
} }
static void sca_close(struct net_device *dev) static void sca_close(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
...@@ -623,23 +531,17 @@ static void sca_close(struct net_device *dev) ...@@ -623,23 +531,17 @@ static void sca_close(struct net_device *dev)
/* reset channel */ /* reset channel */
sca_out(CMD_RESET, get_msci(port) + CMD, port_to_card(port)); sca_out(CMD_RESET, get_msci(port) + CMD, port_to_card(port));
#ifdef __HD64570_H
/* disable MSCI interrupts */ /* disable MSCI interrupts */
sca_out(sca_in(IER0, card) & (phy_node(port) ? 0x0F : 0xF0), sca_out(sca_in(IER0, card) & (phy_node(port) ? 0x0F : 0xF0),
IER0, card); IER0, card);
/* disable DMA interrupts */ /* disable DMA interrupts */
sca_out(sca_in(IER1, card) & (phy_node(port) ? 0x0F : 0xF0), sca_out(sca_in(IER1, card) & (phy_node(port) ? 0x0F : 0xF0),
IER1, card); IER1, card);
#else
/* disable DMA & MSCI IRQ */
sca_outl(sca_inl(IER0, card) &
(phy_node(port) ? 0x00FF00FF : 0xFF00FF00), IER0, card);
#endif
netif_stop_queue(dev); netif_stop_queue(dev);
} }
static int sca_attach(struct net_device *dev, unsigned short encoding, static int sca_attach(struct net_device *dev, unsigned short encoding,
unsigned short parity) unsigned short parity)
{ {
...@@ -653,11 +555,7 @@ static int sca_attach(struct net_device *dev, unsigned short encoding, ...@@ -653,11 +555,7 @@ static int sca_attach(struct net_device *dev, unsigned short encoding,
if (parity != PARITY_NONE && if (parity != PARITY_NONE &&
parity != PARITY_CRC16_PR0 && parity != PARITY_CRC16_PR0 &&
parity != PARITY_CRC16_PR1 && parity != PARITY_CRC16_PR1 &&
#ifdef __HD64570_H
parity != PARITY_CRC16_PR0_CCITT && parity != PARITY_CRC16_PR0_CCITT &&
#else
parity != PARITY_CRC32_PR1_CCITT &&
#endif
parity != PARITY_CRC16_PR1_CCITT) parity != PARITY_CRC16_PR1_CCITT)
return -EINVAL; return -EINVAL;
...@@ -667,34 +565,30 @@ static int sca_attach(struct net_device *dev, unsigned short encoding, ...@@ -667,34 +565,30 @@ static int sca_attach(struct net_device *dev, unsigned short encoding,
} }
#ifdef DEBUG_RINGS #ifdef DEBUG_RINGS
static void sca_dump_rings(struct net_device *dev) static void sca_dump_rings(struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
card_t *card = port_to_card(port); card_t *card = port_to_card(port);
u16 cnt; u16 cnt;
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED) #ifndef PAGE0_ALWAYS_MAPPED
u8 page; u8 page = sca_get_page(card);
#endif
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED)
page = sca_get_page(card);
openwin(card, 0); openwin(card, 0);
#endif #endif
printk(KERN_DEBUG "RX ring: CDA=%u EDA=%u DSR=%02X in=%u %sactive", printk(KERN_DEBUG "RX ring: CDA=%u EDA=%u DSR=%02X in=%u %sactive",
sca_ina(get_dmac_rx(port) + CDAL, card), sca_inw(get_dmac_rx(port) + CDAL, card),
sca_ina(get_dmac_rx(port) + EDAL, card), sca_inw(get_dmac_rx(port) + EDAL, card),
sca_in(DSR_RX(phy_node(port)), card), port->rxin, sca_in(DSR_RX(phy_node(port)), card), port->rxin,
sca_in(DSR_RX(phy_node(port)), card) & DSR_DE?"":"in"); sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in");
for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++) for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++)
printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat)));
printk("\n" KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u " printk("\n" KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u "
"last=%u %sactive", "last=%u %sactive",
sca_ina(get_dmac_tx(port) + CDAL, card), sca_inw(get_dmac_tx(port) + CDAL, card),
sca_ina(get_dmac_tx(port) + EDAL, card), sca_inw(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), port->txin, port->txlast,
sca_in(DSR_TX(phy_node(port)), card) & DSR_DE ? "" : "in"); sca_in(DSR_TX(phy_node(port)), card) & DSR_DE ? "" : "in");
...@@ -702,12 +596,8 @@ static void sca_dump_rings(struct net_device *dev) ...@@ -702,12 +596,8 @@ static void sca_dump_rings(struct net_device *dev)
printk(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); printk(" %02X", readb(&(desc_address(port, cnt, 1)->stat)));
printk("\n"); printk("\n");
printk(KERN_DEBUG "MSCI: MD: %02x %02x %02x, " printk(KERN_DEBUG "MSCI: MD: %02x %02x %02x, ST: %02x %02x %02x %02x,"
"ST: %02x %02x %02x %02x" " FST: %02x CST: %02x %02x\n",
#ifdef __HD64572_H
" %02x"
#endif
", FST: %02x CST: %02x %02x\n",
sca_in(get_msci(port) + MD0, card), sca_in(get_msci(port) + MD0, card),
sca_in(get_msci(port) + MD1, card), sca_in(get_msci(port) + MD1, card),
sca_in(get_msci(port) + MD2, card), sca_in(get_msci(port) + MD2, card),
...@@ -715,52 +605,33 @@ static void sca_dump_rings(struct net_device *dev) ...@@ -715,52 +605,33 @@ static void sca_dump_rings(struct net_device *dev)
sca_in(get_msci(port) + ST1, card), sca_in(get_msci(port) + ST1, card),
sca_in(get_msci(port) + ST2, card), sca_in(get_msci(port) + ST2, card),
sca_in(get_msci(port) + ST3, card), sca_in(get_msci(port) + ST3, card),
#ifdef __HD64572_H
sca_in(get_msci(port) + ST4, card),
#endif
sca_in(get_msci(port) + FST, card), sca_in(get_msci(port) + FST, card),
sca_in(get_msci(port) + CST0, card), sca_in(get_msci(port) + CST0, card),
sca_in(get_msci(port) + CST1, card)); sca_in(get_msci(port) + CST1, card));
#ifdef __HD64572_H
printk(KERN_DEBUG "ILAR: %02x ISR: %08x %08x\n", sca_in(ILAR, card),
sca_inl(ISR0, card), sca_inl(ISR1, card));
#else
printk(KERN_DEBUG "ISR: %02x %02x %02x\n", sca_in(ISR0, card), printk(KERN_DEBUG "ISR: %02x %02x %02x\n", sca_in(ISR0, card),
sca_in(ISR1, card), sca_in(ISR2, card)); sca_in(ISR1, card), sca_in(ISR2, card));
#endif
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED) #ifndef PAGE0_ALWAYS_MAPPED
openwin(card, page); /* Restore original page */ openwin(card, page); /* Restore original page */
#endif #endif
} }
#endif /* DEBUG_RINGS */ #endif /* DEBUG_RINGS */
static int sca_xmit(struct sk_buff *skb, struct net_device *dev) static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
port_t *port = dev_to_port(dev); port_t *port = dev_to_port(dev);
card_t *card = port_to_card(port); card_t *card = port_to_card(port);
pkt_desc __iomem *desc; pkt_desc __iomem *desc;
u32 buff, len; u32 buff, len;
#ifndef ALL_PAGES_ALWAYS_MAPPED
u8 page; u8 page;
u32 maxlen; u32 maxlen;
#endif
spin_lock_irq(&port->lock); spin_lock_irq(&port->lock);
desc = desc_address(port, port->txin + 1, 1); desc = desc_address(port, port->txin + 1, 1);
if (readb(&desc->stat)) { /* allow 1 packet gap */ BUG_ON(readb(&desc->stat)); /* previous xmit should stop queue */
/* should never happen - previous xmit should stop queue */
#ifdef DEBUG_PKT
printk(KERN_DEBUG "%s: transmitter buffer full\n", dev->name);
#endif
netif_stop_queue(dev);
spin_unlock_irq(&port->lock);
return 1; /* request packet to be queued */
}
#ifdef DEBUG_PKT #ifdef DEBUG_PKT
printk(KERN_DEBUG "%s TX(%i):", dev->name, skb->len); printk(KERN_DEBUG "%s TX(%i):", dev->name, skb->len);
...@@ -770,7 +641,6 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -770,7 +641,6 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
desc = desc_address(port, port->txin, 1); desc = desc_address(port, port->txin, 1);
buff = buffer_offset(port, port->txin, 1); buff = buffer_offset(port, port->txin, 1);
len = skb->len; len = skb->len;
#ifndef ALL_PAGES_ALWAYS_MAPPED
page = buff / winsize(card); page = buff / winsize(card);
buff = buff % winsize(card); buff = buff % winsize(card);
maxlen = winsize(card) - buff; maxlen = winsize(card) - buff;
...@@ -780,12 +650,10 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -780,12 +650,10 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
memcpy_toio(winbase(card) + buff, skb->data, maxlen); memcpy_toio(winbase(card) + buff, skb->data, maxlen);
openwin(card, page + 1); openwin(card, page + 1);
memcpy_toio(winbase(card), skb->data + maxlen, len - maxlen); memcpy_toio(winbase(card), skb->data + maxlen, len - maxlen);
} } else
else
#endif
memcpy_toio(winbase(card) + buff, skb->data, len); memcpy_toio(winbase(card) + buff, skb->data, len);
#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED) #ifndef PAGE0_ALWAYS_MAPPED
openwin(card, 0); /* select pkt_desc table page back */ openwin(card, 0); /* select pkt_desc table page back */
#endif #endif
writew(len, &desc->len); writew(len, &desc->len);
...@@ -793,7 +661,7 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -793,7 +661,7 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies; dev->trans_start = jiffies;
port->txin = next_desc(port, port->txin, 1); port->txin = next_desc(port, port->txin, 1);
sca_outa(desc_offset(port, port->txin, 1), sca_outw(desc_offset(port, port->txin, 1),
get_dmac_tx(port) + EDAL, card); 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(phy_node(port)), card); /* Enable TX DMA */
...@@ -809,40 +677,29 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -809,40 +677,29 @@ static int sca_xmit(struct sk_buff *skb, struct net_device *dev)
} }
#ifdef NEED_DETECT_RAM #ifdef NEED_DETECT_RAM
static u32 __devinit sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) static u32 __devinit sca_detect_ram(card_t *card, u8 __iomem *rambase,
u32 ramsize)
{ {
/* Round RAM size to 32 bits, fill from end to start */ /* Round RAM size to 32 bits, fill from end to start */
u32 i = ramsize &= ~3; u32 i = ramsize &= ~3;
#ifndef ALL_PAGES_ALWAYS_MAPPED
u32 size = winsize(card); u32 size = winsize(card);
openwin(card, (i - 4) / size); /* select last window */ openwin(card, (i - 4) / size); /* select last window */
#endif
do { do {
i -= 4; i -= 4;
#ifndef ALL_PAGES_ALWAYS_MAPPED
if ((i + 4) % size == 0) if ((i + 4) % size == 0)
openwin(card, i / size); openwin(card, i / size);
writel(i ^ 0x12345678, rambase + i % size); writel(i ^ 0x12345678, rambase + i % size);
#else } while (i > 0);
writel(i ^ 0x12345678, rambase + i);
#endif
}while (i > 0);
for (i = 0; i < ramsize ; i += 4) { for (i = 0; i < ramsize ; i += 4) {
#ifndef ALL_PAGES_ALWAYS_MAPPED
if (i % size == 0) if (i % size == 0)
openwin(card, i / size); openwin(card, i / size);
if (readl(rambase + i % size) != (i ^ 0x12345678)) if (readl(rambase + i % size) != (i ^ 0x12345678))
break; break;
#else
if (readl(rambase + i) != (i ^ 0x12345678))
break;
#endif
} }
return i; return i;
...@@ -850,7 +707,6 @@ static u32 __devinit sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsi ...@@ -850,7 +707,6 @@ static u32 __devinit sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsi
#endif /* NEED_DETECT_RAM */ #endif /* NEED_DETECT_RAM */
static void __devinit sca_init(card_t *card, int wait_states) static void __devinit sca_init(card_t *card, int wait_states)
{ {
sca_out(wait_states, WCRL, card); /* Wait Control */ sca_out(wait_states, WCRL, card); /* Wait Control */
......
...@@ -53,7 +53,7 @@ static const char* devname = "RISCom/N2"; ...@@ -53,7 +53,7 @@ static const char* devname = "RISCom/N2";
#define NEED_SCA_MSCI_INTR #define NEED_SCA_MSCI_INTR
#define MAX_TX_BUFFERS 10 #define MAX_TX_BUFFERS 10
static char *hw = NULL; /* pointer to hw=xxx command line string */ static char *hw; /* pointer to hw=xxx command line string */
/* RISCom/N2 Board Registers */ /* RISCom/N2 Board Registers */
...@@ -145,7 +145,6 @@ static card_t **new_card = &first_card; ...@@ -145,7 +145,6 @@ static card_t **new_card = &first_card;
&(card)->ports[port] : NULL) &(card)->ports[port] : NULL)
static __inline__ u8 sca_get_page(card_t *card) static __inline__ u8 sca_get_page(card_t *card)
{ {
return inb(card->io + N2_PSR) & PSR_PAGEBITS; return inb(card->io + N2_PSR) & PSR_PAGEBITS;
...@@ -159,11 +158,9 @@ static __inline__ void openwin(card_t *card, u8 page) ...@@ -159,11 +158,9 @@ static __inline__ void openwin(card_t *card, u8 page)
} }
#include "hd64570.c" #include "hd64570.c"
static void n2_set_iface(port_t *port) static void n2_set_iface(port_t *port)
{ {
card_t *card = port->card; card_t *card = port->card;
...@@ -478,7 +475,7 @@ static int __init n2_run(unsigned long io, unsigned long irq, ...@@ -478,7 +475,7 @@ static int __init n2_run(unsigned long io, unsigned long irq,
n2_destroy_card(card); n2_destroy_card(card);
return -ENOBUFS; return -ENOBUFS;
} }
sca_init_sync_port(port); /* Set up SCA memory */ sca_init_port(port); /* Set up SCA memory */
printk(KERN_INFO "%s: RISCom/N2 node %d\n", printk(KERN_INFO "%s: RISCom/N2 node %d\n",
dev->name, port->phy_node); dev->name, port->phy_node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment