xref: /freebsd/sys/dev/puc/puc_bfe.h (revision 9dbf5b0e6876d8c93890754bcc9c748339de79c0)
164220a7eSMarcel Moolenaar /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
464220a7eSMarcel Moolenaar  * Copyright (c) 2006 Marcel Moolenaar
564220a7eSMarcel Moolenaar  * All rights reserved.
664220a7eSMarcel Moolenaar  *
764220a7eSMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
864220a7eSMarcel Moolenaar  * modification, are permitted provided that the following conditions
964220a7eSMarcel Moolenaar  * are met:
1064220a7eSMarcel Moolenaar  *
1164220a7eSMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
1264220a7eSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
1364220a7eSMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
1464220a7eSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
1564220a7eSMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
1664220a7eSMarcel Moolenaar  *
1764220a7eSMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1864220a7eSMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1964220a7eSMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2064220a7eSMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2164220a7eSMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2264220a7eSMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2364220a7eSMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2464220a7eSMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2564220a7eSMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2664220a7eSMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2764220a7eSMarcel Moolenaar  */
2864220a7eSMarcel Moolenaar 
2964220a7eSMarcel Moolenaar #ifndef _DEV_PUC_BFE_H_
3077b2b60dSSergey Kandaurov #define	_DEV_PUC_BFE_H_
3164220a7eSMarcel Moolenaar 
3264220a7eSMarcel Moolenaar #define	PUC_PCI_BARS	6
3364220a7eSMarcel Moolenaar 
3464220a7eSMarcel Moolenaar struct puc_cfg;
3564220a7eSMarcel Moolenaar struct puc_port;
3664220a7eSMarcel Moolenaar 
3764220a7eSMarcel Moolenaar extern const struct puc_cfg puc_pci_devices[];
3864220a7eSMarcel Moolenaar 
3964220a7eSMarcel Moolenaar extern const char puc_driver_name[];
4064220a7eSMarcel Moolenaar 
4164220a7eSMarcel Moolenaar struct puc_bar {
4264220a7eSMarcel Moolenaar 	struct resource *b_res;
4364220a7eSMarcel Moolenaar 	int		b_rid;
4464220a7eSMarcel Moolenaar 	int		b_type;
4564220a7eSMarcel Moolenaar };
4664220a7eSMarcel Moolenaar 
4764220a7eSMarcel Moolenaar struct puc_softc {
4864220a7eSMarcel Moolenaar 	device_t	sc_dev;
4964220a7eSMarcel Moolenaar 
5064220a7eSMarcel Moolenaar 	const struct puc_cfg *sc_cfg;
5164220a7eSMarcel Moolenaar 	intptr_t	sc_cfg_data;
5264220a7eSMarcel Moolenaar 
5364220a7eSMarcel Moolenaar 	struct puc_bar	sc_bar[PUC_PCI_BARS];
5464220a7eSMarcel Moolenaar 	struct rman	sc_ioport;
5564220a7eSMarcel Moolenaar 	struct rman	sc_iomem;
5664220a7eSMarcel Moolenaar 	struct rman	sc_irq;
5764220a7eSMarcel Moolenaar 
5864220a7eSMarcel Moolenaar 	struct resource *sc_ires;
5964220a7eSMarcel Moolenaar 	void		*sc_icookie;
6064220a7eSMarcel Moolenaar 	int		sc_irid;
6164220a7eSMarcel Moolenaar 
6264220a7eSMarcel Moolenaar 	int		sc_nports;
6364220a7eSMarcel Moolenaar 	struct puc_port *sc_port;
6464220a7eSMarcel Moolenaar 
65bab8274cSDimitry Andric 	bool		sc_fastintr:1;
66bab8274cSDimitry Andric 	bool		sc_leaving:1;
67bab8274cSDimitry Andric 	bool		sc_polled:1;
68bab8274cSDimitry Andric 	bool		sc_msi:1;
6964220a7eSMarcel Moolenaar 
7064220a7eSMarcel Moolenaar 	int		sc_ilr;
7164220a7eSMarcel Moolenaar 
7264220a7eSMarcel Moolenaar 	/*
7364220a7eSMarcel Moolenaar 	 * Bitmask of ports that use the serdev I/F. This allows for
7464220a7eSMarcel Moolenaar 	 * 32 ports on ILP32 machines and 64 ports on LP64 machines.
7564220a7eSMarcel Moolenaar 	 */
7664220a7eSMarcel Moolenaar 	u_long		sc_serdevs;
7764220a7eSMarcel Moolenaar };
7864220a7eSMarcel Moolenaar 
7964220a7eSMarcel Moolenaar struct puc_bar *puc_get_bar(struct puc_softc *sc, int rid);
8064220a7eSMarcel Moolenaar 
8164220a7eSMarcel Moolenaar int puc_bfe_attach(device_t);
8264220a7eSMarcel Moolenaar int puc_bfe_detach(device_t);
8364220a7eSMarcel Moolenaar int puc_bfe_probe(device_t, const struct puc_cfg *);
8464220a7eSMarcel Moolenaar 
85ddfc9c4cSWarner Losh int puc_bus_child_location(device_t, device_t, struct sbuf *sb);
86ddfc9c4cSWarner Losh int puc_bus_child_pnpinfo(device_t, device_t, struct sbuf *sb);
872dd1bdf1SJustin Hibbits struct resource *puc_bus_alloc_resource(device_t, device_t, int, int *,
882dd1bdf1SJustin Hibbits     rman_res_t, rman_res_t, rman_res_t, u_int);
892dd1bdf1SJustin Hibbits int puc_bus_get_resource(device_t, device_t, int, int, rman_res_t *, rman_res_t *);
90573e64d4SJohn Baldwin int puc_bus_print_child(device_t, device_t);
9164220a7eSMarcel Moolenaar int puc_bus_read_ivar(device_t, device_t, int, uintptr_t *);
92*9dbf5b0eSJohn Baldwin int puc_bus_release_resource(device_t, device_t, struct resource *);
9364220a7eSMarcel Moolenaar int puc_bus_setup_intr(device_t, device_t, struct resource *, int,
94ef544f63SPaolo Pisati     driver_filter_t *, driver_intr_t *, void *, void **);
9564220a7eSMarcel Moolenaar int puc_bus_teardown_intr(device_t, device_t, struct resource *, void *);
9664220a7eSMarcel Moolenaar 
979725900bSRyan Stone SYSCTL_DECL(_hw_puc);
989725900bSRyan Stone 
9964220a7eSMarcel Moolenaar #endif /* _DEV_PUC_BFE_H_ */
100