/* @twsi: The MVTWSI register structure to use. @tick: The duration of a clock cycle at the current I2C speed.  */
static int twsi_stop(struct mvtwsi_registers *twsi, uint tick)
/* @twsi: The MVTWSI register structure to use. @tick: The duration of a clock cycle at the current I2C speed.  */
static int twsi_stop(struct mvtwsi_registers *twsi, uint tick)
{
	int control, stop_status;
	int status = 0;
	int timeout = 1000;
	control = MVTWSI_CONTROL_TWSIEN | MVTWSI_CONTROL_STOP;
	writel(control | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
	do {
		stop_status = readl(&twsi->status);
		if (stop_status == MVTWSI_STATUS_IDLE)
			break;
		ndelay(tick);
	} while (timeout--);
	control = readl(&twsi->control);
	if (stop_status != MVTWSI_STATUS_IDLE)
		status = mvtwsi_error(MVTWSI_ERROR_TIMEOUT,
				      control, status, MVTWSI_STATUS_IDLE);
	return status;
}