blob: 2e07264695956de7c685f33b0fc73b42c92274ce [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamadac21e19a2016-09-17 03:33:04 +09002/*
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamadac21e19a2016-09-17 03:33:04 +09005 */
6
Masahiro Yamadae4e789d2017-01-21 18:05:24 +09007#include <linux/errno.h>
Simon Glass11c89f32017-05-17 17:18:03 -06008#include <dm.h>
Masahiro Yamadac21e19a2016-09-17 03:33:04 +09009#include <dm/pinctrl.h>
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090010
11#include "init.h"
12
13int uniphier_pin_init(const char *pinconfig_name)
14{
Simon Glasscfd72932019-09-25 08:55:56 -060015 struct udevice *pctldev, *config;
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090016 int ret;
17
18 ret = uclass_first_device(UCLASS_PINCTRL, &pctldev);
19 if (ret)
20 return ret;
21
Simon Glasscfd72932019-09-25 08:55:56 -060022 device_foreach_child(config, pctldev) {
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090023 if (strcmp(config->name, pinconfig_name))
24 continue;
25
26 return pinctrl_generic_set_state(pctldev, config);
27 }
28
29 return -ENODEV;
30}