Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 2 | /* |
| 3 | * SPMI bus uclass driver |
| 4 | * |
| 5 | * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com> |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Patrick Delaunay | 8131335 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 8 | #define LOG_CATEGORY UCLASS_SPMI |
| 9 | |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 10 | #include <common.h> |
| 11 | #include <dm.h> |
| 12 | #include <errno.h> |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 13 | #include <spmi/spmi.h> |
| 14 | #include <linux/ctype.h> |
| 15 | |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 16 | int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg) |
| 17 | { |
| 18 | const struct dm_spmi_ops *ops = dev_get_driver_ops(dev); |
| 19 | |
| 20 | if (!ops || !ops->read) |
| 21 | return -ENOSYS; |
| 22 | |
| 23 | return ops->read(dev, usid, pid, reg); |
| 24 | } |
| 25 | |
| 26 | int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg, |
| 27 | uint8_t value) |
| 28 | { |
| 29 | const struct dm_spmi_ops *ops = dev_get_driver_ops(dev); |
| 30 | |
| 31 | if (!ops || !ops->write) |
| 32 | return -ENOSYS; |
| 33 | |
| 34 | return ops->write(dev, usid, pid, reg, value); |
| 35 | } |
| 36 | |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 37 | UCLASS_DRIVER(spmi) = { |
| 38 | .id = UCLASS_SPMI, |
| 39 | .name = "spmi", |
Simon Glass | 1823034 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 40 | .post_bind = dm_scan_fdt_dev, |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 41 | }; |