mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 23:51:28 +00:00
oak: stm32f0: implement i2c_set_timeout
EC communicates with PD through I2C host command. This CL adds i2c_set_timeout implementation. BRANCH=none BUG=chrome-os-partner:41608 TEST=manual build and load on oak, check PD host command. Change-Id: I05259b40223b435eaf2a0c38954573e97ea4b32b Signed-off-by: Rong Chang <rongchang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306909 Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
@@ -189,13 +189,6 @@ void pd_send_host_event(int mask)
|
||||
host_set_single_event(EC_HOST_EVENT_PD_MCU);
|
||||
}
|
||||
|
||||
void __board_i2c_set_timeout(int port, uint32_t timeout)
|
||||
{
|
||||
}
|
||||
|
||||
void i2c_set_timeout(int port, uint32_t timeout)
|
||||
__attribute__((weak, alias("__board_i2c_set_timeout")));
|
||||
|
||||
/**
|
||||
* There is a level shift for AC_OK & LID_OPEN signal between AP & EC,
|
||||
* disable it (drive high) when AP is off, otherwise enable it (drive low).
|
||||
|
||||
@@ -40,6 +40,18 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* I2C port state data */
|
||||
struct i2c_port_data {
|
||||
uint32_t timeout_us; /* Transaction timeout, or 0 to use default */
|
||||
};
|
||||
static struct i2c_port_data pdata[I2C_PORT_COUNT];
|
||||
|
||||
void i2c_set_timeout(int port, uint32_t timeout)
|
||||
{
|
||||
pdata[port].timeout_us = timeout ? timeout : I2C_TX_TIMEOUT_MASTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for ISR register to contain the specified mask.
|
||||
*
|
||||
@@ -48,7 +60,7 @@
|
||||
*/
|
||||
static int wait_isr(int port, int mask)
|
||||
{
|
||||
uint64_t timeout = get_time().val + I2C_TX_TIMEOUT_MASTER;
|
||||
uint64_t timeout = get_time().val + pdata[port].timeout_us;
|
||||
|
||||
while (get_time().val < timeout) {
|
||||
int isr = STM32_I2C_ISR(port);
|
||||
@@ -143,6 +155,9 @@ defined(CONFIG_LOW_POWER_IDLE) && \
|
||||
|
||||
/* Set up initial bus frequencies */
|
||||
i2c_set_freq_port(p);
|
||||
|
||||
/* Set up default timeout */
|
||||
i2c_set_timeout(port, 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user