@@ -34,4 +34,12 @@ void clock_init_sec(void);
void clock_init_uart(void);
#endif
+/*
+ * sunxi_clk_bind() - Bind reset device as child of clock device
+ *
+ * @cdev: clock udevice
+ * @return 0 success, or error value
+ */
+int sunxi_clk_bind(struct udevice *cdev);
+
#endif /* _SUNXI_CLOCK_H */
@@ -4,4 +4,5 @@
# SPDX-License-Identifier: GPL-2.0+
#
+obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
@@ -137,4 +137,5 @@ U_BOOT_DRIVER(clk_sun50i_a64) = {
.ofdata_to_platdata = a64_clk_ofdata_to_platdata,
.ops = &a64_clk_ops,
.probe = a64_clk_probe,
+ .bind = sunxi_clk_bind,
};
new file mode 100644
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <dm/lists.h>
+
+int sunxi_clk_bind(struct udevice *cdev)
+{
+ struct udevice *rst_dev;
+ char *dev_name = "reset";
+ char drv_name[30];
+ int ret;
+
+ /**
+ * reset driver doesn't have separate dt binding, so probe them
+ * using driver name.
+ * example: sun50i_a64_ccu is clock driver,
+ * sun50i_a64_reset is reset driver.
+ */
+ strcpy(drv_name, cdev->driver->name);
+ memcpy(&drv_name[strlen(drv_name) - 3], dev_name, strlen(dev_name));
+
+ ret = device_bind_driver_to_node(cdev, drv_name, dev_name,
+ dev_ofnode(cdev), &rst_dev);
+ if (ret) {
+ debug("Warning: failed to bind (%s) reset driver: ret=%d\n",
+ drv_name, ret);
+ return ret;
+ }
+
+ return 0;
+}