DECLARE_GLOBAL_DATA_PTR;
-#if CONFIG_IS_ENABLED(PINCTRL_FULL)
/**
* pinctrl_config_one() - apply pinctrl settings for a single node
*
*/
state = dectoul(statename, &end);
if (*end)
- return -EINVAL;
+ return -ENOSYS;
}
snprintf(propname, sizeof(propname), "pinctrl-%d", state);
list = dev_read_prop(dev, propname, &size);
if (!list)
- return -EINVAL;
+ return -ENOSYS;
size /= sizeof(*list);
for (i = 0; i < size; i++) {
return 0;
}
+#if CONFIG_IS_ENABLED(PINCTRL_FULL)
UCLASS_DRIVER(pinconfig) = {
.id = UCLASS_PINCONFIG,
#if CONFIG_IS_ENABLED(PINCONF_RECURSIVE)
.name = "pinconfig",
.id = UCLASS_PINCONFIG,
};
-
-#else
-static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
-{
- return -ENODEV;
-}
-
-static int pinconfig_post_bind(struct udevice *dev)
-{
- return 0;
-}
#endif
static int
{
struct ofnode_phandle_args args;
unsigned gpio_offset, pfc_base, pfc_pins;
- int ret;
+ int ret = 0;
+ int i = 0;
- ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3,
- 0, &args);
- if (ret) {
- dev_dbg(dev, "%s: dev_read_phandle_with_args: err=%d\n",
- __func__, ret);
- return ret;
- }
+ while (ret == 0) {
+ ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3,
+ i++, &args);
+ if (ret) {
+ dev_dbg(dev, "%s: dev_read_phandle_with_args: err=%d\n",
+ __func__, ret);
+ return ret;
+ }
- ret = uclass_get_device_by_ofnode(UCLASS_PINCTRL,
- args.node, pctldev);
- if (ret) {
- dev_dbg(dev,
- "%s: uclass_get_device_by_of_offset failed: err=%d\n",
- __func__, ret);
- return ret;
- }
+ ret = uclass_get_device_by_ofnode(UCLASS_PINCTRL,
+ args.node, pctldev);
+ if (ret) {
+ dev_dbg(dev,
+ "%s: uclass_get_device_by_of_offset failed: err=%d\n",
+ __func__, ret);
+ return ret;
+ }
- gpio_offset = args.args[0];
- pfc_base = args.args[1];
- pfc_pins = args.args[2];
+ gpio_offset = args.args[0];
+ pfc_base = args.args[1];
+ pfc_pins = args.args[2];
- if (offset < gpio_offset || offset > gpio_offset + pfc_pins) {
- dev_dbg(dev,
- "%s: GPIO can not be mapped to pincontrol pin\n",
- __func__);
- return -EINVAL;
+ if (offset >= gpio_offset && offset <= gpio_offset + pfc_pins)
+ break;
}
offset -= gpio_offset;
* Try full-implemented pinctrl first.
* If it fails or is not implemented, try simple one.
*/
- if (pinctrl_select_state_full(dev, statename))
- return pinctrl_select_state_simple(dev);
+ if (CONFIG_IS_ENABLED(PINCTRL_FULL))
+ return pinctrl_select_state_full(dev, statename);
- return 0;
+ return pinctrl_select_state_simple(dev);
}
int pinctrl_request(struct udevice *dev, int func, int flags)
}
/**
- * pinconfig_post_bind() - post binding for PINCTRL uclass
+ * pinctrl_post_bind() - post binding for PINCTRL uclass
* Recursively bind child nodes as pinconfig devices in case of full pinctrl.
*
* @dev: pinctrl device
{
const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
- /*
- * Make sure that the pinctrl driver gets probed after binding
- * as some pinctrl drivers also register the GPIO driver during
- * probe, and if they are not probed GPIO-s are not registered.
- */
- dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
-
if (!ops) {
dev_dbg(dev, "ops is not set. Do not bind.\n");
return -EINVAL;
}
/*
- * If set_state callback is set, we assume this pinctrl driver is the
- * full implementation. In this case, its child nodes should be bound
- * so that peripheral devices can easily search in parent devices
- * during later DT-parsing.
+ * If the pinctrl driver has the full implementation, its child nodes
+ * should be bound so that peripheral devices can easily search in
+ * parent devices during later DT-parsing.
*/
- if (ops->set_state)
+ if (CONFIG_IS_ENABLED(PINCTRL_FULL))
return pinconfig_post_bind(dev);
return 0;