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> 12 #include <spmi/spmi.h> 13 #include <linux/ctype.h> 14 15 int 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 25 int 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 36 UCLASS_DRIVER(spmi) = { 37 .id = UCLASS_SPMI, 38 .name = "spmi", 39 .post_bind = dm_scan_fdt_dev, 40 }; 41