2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2015 Landon Fuller <landon@landonf.org>
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 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15 * redistribution must be conditioned upon including a substantially
16 * similar Disclaimer requirement for further binary redistribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
22 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24 * OR 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
27 * IN 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
29 * THE POSSIBILITY OF SUCH DAMAGES.
34 #ifndef _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
35 #define _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
37 #include <sys/param.h>
41 * Shared PCIe-G2 Bridge/Host Bridge definitions.
44 DECLARE_CLASS(bhnd_pcie2_driver);
45 struct bhnd_pcie2_softc;
47 int bhnd_pcie2_generic_probe(device_t dev);
48 int bhnd_pcie2_generic_attach(device_t dev);
49 int bhnd_pcie2_generic_detach(device_t dev);
50 int bhnd_pcie2_generic_suspend(device_t dev);
51 int bhnd_pcie2_generic_resume(device_t dev);
54 uint32_t bhnd_pcie2_read_proto_reg(struct bhnd_pcie2_softc *sc,
56 void bhnd_pcie2_write_proto_reg(struct bhnd_pcie2_softc *sc,
57 uint32_t addr, uint32_t val);
58 int bhnd_pcie2_mdio_read(struct bhnd_pcie2_softc *sc, int phy,
60 int bhnd_pcie2_mdio_write(struct bhnd_pcie2_softc *sc, int phy,
62 int bhnd_pcie2_mdio_read_ext(struct bhnd_pcie2_softc *sc, int phy,
63 int devaddr, int reg);
64 int bhnd_pcie2_mdio_write_ext(struct bhnd_pcie2_softc *sc,
65 int phy, int devaddr, int reg, int val);
68 * bhnd_pcie2 child device info
70 struct bhnd_pcie2_devinfo {
71 struct resource_list resources;
75 * Generic PCIe-G2 bridge/end-point driver state.
77 * Must be first member of all subclass softc structures.
79 struct bhnd_pcie2_softc {
80 device_t dev; /**< pci device */
81 uint32_t quirks; /**< quirk flags */
83 struct mtx mtx; /**< state mutex used to protect
84 interdependent register
87 struct bhnd_resource *mem_res; /**< device register block. */
88 int mem_rid; /**< register block RID */
92 #define BHND_PCIE2_LOCK_INIT(sc) \
93 mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
94 "BHND PCIe-G2 driver lock", MTX_DEF)
95 #define BHND_PCIE2_LOCK(sc) mtx_lock(&(sc)->mtx)
96 #define BHND_PCIE2_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
97 #define BHND_PCIE2_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->mtx, what)
98 #define BHND_PCIE2_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx)
100 #endif /* _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_ */