#include <dm/device.h>
#include <dm/lists.h>
#include <dm/pinctrl.h>
+#include <dm/root.h>
#include <dm/uclass.h>
DECLARE_GLOBAL_DATA_PTR;
static int pinconfig_post_bind(struct udevice *dev)
{
- return 0;
+ /* Scan the bus for devices */
+ return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
}
#endif
return 0;
}
+int pinctrl_request(struct udevice *dev, int func, int flags)
+{
+ struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+ if (!ops->request)
+ return -ENOSYS;
+
+ return ops->request(dev, func, flags);
+}
+
+int pinctrl_request_noflags(struct udevice *dev, int func)
+{
+ return pinctrl_request(dev, func, 0);
+}
+
+int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph)
+{
+ struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+ if (!ops->get_periph_id)
+ return -ENOSYS;
+
+ return ops->get_periph_id(dev, periph);
+}
+
/**
* pinconfig_post-bind() - post binding for PINCTRL uclass
* Recursively bind child nodes as pinconfig devices in case of full pinctrl.
}
/*
- * 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.
+ * The pinctrl driver child nodes should be bound so that peripheral
+ * devices can easily search in parent devices during later DT-parsing.
*/
- if (ops->set_state)
- return pinconfig_post_bind(dev);
-
- return 0;
+ return pinconfig_post_bind(dev);
}
UCLASS_DRIVER(pinctrl) = {
int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector,
unsigned param, unsigned argument);
int (*set_state)(struct udevice *dev, struct udevice *config);
+
+ /* for pinctrl-simple */
int (*set_state_simple)(struct udevice *dev, struct udevice *periph);
+ /**
+ * request() - Request a particular pinctrl function
+ *
+ * This activates the selected function.
+ *
+ * @dev: Device to adjust (UCLASS_PINCTRL)
+ * @func: Function number (driver-specific)
+ * @return 0 if OK, -ve on error
+ */
+ int (*request)(struct udevice *dev, int func, int flags);
+
+ /**
+ * get_periph_id() - get the peripheral ID for a device
+ *
+ * This generally looks at the peripheral's device tree node to work
+ * out the peripheral ID. The return value is normally interpreted as
+ * enum periph_id. so long as this is defined by the platform (which it
+ * should be).
+ *
+ * @dev: Pinctrl device to use for decoding
+ * @periph: Device to check
+ * @return peripheral ID of @periph, or -ENOENT on error
+ */
+ int (*get_periph_id)(struct udevice *dev, struct udevice *periph);
};
#define pinctrl_get_ops(dev) ((struct pinctrl_ops *)(dev)->driver->ops)
}
#endif
+/**
+ * pinctrl_request() - Request a particular pinctrl function
+ *
+ * @dev: Device to check (UCLASS_PINCTRL)
+ * @func: Function number (driver-specific)
+ * @flags: Flags (driver-specific)
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_request(struct udevice *dev, int func, int flags);
+
+/**
+ * pinctrl_request_noflags() - Request a particular pinctrl function
+ *
+ * This is similar to pinctrl_request() but uses 0 for @flags.
+ *
+ * @dev: Device to check (UCLASS_PINCTRL)
+ * @func: Function number (driver-specific)
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_request_noflags(struct udevice *dev, int func);
+
+/**
+ * pinctrl_get_periph_id() - get the peripheral ID for a device
+ *
+ * This generally looks at the peripheral's device tree node to work out the
+ * peripheral ID. The return value is normally interpreted as enum periph_id.
+ * so long as this is defined by the platform (which it should be).
+ *
+ * @dev: Pinctrl device to use for decoding
+ * @periph: Device to check
+ * @return peripheral ID of @periph, or -ENOENT on error
+ */
+int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph);
+
#endif /* __PINCTRL_H */