]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - include/spmi/spmi.h
cmd: add command for accessing the RPM via SMD protocol
[karo-tx-uboot.git] / include / spmi / spmi.h
1 #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  */
16 struct dm_spmi_ops {
17         int (*read)(struct udevice *dev, void *buf, int usid, int pid, int reg,
18                     uint8_t bc);
19         int (*write)(struct udevice *dev, const void *buf, int usid, int pid,
20                      int reg, uint8_t bc);
21 };
22
23 /**
24  * spmi_reg_read() - read a register from specific slave/peripheral
25  *
26  * @dev:        SPMI bus to read
27  * @usid        SlaveID
28  * @pid         Peripheral ID
29  * @reg:        Register to read
30  * @return value read on success or negative value of errno.
31  */
32 int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg);
33
34 /**
35  * spmi_reg_write() - write a register of specific slave/peripheral
36  *
37  * @dev:        SPMI bus to write
38  * @usid        SlaveID
39  * @pid         Peripheral ID
40  * @reg:        Register to write
41  * @value:      Value to write
42  * @return 0 on success or negative value of errno.
43  */
44 int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
45                    uint8_t value);
46
47 /**
48  * spmi_read() - read a range of registers from specific slave/peripheral
49  *
50  * @dev:        SPMI bus to read
51  * @usid        SlaveID
52  * @pid         Peripheral ID
53  * @reg:        Register to read
54  * @len:        Byte count to read
55  * @return value read on success or negative value of errno.
56  */
57 int spmi_read(struct udevice *dev, void *buf, int usid, int pid, int reg,
58               uint8_t len);
59
60 /**
61  * spmi_write() - write to a range of registers of specific slave/peripheral
62  *
63  * @dev:        SPMI bus to write
64  * @usid        SlaveID
65  * @pid         Peripheral ID
66  * @reg:        Register to write
67  * @value:      Value to write
68  * @len:        Byte count to write
69  * @return 0 on success or negative value of errno.
70  */
71 int spmi_write(struct udevice *dev, const void *buf, int usid, int pid,
72                int reg, uint8_t len);
73
74 #endif