summaryrefslogtreecommitdiff
path: root/drivers/spmi/spmi-uclass.c
blob: ff098731bb2dc8bdbbf4d3e39358f1c5fab8f449 (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
// SPDX-License-Identifier: GPL-2.0+
/*
 * SPMI bus uclass driver
 *
 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
 */

#include <common.h>
#include <dm.h>
#include <errno.h>
#include <spmi/spmi.h>
#include <linux/ctype.h>

int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
{
	const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);

	if (!ops || !ops->read)
		return -ENOSYS;

	return ops->read(dev, usid, pid, reg);
}

int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
		   uint8_t value)
{
	const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);

	if (!ops || !ops->write)
		return -ENOSYS;

	return ops->write(dev, usid, pid, reg, value);
}

UCLASS_DRIVER(spmi) = {
	.id		= UCLASS_SPMI,
	.name		= "spmi",
	.post_bind	= dm_scan_fdt_dev,
};