Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 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, 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 |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 29 | * Return: value read on success or negative value of errno. |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 30 | */ |
| 31 | int 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 |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 41 | * Return: 0 on success or negative value of errno. |
Mateusz Kulikowski | 946797f | 2016-03-31 23:12:27 +0200 | [diff] [blame] | 42 | */ |
| 43 | int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg, |
| 44 | uint8_t value); |
| 45 | |
| 46 | #endif |