summaryrefslogtreecommitdiff
path: root/drivers/power/pmic/raa215300.c
blob: a581a1f6dc15018eec284f1990bde8b79303a669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2023 Renesas Electronics Corporation
 */

#include <dm.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <i2c.h>
#include <power/pmic.h>

#define RAA215300_REG_COUNT 0x80

static int raa215300_reg_count(struct udevice *dev)
{
	return RAA215300_REG_COUNT;
}

static struct dm_pmic_ops raa215300_ops = {
	.reg_count = raa215300_reg_count,
	.read = dm_i2c_read,
	.write = dm_i2c_write,
};

static const struct udevice_id raa215300_ids[] = {
	{ .compatible = "renesas,raa215300" },
	{ /* sentinel */ }
};

static int raa215300_bind(struct udevice *dev)
{
	if (IS_ENABLED(CONFIG_SYSRESET_RAA215300)) {
		struct driver *drv = lists_driver_lookup_name("raa215300_sysreset");
		if (!drv)
			return -ENOENT;

		return device_bind(dev, drv, dev->name, NULL, dev_ofnode(dev),
				   NULL);
	}

	return 0;
}

U_BOOT_DRIVER(raa215300_pmic) = {
	.name = "raa215300_pmic",
	.id = UCLASS_PMIC,
	.of_match = raa215300_ids,
	.bind = raa215300_bind,
	.ops = &raa215300_ops,
};