Tue Apr 9 03:56:08 2019 UTC ()
 KNF. No functional change.


(msaitoh)
diff -r1.19 -r1.20 src/sys/dev/mca/if_le_mca.c

cvs diff -r1.19 -r1.20 src/sys/dev/mca/if_le_mca.c (expand / switch to unified diff)

--- src/sys/dev/mca/if_le_mca.c 2010/11/13 13:52:04 1.19
+++ src/sys/dev/mca/if_le_mca.c 2019/04/09 03:56:08 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_le_mca.c,v 1.19 2010/11/13 13:52:04 uebayasi Exp $ */ 1/* $NetBSD: if_le_mca.c,v 1.20 2019/04/09 03:56:08 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * 35 *
36 * Syskonnect was very helpful and provided docs for these cards promptly. 36 * Syskonnect was very helpful and provided docs for these cards promptly.
37 * I wish all vendors would be like that! 37 * I wish all vendors would be like that!
38 * I'd like to thank to Alfred Arnold, author of the Linux driver, for 38 * I'd like to thank to Alfred Arnold, author of the Linux driver, for
39 * giving me contact to The Right Syskonnect person, too :-) 39 * giving me contact to The Right Syskonnect person, too :-)
40 * 40 *
41 * Sources: 41 * Sources:
42 * SKNET MC+ Technical Manual, version 1.1, July 21 1993 42 * SKNET MC+ Technical Manual, version 1.1, July 21 1993
43 * SKNET personal Technisches Manual, version 1.2, April 14 1988 43 * SKNET personal Technisches Manual, version 1.2, April 14 1988
44 * SKNET junior Technisches Manual, version 1.0, July 14 1987 44 * SKNET junior Technisches Manual, version 1.0, July 14 1987
45 */ 45 */
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48__KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,v 1.19 2010/11/13 13:52:04 uebayasi Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,v 1.20 2019/04/09 03:56:08 msaitoh Exp $");
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/mbuf.h> 52#include <sys/mbuf.h>
53#include <sys/syslog.h> 53#include <sys/syslog.h>
54#include <sys/socket.h> 54#include <sys/socket.h>
55#include <sys/device.h> 55#include <sys/device.h>
56 56
57#include <net/if.h> 57#include <net/if.h>
58#include <net/if_ether.h> 58#include <net/if_ether.h>
59#include <net/if_media.h> 59#include <net/if_media.h>
60 60
61#include <sys/cpu.h> 61#include <sys/cpu.h>
@@ -63,76 +63,76 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_mca.c, @@ -63,76 +63,76 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,
63#include <sys/bus.h> 63#include <sys/bus.h>
64 64
65#include <dev/ic/lancereg.h> 65#include <dev/ic/lancereg.h>
66#include <dev/ic/lancevar.h> 66#include <dev/ic/lancevar.h>
67#include <dev/ic/am7990reg.h> 67#include <dev/ic/am7990reg.h>
68#include <dev/ic/am7990var.h> 68#include <dev/ic/am7990var.h>
69 69
70#include <dev/mca/mcareg.h> 70#include <dev/mca/mcareg.h>
71#include <dev/mca/mcavar.h> 71#include <dev/mca/mcavar.h>
72#include <dev/mca/mcadevs.h> 72#include <dev/mca/mcadevs.h>
73 73
74#include <dev/mca/if_lereg.h> 74#include <dev/mca/if_lereg.h>
75 75
76int le_mca_match(device_t, cfdata_t, void *); 
77void le_mca_attach(device_t, device_t, void *); 
78 
79struct le_mca_softc { 76struct le_mca_softc {
80 struct am7990_softc sc_am7990; /* glue to MI code */ 77 struct am7990_softc sc_am7990; /* glue to MI code */
81 78
82 void *sc_ih; 79 void *sc_ih;
83 bus_space_tag_t sc_memt; 80 bus_space_tag_t sc_memt;
84 bus_space_handle_t sc_memh; 81 bus_space_handle_t sc_memh;
85}; 82};
86 83
87static void le_mca_wrcsr(struct lance_softc *, uint16_t, uint16_t); 84static int le_mca_match(device_t, cfdata_t, void *);
88static uint16_t le_mca_rdcsr(struct lance_softc *, uint16_t); 85static void le_mca_attach(device_t, device_t, void *);
89static void le_mca_hwreset(struct lance_softc *); 86
90static int le_mca_intredge(void *); 87static void le_mca_wrcsr(struct lance_softc *, uint16_t, uint16_t);
 88static uint16_t le_mca_rdcsr(struct lance_softc *, uint16_t);
 89static void le_mca_hwreset(struct lance_softc *);
 90static int le_mca_intredge(void *);
