Commit 12632459 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul
Browse files

soundwire: cadence: merge routines to clear/set bits

parent af4cc917
Loading
Loading
Loading
Loading
+8 −20
Original line number Diff line number Diff line
@@ -211,26 +211,6 @@ static inline void cdns_updatel(struct sdw_cdns *cdns,
	cdns_writel(cdns, offset, tmp);
}

static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)
{
	int timeout = 10;
	u32 reg_read;

	writel(value, cdns->registers + offset);

	/* Wait for bit to be self cleared */
	do {
		reg_read = readl(cdns->registers + offset);
		if ((reg_read & value) == 0)
			return 0;

		timeout--;
		udelay(50);
	} while (timeout != 0);

	return -EAGAIN;
}

static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
{
	int timeout = 10;
@@ -249,6 +229,14 @@ static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
	return -ETIMEDOUT;
}

static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value)
{
	writel(value, cdns->registers + offset);

	/* Wait for bit to be self cleared */
	return cdns_set_wait(cdns, offset, value, 0);
}

/*
 * all changes to the MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL
 * need to be confirmed with a write to MCP_CONFIG_UPDATE