blob: 34fe8f6644c3212f5c65de16ce1f2b1aa4626eab [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Mateusz Kulikowski946797f2016-03-31 23:12:27 +02002/*
3 * SPMI bus uclass driver
4 *
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Mateusz Kulikowski946797f2016-03-31 23:12:27 +02006 */
7
Patrick Delaunay81313352021-04-27 11:02:19 +02008#define LOG_CATEGORY UCLASS_SPMI
9
Mateusz Kulikowski946797f2016-03-31 23:12:27 +020010#include <dm.h>
11#include <errno.h>
Mateusz Kulikowski946797f2016-03-31 23:12:27 +020012#include <spmi/spmi.h>
13#include <linux/ctype.h>
14
Mateusz Kulikowski946797f2016-03-31 23:12:27 +020015int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
16{
17 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
18
19 if (!ops || !ops->read)
20 return -ENOSYS;
21
22 return ops->read(dev, usid, pid, reg);
23}
24
25int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
26 uint8_t value)
27{
28 const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
29
30 if (!ops || !ops->write)
31 return -ENOSYS;
32
33 return ops->write(dev, usid, pid, reg, value);
34}
35
Mateusz Kulikowski946797f2016-03-31 23:12:27 +020036UCLASS_DRIVER(spmi) = {
37 .id = UCLASS_SPMI,
38 .name = "spmi",
Simon Glass18230342016-07-05 17:10:10 -060039 .post_bind = dm_scan_fdt_dev,
Mateusz Kulikowski946797f2016-03-31 23:12:27 +020040};