blob: 3242e6bbd07f8b93da694fa9f8916a2fc87cc99a [file] [log] [blame]
Mateusz Kulikowski04868b42016-03-31 23:12:27 +02001#ifndef _SPMI_SPMI_H
2#define _SPMI_SPMI_H
3
4/**
5 * struct dm_spmi_ops - SPMI device I/O interface
6 *
7 * Should be implemented by UCLASS_SPMI device drivers. The standard
8 * device operations provides the I/O interface for it's childs.
9 *
10 * @read: read register 'reg' of slave 'usid' and peripheral 'pid'
11 * @write: write register 'reg' of slave 'usid' and peripheral 'pid'
12 *
13 * Each register is 8-bit, both read and write can return negative values
14 * on error.
15 */
16struct dm_spmi_ops {
17 int (*read)(struct udevice *dev, int usid, int pid, int reg);
18 int (*write)(struct udevice *dev, int usid, int pid, int reg,
19 uint8_t value);
20};
21
22/**
23 * spmi_reg_read() - read a register from specific slave/peripheral
24 *
25 * @dev: SPMI bus to read
26 * @usid SlaveID
27 * @pid Peripheral ID
28 * @reg: Register to read
29 * @return value read on success or negative value of errno.
30 */
31int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg);
32
33/**
34 * spmi_reg_write() - write a register of specific slave/peripheral
35 *
36 * @dev: SPMI bus to write
37 * @usid SlaveID
38 * @pid Peripheral ID
39 * @reg: Register to write
40 * @value: Value to write
41 * @return 0 on success or negative value of errno.
42 */
43int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
44 uint8_t value);
45
46#endif