xref: /openbmc/u-boot/arch/arm/mach-uniphier/pinctrl-glue.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016 Socionext Inc.
4  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5  */
6 
7 #include <common.h>
8 #include <linux/errno.h>
9 #include <dm.h>
10 #include <dm/pinctrl.h>
11 
12 #include "init.h"
13 
uniphier_pin_init(const char * pinconfig_name)14 int uniphier_pin_init(const char *pinconfig_name)
15 {
16 	struct udevice *pctldev, *config, *next;
17 	int ret;
18 
19 	ret = uclass_first_device(UCLASS_PINCTRL, &pctldev);
20 	if (ret)
21 		return ret;
22 
23 	device_foreach_child_safe(config, next, pctldev) {
24 		if (strcmp(config->name, pinconfig_name))
25 			continue;
26 
27 		return pinctrl_generic_set_state(pctldev, config);
28 	}
29 
30 	return -ENODEV;
31 }
32