91 91
92static void le_mca_copytobuf(struct lance_softc *, void *, int, int); 92static void le_mca_copytobuf(struct lance_softc *, void *, int, int);
93static void le_mca_copyfrombuf(struct lance_softc *, void *, int, int); 93static void le_mca_copyfrombuf(struct lance_softc *, void *, int, int);
94static void le_mca_zerobuf(struct lance_softc *, int, int); 94static void le_mca_zerobuf(struct lance_softc *, int, int);
95 95
96static inline void le_mca_wrreg(struct le_mca_softc *, int, int); 96static inline void le_mca_wrreg(struct le_mca_softc *, int, int);
97#define le_mca_set_RAP(sc, reg_number) \ 97#define le_mca_set_RAP(sc, reg_number) \
98 le_mca_wrreg(sc, reg_number, RAP | REGWRITE) 98 le_mca_wrreg(sc, reg_number, RAP | REGWRITE)
99 99
100CFATTACH_DECL_NEW(le_mca, sizeof(struct le_mca_softc), 100CFATTACH_DECL_NEW(le_mca, sizeof(struct le_mca_softc),
101 le_mca_match, le_mca_attach, NULL, NULL); 101 le_mca_match, le_mca_attach, NULL, NULL);
102 102
103/* SKNET MC+ POS mapping */ 103/* SKNET MC+ POS mapping */
104static const u_int8_t sknet_mcp_irq[] = { 104static const uint8_t sknet_mcp_irq[] = {
105 3, 5, 10, 11 105 3, 5, 10, 11
106}; 106};
107static const u_int8_t sknet_mcp_media[] = { 107static const uint8_t sknet_mcp_media[] = {
108 IFM_ETHER|IFM_10_2, 108 IFM_ETHER | IFM_10_2,
109 IFM_ETHER|IFM_10_T, 109 IFM_ETHER | IFM_10_T,
110 IFM_ETHER|IFM_10_5, 110 IFM_ETHER | IFM_10_5,
111 0 111 0
112}; 112};
113 113
114int 114int
115le_mca_match(device_t parent, cfdata_t cf, void *aux) 115le_mca_match(device_t parent, cfdata_t cf, void *aux)
116{ 116{
117 struct mca_attach_args *ma = aux; 117 struct mca_attach_args *ma = aux;
118 118
119 switch(ma->ma_id) { 119 switch(ma->ma_id) {
120 case MCA_PRODUCT_SKNETPER: 120 case MCA_PRODUCT_SKNETPER:
121 case MCA_PRODUCT_SKNETG: 121 case MCA_PRODUCT_SKNETG:
122 return (1); 122 return 1;
123 } 123 }
124 124
125 return (0); 125 return 0;
126} 126}
127 127
128void 128void
129le_mca_attach(device_t parent, device_t self, void *aux) 129le_mca_attach(device_t parent, device_t self, void *aux)
130{ 130{
131 struct le_mca_softc *lesc = device_private(self); 131 struct le_mca_softc *lesc = device_private(self);
132 struct lance_softc *sc = &lesc->sc_am7990.lsc; 132 struct lance_softc *sc = &lesc->sc_am7990.lsc;
133 struct mca_attach_args *ma = aux; 133 struct mca_attach_args *ma = aux;
134 int i, pos2, pos3, pos4, irq, membase, supmedia=0; 134 int i, pos2, pos3, pos4, irq, membase, supmedia=0;
135 const char *typestr; 135 const char *typestr;
136 136
137 sc->sc_dev = self; 137 sc->sc_dev = self;
138 138
@@ -271,30 +271,30 @@ le_mca_attach(device_t parent, device_t  @@ -271,30 +271,30 @@ le_mca_attach(device_t parent, device_t
271/* 271/*
272 * Controller interrupt. 272 * Controller interrupt.
273 */ 273 */
274int 274int
275le_mca_intredge(void *arg) 275le_mca_intredge(void *arg)
276{ 276{
277 277
278 /* 278 /*
279 * We could check the IRQ bit of LE_PORT, but it seems to be unset 279 * We could check the IRQ bit of LE_PORT, but it seems to be unset
280 * at this time anyway. 280 * at this time anyway.
281 */ 281 */
282 282
283 if (am7990_intr(arg) == 0) 283 if (am7990_intr(arg) == 0)
284 return (0); 284 return 0;
285 for(;;) 285 for(;;)
286 if (am7990_intr(arg) == 0) 286 if (am7990_intr(arg) == 0)
287 return (1); 287 return 1;
288} 288}
289 289
290/* 290/*
291 * Push a value to LANCE controller. 291 * Push a value to LANCE controller.
292 */ 292 */
293static inline void 293static inline void
294le_mca_wrreg(struct le_mca_softc *sc, int val, int type) 294le_mca_wrreg(struct le_mca_softc *sc, int val, int type)
295{ 295{
296 296
297 /* 297 /*
298 * This follows steps in SKNET Personal/MC2+ docs: 298 * This follows steps in SKNET Personal/MC2+ docs:
299 * 1. write reg. number to LANCE register 299 * 1. write reg. number to LANCE register
300 * 2. write value RESET | type to port 300 * 2. write value RESET | type to port
@@ -338,34 +338,31 @@ le_mca_hwreset(struct lance_softc *sc) @@ -338,34 +338,31 @@ le_mca_hwreset(struct lance_softc *sc)
338{ 338{
339 struct le_mca_softc *lsc = (struct le_mca_softc *)sc; 339 struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
340 340
341 bus_space_write_1(lsc->sc_memt, lsc->sc_memh, LE_PORT, 0); 341 bus_space_write_1(lsc->sc_memt, lsc->sc_memh, LE_PORT, 0);
342 delay(5); /* Delay >= 5 microseconds */ 342 delay(5); /* Delay >= 5 microseconds */
343 bus_space_write_1(lsc->sc_memt, lsc->sc_memh, LE_PORT, RESET); 343 bus_space_write_1(lsc->sc_memt, lsc->sc_memh, LE_PORT, RESET);
344} 344}
345 345
346static void 346static void
347le_mca_copytobuf(struct lance_softc *sc, void *from, int boff, int len) 347le_mca_copytobuf(struct lance_softc *sc, void *from, int boff, int len)
348{ 348{
349 struct le_mca_softc *lsc = (struct le_mca_softc *)sc; 349 struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
350 350
351 bus_space_write_region_1(lsc->sc_memt, lsc->sc_memh, boff, 351 bus_space_write_region_1(lsc->sc_memt, lsc->sc_memh, boff, from, len);
352 from, len); 
353} 352}
354 353
355static void 354static void
356le_mca_copyfrombuf(struct lance_softc *sc, void *to, int boff, int len) 355le_mca_copyfrombuf(struct lance_softc *sc, void *to, int boff, int len)
357{ 356{
358 struct le_mca_softc *lsc = (struct le_mca_softc *)sc; 357 struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
359 358
360 bus_space_read_region_1(lsc->sc_memt, lsc->sc_memh, boff, 359 bus_space_read_region_1(lsc->sc_memt, lsc->sc_memh, boff, to, len);
361 to, len); 
362} 360}
363 361
364static void 362static void
365le_mca_zerobuf(struct lance_softc *sc, int boff, int len) 363le_mca_zerobuf(struct lance_softc *sc, int boff, int len)
366{ 364{
367 struct le_mca_softc *lsc = (struct le_mca_softc *)sc; 365 struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
368 366
369 bus_space_set_region_1(lsc->sc_memt, lsc->sc_memh, boff, 367 bus_space_set_region_1(lsc->sc_memt, lsc->sc_memh, boff, 0x00, len);
370 0x00, len); 
371} 368}