summaryrefslogtreecommitdiffstats
path: root/drivers/net/arcnet
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-05-05 13:06:07 -0400
committerMichael Grzeschik <m.grzeschik@pengutronix.de>2015-09-23 02:44:26 -0400
commitf0b9c27c0c933a6545ea57d4edbc56a4db435c84 (patch)
treea99854d2cb6a1a16b9f96fadcc51fd883d5d1ab2 /drivers/net/arcnet
parent0fec65130b9f11a73d74f47025491f97f82ba070 (diff)
arcnet: com90io: Use arcnet_<I/O> routines
Simplify and make consistent the current uses of inb/outb by using the newly introduced arcnet_<I/O> equivalents. o Add new #defines for register offsets o Remove old #defines that included the ioaddr o Remove obfuscating macros by expanding them in-place where appropriate Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Diffstat (limited to 'drivers/net/arcnet')
-rw-r--r--drivers/net/arcnet/com90io.c101
1 files changed, 48 insertions, 53 deletions
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index ce15d1911048..7e084f148fa0 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -59,23 +59,14 @@ static void com90io_copy_from_card(struct net_device *dev, int bufnum,
59#define ARCNET_TOTAL_SIZE 16 59#define ARCNET_TOTAL_SIZE 16
60 60
61/* COM 9026 controller chip --> ARCnet register addresses */ 61/* COM 9026 controller chip --> ARCnet register addresses */
62#define _INTMASK (ioaddr + 0) /* writable */ 62#define COM9026_REG_W_INTMASK 0 /* writable */
63#define _STATUS (ioaddr + 0) /* readable */ 63#define COM9026_REG_R_STATUS 0 /* readable */
64#define _COMMAND (ioaddr + 1) /* writable, returns random vals on read (?) */ 64#define COM9026_REG_W_COMMAND 1 /* writable, returns random vals on read (?) */
65#define _RESET (ioaddr + 8) /* software reset (on read) */ 65#define COM9026_REG_RW_CONFIG 2 /* Configuration register */
66#define _MEMDATA (ioaddr + 12) /* Data port for IO-mapped memory */ 66#define COM9026_REG_R_RESET 8 /* software reset (on read) */
67#define _ADDR_HI (ioaddr + 15) /* Control registers for said */ 67#define COM9026_REG_RW_MEMDATA 12 /* Data port for IO-mapped memory */
68#define _ADDR_LO (ioaddr + 14) 68#define COM9026_REG_W_ADDR_LO 14 /* Control registers for said */
69#define _CONFIG (ioaddr + 2) /* Configuration register */ 69#define COM9026_REG_W_ADDR_HI 15
70
71#undef ASTATUS
72#undef ACOMMAND
73#undef AINTMASK
74
75#define ASTATUS() inb(_STATUS)
76#define ACOMMAND(cmd) outb((cmd), _COMMAND)
77#define AINTMASK(msk) outb((msk), _INTMASK)
78#define SETCONF() outb((lp->config), _CONFIG)
79 70
80/**************************************************************************** 71/****************************************************************************
81 * * 72 * *
@@ -90,10 +81,10 @@ static u_char get_buffer_byte(struct net_device *dev, unsigned offset)
90{ 81{
91 int ioaddr = dev->base_addr; 82 int ioaddr = dev->base_addr;
92 83
93 outb(offset >> 8, _ADDR_HI); 84 arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
94 outb(offset & 0xff, _ADDR_LO); 85 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
95 86
96 return inb(_MEMDATA); 87 return arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
97} 88}
98 89
99#ifdef ONE_AT_A_TIME_TX 90#ifdef ONE_AT_A_TIME_TX
@@ -102,10 +93,10 @@ static void put_buffer_byte(struct net_device *dev, unsigned offset,
102{ 93{
103 int ioaddr = dev->base_addr; 94 int ioaddr = dev->base_addr;
104 95
105 outb(offset >> 8, _ADDR_HI); 96 arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
106 outb(offset & 0xff, _ADDR_LO); 97 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
107 98
108 outb(datum, _MEMDATA); 99 arcnet_outb(datum, ioaddr, COM9026_REG_RW_MEMDATA);
109} 100}
110 101
111#endif 102#endif
@@ -115,14 +106,14 @@ static void get_whole_buffer(struct net_device *dev, unsigned offset,
115{ 106{
116 int ioaddr = dev->base_addr; 107 int ioaddr = dev->base_addr;
117 108
118 outb((offset >> 8) | AUTOINCflag, _ADDR_HI); 109 arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
119 outb(offset & 0xff, _ADDR_LO); 110 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
120 111
121 while (length--) 112 while (length--)
122#ifdef ONE_AT_A_TIME_RX 113#ifdef ONE_AT_A_TIME_RX
123 *(dest++) = get_buffer_byte(dev, offset++); 114 *(dest++) = get_buffer_byte(dev, offset++);
124#else 115#else
125 *(dest++) = inb(_MEMDATA); 116 *(dest++) = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
126#endif 117#endif
127} 118}
128 119
@@ -131,14 +122,14 @@ static void put_whole_buffer(struct net_device *dev, unsigned offset,
131{ 122{
132 int ioaddr = dev->base_addr; 123 int ioaddr = dev->base_addr;
133 124
134 outb((offset >> 8) | AUTOINCflag, _ADDR_HI); 125 arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
135 outb(offset & 0xff, _ADDR_LO); 126 arcnet_outb(offset & 0xff, ioaddr,COM9026_REG_W_ADDR_LO);
136 127
137 while (length--) 128 while (length--)
138#ifdef ONE_AT_A_TIME_TX 129#ifdef ONE_AT_A_TIME_TX
139 put_buffer_byte(dev, offset++, *(dest++)); 130 put_buffer_byte(dev, offset++, *(dest++));
140#else 131#else
141 outb(*(dest++), _MEMDATA); 132 arcnet_outb(*(dest++), ioaddr, COM9026_REG_RW_MEMDATA);
142#endif 133#endif
143} 134}
144 135
@@ -164,15 +155,15 @@ static int __init com90io_probe(struct net_device *dev)
164 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); 155 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
165 return -ENXIO; 156 return -ENXIO;
166 } 157 }
167 if (ASTATUS() == 0xFF) { 158 if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
168 arc_printk(D_INIT_REASONS, dev, "IO address %x empty\n", 159 arc_printk(D_INIT_REASONS, dev, "IO address %x empty\n",
169 ioaddr); 160 ioaddr);
170 goto err_out; 161 goto err_out;
171 } 162 }
172 inb(_RESET); 163 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
173 mdelay(RESETtime); 164 mdelay(RESETtime);
174 165
175 status = ASTATUS(); 166 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
176 167
177 if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { 168 if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
178 arc_printk(D_INIT_REASONS, dev, "Status invalid (%Xh)\n", 169 arc_printk(D_INIT_REASONS, dev, "Status invalid (%Xh)\n",
@@ -181,26 +172,28 @@ static int __init com90io_probe(struct net_device *dev)
181 } 172 }
182 arc_printk(D_INIT_REASONS, dev, "Status after reset: %X\n", status); 173 arc_printk(D_INIT_REASONS, dev, "Status after reset: %X\n", status);
183 174
184 ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); 175 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
176 ioaddr, COM9026_REG_W_COMMAND);
185 177
186 arc_printk(D_INIT_REASONS, dev, "Status after reset acknowledged: %X\n", 178 arc_printk(D_INIT_REASONS, dev, "Status after reset acknowledged: %X\n",
187 status); 179 status);
188 180
189 status = ASTATUS(); 181 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
190 182
191 if (status & RESETflag) { 183 if (status & RESETflag) {
192 arc_printk(D_INIT_REASONS, dev, "Eternal reset (status=%Xh)\n", 184 arc_printk(D_INIT_REASONS, dev, "Eternal reset (status=%Xh)\n",
193 status); 185 status);
194 goto err_out; 186 goto err_out;
195 } 187 }
196 outb((0x16 | IOMAPflag) & ~ENABLE16flag, _CONFIG); 188 arcnet_outb((0x16 | IOMAPflag) & ~ENABLE16flag,
189 ioaddr, COM9026_REG_RW_CONFIG);
197 190
198 /* Read first loc'n of memory */ 191 /* Read first loc'n of memory */
199 192
200 outb(AUTOINCflag, _ADDR_HI); 193 arcnet_outb(AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
201 outb(0, _ADDR_LO); 194 arcnet_outb(0, ioaddr, COM9026_REG_W_ADDR_LO);
202 195
203 status = inb(_MEMDATA); 196 status = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
204 if (status != 0xd1) { 197 if (status != 0xd1) {
205 arc_printk(D_INIT_REASONS, dev, "Signature byte not found (%Xh instead).\n", 198 arc_printk(D_INIT_REASONS, dev, "Signature byte not found (%Xh instead).\n",
206 status); 199 status);
@@ -213,9 +206,9 @@ static int __init com90io_probe(struct net_device *dev)
213 */ 206 */
214 207
215 airqmask = probe_irq_on(); 208 airqmask = probe_irq_on();
216 outb(NORXflag, _INTMASK); 209 arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
217 udelay(1); 210 udelay(1);
218 outb(0, _INTMASK); 211 arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
219 dev->irq = probe_irq_off(airqmask); 212 dev->irq = probe_irq_off(airqmask);
220 213
221 if ((int)dev->irq <= 0) { 214 if ((int)dev->irq <= 0) {
@@ -264,7 +257,7 @@ static int __init com90io_found(struct net_device *dev)
264 lp->hw.copy_from_card = com90io_copy_from_card; 257 lp->hw.copy_from_card = com90io_copy_from_card;
265 258
266 lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag; 259 lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
267 SETCONF(); 260 arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
268 261
269 /* get and check the station ID from offset 1 in shmem */ 262 /* get and check the station ID from offset 1 in shmem */
270 263
@@ -272,7 +265,8 @@ static int __init com90io_found(struct net_device *dev)
272 265
273 err = register_netdev(dev); 266 err = register_netdev(dev);
274 if (err) { 267 if (err) {
275 outb((inb(_CONFIG) & ~IOMAPflag), _CONFIG); 268 arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
269 ioaddr, COM9026_REG_RW_CONFIG);
276 free_irq(dev->irq, dev); 270 free_irq(dev->irq, dev);
277 release_region(dev->base_addr, ARCNET_TOTAL_SIZE); 271 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
278 return err; 272 return err;
@@ -297,19 +291,20 @@ static int com90io_reset(struct net_device *dev, int really_reset)
297 short ioaddr = dev->base_addr; 291 short ioaddr = dev->base_addr;
298 292
299 arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n", 293 arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
300 dev->name, ASTATUS()); 294 dev->name, arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
301 295
302 if (really_reset) { 296 if (really_reset) {
303 /* reset the card */ 297 /* reset the card */
304 inb(_RESET); 298 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
305 mdelay(RESETtime); 299 mdelay(RESETtime);
306 } 300 }
307 /* Set the thing to IO-mapped, 8-bit mode */ 301 /* Set the thing to IO-mapped, 8-bit mode */
308 lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag; 302 lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
309 SETCONF(); 303 arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
310 304
311 ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */ 305 arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
312 ACOMMAND(CFLAGScmd | CONFIGclear); 306 /* clear flags & end reset */
307 arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
313 308
314 /* verify that the ARCnet signature byte is present */ 309 /* verify that the ARCnet signature byte is present */
315 if (get_buffer_byte(dev, 0) != TESTvalue) { 310 if (get_buffer_byte(dev, 0) != TESTvalue) {
@@ -317,8 +312,7 @@ static int com90io_reset(struct net_device *dev, int really_reset)
317 return 1; 312 return 1;
318 } 313 }
319 /* enable extended (512-byte) packets */ 314 /* enable extended (512-byte) packets */
320 ACOMMAND(CONFIGcmd | EXTconf); 315 arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
321
322 /* done! return success. */ 316 /* done! return success. */
323 return 0; 317 return 0;
324} 318}
@@ -327,21 +321,21 @@ static void com90io_command(struct net_device *dev, int cmd)
327{ 321{
328 short ioaddr = dev->base_addr; 322 short ioaddr = dev->base_addr;
329 323
330 ACOMMAND(cmd); 324 arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
331} 325}
332 326
333static int com90io_status(struct net_device *dev) 327static int com90io_status(struct net_device *dev)
334{ 328{
335 short ioaddr = dev->base_addr; 329 short ioaddr = dev->base_addr;
336 330
337 return ASTATUS(); 331 return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
338} 332}
339 333
340static void com90io_setmask(struct net_device *dev, int mask) 334static void com90io_setmask(struct net_device *dev, int mask)
341{ 335{
342 short ioaddr = dev->base_addr; 336 short ioaddr = dev->base_addr;
343 337
344 AINTMASK(mask); 338 arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
345} 339}
346 340
347static void com90io_copy_to_card(struct net_device *dev, int bufnum, 341static void com90io_copy_to_card(struct net_device *dev, int bufnum,
@@ -427,7 +421,8 @@ static void __exit com90io_exit(void)
427 /* In case the old driver is loaded later, 421 /* In case the old driver is loaded later,
428 * set the thing back to MMAP mode 422 * set the thing back to MMAP mode
429 */ 423 */
430 outb((inb(_CONFIG) & ~IOMAPflag), _CONFIG); 424 arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
425 ioaddr, COM9026_REG_RW_CONFIG);
431 426
432 free_irq(dev->irq, dev); 427 free_irq(dev->irq, dev);
433 release_region(dev->base_addr, ARCNET_TOTAL_SIZE); 428 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);