Deleted Added
full compact
fdt_pinctrl.c (283485) fdt_pinctrl.c (273669)
1/*-
2 * Copyright (c) 2014 Ian Lepore <ian@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2014 Ian Lepore <ian@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: stable/10/sys/dev/fdt/fdt_pinctrl.c 283485 2015-05-24 18:00:29Z ian $
26 * $FreeBSD: stable/10/sys/dev/fdt/fdt_pinctrl.c 273669 2014-10-26 03:41:27Z ian $
27 */
28
29#include <sys/cdefs.h>
30#include <sys/param.h>
31
32#include <dev/ofw/ofw_bus.h>
33#include <dev/ofw/ofw_bus_subr.h>
34

--- 6 unchanged lines hidden (view full) ---

41fdt_pinctrl_configure(device_t client, u_int index)
42{
43 device_t pinctrl;
44 phandle_t *configs;
45 int i, nconfigs;
46 char name[16];
47
48 snprintf(name, sizeof(name), "pinctrl-%u", index);
27 */
28
29#include <sys/cdefs.h>
30#include <sys/param.h>
31
32#include <dev/ofw/ofw_bus.h>
33#include <dev/ofw/ofw_bus_subr.h>
34

--- 6 unchanged lines hidden (view full) ---

41fdt_pinctrl_configure(device_t client, u_int index)
42{
43 device_t pinctrl;
44 phandle_t *configs;
45 int i, nconfigs;
46 char name[16];
47
48 snprintf(name, sizeof(name), "pinctrl-%u", index);
49 nconfigs = OF_getencprop_alloc(ofw_bus_get_node(client), name,
49 nconfigs = OF_getprop_alloc(ofw_bus_get_node(client), name,
50 sizeof(*configs), (void **)&configs);
51 if (nconfigs < 0)
52 return (ENOENT);
53 if (nconfigs == 0)
54 return (0); /* Empty property is documented as valid. */
55 for (i = 0; i < nconfigs; i++) {
56 if ((pinctrl = OF_device_from_xref(configs[i])) != NULL)
57 FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);

--- 59 unchanged lines hidden (view full) ---

117{
118 phandle_t node, *configs;
119 int i, nconfigs;
120
121 for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
122 if (!fdt_is_enabled(node))
123 continue;
124 pinctrl_configure_children(pinctrl, node);
50 sizeof(*configs), (void **)&configs);
51 if (nconfigs < 0)
52 return (ENOENT);
53 if (nconfigs == 0)
54 return (0); /* Empty property is documented as valid. */
55 for (i = 0; i < nconfigs; i++) {
56 if ((pinctrl = OF_device_from_xref(configs[i])) != NULL)
57 FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);

--- 59 unchanged lines hidden (view full) ---

117{
118 phandle_t node, *configs;
119 int i, nconfigs;
120
121 for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
122 if (!fdt_is_enabled(node))
123 continue;
124 pinctrl_configure_children(pinctrl, node);
125 nconfigs = OF_getencprop_alloc(node, "pinctrl-0",
125 nconfigs = OF_getencprop_alloc(node, "pinctrl-0",
126 sizeof(*configs), (void **)&configs);
126 sizeof(*configs), (void **)&configs);
127 if (nconfigs <= 0)
128 continue;
129 if (bootverbose) {
130 char name[32];
127#ifdef DEBUG
128 {
129 char name[32];
131 OF_getprop(node, "name", &name, sizeof(name));
130 OF_getprop(node, "name", &name, sizeof(name));
132 printf("Processing %d pin-config node(s) in pinctrl-0 for %s\n",
133 nconfigs, name);
131 printf("%d items in pinctrl-0 for %s\n", nconfigs, name);
134 }
132 }
133#endif
134 if (nconfigs <= 0)
135 continue;
135 for (i = 0; i < nconfigs; i++) {
136 if (OF_device_from_xref(configs[i]) == pinctrl)
137 FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);
138 }
139 free(configs, M_OFWPROP);
140 }
141 return (0);
142}
143
144int
145fdt_pinctrl_configure_tree(device_t pinctrl)
146{
147
148 return (pinctrl_configure_children(pinctrl, OF_peer(0)));
149}
150
136 for (i = 0; i < nconfigs; i++) {
137 if (OF_device_from_xref(configs[i]) == pinctrl)
138 FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);
139 }
140 free(configs, M_OFWPROP);
141 }
142 return (0);
143}
144
145int
146fdt_pinctrl_configure_tree(device_t pinctrl)
147{
148
149 return (pinctrl_configure_children(pinctrl, OF_peer(0)));
150}
151