3 .\" Copyright (c) 2018 Oleksandr Tymoshenko
5 .\" All rights reserved.
7 .\" This program is free software.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .Dt ofw_bus_is_compatible 9
35 .Nm ofw_bus_is_compatible ,
36 .Nm ofw_bus_is_compatible_strict ,
37 .Nm ofw_bus_node_is_compatible ,
38 .Nm ofw_bus_search_compatible
39 .Nd check device tree nodes for compatibility with drivers
41 .In dev/ofw/openfirm.h
43 .In dev/ofw/ofw_bus_subr.h
45 .Fn ofw_bus_is_compatible "device_t dev" "const char *compatstr"
47 .Fn ofw_bus_is_compatible_strict "device_t dev" "const char *compatstr"
49 .Fn ofw_bus_node_is_compatible "phandle_t node" "const char *compatstr"
50 .Ft const struct ofw_compat_data *
51 .Fn ofw_bus_search_compatible "device_t dev" "const struct ofw_compat_data *compat"
53 The "compatible" property of the device tree node is used to
54 identify the type of the device the node represents.
55 The property is a list of one or more strings that represent
56 hardware types the device is compatible with.
57 The common format for such strings is "vendor,hardware"
58 where "vendor" is an abbreviated name of the manufacturer
59 and "hardware" is a device identifier, for instance, "fsl"
60 for "Freescale" and "imx6ul-i2c" for the I2C controller.
61 More than one string is required for compatibility with
62 older revisions of the driver.
63 If hardware revision B is backward compatible with revision
64 A device tree node can signal this compatibility by
65 providing both "vndr,hrdwrA" and "vndr,hrdwrB" strings in
66 the "compatibile" property value.
67 This way older driver can use features available only in
68 revision A, and the new version of the driver can take
69 advantage of revision B feature set.
71 .Fn ofw_bus_is_compatible
74 value occurs in the "compatible" property list of the device
75 tree node associated with the device
79 .Fn ofw_bus_is_compatible_strict
80 return 1 if the "compatible"
81 property of the device tree node associated with the device
83 consists of only one string and this string is equal to
87 .Fn ofw_bus_node_is_compatible
90 value occurs in the "compatible" property list of the device
95 .Fn ofw_bus_search_compatible
96 returns pointer to the first entry of the
98 table whose ocd_str field occurs in "compatible" property of
99 the device tree node associated with the device
103 table is an array of struct ofw_compat_data elements defined as follows:
104 .Bd -literal -offset indent
105 struct ofw_compat_data {
112 table must be terminated by the entry with ocd_str set to NULL.
113 If the device tree node is not compatible with any of
114 the entries, the function returns the pointer to the
117 .Bd -literal -offset indent
118 static struct ofw_compat_data compat_data[] = {
119 {"arm,hrdwrA", FEATURE_A},
120 {"arm,hrdwrB", FEATURE_A | FEATURE_B},
125 hrdwr_probe(device_t dev)
128 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
134 hrdwr_attach(device_t dev)
137 sc = device_get_softc(dev);
138 sc->sc_features = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
143 .Xr ofw_bus_find_compatible 9
145 This manual page was written by
146 .An Oleksandr Tymoshenko .