// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2019 Texas Instruments Incorporated, <www.ti.com>
 * Keerthy <j-keerthy@ti.com>
 */

#include <common.h>
#include <fdtdec.h>
#include <errno.h>
#include <dm.h>
#include <i2c.h>
#include <power/pmic.h>
#include <power/regulator.h>
#include <power/tps65941.h>
#include <dm/device.h>

static const struct pmic_child_info pmic_children_info[] = {
	{ .prefix = "ldo", .driver = TPS65941_LDO_DRIVER },
	{ .prefix = "buck", .driver = TPS65941_BUCK_DRIVER },
	{ },
};

static int tps65941_write(struct udevice *dev, uint reg, const uint8_t *buff,
			  int len)
{
	if (dm_i2c_write(dev, reg, buff, len)) {
		pr_err("write error to device: %p register: %#x!\n", dev, reg);
		return -EIO;
	}

	return 0;
}

static int tps65941_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
	if (dm_i2c_read(dev, reg, buff, len)) {
		pr_err("read error from device: %p register: %#x!\n", dev, reg);
		return -EIO;
	}

	return 0;
}

static int tps65941_bind(struct udevice *dev)
{
	ofnode regulators_node;
	int children;

	regulators_node = dev_read_subnode(dev, "regulators");
	if (!ofnode_valid(regulators_node)) {
		debug("%s: %s regulators subnode not found!\n", __func__,
		      dev->name);
		return -ENXIO;
	}

	debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);

	children = pmic_bind_children(dev, regulators_node, pmic_children_info);
	if (!children)
		printf("%s: %s - no child found\n", __func__, dev->name);

	/* Probe all the child devices */
	return dm_scan_fdt_dev(dev);
}

static struct dm_pmic_ops tps65941_ops = {
	.read = tps65941_read,
	.write = tps65941_write,
};

static const struct udevice_id tps65941_ids[] = {
	{ .compatible = "ti,tps659411", .data = TPS659411 },
	{ .compatible = "ti,tps659413", .data = TPS659413 },
	{ }
};

U_BOOT_DRIVER(pmic_tps65941) = {
	.name = "tps65941_pmic",
	.id = UCLASS_PMIC,
	.of_match = tps65941_ids,
	.bind = tps65941_bind,
	.ops = &tps65941_ops,
};
