Ejemplo n.º 1
0
int tps65090_fet_disable(unsigned int fet_id)
{
	int ret;

	if (tps65090_check_fet(fet_id))
		return -1;
	if (tps65090_select())
		return -1;
	ret = tps65090_fet_set(fet_id, 0);
	tps65090_deselect();

	return ret;
}
Ejemplo n.º 2
0
int tps65090_fet_disable(unsigned int fet_id)
{
	struct pmic *pmic;
	int ret;

	ret = tps65090_check_fet(fet_id);
	if (ret)
		return ret;

	pmic = pmic_get(TPS65090_NAME);
	if (!pmic)
		return -EACCES;
	ret = tps65090_fet_set(pmic, fet_id, false);

	return ret;
}
Ejemplo n.º 3
0
int tps65090_fet_enable(unsigned int fet_id)
{
	struct pmic *pmic;
	ulong start;
	int loops;
	int ret;

	ret = tps65090_check_fet(fet_id);
	if (ret)
		return ret;

	pmic = pmic_get(TPS65090_NAME);
	if (!pmic)
		return -EACCES;

	start = get_timer(0);
	for (loops = 0;; loops++) {
		ret = tps65090_fet_set(pmic, fet_id, true);
		if (!ret)
			break;

		if (get_timer(start) > 100)
			break;

		/* Turn it off and try again until we time out */
		tps65090_fet_set(pmic, fet_id, false);
	}

	if (ret)
		debug("%s: FET%d failed to power on: time=%lums, loops=%d\n",
		      __func__, fet_id, get_timer(start), loops);
	else if (loops)
		debug("%s: FET%d powered on after %lums, loops=%d\n",
		      __func__, fet_id, get_timer(start), loops);

	/*
	 * Unfortunately, there are some conditions where the power
	 * good bit will be 0, but the fet still comes up. One such
	 * case occurs with the lcd backlight. We'll just return 0 here
	 * and assume that the fet will eventually come up.
	 */
	if (ret == -EAGAIN)
		ret = 0;

	return ret;
}
Ejemplo n.º 4
0
int tps65090_fet_is_enabled(unsigned int fet_id)
{
	unsigned char reg;
	int ret;

	if (tps65090_check_fet(fet_id))
		return -1;
	if (tps65090_select())
		return -1;
	ret = tps65090_i2c_read(REG_FET1_CTRL + fet_id - 1, &reg);
	tps65090_deselect();
	if (ret) {
		debug("fail to read FET%u_CTRL register over I2C", fet_id);
		return -2;
	}

	return reg & FET_CTRL_ENFET;
}
Ejemplo n.º 5
0
int tps65090_fet_enable(unsigned int fet_id)
{
	int loops;
	ulong start;
	int ret = 0;

	if (tps65090_check_fet(fet_id))
		return -1;
	if (tps65090_select())
		return -1;
	start = get_timer(0);
	for (loops = 0; ; loops++) {
		ret = tps65090_fet_set(fet_id, 1);
		if (!ret)
			break;

		if (get_timer(start) > 100)
			break;

		/* Turn it off and try again until we time out */
		tps65090_fet_set(fet_id, 0);
	}
	tps65090_deselect();

	if (ret) {
		debug("%s: FET%d failed to power on: time=%lums, loops=%d\n",
	      __func__, fet_id, get_timer(start), loops);
	} else if (loops) {
		debug("%s: FET%d powered on after %lums, loops=%d\n",
		      __func__, fet_id, get_timer(start), loops);
	}
	/*
	 * Unfortunately, there are some conditions where the power
	 * good bit will be 0, but the fet still comes up. One such
	 * case occurs with the lcd backlight. We'll just return 0 here
	 * and assume that the fet will eventually come up.
	 */
	if (ret == FET_ERR_NOT_READY)
		ret = 0;

	return ret;
}
Ejemplo n.º 6
0
int tps65090_fet_is_enabled(unsigned int fet_id)
{
	struct pmic *pmic;
	u32 reg;
	int ret;

	ret = tps65090_check_fet(fet_id);
	if (ret)
		return ret;

	pmic = pmic_get(TPS65090_NAME);
	if (!pmic)
		return -ENODEV;
	ret = pmic_reg_read(pmic, REG_FET1_CTRL + fet_id - 1, &reg);
	if (ret) {
		debug("fail to read FET%u_CTRL register over I2C", fet_id);
		return -EIO;
	}

	return reg & FET_CTRL_ENFET;
}