diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/i2c.h | 30 | ||||
-rw-r--r-- | include/i2c_arbitration.h | 44 |
2 files changed, 45 insertions, 29 deletions
diff --git a/include/i2c.h b/include/i2c.h index dbf933e102..d14008a2d0 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -48,32 +48,4 @@ int i2c_write8(int port, int slave_addr, int offset, int data); int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data, int len); -/** - * Claim an I2C port for use in master mode - * - * If this function succeed, then you must later call board_i2c_release() - * to release the claim. - * - * This function may optionally be implemented by a board file. If provided - * then it should check the port number and arbitrate as needed. - * - * This function will not be called to claim an already-claimed port. - * - * @param port Port to claim (0 for first, 1 for second, etc.) - * @return 0 if claimed successfully, -1 if it is in use - */ -int board_i2c_claim(int port); - -/** - * Release an I2C port (after previously being claimed) - * - * This function may optionally be implemented by a board file. If provided - * then it should check the port number and arbitrate as needed. - * - * This function will not be called to release an already-released port. - * - * @param port Port to claim (0 for first, 1 for second, etc.) - */ -void board_i2c_release(int port); - #endif /* __CROS_EC_I2C_H */ diff --git a/include/i2c_arbitration.h b/include/i2c_arbitration.h new file mode 100644 index 0000000000..cf4d39d247 --- /dev/null +++ b/include/i2c_arbitration.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* I2C arbitration for Chrome EC */ + +#ifndef __CROS_EC_I2C_ARBITRATION_H +#define __CROS_EC_I2C_ARBITRATION_H + +#include "common.h" + +#ifdef CONFIG_I2C_ARBITRATION + +/** + * Claim an I2C port for use in master mode. + * + * If this function succeeds, you must later call i2c_release() to release the + * claim. + * + * This function must not be called to claim an already-claimed port. + * + * @param port Port to claim (0 for first, 1 for second, etc.) + * @return 0 if claimed successfully, -1 if it is in use + */ +int i2c_claim(int port); + +/** + * Release an I2C port (after previously being claimed) + * + * This function must not be called to release an already-released port. + * + * @param port Port to claim (0 for first, 1 for second, etc.) + */ +void i2c_release(int port); + +#else + +static inline int i2c_claim(int port) { return EC_SUCCESS; } +static inline void i2c_release(int port) {} + +#endif + +#endif /* __CROS_EC_I2C_ARBITRATION_H */ |