blob: ff098731bb2dc8bdbbf4d3e39358f1c5fab8f449 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Mateusz Kulikowski04868b42016-03-31 23:12:27 +02002/*
3 * SPMI bus uclass driver
4 *
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Mateusz Kulikowski04868b42016-03-31 23:12:27 +02006 */
7
8#include <common.h>
9#include <dm.h>
10#include <errno.h>
Mateusz Kulikowski04868b42016-03-31 23:12:27 +020011#include <spmi/spmi.h>
12#include <linux/ctype.h>
13
Mateusz Kulikowski04868b42016-03-31 23:12:27 +020014int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
15{
16 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
17
18 if (!ops || !ops->read)
19 return -ENOSYS;
20
21 return ops->read(dev, usid, pid, reg);
22}
23
24int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
25 uint8_t value)
26{
27 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
28
29 if (!ops || !ops->write)
30 return -ENOSYS;
31
32 return ops->write(dev, usid, pid, reg, value);
33}
34
Mateusz Kulikowski04868b42016-03-31 23:12:27 +020035UCLASS_DRIVER(spmi) = {
36 .id = UCLASS_SPMI,
37 .name = "spmi",
Simon Glass91195482016-07-05 17:10:10 -060038 .post_bind = dm_scan_fdt_dev,
Mateusz Kulikowski04868b42016-03-31 23:12:27 +020039};