i2c.h (3204B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 * 8 * File: i2c.h 9 * Purpose: Implementation of I2C bus commands 10 */ 11 12 #ifndef _SAL_I2C_H 13 #define _SAL_I2C_H 14 15 #include <sal/types.h> 16 17 /* 18 * i2c_bus - The number of the I2C bus to access on 19 * i2c_dev - the device on the I2C bus (slave device ID/address) to be accessed 20 * addr - The address in the device to be accessed (register address). Used if alen>0 21 * addr_len - the length of the address in bytes, should be between 0 and 4 22 * data - the data buffer for the I2C operation 23 * data_len - the length of the data 24 * 25 * Returns : 0 - success, otherwise - failure 26 */ 27 extern int 28 sal_i2c_read(int i2c_bus, uint16 i2c_dev, uint32 addr, uint8 addr_len, uint8 *data, 29 uint8 data_len); 30 31 /* 32 * i2c_bus - The number of the I2C bus to access on 33 * i2c_dev - the device on the I2C bus (slave device ID/address) to be accessed 34 * addr - The address in the device to be accessed (register address). Used if addr_len>0 35 * addr_len - the length of the address in bytes, should be between 0 and 4 36 * data - the data buffer for the I2C operation 37 * data_len - the length of the data 38 * 39 * Returns : 0 - success, otherwise - failure 40 */ 41 extern int 42 sal_i2c_write(int i2c_bus, uint16 i2c_dev, uint32 addr, uint8 addr_len, uint8 *data, 43 uint8 data_len); 44 45 /* 46 * Function : sal_i2c_write_split 47 * Purpose : Provide i2c bus write functionality using CPU i2c controller 48 * Splits the I2C write operation in the implementation to address and data. 49 * Returns : 0 - success, otherwise - failure 50 */ 51 extern int 52 sal_i2c_write_split( 53 int i2c_bus, /* The number of the I2C bus to access on */ 54 uint16 i2c_dev, /* the device on the I2C bus (slave device ID/address) to be accessed */ 55 uint32 addr, /* The address in the device to be accessed (register address). Used if addr_len>0 */ 56 uint8 addr_len, /* the length of the address in bytes, should be between 0 and 4. */ 57 uint8 *data, /* the buffer of the data to be written. */ 58 uint8 data_len);/* the length of the data to write. */ 59 60 /* 61 * Function: cpu_i2c_device_present 62 * Purpose: Probe the I2C bus using i2c_dev, report if a device responds. 63 * The I2C bus is released upon return. 64 * No further action is taken. 65 * 66 * Parameters: 67 * i2c_dev - I2C slave address 68 * 69 * Return: 70 * _SHR_E_NONE - An I2C device responds at the indicated slave address i2c_dev. 71 * otherwise - No I2C response at the indicated saddr, or I/O error. 72 */ 73 extern int 74 sal_i2c_device_present( 75 int i2c_bus, /* The number of the I2C bus to access on */ 76 uint16 i2c_dev);/* the device on the I2C bus (slave device ID/address) to be accessed */ 77 78 #define SAL_I2C_FAST_ACCESS (0x1) 79 /* 80 * unit - I2C controller 81 * flags - SAL_I2C_* flags 82 */ 83 extern int 84 sal_i2c_config_set(int unit, uint32 flags); 85 86 /* 87 * unit - I2C controller 88 * flags - SAL_I2C_* flags 89 */ 90 extern int 91 sal_i2c_config_get(int unit, uint32 *flags); 92 #endif /* _SAL_I2C_H */