Mateusz Kulikowski | 04868b4 | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 1 | /* |
| 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> |
Mateusz Kulikowski | 04868b4 | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 12 | #include <spmi/spmi.h> |
| 13 | #include <linux/ctype.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg) |
| 18 | { |
| 19 | const struct dm_spmi_ops *ops = dev_get_driver_ops(dev); |
| 20 | |
| 21 | if (!ops || !ops->read) |
| 22 | return -ENOSYS; |
| 23 | |
| 24 | return ops->read(dev, usid, pid, reg); |
| 25 | } |
| 26 | |
| 27 | int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg, |
| 28 | uint8_t value) |
| 29 | { |
| 30 | const struct dm_spmi_ops *ops = dev_get_driver_ops(dev); |
| 31 | |
| 32 | if (!ops || !ops->write) |
| 33 | return -ENOSYS; |
| 34 | |
| 35 | return ops->write(dev, usid, pid, reg, value); |
| 36 | } |
| 37 | |
Mateusz Kulikowski | 04868b4 | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 38 | UCLASS_DRIVER(spmi) = { |
| 39 | .id = UCLASS_SPMI, |
| 40 | .name = "spmi", |
Simon Glass | 9119548 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 41 | .post_bind = dm_scan_fdt_dev, |
Mateusz Kulikowski | 04868b4 | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 42 | }; |