blob: 4ddd51b556ec1e3092ffe82dcd23ca1c2ea0db87 [file] [log] [blame]
Mateusz Kulikowski04868b42016-03-31 23:12:27 +02001/*
2 * SPMI bus uclass driver
3 *
4 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <common.h>
10#include <dm.h>
11#include <errno.h>
12#include <dm/root.h>
13#include <spmi/spmi.h>
14#include <linux/ctype.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
18int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
19{
20 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
21
22 if (!ops || !ops->read)
23 return -ENOSYS;
24
25 return ops->read(dev, usid, pid, reg);
26}
27
28int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
29 uint8_t value)
30{
31 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
32
33 if (!ops || !ops->write)
34 return -ENOSYS;
35
36 return ops->write(dev, usid, pid, reg, value);
37}
38
39static int spmi_post_bind(struct udevice *dev)
40{
41 return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
42}
43
44UCLASS_DRIVER(spmi) = {
45 .id = UCLASS_SPMI,
46 .name = "spmi",
47 .post_bind = spmi_post_bind,
48};