1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
10 #include <dm/pinctrl.h>
12 static const char * const sandbox_pins[] = {
19 static const char * const sandbox_groups[] = {
26 static const char * const sandbox_functions[] = {
32 static const struct pinconf_param sandbox_conf_params[] = {
33 { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
34 { "bias-high-impedance", PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0 },
35 { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 },
36 { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
37 { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 1 },
38 { "bias-pull-pin-default", PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, 1 },
39 { "drive-open-drain", PIN_CONFIG_DRIVE_OPEN_DRAIN, 0 },
40 { "drive-open-source", PIN_CONFIG_DRIVE_OPEN_SOURCE, 0 },
41 { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 },
42 { "input-enable", PIN_CONFIG_INPUT_ENABLE, 1 },
43 { "input-disable", PIN_CONFIG_INPUT_ENABLE, 0 },
46 static int sandbox_get_pins_count(struct udevice *dev)
48 return ARRAY_SIZE(sandbox_pins);
51 static const char *sandbox_get_pin_name(struct udevice *dev, unsigned selector)
53 return sandbox_pins[selector];
56 static int sandbox_get_groups_count(struct udevice *dev)
58 return ARRAY_SIZE(sandbox_groups);
61 static const char *sandbox_get_group_name(struct udevice *dev,
64 return sandbox_groups[selector];
67 static int sandbox_get_functions_count(struct udevice *dev)
69 return ARRAY_SIZE(sandbox_functions);
72 static const char *sandbox_get_function_name(struct udevice *dev,
75 return sandbox_functions[selector];
78 static int sandbox_pinmux_set(struct udevice *dev, unsigned pin_selector,
79 unsigned func_selector)
81 debug("sandbox pinmux: pin = %d (%s), function = %d (%s)\n",
82 pin_selector, sandbox_get_pin_name(dev, pin_selector),
83 func_selector, sandbox_get_function_name(dev, func_selector));
88 static int sandbox_pinmux_group_set(struct udevice *dev,
89 unsigned group_selector,
90 unsigned func_selector)
92 debug("sandbox pinmux: group = %d (%s), function = %d (%s)\n",
93 group_selector, sandbox_get_group_name(dev, group_selector),
94 func_selector, sandbox_get_function_name(dev, func_selector));
99 static int sandbox_pinconf_set(struct udevice *dev, unsigned pin_selector,
100 unsigned param, unsigned argument)
102 debug("sandbox pinconf: pin = %d (%s), param = %d, arg = %d\n",
103 pin_selector, sandbox_get_pin_name(dev, pin_selector),
109 static int sandbox_pinconf_group_set(struct udevice *dev,
110 unsigned group_selector,
111 unsigned param, unsigned argument)
113 debug("sandbox pinconf: group = %d (%s), param = %d, arg = %d\n",
114 group_selector, sandbox_get_group_name(dev, group_selector),
120 const struct pinctrl_ops sandbox_pinctrl_ops = {
121 .get_pins_count = sandbox_get_pins_count,
122 .get_pin_name = sandbox_get_pin_name,
123 .get_groups_count = sandbox_get_groups_count,
124 .get_group_name = sandbox_get_group_name,
125 .get_functions_count = sandbox_get_functions_count,
126 .get_function_name = sandbox_get_function_name,
127 .pinmux_set = sandbox_pinmux_set,
128 .pinmux_group_set = sandbox_pinmux_group_set,
129 .pinconf_num_params = ARRAY_SIZE(sandbox_conf_params),
130 .pinconf_params = sandbox_conf_params,
131 .pinconf_set = sandbox_pinconf_set,
132 .pinconf_group_set = sandbox_pinconf_group_set,
133 .set_state = pinctrl_generic_set_state,
136 static const struct udevice_id sandbox_pinctrl_match[] = {
137 { .compatible = "sandbox,pinctrl" },
141 U_BOOT_DRIVER(sandbox_pinctrl) = {
142 .name = "sandbox_pinctrl",
143 .id = UCLASS_PINCTRL,
144 .of_match = sandbox_pinctrl_match,
145 .ops = &sandbox_pinctrl_ops,