Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / marvell / gtvar.h
blobd6505230107a4a2878fda39ac44088426d93eb59
1 /* $NetBSD: gtvar.h,v 1.13 2007/02/21 23:00:00 thorpej Exp $ */
3 /*
4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
5 * All rights reserved.
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.
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.
41 * gtvar.h -- placeholder for GT system controller driver
43 #ifndef _DISCOVERY_DEV_GTVAR_H_
44 #define _DISCOVERY_DEV_GTVAR_H_
46 #include <sys/systm.h>
48 struct gt_softc {
49 struct device gt_dev;
50 bus_dma_tag_t gt_dmat;
51 bus_space_tag_t gt_memt; /* the GT itself */
52 bus_space_tag_t gt_pci0_memt; /* PCI0 mem space */
53 bus_space_tag_t gt_pci0_iot; /* PCI0 i/o space */
54 bool gt_pci0_host; /* We're host on PCI0 if TRUE */
55 bus_space_tag_t gt_pci1_memt; /* PCI1 mem space */
56 bus_space_tag_t gt_pci1_iot; /* PCI1 i/o space */
57 bool gt_pci1_host; /* We're host on PCI1 if TRUE */
59 bus_space_handle_t gt_memh; /* to access the GT registers */
60 int gt_childmask; /* what children are present */
63 #define GT_CHILDOK(gt, ga, cd, pos, max) \
64 (((ga)->ga_unit) < (max) && \
65 !((gt)->gt_childmask & (1 << (((ga)->ga_unit) + (pos)))) && \
66 !strcmp((ga)->ga_name, (cd)->cd_name))
68 #define GT_MPSCOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 0, 2)
69 #define GT_PCIOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 2, 2)
70 #define GT_ETHEROK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 4, 3)
71 #define GT_OBIOOK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 7, 5)
72 #define GT_I2COK(gt, ga, cd) GT_CHILDOK((gt), (ga), (cd), 12, 1)
74 #define GT_CHILDFOUND(gt, ga, pos) \
75 ((void)(((gt)->gt_childmask |= (1 << (((ga)->ga_unit) + (pos))))))
77 #define GT_MPSCFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 0)
78 #define GT_PCIFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 2)
79 #define GT_ETHERFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 4)
80 #define GT_OBIOFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 7)
81 #define GT_I2CFOUND(gt, ga) GT_CHILDFOUND((gt), (ga), 12)
83 struct gt_attach_args {
84 const char *ga_name; /* class name of device */
85 bus_dma_tag_t ga_dmat; /* dma tag */
86 bus_space_tag_t ga_memt; /* GT bus space tag */
87 bus_space_handle_t ga_memh; /* GT bus space handle */
88 int ga_unit; /* instance of ga_name */
91 struct obio_attach_args {
92 const char *oa_name; /* call name of device */
93 bus_space_tag_t oa_memt; /* bus space tag */
94 bus_addr_t oa_offset; /* offset (absolute) to device */
95 bus_size_t oa_size; /* size (strided) of device */
96 int oa_irq; /* irq */
99 #ifdef _KERNEL
100 #include "locators.h"
102 #ifdef DEBUG
103 extern int gtpci_debug;
104 #endif
107 * Locators for GT private devices, as specified to config.
109 #define GT_UNK_UNIT GTCF_UNIT_DEFAULT /* wcarded 'function' */
111 #define OBIO_UNK_OFFSET OBIOCF_OFFSET_DEFAULT /* wcarded 'offset' */
113 #define OBIO_UNK_SIZE OBIOCF_SIZE_DEFAULT /* wcarded 'size' */
115 #define OBIO_UNK_IRQ OBIOCF_IRQ_DEFAULT /* wcarded 'irq' */
117 void gt_attach_common(struct gt_softc *);
118 uint32_t gt_read_mpp(void);
119 int gt_cfprint(void *, const char *);
121 /* int gt_bs_extent_init(struct discovery_bus_space *, char *); AKB */
122 int gt_mii_read(device_t, device_t, int, int);
123 void gt_mii_write(device_t, device_t, int, int, int);
124 int gtget_macaddr(struct gt_softc *,int, char *);
125 void gt_watchdog_service(void);
126 bus_addr_t gt_dma_phys_to_bus_mem(bus_dma_tag_t, bus_addr_t);
127 bus_addr_t gt_dma_bus_mem_to_phys(bus_dma_tag_t, bus_addr_t);
129 #define gt_read(gt,o) \
130 bus_space_read_4((gt)->gt_memt, (gt)->gt_memh, (o))
131 #define gt_write(gt,o,v) \
132 bus_space_write_4((gt)->gt_memt, (gt)->gt_memh, (o), (v))
134 #if defined(__powerpc__)
135 static __inline int
136 atomic_add(volatile int *p, int v)
138 int rv;
139 int rtmp;
141 __asm volatile(
142 "1: lwarx %0,0,%2\n"
143 " add %1,%3,%0\n"
144 " stwcx. %1,0,%2\n"
145 " bne- 1b\n"
146 " sync"
147 : "=&r"(rv), "=&r"(rtmp)
148 : "r"(p), "r"(v)
149 : "cc");
151 return rv;
154 #endif /* __powerpc__ */
156 #endif /* _KERNEL */
158 #endif /* _DISCOVERY_DEV_GTVAR_H_ */