1158124Smarcel/*-
2158124Smarcel * Copyright (c) 2006 Marcel Moolenaar
3158124Smarcel * All rights reserved.
4158124Smarcel *
5158124Smarcel * Redistribution and use in source and binary forms, with or without
6158124Smarcel * modification, are permitted provided that the following conditions
7158124Smarcel * are met:
8158124Smarcel *
9158124Smarcel * 1. Redistributions of source code must retain the above copyright
10158124Smarcel *    notice, this list of conditions and the following disclaimer.
11158124Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12158124Smarcel *    notice, this list of conditions and the following disclaimer in the
13158124Smarcel *    documentation and/or other materials provided with the distribution.
14158124Smarcel *
15158124Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16158124Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17158124Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18158124Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19158124Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20158124Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21158124Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22158124Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23158124Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24158124Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25158124Smarcel *
26158124Smarcel * $FreeBSD$
27158124Smarcel */
28158124Smarcel
29158124Smarcel#ifndef _DEV_PUC_BFE_H_
30251862Spluknet#define	_DEV_PUC_BFE_H_
31158124Smarcel
32158124Smarcel#define	PUC_PCI_BARS	6
33158124Smarcel
34158124Smarcelstruct puc_cfg;
35158124Smarcelstruct puc_port;
36158124Smarcel
37158124Smarcelextern const struct puc_cfg puc_pci_devices[];
38158124Smarcel
39158124Smarcelextern devclass_t puc_devclass;
40158124Smarcelextern const char puc_driver_name[];
41158124Smarcel
42158124Smarcelstruct puc_bar {
43158124Smarcel	struct resource *b_res;
44158124Smarcel	int		b_rid;
45158124Smarcel	int		b_type;
46158124Smarcel};
47158124Smarcel
48158124Smarcelstruct puc_softc {
49158124Smarcel	device_t	sc_dev;
50158124Smarcel
51158124Smarcel	const struct puc_cfg *sc_cfg;
52158124Smarcel	intptr_t	sc_cfg_data;
53158124Smarcel
54158124Smarcel	struct puc_bar	sc_bar[PUC_PCI_BARS];
55158124Smarcel	struct rman	sc_ioport;
56158124Smarcel	struct rman	sc_iomem;
57158124Smarcel	struct rman	sc_irq;
58158124Smarcel
59158124Smarcel	struct resource *sc_ires;
60158124Smarcel	void		*sc_icookie;
61158124Smarcel	int		sc_irid;
62158124Smarcel
63158124Smarcel	int		sc_nports;
64158124Smarcel	struct puc_port *sc_port;
65158124Smarcel
66158124Smarcel	int		sc_fastintr:1;
67158124Smarcel	int		sc_leaving:1;
68158124Smarcel	int		sc_polled:1;
69158124Smarcel
70158124Smarcel	int		sc_ilr;
71158124Smarcel
72158124Smarcel	/*
73158124Smarcel	 * Bitmask of ports that use the serdev I/F. This allows for
74158124Smarcel	 * 32 ports on ILP32 machines and 64 ports on LP64 machines.
75158124Smarcel	 */
76158124Smarcel	u_long		sc_serdevs;
77158124Smarcel};
78158124Smarcel
79158124Smarcelstruct puc_bar *puc_get_bar(struct puc_softc *sc, int rid);
80158124Smarcel
81158124Smarcelint puc_bfe_attach(device_t);
82158124Smarcelint puc_bfe_detach(device_t);
83158124Smarcelint puc_bfe_probe(device_t, const struct puc_cfg *);
84158124Smarcel
85223091Sjhbint puc_bus_child_location_str(device_t, device_t, char *, size_t);
86223091Sjhbint puc_bus_child_pnpinfo_str(device_t, device_t, char *, size_t);
87158124Smarcelstruct resource *puc_bus_alloc_resource(device_t, device_t, int, int *, u_long,
88158124Smarcel    u_long, u_long, u_int);
89158124Smarcelint puc_bus_get_resource(device_t, device_t, int, int, u_long *, u_long *);
90223091Sjhbint puc_bus_print_child(device_t, device_t);
91158124Smarcelint puc_bus_read_ivar(device_t, device_t, int, uintptr_t *);
92158124Smarcelint puc_bus_release_resource(device_t, device_t, int, int, struct resource *);
93158124Smarcelint puc_bus_setup_intr(device_t, device_t, struct resource *, int,
94166901Spiso    driver_filter_t *, driver_intr_t *, void *, void **);
95158124Smarcelint puc_bus_teardown_intr(device_t, device_t, struct resource *, void *);
96158124Smarcel
97158124Smarcel#endif /* _DEV_PUC_BFE_H_ */
98