aboutsummaryrefslogtreecommitdiff
path: root/include/spmi/spmi.h
blob: 3242e6bbd07f8b93da694fa9f8916a2fc87cc99a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _SPMI_SPMI_H
#define _SPMI_SPMI_H

/**
 * struct dm_spmi_ops - SPMI device I/O interface
 *
 * Should be implemented by UCLASS_SPMI device drivers. The standard
 * device operations provides the I/O interface for it's childs.
 *
 * @read:      read register 'reg' of slave 'usid' and peripheral 'pid'
 * @write:     write register 'reg' of slave 'usid' and peripheral 'pid'
 *
 * Each register is 8-bit, both read and write can return negative values
 * on error.
 */
struct dm_spmi_ops {
	int (*read)(struct udevice *dev, int usid, int pid, int reg);
	int (*write)(struct udevice *dev, int usid, int pid, int reg,
		     uint8_t value);
};

/**
 * spmi_reg_read() - read a register from specific slave/peripheral
 *
 * @dev:	SPMI bus to read
 * @usid	SlaveID
 * @pid		Peripheral ID
 * @reg:	Register to read
 * @return value read on success or negative value of errno.
 */
int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg);

/**
 * spmi_reg_write() - write a register of specific slave/peripheral
 *
 * @dev:	SPMI bus to write
 * @usid	SlaveID
 * @pid		Peripheral ID
 * @reg:	Register to write
 * @value:	Value to write
 * @return 0 on success or negative value of errno.
 */
int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
		   uint8_t value);

#endif