2 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <dm/pinctrl.h>
13 static const char * const sandbox_pins
[] = {
20 static const char * const sandbox_groups
[] = {
27 static const char * const sandbox_functions
[] = {
33 static const struct pinconf_param sandbox_conf_params
[] = {
34 { "bias-disable", PIN_CONFIG_BIAS_DISABLE
, 0 },
35 { "bias-high-impedance", PIN_CONFIG_BIAS_HIGH_IMPEDANCE
, 0 },
36 { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD
, 0 },
37 { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP
, 1 },
38 { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN
, 1 },
39 { "bias-pull-pin-default", PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
, 1 },
40 { "drive-open-drain", PIN_CONFIG_DRIVE_OPEN_DRAIN
, 0 },
41 { "drive-open-source", PIN_CONFIG_DRIVE_OPEN_SOURCE
, 0 },
42 { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH
, 0 },
43 { "input-enable", PIN_CONFIG_INPUT_ENABLE
, 1 },
44 { "input-disable", PIN_CONFIG_INPUT_ENABLE
, 0 },
47 static int sandbox_get_pins_count(struct udevice
*dev
)
49 return ARRAY_SIZE(sandbox_pins
);
52 static const char *sandbox_get_pin_name(struct udevice
*dev
, unsigned selector
)
54 return sandbox_pins
[selector
];
57 static int sandbox_get_groups_count(struct udevice
*dev
)
59 return ARRAY_SIZE(sandbox_groups
);
62 static const char *sandbox_get_group_name(struct udevice
*dev
,
65 return sandbox_groups
[selector
];
68 static int sandbox_get_functions_count(struct udevice
*dev
)
70 return ARRAY_SIZE(sandbox_functions
);
73 static const char *sandbox_get_function_name(struct udevice
*dev
,
76 return sandbox_functions
[selector
];
79 static int sandbox_pinmux_set(struct udevice
*dev
, unsigned pin_selector
,
80 unsigned func_selector
)
82 debug("sandbox pinmux: pin = %d (%s), function = %d (%s)\n",
83 pin_selector
, sandbox_get_pin_name(dev
, pin_selector
),
84 func_selector
, sandbox_get_function_name(dev
, func_selector
));
89 static int sandbox_pinmux_group_set(struct udevice
*dev
,
90 unsigned group_selector
,
91 unsigned func_selector
)
93 debug("sandbox pinmux: group = %d (%s), function = %d (%s)\n",
94 group_selector
, sandbox_get_group_name(dev
, group_selector
),
95 func_selector
, sandbox_get_function_name(dev
, func_selector
));
100 static int sandbox_pinconf_set(struct udevice
*dev
, unsigned pin_selector
,
101 unsigned param
, unsigned argument
)
103 debug("sandbox pinconf: pin = %d (%s), param = %d, arg = %d\n",
104 pin_selector
, sandbox_get_pin_name(dev
, pin_selector
),
110 static int sandbox_pinconf_group_set(struct udevice
*dev
,
111 unsigned group_selector
,
112 unsigned param
, unsigned argument
)
114 debug("sandbox pinconf: group = %d (%s), param = %d, arg = %d\n",
115 group_selector
, sandbox_get_group_name(dev
, group_selector
),
121 const struct pinctrl_ops sandbox_pinctrl_ops
= {
122 .get_pins_count
= sandbox_get_pins_count
,
123 .get_pin_name
= sandbox_get_pin_name
,
124 .get_groups_count
= sandbox_get_groups_count
,
125 .get_group_name
= sandbox_get_group_name
,
126 .get_functions_count
= sandbox_get_functions_count
,
127 .get_function_name
= sandbox_get_function_name
,
128 .pinmux_set
= sandbox_pinmux_set
,
129 .pinmux_group_set
= sandbox_pinmux_group_set
,
130 .pinconf_num_params
= ARRAY_SIZE(sandbox_conf_params
),
131 .pinconf_params
= sandbox_conf_params
,
132 .pinconf_set
= sandbox_pinconf_set
,
133 .pinconf_group_set
= sandbox_pinconf_group_set
,
134 .set_state
= pinctrl_generic_set_state
,
137 static const struct udevice_id sandbox_pinctrl_match
[] = {
138 { .compatible
= "sandbox,pinctrl" },
142 U_BOOT_DRIVER(sandbox_pinctrl
) = {
143 .name
= "sandbox_pinctrl",
144 .id
= UCLASS_PINCTRL
,
145 .of_match
= sandbox_pinctrl_match
,
146 .ops
= &sandbox_pinctrl_ops
,