1 /* $NetBSD: if_cs_smdk24x0.c,v 1.2 2005/12/11 12:17:09 christos Exp $ */
4 * Copyright (c) 2003 Genetec corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Genetec corporation may not be used to endorse
16 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED BY GENETEC CORP. ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORP.
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 /* derived from sys/dev/isa/if_cs_isa.c */
35 * Digital Equipment Corporation. All rights reserved.
37 * This software is furnished under license and may be used and
38 * copied only in accordance with the following terms and conditions.
39 * Subject to these conditions, you may download, copy, install,
40 * use, modify and distribute this software in source and/or binary
41 * form. No title or ownership is transferred hereby.
43 * 1) Any source code used, modified or distributed must reproduce
44 * and retain this copyright notice and list of conditions as
45 * they appear in the source file.
47 * 2) No right is granted to use any trade name, trademark, or logo of
48 * Digital Equipment Corporation. Neither the "Digital Equipment
49 * Corporation" name nor any trademark or logo of Digital Equipment
50 * Corporation may be used to endorse or promote products derived
51 * from this software without the prior written permission of
52 * Digital Equipment Corporation.
54 * 3) This software is provided "AS-IS" and any express or implied
55 * warranties, including but not limited to, any implied warranties
56 * of merchantability, fitness for a particular purpose, or
57 * non-infringement are disclaimed. In no event shall DIGITAL be
58 * liable for any damages whatsoever, and in particular, DIGITAL
59 * shall not be liable for special, indirect, consequential, or
60 * incidental damages or damages for lost profits, loss of
61 * revenue or loss of use, whether such damages arise in contract,
62 * negligence, tort, under statute, in equity, at law or otherwise,
63 * even if advised of the possibility of such damage.
67 * driver for SMDK24[10]0's on-board CS8900A Ethernet
69 * CS8900A is located at CS3 area.
71 * A24=0: Memory access
74 #include <sys/cdefs.h>
75 __KERNEL_RCSID(0, "$NetBSD: if_cs_smdk24x0.c,v 1.2 2005/12/11 12:17:09 christos Exp $");
77 #include <sys/param.h>
78 #include <sys/systm.h>
79 #include <sys/socket.h>
80 #include <sys/device.h>
88 #include <net/if_ether.h>
89 #include <net/if_media.h>
91 #include <machine/bus.h>
92 #include <machine/intr.h>
94 #include <arch/arm/s3c2xx0/s3c2410reg.h>
95 #include <arch/arm/s3c2xx0/s3c2410var.h>
97 #include <dev/ic/cs89x0reg.h>
98 #include <dev/ic/cs89x0var.h>
100 #include "locators.h"
101 #include "opt_smdk2xx0.h" /* SMDK24X0_ETHER_ADDR_FIXED */
103 int cs_ssextio_probe(device_t
, cfdata_t
, void *);
104 void cs_ssextio_attach(device_t
, device_t
, void *);
107 * I/O access is done when A24==1.
108 * default value for I/O base address is 0x300
110 #define IOADDR(base) (base + (1<<24) + 0x0300)
112 CFATTACH_DECL_NEW(cs_ssextio
, sizeof(struct cs_softc
),
113 cs_ssextio_probe
, cs_ssextio_attach
, NULL
, NULL
);
116 cs_ssextio_probe(device_t parent
, cfdata_t cf
, void *aux
)
118 struct s3c2xx0_attach_args
*sa
= aux
;
119 bus_space_tag_t iot
= sa
->sa_iot
;
120 bus_space_handle_t ioh
;
122 int rv
= 0, have_io
= 0;
125 if (sa
->sa_intr
== SSEXTIOCF_INTR_DEFAULT
)
127 if (sa
->sa_addr
== SSEXTIOCF_ADDR_DEFAULT
)
128 sa
->sa_addr
= S3C2410_BANK_START(3);
133 ioaddr
= IOADDR(sa
->sa_addr
);
134 if (bus_space_map(iot
, ioaddr
, CS8900_IOSIZE
, 0, &ioh
))
138 memset(&sc
, 0, sizeof sc
);
145 for (i
=0; i
<=PKTPG_IND_ADDR
; i
+= 2) {
147 printf( "\n%04x: ", i
);
148 printf("%04x ", CS_READ_PACKET_PAGE_IO(&sc
, i
));
153 /* Verify that it's a Crystal product. */
154 if (CS_READ_PACKET_PAGE_IO(&sc
, PKTPG_EISA_NUM
) != EISA_NUM_CRYSTAL
)
158 * Verify that it's a supported chip.
160 switch (CS_READ_PACKET_PAGE_IO(&sc
, PKTPG_PRODUCT_ID
) & PROD_ID_MASK
) {
164 case PROD_ID_CS8920M
:
171 bus_space_unmap(iot
, ioh
, CS8900_IOSIZE
);
176 /* media selection: UTP only */
177 static int cs_media
[] = {
180 IFM_ETHER
|IFM_10_T
|IFM_FDX
,
185 cs_ssextio_attach(device_t parent
, device_t self
, void *aux
)
187 struct cs_softc
*sc
= device_private(self
);
188 struct s3c2xx0_attach_args
*sa
= aux
;
190 #ifdef SMDK24X0_ETHER_ADDR_FIXED
191 static u_int8_t enaddr
[ETHER_ADDR_LEN
] = {SMDK24X0_ETHER_ADDR_FIXED
};
197 sc
->sc_iot
= sc
->sc_memt
= sa
->sa_iot
;
198 /* sc_irq is an IRQ number in ISA world. set 10 for INTRQ0 of CS8900A */
204 ioaddr
= IOADDR(sa
->sa_addr
);
205 if (bus_space_map(sc
->sc_iot
, ioaddr
, CS8900_IOSIZE
, 0, &sc
->sc_ioh
)) {
206 aprint_error(": unable to map i/o space\n");
210 if (bus_space_map(sc
->sc_iot
, sa
->sa_addr
, CS8900_MEMSIZE
,
212 aprint_error(": unable to map memory space");
214 sc
->sc_cfgflags
|= CFGFLG_MEM_MODE
;
215 sc
->sc_pktpgaddr
= sa
->sa_addr
;
218 /* CS8900A is very slow. (nOE->Data valid: 135ns max.)
219 We need to use IOCHRDY signal */
220 sc
->sc_cfgflags
|= CFGFLG_IOCHRDY
;
222 sc
->sc_ih
= s3c2410_extint_establish(sa
->sa_intr
, IPL_NET
, IST_EDGE_RISING
,
224 if (sc
->sc_ih
== NULL
) {
225 aprint_error(": unable to establish interrupt\n");
231 /* SMDK24X0 doesn't have EEPRMO hooked to CS8900A */
232 sc
->sc_cfgflags
|= CFGFLG_NOT_EEPROM
;
234 cs_attach(sc
, enaddr
, cs_media
,
235 sizeof(cs_media
) / sizeof(cs_media
[0]), IFM_ETHER
|IFM_10_T
);