Commit ab7f4e5d authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: more cleanup in HE driver

parent 03286272
...@@ -77,14 +77,6 @@ ...@@ -77,14 +77,6 @@
#include <linux/atmdev.h> #include <linux/atmdev.h>
#include <linux/atm.h> #include <linux/atm.h>
#include <linux/sonet.h> #include <linux/sonet.h>
#ifndef ATM_OC12_PCR
#define ATM_OC12_PCR (622080000/1080*1040/8/53)
#endif
#ifdef BUS_INT_WAR
void sn_add_polled_interrupt(int irq, int interval);
void sn_delete_polled_interrupt(int irq);
#endif
#define USE_TASKLET #define USE_TASKLET
#define USE_HE_FIND_VCC #define USE_HE_FIND_VCC
...@@ -171,22 +163,17 @@ static short sdh = 1; ...@@ -171,22 +163,17 @@ static short sdh = 1;
static struct atmdev_ops he_ops = static struct atmdev_ops he_ops =
{ {
open: he_open, .open = he_open,
close: he_close, .close = he_close,
ioctl: he_ioctl, .ioctl = he_ioctl,
send: he_send, .send = he_send,
sg_send: he_sg_send, .sg_send = he_sg_send,
phy_put: he_phy_put, .phy_put = he_phy_put,
phy_get: he_phy_get, .phy_get = he_phy_get,
proc_read: he_proc_read, .proc_read = he_proc_read,
owner: THIS_MODULE .owner = THIS_MODULE
}; };
/* see the comments in he.h about global_lock */
#define HE_SPIN_LOCK(dev, flags) spin_lock_irqsave(&(dev)->global_lock, flags)
#define HE_SPIN_UNLOCK(dev, flags) spin_unlock_irqrestore(&(dev)->global_lock, flags)
#define he_writel(dev, val, reg) do { writel(val, (dev)->membase + (reg)); wmb(); } while (0) #define he_writel(dev, val, reg) do { writel(val, (dev)->membase + (reg)); wmb(); } while (0)
#define he_readl(dev, reg) readl((dev)->membase + (reg)) #define he_readl(dev, reg) readl((dev)->membase + (reg))
...@@ -233,26 +220,26 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags) ...@@ -233,26 +220,26 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* figure 2.2 connection id */ /* figure 2.2 connection id */
#define he_mkcid(dev, vpi, vci) (((vpi<<(dev)->vcibits) | vci) & 0x1fff) #define he_mkcid(dev, vpi, vci) (((vpi << (dev)->vcibits) | vci) & 0x1fff)
/* 2.5.1 per connection transmit state registers */ /* 2.5.1 per connection transmit state registers */
#define he_writel_tsr0(dev, val, cid) \ #define he_writel_tsr0(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 0) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 0)
#define he_readl_tsr0(dev, cid) \ #define he_readl_tsr0(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 0) he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 0)
#define he_writel_tsr1(dev, val, cid) \ #define he_writel_tsr1(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 1) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 1)
#define he_writel_tsr2(dev, val, cid) \ #define he_writel_tsr2(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 2) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 2)
#define he_writel_tsr3(dev, val, cid) \ #define he_writel_tsr3(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 3) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 3)
#define he_writel_tsr4(dev, val, cid) \ #define he_writel_tsr4(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 4) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 4)
/* from page 2-20 /* from page 2-20
* *
...@@ -263,43 +250,43 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags) ...@@ -263,43 +250,43 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
*/ */
#define he_writel_tsr4_upper(dev, val, cid) \ #define he_writel_tsr4_upper(dev, val, cid) \
he_writel_internal(dev, val, CONFIG_TSRA | (cid<<3) | 4, \ he_writel_internal(dev, val, CONFIG_TSRA | (cid << 3) | 4, \
CON_CTL_TCM \ CON_CTL_TCM \
| CON_BYTE_DISABLE_2 \ | CON_BYTE_DISABLE_2 \
| CON_BYTE_DISABLE_1 \ | CON_BYTE_DISABLE_1 \
| CON_BYTE_DISABLE_0) | CON_BYTE_DISABLE_0)
#define he_readl_tsr4(dev, cid) \ #define he_readl_tsr4(dev, cid) \
he_readl_tcm(dev, CONFIG_TSRA | (cid<<3) | 4) he_readl_tcm(dev, CONFIG_TSRA | (cid << 3) | 4)
#define he_writel_tsr5(dev, val, cid) \ #define he_writel_tsr5(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 5) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 5)
#define he_writel_tsr6(dev, val, cid) \ #define he_writel_tsr6(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 6) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 6)
#define he_writel_tsr7(dev, val, cid) \ #define he_writel_tsr7(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRA | (cid<<3) | 7) he_writel_tcm(dev, val, CONFIG_TSRA | (cid << 3) | 7)
#define he_writel_tsr8(dev, val, cid) \ #define he_writel_tsr8(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 0) he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 0)
#define he_writel_tsr9(dev, val, cid) \ #define he_writel_tsr9(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 1) he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 1)
#define he_writel_tsr10(dev, val, cid) \ #define he_writel_tsr10(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 2) he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 2)
#define he_writel_tsr11(dev, val, cid) \ #define he_writel_tsr11(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRB | (cid<<2) | 3) he_writel_tcm(dev, val, CONFIG_TSRB | (cid << 2) | 3)
#define he_writel_tsr12(dev, val, cid) \ #define he_writel_tsr12(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 0) he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 0)
#define he_writel_tsr13(dev, val, cid) \ #define he_writel_tsr13(dev, val, cid) \
he_writel_tcm(dev, val, CONFIG_TSRC | (cid<<1) | 1) he_writel_tcm(dev, val, CONFIG_TSRC | (cid << 1) | 1)
#define he_writel_tsr14(dev, val, cid) \ #define he_writel_tsr14(dev, val, cid) \
...@@ -315,30 +302,30 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags) ...@@ -315,30 +302,30 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
/* 2.7.1 per connection receive state registers */ /* 2.7.1 per connection receive state registers */
#define he_writel_rsr0(dev, val, cid) \ #define he_writel_rsr0(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 0) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 0)
#define he_readl_rsr0(dev, cid) \ #define he_readl_rsr0(dev, cid) \
he_readl_rcm(dev, 0x00000 | (cid<<3) | 0) he_readl_rcm(dev, 0x00000 | (cid << 3) | 0)
#define he_writel_rsr1(dev, val, cid) \ #define he_writel_rsr1(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 1) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 1)
#define he_writel_rsr2(dev, val, cid) \ #define he_writel_rsr2(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 2) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 2)
#define he_writel_rsr3(dev, val, cid) \ #define he_writel_rsr3(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 3) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 3)
#define he_writel_rsr4(dev, val, cid) \ #define he_writel_rsr4(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 4) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 4)
#define he_writel_rsr5(dev, val, cid) \ #define he_writel_rsr5(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 5) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 5)
#define he_writel_rsr6(dev, val, cid) \ #define he_writel_rsr6(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 6) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 6)
#define he_writel_rsr7(dev, val, cid) \ #define he_writel_rsr7(dev, val, cid) \
he_writel_rcm(dev, val, 0x00000 | (cid<<3) | 7) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7)
static __inline__ struct atm_vcc* static __inline__ struct atm_vcc*
he_find_vcc(struct he_dev *he_dev, unsigned cid) he_find_vcc(struct he_dev *he_dev, unsigned cid)
...@@ -349,7 +336,7 @@ he_find_vcc(struct he_dev *he_dev, unsigned cid) ...@@ -349,7 +336,7 @@ he_find_vcc(struct he_dev *he_dev, unsigned cid)
int vci; int vci;
vpi = cid >> he_dev->vcibits; vpi = cid >> he_dev->vcibits;
vci = cid & ((1<<he_dev->vcibits)-1); vci = cid & ((1 << he_dev->vcibits) - 1);
spin_lock_irqsave(&he_dev->atm_dev->lock, flags); spin_lock_irqsave(&he_dev->atm_dev->lock, flags);
for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next) for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next)
...@@ -443,12 +430,12 @@ he_remove_one (struct pci_dev *pci_dev) ...@@ -443,12 +430,12 @@ he_remove_one (struct pci_dev *pci_dev)
static unsigned static unsigned
rate_to_atmf(unsigned rate) /* cps to atm forum format */ rate_to_atmf(unsigned rate) /* cps to atm forum format */
{ {
#define NONZERO (1<<14) #define NONZERO (1 << 14)
unsigned exp = 0; unsigned exp = 0;
if (rate == 0) if (rate == 0)
return(0); return 0;
rate <<= 9; rate <<= 9;
while (rate > 0x3ff) { while (rate > 0x3ff) {
...@@ -761,26 +748,27 @@ he_init_cs_block_rcm(struct he_dev *he_dev) ...@@ -761,26 +748,27 @@ he_init_cs_block_rcm(struct he_dev *he_dev)
(he_dev->atm_dev->link_rate * 2); (he_dev->atm_dev->link_rate * 2);
#else #else
/* this is pretty, but avoids _divdu3 and is mostly correct */ /* this is pretty, but avoids _divdu3 and is mostly correct */
buf = 0;
mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR; mult = he_dev->atm_dev->link_rate / ATM_OC3_PCR;
if (rate_cps > (68 * mult))
buf = 1;
if (rate_cps > (136 * mult))
buf = 2;
if (rate_cps > (204 * mult))
buf = 3;
if (rate_cps > (272 * mult)) if (rate_cps > (272 * mult))
buf = 4; buf = 4;
else if (rate_cps > (204 * mult))
buf = 3;
else if (rate_cps > (136 * mult))
buf = 2;
else if (rate_cps > (68 * mult))
buf = 1;
else
buf = 0;
#endif #endif
if (buf > buf_limit) if (buf > buf_limit)
buf = buf_limit; buf = buf_limit;
reg = (reg<<16) | ((i<<8) | buf); reg = (reg << 16) | ((i << 8) | buf);
#define RTGTBL_OFFSET 0x400 #define RTGTBL_OFFSET 0x400
if (rate_atmf & 0x1) if (rate_atmf & 0x1)
he_writel_rcm(he_dev, reg, he_writel_rcm(he_dev, reg,
CONFIG_RCMABR + RTGTBL_OFFSET + (rate_atmf>>1)); CONFIG_RCMABR + RTGTBL_OFFSET + (rate_atmf >> 1));
++rate_atmf; ++rate_atmf;
} }
...@@ -839,7 +827,7 @@ he_init_group(struct he_dev *he_dev, int group) ...@@ -839,7 +827,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev->rbps_base[i].phys = dma_handle; he_dev->rbps_base[i].phys = dma_handle;
} }
he_dev->rbps_tail = &he_dev->rbps_base[CONFIG_RBPS_SIZE-1]; he_dev->rbps_tail = &he_dev->rbps_base[CONFIG_RBPS_SIZE - 1];
he_writel(he_dev, he_dev->rbps_phys, G0_RBPS_S + (group * 32)); he_writel(he_dev, he_dev->rbps_phys, G0_RBPS_S + (group * 32));
he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail), he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail),
...@@ -848,7 +836,7 @@ he_init_group(struct he_dev *he_dev, int group) ...@@ -848,7 +836,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPS_BS + (group * 32)); G0_RBPS_BS + (group * 32));
he_writel(he_dev, he_writel(he_dev,
RBP_THRESH(CONFIG_RBPS_THRESH) | RBP_THRESH(CONFIG_RBPS_THRESH) |
RBP_QSIZE(CONFIG_RBPS_SIZE-1) | RBP_QSIZE(CONFIG_RBPS_SIZE - 1) |
RBP_INT_ENB, RBP_INT_ENB,
G0_RBPS_QI + (group * 32)); G0_RBPS_QI + (group * 32));
#else /* !USE_RBPS */ #else /* !USE_RBPS */
...@@ -902,7 +890,7 @@ he_init_group(struct he_dev *he_dev, int group) ...@@ -902,7 +890,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF); he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF);
he_dev->rbpl_base[i].phys = dma_handle; he_dev->rbpl_base[i].phys = dma_handle;
} }
he_dev->rbpl_tail = &he_dev->rbpl_base[CONFIG_RBPL_SIZE-1]; he_dev->rbpl_tail = &he_dev->rbpl_base[CONFIG_RBPL_SIZE - 1];
he_writel(he_dev, he_dev->rbpl_phys, G0_RBPL_S + (group * 32)); he_writel(he_dev, he_dev->rbpl_phys, G0_RBPL_S + (group * 32));
he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail), he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail),
...@@ -911,7 +899,7 @@ he_init_group(struct he_dev *he_dev, int group) ...@@ -911,7 +899,7 @@ he_init_group(struct he_dev *he_dev, int group)
G0_RBPL_BS + (group * 32)); G0_RBPL_BS + (group * 32));
he_writel(he_dev, he_writel(he_dev,
RBP_THRESH(CONFIG_RBPL_THRESH) | RBP_THRESH(CONFIG_RBPL_THRESH) |
RBP_QSIZE(CONFIG_RBPL_SIZE-1) | RBP_QSIZE(CONFIG_RBPL_SIZE - 1) |
RBP_INT_ENB, RBP_INT_ENB,
G0_RBPL_QI + (group * 32)); G0_RBPL_QI + (group * 32));
...@@ -929,7 +917,7 @@ he_init_group(struct he_dev *he_dev, int group) ...@@ -929,7 +917,7 @@ he_init_group(struct he_dev *he_dev, int group)
he_writel(he_dev, he_dev->rbrq_phys, G0_RBRQ_ST + (group * 16)); he_writel(he_dev, he_dev->rbrq_phys, G0_RBRQ_ST + (group * 16));
he_writel(he_dev, 0, G0_RBRQ_H + (group * 16)); he_writel(he_dev, 0, G0_RBRQ_H + (group * 16));
he_writel(he_dev, he_writel(he_dev,
RBRQ_THRESH(CONFIG_RBRQ_THRESH) | RBRQ_SIZE(CONFIG_RBRQ_SIZE-1), RBRQ_THRESH(CONFIG_RBRQ_THRESH) | RBRQ_SIZE(CONFIG_RBRQ_SIZE - 1),
G0_RBRQ_Q + (group * 16)); G0_RBRQ_Q + (group * 16));
if (irq_coalesce) { if (irq_coalesce) {
hprintk("coalescing interrupts\n"); hprintk("coalescing interrupts\n");
...@@ -979,7 +967,7 @@ he_init_irq(struct he_dev *he_dev) ...@@ -979,7 +967,7 @@ he_init_irq(struct he_dev *he_dev)
he_dev->irq_head = he_dev->irq_base; he_dev->irq_head = he_dev->irq_base;
he_dev->irq_tail = he_dev->irq_base; he_dev->irq_tail = he_dev->irq_base;
for (i=0; i < CONFIG_IRQ_SIZE; ++i) for (i = 0; i < CONFIG_IRQ_SIZE; ++i)
he_dev->irq_base[i].isw = ITYPE_INVALID; he_dev->irq_base[i].isw = ITYPE_INVALID;
he_writel(he_dev, he_dev->irq_phys, IRQ0_BASE); he_writel(he_dev, he_dev->irq_phys, IRQ0_BASE);
...@@ -1018,11 +1006,6 @@ he_init_irq(struct he_dev *he_dev) ...@@ -1018,11 +1006,6 @@ he_init_irq(struct he_dev *he_dev)
he_dev->irq = he_dev->pci_dev->irq; he_dev->irq = he_dev->pci_dev->irq;
#ifdef BUS_INT_WAR
HPRINTK("sn_add_polled_interrupt(irq %d, 1)\n", he_dev->irq);
sn_add_polled_interrupt(he_dev->irq, 1);
#endif
return 0; return 0;
} }
...@@ -1138,12 +1121,12 @@ he_start(struct atm_dev *dev) ...@@ -1138,12 +1121,12 @@ he_start(struct atm_dev *dev)
pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0); pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
/* 4.7 read prom contents */ /* 4.7 read prom contents */
for (i=0; i<PROD_ID_LEN; ++i) for (i = 0; i < PROD_ID_LEN; ++i)
he_dev->prod_id[i] = read_prom_byte(he_dev, PROD_ID + i); he_dev->prod_id[i] = read_prom_byte(he_dev, PROD_ID + i);
he_dev->media = read_prom_byte(he_dev, MEDIA); he_dev->media = read_prom_byte(he_dev, MEDIA);
for (i=0; i<6; ++i) for (i = 0; i < 6; ++i)
dev->esi[i] = read_prom_byte(he_dev, MAC_ADDR + i); dev->esi[i] = read_prom_byte(he_dev, MAC_ADDR + i);
hprintk("%s%s, %x:%x:%x:%x:%x:%x\n", hprintk("%s%s, %x:%x:%x:%x:%x:%x\n",
...@@ -1323,15 +1306,15 @@ he_start(struct atm_dev *dev) ...@@ -1323,15 +1306,15 @@ he_start(struct atm_dev *dev)
he_writel(he_dev, 0x0, TXAAL5_PROTO); he_writel(he_dev, 0x0, TXAAL5_PROTO);
he_writel(he_dev, PHY_INT_ENB | he_writel(he_dev, PHY_INT_ENB |
(he_is622(he_dev) ? PTMR_PRE(67-1) : PTMR_PRE(50-1)), (he_is622(he_dev) ? PTMR_PRE(67 - 1) : PTMR_PRE(50 - 1)),
RH_CONFIG); RH_CONFIG);
/* 5.1.3 initialize connection memory */ /* 5.1.3 initialize connection memory */
for (i=0; i < TCM_MEM_SIZE; ++i) for (i = 0; i < TCM_MEM_SIZE; ++i)
he_writel_tcm(he_dev, 0, i); he_writel_tcm(he_dev, 0, i);
for (i=0; i < RCM_MEM_SIZE; ++i) for (i = 0; i < RCM_MEM_SIZE; ++i)
he_writel_rcm(he_dev, 0, i); he_writel_rcm(he_dev, 0, i);
/* /*
...@@ -1512,7 +1495,7 @@ he_start(struct atm_dev *dev) ...@@ -1512,7 +1495,7 @@ he_start(struct atm_dev *dev)
} }
he_dev->tpd_head = he_dev->tpd_base; he_dev->tpd_head = he_dev->tpd_base;
he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS-1]; he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS - 1];
#endif #endif
if (he_init_group(he_dev, 0) != 0) if (he_init_group(he_dev, 0) != 0)
...@@ -1652,12 +1635,8 @@ he_stop(struct he_dev *he_dev) ...@@ -1652,12 +1635,8 @@ he_stop(struct he_dev *he_dev)
he_dev->atm_dev->phy->stop(he_dev->atm_dev); he_dev->atm_dev->phy->stop(he_dev->atm_dev);
#endif /* CONFIG_ATM_HE_USE_SUNI */ #endif /* CONFIG_ATM_HE_USE_SUNI */
if (he_dev->irq) { if (he_dev->irq)
#ifdef BUS_INT_WAR
sn_delete_polled_interrupt(he_dev->irq);
#endif
free_irq(he_dev->irq, he_dev); free_irq(he_dev->irq, he_dev);
}
if (he_dev->irq_base) if (he_dev->irq_base)
pci_free_consistent(he_dev->pci_dev, (CONFIG_IRQ_SIZE+1) pci_free_consistent(he_dev->pci_dev, (CONFIG_IRQ_SIZE+1)
...@@ -1669,7 +1648,7 @@ he_stop(struct he_dev *he_dev) ...@@ -1669,7 +1648,7 @@ he_stop(struct he_dev *he_dev)
if (he_dev->rbpl_base) { if (he_dev->rbpl_base) {
#ifdef USE_RBPL_POOL #ifdef USE_RBPL_POOL
for (i=0; i<CONFIG_RBPL_SIZE; ++i) { for (i = 0; i < CONFIG_RBPL_SIZE; ++i) {
void *cpuaddr = he_dev->rbpl_virt[i].virt; void *cpuaddr = he_dev->rbpl_virt[i].virt;
dma_addr_t dma_handle = he_dev->rbpl_base[i].phys; dma_addr_t dma_handle = he_dev->rbpl_base[i].phys;
...@@ -1691,7 +1670,7 @@ he_stop(struct he_dev *he_dev) ...@@ -1691,7 +1670,7 @@ he_stop(struct he_dev *he_dev)
#ifdef USE_RBPS #ifdef USE_RBPS
if (he_dev->rbps_base) { if (he_dev->rbps_base) {
#ifdef USE_RBPS_POOL #ifdef USE_RBPS_POOL
for (i=0; i<CONFIG_RBPS_SIZE; ++i) { for (i = 0; i < CONFIG_RBPS_SIZE; ++i) {
void *cpuaddr = he_dev->rbps_virt[i].virt; void *cpuaddr = he_dev->rbps_virt[i].virt;
dma_addr_t dma_handle = he_dev->rbps_base[i].phys; dma_addr_t dma_handle = he_dev->rbps_base[i].phys;
...@@ -1790,7 +1769,7 @@ __alloc_tpd(struct he_dev *he_dev) ...@@ -1790,7 +1769,7 @@ __alloc_tpd(struct he_dev *he_dev)
} }
#define AAL5_LEN(buf,len) \ #define AAL5_LEN(buf,len) \
((((unsigned char *)(buf))[(len)-6]<<8) | \ ((((unsigned char *)(buf))[(len)-6] << 8) | \
(((unsigned char *)(buf))[(len)-5])) (((unsigned char *)(buf))[(len)-5]))
/* 2.10.1.2 receive /* 2.10.1.2 receive
...@@ -1800,7 +1779,7 @@ __alloc_tpd(struct he_dev *he_dev) ...@@ -1800,7 +1779,7 @@ __alloc_tpd(struct he_dev *he_dev)
*/ */
#define TCP_CKSUM(buf,len) \ #define TCP_CKSUM(buf,len) \
((((unsigned char *)(buf))[(len)-2]<<8) | \ ((((unsigned char *)(buf))[(len)-2] << 8) | \
(((unsigned char *)(buf))[(len-1)])) (((unsigned char *)(buf))[(len-1)]))
static int static int
...@@ -2171,7 +2150,7 @@ he_tasklet(unsigned long data) ...@@ -2171,7 +2150,7 @@ he_tasklet(unsigned long data)
HPRINTK("tasklet (0x%lx)\n", data); HPRINTK("tasklet (0x%lx)\n", data);
#ifdef USE_TASKLET #ifdef USE_TASKLET
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
#endif #endif
while (he_dev->irq_head != he_dev->irq_tail) { while (he_dev->irq_head != he_dev->irq_tail) {
...@@ -2209,10 +2188,10 @@ he_tasklet(unsigned long data) ...@@ -2209,10 +2188,10 @@ he_tasklet(unsigned long data)
case ITYPE_PHY: case ITYPE_PHY:
HPRINTK("phy interrupt\n"); HPRINTK("phy interrupt\n");
#ifdef CONFIG_ATM_HE_USE_SUNI #ifdef CONFIG_ATM_HE_USE_SUNI
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->interrupt) if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->interrupt)
he_dev->atm_dev->phy->interrupt(he_dev->atm_dev); he_dev->atm_dev->phy->interrupt(he_dev->atm_dev);
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
#endif #endif
break; break;
case ITYPE_OTHER: case ITYPE_OTHER:
...@@ -2257,7 +2236,7 @@ he_tasklet(unsigned long data) ...@@ -2257,7 +2236,7 @@ he_tasklet(unsigned long data)
(void) he_readl(he_dev, INT_FIFO); /* 8.1.2 controller errata */ (void) he_readl(he_dev, INT_FIFO); /* 8.1.2 controller errata */
} }
#ifdef USE_TASKLET #ifdef USE_TASKLET
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
#endif #endif
} }
...@@ -2271,7 +2250,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2271,7 +2250,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
if (he_dev == NULL) if (he_dev == NULL)
return IRQ_NONE; return IRQ_NONE;
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
he_dev->irq_tail = (struct he_irq *) (((unsigned long)he_dev->irq_base) | he_dev->irq_tail = (struct he_irq *) (((unsigned long)he_dev->irq_base) |
(*he_dev->irq_tailoffset << 2)); (*he_dev->irq_tailoffset << 2));
...@@ -2301,7 +2280,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs) ...@@ -2301,7 +2280,7 @@ he_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
(void) he_readl(he_dev, INT_FIFO); (void) he_readl(he_dev, INT_FIFO);
#endif #endif
} }
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
...@@ -2438,9 +2417,9 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2438,9 +2417,9 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed; goto open_failed;
} }
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
tsr0 = he_readl_tsr0(he_dev, cid); tsr0 = he_readl_tsr0(he_dev, cid);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (TSR0_CONN_STATE(tsr0) != 0) { if (TSR0_CONN_STATE(tsr0) != 0) {
hprintk("cid 0x%x not idle (tsr0 = 0x%x)\n", cid, tsr0); hprintk("cid 0x%x not idle (tsr0 = 0x%x)\n", cid, tsr0);
...@@ -2467,7 +2446,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2467,7 +2446,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed; goto open_failed;
} }
HE_SPIN_LOCK(he_dev, flags); /* also protects he_dev->cs_stper[] */ spin_lock_irqsave(&he_dev->global_lock, flags); /* also protects he_dev->cs_stper[] */
/* find an unused cs_stper register */ /* find an unused cs_stper register */
for (reg = 0; reg < HE_NUM_CS_STPER; ++reg) for (reg = 0; reg < HE_NUM_CS_STPER; ++reg)
...@@ -2477,7 +2456,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2477,7 +2456,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
if (reg == HE_NUM_CS_STPER) { if (reg == HE_NUM_CS_STPER) {
err = -EBUSY; err = -EBUSY;
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
goto open_failed; goto open_failed;
} }
...@@ -2495,7 +2474,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2495,7 +2474,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
he_writel_mbox(he_dev, rate_to_atmf(period/2), he_writel_mbox(he_dev, rate_to_atmf(period/2),
CS_STPER0 + reg); CS_STPER0 + reg);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
tsr0 = TSR0_CBR | TSR0_GROUP(0) | tsr0_aal | tsr0 = TSR0_CBR | TSR0_GROUP(0) | tsr0_aal |
TSR0_RC_INDEX(reg); TSR0_RC_INDEX(reg);
...@@ -2506,7 +2485,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2506,7 +2485,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed; goto open_failed;
} }
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel_tsr0(he_dev, tsr0, cid); he_writel_tsr0(he_dev, tsr0, cid);
he_writel_tsr4(he_dev, tsr4 | 1, cid); he_writel_tsr4(he_dev, tsr4 | 1, cid);
...@@ -2528,7 +2507,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2528,7 +2507,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
#ifdef CONFIG_IA64_SGI_SN2 #ifdef CONFIG_IA64_SGI_SN2
(void) he_readl_tsr0(he_dev, cid); (void) he_readl_tsr0(he_dev, cid);
#endif #endif
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
} }
if (vcc->qos.rxtp.traffic_class != ATM_NONE) { if (vcc->qos.rxtp.traffic_class != ATM_NONE) {
...@@ -2549,11 +2528,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2549,11 +2528,11 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
goto open_failed; goto open_failed;
} }
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
rsr0 = he_readl_rsr0(he_dev, cid); rsr0 = he_readl_rsr0(he_dev, cid);
if (rsr0 & RSR0_OPEN_CONN) { if (rsr0 & RSR0_OPEN_CONN) {
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
hprintk("cid 0x%x not idle (rsr0 = 0x%x)\n", cid, rsr0); hprintk("cid 0x%x not idle (rsr0 = 0x%x)\n", cid, rsr0);
err = -EBUSY; err = -EBUSY;
...@@ -2585,7 +2564,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2585,7 +2564,7 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
(void) he_readl_rsr0(he_dev, cid); (void) he_readl_rsr0(he_dev, cid);
#endif #endif
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
#ifndef USE_HE_FIND_VCC #ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = vcc; HE_LOOKUP_VCC(he_dev, cid) = vcc;
...@@ -2631,7 +2610,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2631,7 +2610,7 @@ he_close(struct atm_vcc *vcc)
/* wait for previous close (if any) to finish */ /* wait for previous close (if any) to finish */
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
while (he_readl(he_dev, RCC_STAT) & RCC_BUSY) { while (he_readl(he_dev, RCC_STAT) & RCC_BUSY) {
HPRINTK("close cid 0x%x RCC_BUSY\n", cid); HPRINTK("close cid 0x%x RCC_BUSY\n", cid);
udelay(250); udelay(250);
...@@ -2645,7 +2624,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2645,7 +2624,7 @@ he_close(struct atm_vcc *vcc)
(void) he_readl_rsr0(he_dev, cid); (void) he_readl_rsr0(he_dev, cid);
#endif #endif
he_writel_mbox(he_dev, cid, RXCON_CLOSE); he_writel_mbox(he_dev, cid, RXCON_CLOSE);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
timeout = schedule_timeout(30*HZ); timeout = schedule_timeout(30*HZ);
...@@ -2693,7 +2672,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2693,7 +2672,7 @@ he_close(struct atm_vcc *vcc)
/* 2.3.1.1 generic close operations with flush */ /* 2.3.1.1 generic close operations with flush */
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel_tsr4_upper(he_dev, TSR4_FLUSH_CONN, cid); he_writel_tsr4_upper(he_dev, TSR4_FLUSH_CONN, cid);
/* also clears TSR4_SESSION_ENDED */ /* also clears TSR4_SESSION_ENDED */
#ifdef CONFIG_IA64_SGI_SN2 #ifdef CONFIG_IA64_SGI_SN2
...@@ -2724,7 +2703,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2724,7 +2703,7 @@ he_close(struct atm_vcc *vcc)
add_wait_queue(&he_vcc->tx_waitq, &wait); add_wait_queue(&he_vcc->tx_waitq, &wait);
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
__enqueue_tpd(he_dev, tpd, cid); __enqueue_tpd(he_dev, tpd, cid);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
timeout = schedule_timeout(30*HZ); timeout = schedule_timeout(30*HZ);
...@@ -2736,7 +2715,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2736,7 +2715,7 @@ he_close(struct atm_vcc *vcc)
goto close_tx_incomplete; goto close_tx_incomplete;
} }
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
while (!((tsr4 = he_readl_tsr4(he_dev, cid)) & TSR4_SESSION_ENDED)) { while (!((tsr4 = he_readl_tsr4(he_dev, cid)) & TSR4_SESSION_ENDED)) {
HPRINTK("close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)\n", cid, tsr4); HPRINTK("close tx cid 0x%x !TSR4_SESSION_ENDED (tsr4 = 0x%x)\n", cid, tsr4);
udelay(250); udelay(250);
...@@ -2761,7 +2740,7 @@ he_close(struct atm_vcc *vcc) ...@@ -2761,7 +2740,7 @@ he_close(struct atm_vcc *vcc)
he_dev->total_bw -= he_dev->cs_stper[reg].pcr; he_dev->total_bw -= he_dev->cs_stper[reg].pcr;
} }
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
HPRINTK("close tx cid 0x%x complete\n", cid); HPRINTK("close tx cid 0x%x complete\n", cid);
} }
...@@ -2818,7 +2797,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -2818,7 +2797,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
return -EINVAL; return -EINVAL;
} }
#endif #endif
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
tpd = __alloc_tpd(he_dev); tpd = __alloc_tpd(he_dev);
if (tpd == NULL) { if (tpd == NULL) {
...@@ -2827,7 +2806,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -2827,7 +2806,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else else
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
atomic_inc(&vcc->stats->tx_err); atomic_inc(&vcc->stats->tx_err);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
...@@ -2869,7 +2848,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -2869,7 +2848,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
else else
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
atomic_inc(&vcc->stats->tx_err); atomic_inc(&vcc->stats->tx_err);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
tpd->status |= TPD_USERCELL; tpd->status |= TPD_USERCELL;
...@@ -2884,7 +2863,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -2884,7 +2863,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
} }
tpd->iovec[slot-1].len |= TPD_LST; tpd->iovec[slot - 1].len |= TPD_LST;
#else #else
tpd->address0 = pci_map_single(he_dev->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE); tpd->address0 = pci_map_single(he_dev->pci_dev, skb->data, skb->len, PCI_DMA_TODEVICE);
tpd->length0 = skb->len | TPD_LST; tpd->length0 = skb->len | TPD_LST;
...@@ -2897,7 +2876,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -2897,7 +2876,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
ATM_SKB(skb)->vcc = vcc; ATM_SKB(skb)->vcc = vcc;
__enqueue_tpd(he_dev, tpd, cid); __enqueue_tpd(he_dev, tpd, cid);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
atomic_inc(&vcc->stats->tx); atomic_inc(&vcc->stats->tx);
...@@ -2919,7 +2898,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg) ...@@ -2919,7 +2898,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
copy_from_user(&reg, (struct he_ioctl_reg *) arg, copy_from_user(&reg, (struct he_ioctl_reg *) arg,
sizeof(struct he_ioctl_reg)); sizeof(struct he_ioctl_reg));
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
switch (reg.type) { switch (reg.type) {
case HE_REGTYPE_PCI: case HE_REGTYPE_PCI:
reg.val = he_readl(he_dev, reg.addr); reg.val = he_readl(he_dev, reg.addr);
...@@ -2940,7 +2919,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg) ...@@ -2940,7 +2919,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void *arg)
err = -EINVAL; err = -EINVAL;
break; break;
} }
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (err == 0) if (err == 0)
copy_to_user((struct he_ioctl_reg *) arg, &reg, copy_to_user((struct he_ioctl_reg *) arg, &reg,
sizeof(struct he_ioctl_reg)); sizeof(struct he_ioctl_reg));
...@@ -2966,12 +2945,12 @@ he_phy_put(struct atm_dev *atm_dev, unsigned char val, unsigned long addr) ...@@ -2966,12 +2945,12 @@ he_phy_put(struct atm_dev *atm_dev, unsigned char val, unsigned long addr)
HPRINTK("phy_put(val 0x%x, addr 0x%lx)\n", val, addr); HPRINTK("phy_put(val 0x%x, addr 0x%lx)\n", val, addr);
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
he_writel(he_dev, val, FRAMER + (addr*4)); he_writel(he_dev, val, FRAMER + (addr*4));
#ifdef CONFIG_IA64_SGI_SN2 #ifdef CONFIG_IA64_SGI_SN2
(void) he_readl(he_dev, FRAMER + (addr*4)); (void) he_readl(he_dev, FRAMER + (addr*4));
#endif #endif
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
} }
...@@ -2982,9 +2961,9 @@ he_phy_get(struct atm_dev *atm_dev, unsigned long addr) ...@@ -2982,9 +2961,9 @@ he_phy_get(struct atm_dev *atm_dev, unsigned long addr)
struct he_dev *he_dev = HE_DEV(atm_dev); struct he_dev *he_dev = HE_DEV(atm_dev);
unsigned reg; unsigned reg;
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
reg = he_readl(he_dev, FRAMER + (addr*4)); reg = he_readl(he_dev, FRAMER + (addr*4));
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
HPRINTK("phy_get(addr 0x%lx) =0x%x\n", addr, reg); HPRINTK("phy_get(addr 0x%lx) =0x%x\n", addr, reg);
return reg; return reg;
...@@ -3015,12 +2994,12 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page) ...@@ -3015,12 +2994,12 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
if (!left--) if (!left--)
return sprintf(page, "Mismatched Cells VPI/VCI Not Open Dropped Cells RCM Dropped Cells\n"); return sprintf(page, "Mismatched Cells VPI/VCI Not Open Dropped Cells RCM Dropped Cells\n");
HE_SPIN_LOCK(he_dev, flags); spin_lock_irqsave(&he_dev->global_lock, flags);
mcc += he_readl(he_dev, MCC); mcc += he_readl(he_dev, MCC);
oec += he_readl(he_dev, OEC); oec += he_readl(he_dev, OEC);
dcc += he_readl(he_dev, DCC); dcc += he_readl(he_dev, DCC);
cec += he_readl(he_dev, CEC); cec += he_readl(he_dev, CEC);
HE_SPIN_UNLOCK(he_dev, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
if (!left--) if (!left--)
return sprintf(page, "%16ld %16ld %13ld %17ld\n\n", return sprintf(page, "%16ld %16ld %13ld %17ld\n\n",
...@@ -3090,32 +3069,31 @@ read_prom_byte(struct he_dev *he_dev, int addr) ...@@ -3090,32 +3069,31 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel(he_dev, val, HOST_CNTL); he_writel(he_dev, val, HOST_CNTL);
/* Send READ instruction */ /* Send READ instruction */
for (i=0; i<sizeof(readtab)/sizeof(readtab[0]); i++) { for (i = 0; i < sizeof(readtab)/sizeof(readtab[0]); i++) {
he_writel(he_dev, val | readtab[i], HOST_CNTL); he_writel(he_dev, val | readtab[i], HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
} }
/* Next, we need to send the byte address to read from */ /* Next, we need to send the byte address to read from */
for (i=7; i>=0; i--) { for (i = 7; i >= 0; i--) {
he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL); he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL); he_writel(he_dev, val | clocktab[j++] | (((addr >> i) & 1) << 9), HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
} }
j=0; j = 0;
val &= 0xFFFFF7FF; /* Turn off write enable */ val &= 0xFFFFF7FF; /* Turn off write enable */
he_writel(he_dev, val, HOST_CNTL); he_writel(he_dev, val, HOST_CNTL);
/* Now, we can read data from the EEPROM by clocking it in */ /* Now, we can read data from the EEPROM by clocking it in */
for (i=7; i>=0; i--) { for (i = 7; i >= 0; i--) {
he_writel(he_dev, val | clocktab[j++], HOST_CNTL); he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
tmp_read = he_readl(he_dev, HOST_CNTL); tmp_read = he_readl(he_dev, HOST_CNTL);
byte_read |= (unsigned char) byte_read |= (unsigned char)
((tmp_read & ID_DOUT) ((tmp_read & ID_DOUT) >> ID_DOFFSET << i);
>> ID_DOFFSET << i);
he_writel(he_dev, val | clocktab[j++], HOST_CNTL); he_writel(he_dev, val | clocktab[j++], HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
} }
...@@ -3123,7 +3101,7 @@ read_prom_byte(struct he_dev *he_dev, int addr) ...@@ -3123,7 +3101,7 @@ read_prom_byte(struct he_dev *he_dev, int addr)
he_writel(he_dev, val | ID_CS, HOST_CNTL); he_writel(he_dev, val | ID_CS, HOST_CNTL);
udelay(EEPROM_DELAY); udelay(EEPROM_DELAY);
return (byte_read); return byte_read;
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
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