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