blob: b45f72f59a77862b8256f4bd19d6d2db77694d5a [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
Simon Glass51a3ec32017-05-17 17:18:07 -06007#include <common.h>
Masahiro Yamadae4e789d2017-01-21 18:05:24 +09008#include <linux/errno.h>
Simon Glass11c89f32017-05-17 17:18:03 -06009#include <dm.h>
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090010#include <dm/pinctrl.h>
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090011
12#include "init.h"
13
14int uniphier_pin_init(const char *pinconfig_name)
15{
Simon Glasscfd72932019-09-25 08:55:56 -060016 struct udevice *pctldev, *config;
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090017 int ret;
18
19 ret = uclass_first_device(UCLASS_PINCTRL, &pctldev);
20 if (ret)
21 return ret;
22
Simon Glasscfd72932019-09-25 08:55:56 -060023 device_foreach_child(config, pctldev) {
Masahiro Yamadac21e19a2016-09-17 03:33:04 +090024 if (strcmp(config->name, pinconfig_name))
25 continue;
26
27 return pinctrl_generic_set_state(pctldev, config);
28 }
29
30 return -ENODEV;
31}