RTEMS: bsps/powerpc/beatnik/net/if_gfe/gtvar.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
gtvar.h
1/* $NetBSD: gtvar.h,v 1.7.4.1 2005/04/29 11:28:56 kent Exp $ */
2
3/*
4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project by
18 * Allegro Networks, Inc., and Wasabi Systems, Inc.
19 * 4. The name of Allegro Networks, Inc. may not be used to endorse
20 * or promote products derived from this software without specific prior
21 * written permission.
22 * 5. The name of Wasabi Systems, Inc. may not be used to endorse
23 * or promote products derived from this software without specific prior
24 * written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY ALLEGRO NETWORKS, INC. AND
27 * WASABI SYSTEMS, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
28 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL EITHER ALLEGRO NETWORKS, INC. OR WASABI SYSTEMS, INC.
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40/*
41 * gtvar.h -- placeholder for GT system controller driver
42 */
43#ifndef _DISCOVERY_DEV_GTVAR_H_
44#define _DISCOVERY_DEV_GTVAR_H_
45
46#include <sys/systm.h>
47
48 struct gt_softc {
49#ifndef __rtems__
50 struct device gt_dev;
51 bus_dma_tag_t gt_dmat;
52 bus_space_tag_t gt_memt; /* the GT itself */
53 bus_space_tag_t gt_pci0_memt; /* PCI0 mem space */
54 bus_space_tag_t gt_pci0_iot; /* PCI0 i/o space */
55 boolean_t gt_pci0_host; /* We're host on PCI0 if TRUE */
56 bus_space_tag_t gt_pci1_memt; /* PCI1 mem space */
57 bus_space_tag_t gt_pci1_iot; /* PCI1 i/o space */
58 boolean_t gt_pci1_host; /* We're host on PCI1 if TRUE */
59
60 bus_space_handle_t gt_memh; /* to access the GT registers */
61#else
62 unsigned gt_memh;
63#endif
64 int gt_childmask; /* what children are present */
65};
66
67#define GT_CHILDOK(gt, ga, cd, pos, max) \
68 (((ga)->ga_unit) < (max) && \
69 !((gt)->gt_childmask & (1 << (((ga)->ga_unit) + (pos)))) && \
70 !strcmp((ga)->ga_name, (cd)->cd_name))
71
72#define GT_MPSCOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 0, 2)
73#define GT_PCIOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 2, 2)
74#define GT_ETHEROK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 4, 3)
75#define GT_OBIOOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 7, 5)
76#define GT_I2COK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 12, 1)
77
78#define GT_CHILDFOUND(gt, ga, pos) \
79 ((void)(((gt)->gt_childmask |= (1 << (((ga)->ga_unit) + (pos))))))
80
81#define GT_MPSCFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 0)
82#define GT_PCIFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 2)
83#define GT_ETHERFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 4)
84#define GT_OBIOFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 7)
85#define GT_I2CFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 12)
86
87#ifndef __rtems__
88 struct gt_attach_args {
89 const char *ga_name; /* class name of device */
90 bus_dma_tag_t ga_dmat; /* dma tag */
91 bus_space_tag_t ga_memt; /* GT bus space tag */
92 bus_space_handle_t ga_memh; /* GT bus space handle */
93 int ga_unit; /* instance of ga_name */
94};
95
96 struct obio_attach_args {
97 const char *oa_name; /* call name of device */
98 bus_space_tag_t oa_memt; /* bus space tag */
99 bus_addr_t oa_offset; /* offset (absolute) to device */
100 bus_size_t oa_size; /* size (strided) of device */
101 int oa_irq; /* irq */
102};
103#endif
104
105#ifdef _KERNEL
106#ifndef __rtems__
107#include "locators.h"
108#endif
109
110#ifdef DEBUG
111extern int gtpci_debug;
112#endif
113
114/*
115 * Locators for GT private devices, as specified to config.
116 */
117#define GT_UNK_UNIT GTCF_UNIT_DEFAULT /* wcarded 'function' */
118
119#define OBIO_UNK_OFFSET OBIOCF_OFFSET_DEFAULT /* wcarded 'offset' */
120
121#define OBIO_UNK_SIZE OBIOCF_SIZE_DEFAULT /* wcarded 'size' */
122
123#define OBIO_UNK_IRQ OBIOCF_IRQ_DEFAULT /* wcarded 'irq' */
124
125void gt_attach_common(struct gt_softc *);
126uint32_t gt_read_mpp(void);
127int gt_cfprint(void *, const char *);
128
129#ifndef __rtems__
130/* int gt_bs_extent_init(struct discovery_bus_space *, char *); AKB */
131int gt_mii_read(struct device *, struct device *, int, int);
132void gt_mii_write(struct device *, struct device *, int, int, int);
133int gtget_macaddr(struct gt_softc *,int, char *);
134
135void gt_watchdog_service(void);
136bus_addr_t gt_dma_phys_to_bus_mem(bus_dma_tag_t, bus_addr_t);
137bus_addr_t gt_dma_bus_mem_to_phys(bus_dma_tag_t, bus_addr_t);
138
139#define gt_read(gt,o) \
140 bus_space_read_4((gt)->gt_memt, (gt)->gt_memh, (o))
141#define gt_write(gt,o,v) \
142 bus_space_write_4((gt)->gt_memt, (gt)->gt_memh, (o), (v))
143#else
144#endif
145
146#if defined(__powerpc__)
147static __inline volatile int
148atomic_add(volatile int *p, int v)
149{
150 int rv;
151 int rtmp;
152
153 __asm __volatile(
154 "1: lwarx %0,0,%3\n"
155 " add %1,%4,%0\n"
156 " stwcx. %1,0,%3\n"
157 " bne- 1b\n"
158 " sync"
159 : "=&r"(rv), "=&r"(rtmp), "=m"(*p)
160 : "r"(p), "r"(v), "m"(*p)
161 : "cc");
162
163 return rv;
164}
165
166#endif /* __powerpc__ */
167
168#endif /* _KERNEL */
169
170#endif /* _DISCOVERY_DEV_GTVAR_H_ */
device
Definition: rtemscompat1.h:15
gt_attach_args
Definition: gtvar.h:88
gt_softc
Definition: gtvar.h:48
obio_attach_args
Definition: gtvar.h:96
p
unsigned p
Definition: tte.h:17