Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/fdt/fdt_pinctrl.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | fdt_pinctrl_configure(device_t client, u_int index) | ||||
if (nconfigs < 0) | if (nconfigs < 0) | ||||
return (ENOENT); | return (ENOENT); | ||||
if (nconfigs == 0) | if (nconfigs == 0) | ||||
return (0); /* Empty property is documented as valid. */ | return (0); /* Empty property is documented as valid. */ | ||||
for (i = 0; i < nconfigs; i++) { | for (i = 0; i < nconfigs; i++) { | ||||
if ((pinctrl = OF_device_from_xref(configs[i])) != NULL) | if ((pinctrl = OF_device_from_xref(configs[i])) != NULL) | ||||
FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); | FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); | ||||
} | } | ||||
free(configs, M_OFWPROP); | OF_prop_free(configs); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
fdt_pinctrl_configure_by_name(device_t client, const char * name) | fdt_pinctrl_configure_by_name(device_t client, const char * name) | ||||
{ | { | ||||
char * names; | char * names; | ||||
int i, offset, nameslen; | int i, offset, nameslen; | ||||
nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names", | nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names", | ||||
sizeof(*names), (void **)&names); | sizeof(*names), (void **)&names); | ||||
if (nameslen <= 0) | if (nameslen <= 0) | ||||
return (ENOENT); | return (ENOENT); | ||||
for (i = 0, offset = 0; offset < nameslen; i++) { | for (i = 0, offset = 0; offset < nameslen; i++) { | ||||
if (strcmp(name, &names[offset]) == 0) | if (strcmp(name, &names[offset]) == 0) | ||||
break; | break; | ||||
offset += strlen(&names[offset]) + 1; | offset += strlen(&names[offset]) + 1; | ||||
} | } | ||||
free(names, M_OFWPROP); | OF_prop_free(names); | ||||
if (offset < nameslen) | if (offset < nameslen) | ||||
return (fdt_pinctrl_configure(client, i)); | return (fdt_pinctrl_configure(client, i)); | ||||
else | else | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
static int | static int | ||||
pinctrl_register_children(device_t pinctrl, phandle_t parent, | pinctrl_register_children(device_t pinctrl, phandle_t parent, | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (bootverbose) { | ||||
OF_getprop(node, "name", &name, sizeof(name)); | OF_getprop(node, "name", &name, sizeof(name)); | ||||
printf("Processing %d pin-config node(s) in pinctrl-0 for %s\n", | printf("Processing %d pin-config node(s) in pinctrl-0 for %s\n", | ||||
nconfigs, name); | nconfigs, name); | ||||
} | } | ||||
for (i = 0; i < nconfigs; i++) { | for (i = 0; i < nconfigs; i++) { | ||||
if (OF_device_from_xref(configs[i]) == pinctrl) | if (OF_device_from_xref(configs[i]) == pinctrl) | ||||
FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); | FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]); | ||||
} | } | ||||
free(configs, M_OFWPROP); | OF_prop_free(configs); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
fdt_pinctrl_configure_tree(device_t pinctrl) | fdt_pinctrl_configure_tree(device_t pinctrl) | ||||
{ | { | ||||
return (pinctrl_configure_children(pinctrl, OF_peer(0))); | return (pinctrl_configure_children(pinctrl, OF_peer(0))); | ||||
} | } | ||||