// SPDX-License-Identifier: GPL-2.0 #define USE_HW_I2C #ifdef USE_HW_I2C #include "ddk750_chip.h" #include "ddk750_reg.h" #include "ddk750_hwi2c.h" #include "ddk750_power.h" #define MAX_HWI2C_FIFO … #define HWI2C_WAIT_TIMEOUT … int sm750_hw_i2c_init(unsigned char bus_speed_mode) { … } void sm750_hw_i2c_close(void) { … } static long hw_i2c_wait_tx_done(void) { … } /* * This function writes data to the i2c slave device registers. * * Parameters: * addr - i2c Slave device address * length - Total number of bytes to be written to the device * buf - The buffer that contains the data to be written to the * i2c device. * * Return Value: * Total number of bytes those are actually written. */ static unsigned int hw_i2c_write_data(unsigned char addr, unsigned int length, unsigned char *buf) { … } /* * This function reads data from the slave device and stores them * in the given buffer * * Parameters: * addr - i2c Slave device address * length - Total number of bytes to be read * buf - Pointer to a buffer to be filled with the data read * from the slave device. It has to be the same size as the * length to make sure that it can keep all the data read. * * Return Value: * Total number of actual bytes read from the slave device */ static unsigned int hw_i2c_read_data(unsigned char addr, unsigned int length, unsigned char *buf) { … } /* * This function reads the slave device's register * * Parameters: * deviceAddress - i2c Slave device address which register * to be read from * registerIndex - Slave device's register to be read * * Return Value: * Register value */ unsigned char sm750_hw_i2c_read_reg(unsigned char addr, unsigned char reg) { … } /* * This function writes a value to the slave device's register * * Parameters: * deviceAddress - i2c Slave device address which register * to be written * registerIndex - Slave device's register to be written * data - Data to be written to the register * * Result: * 0 - Success * -1 - Fail */ int sm750_hw_i2c_write_reg(unsigned char addr, unsigned char reg, unsigned char data) { … } #endif