1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2015 Landon Fuller <landon@landonf.org>
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 * 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.
17 *
18 * NO WARRANTY
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.
30 *
31 * $FreeBSD$
32 */
33
34 #ifndef _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
35 #define _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
36
37 #include <sys/param.h>
38 #include <sys/bus.h>
39
40 /*
41 * Shared PCIe-G2 Bridge/Host Bridge definitions.
42 */
43
44 DECLARE_CLASS(bhnd_pcie2_driver);
45 struct bhnd_pcie2_softc;
46
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);
52
53 uint32_t bhnd_pcie2_read_proto_reg(struct bhnd_pcie2_softc *sc,
54 uint32_t addr);
55 void bhnd_pcie2_write_proto_reg(struct bhnd_pcie2_softc *sc,
56 uint32_t addr, uint32_t val);
57 int bhnd_pcie2_mdio_read(struct bhnd_pcie2_softc *sc, int phy,
58 int reg);
59 int bhnd_pcie2_mdio_write(struct bhnd_pcie2_softc *sc, int phy,
60 int reg, int val);
61 int bhnd_pcie2_mdio_read_ext(struct bhnd_pcie2_softc *sc, int phy,
62 int devaddr, int reg);
63 int bhnd_pcie2_mdio_write_ext(struct bhnd_pcie2_softc *sc,
64 int phy, int devaddr, int reg, int val);
65
66 /**
67 * bhnd_pcie2 child device info
68 */
69 struct bhnd_pcie2_devinfo {
70 struct resource_list resources;
71 };
72
73 /*
74 * Generic PCIe-G2 bridge/end-point driver state.
75 *
76 * Must be first member of all subclass softc structures.
77 */
78 struct bhnd_pcie2_softc {
79 device_t dev; /**< pci device */
80 uint32_t quirks; /**< quirk flags */
81
82 struct mtx mtx; /**< state mutex used to protect
83 interdependent register
84 accesses. */
85
86 struct bhnd_resource *mem_res; /**< device register block. */
87 int mem_rid; /**< register block RID */
88 };
89
90 #define BHND_PCIE2_LOCK_INIT(sc) \
91 mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
92 "BHND PCIe-G2 driver lock", MTX_DEF)
93 #define BHND_PCIE2_LOCK(sc) mtx_lock(&(sc)->mtx)
94 #define BHND_PCIE2_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
95 #define BHND_PCIE2_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->mtx, what)
96 #define BHND_PCIE2_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx)
97
98 #endif /* _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_ */
Cache object: 69961ae0740beb810043bfffeb4d3a41
|