Beispiel #1
0
/* Send a word over the powerbus */
static int twl4030_send_pb_msg(unsigned msg)
{
	u8	val;
	int	ret;

	/* save powerbus configuration */
	ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
			      TWL4030_PM_MASTER_PB_CFG);
	if (ret < 0)
		return ret;

	/* Enable i2c access to powerbus */
	ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val | PB_I2C_BWEN,
			       TWL4030_PM_MASTER_PB_CFG);
	if (ret < 0)
		return ret;

	ret = twl4030_wait_pb_ready();
	if (ret < 0)
		return ret;

	ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, msg >> 8,
			       TWL4030_PM_MASTER_PB_WORD_MSB);
	if (ret < 0)
		return ret;

	ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, msg & 0xff,
			       TWL4030_PM_MASTER_PB_WORD_LSB);
	if (ret < 0)
		return ret;

	ret = twl4030_wait_pb_ready();
	if (ret < 0)
		return ret;

	/* Restore powerbus configuration */
	return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val,
				TWL4030_PM_MASTER_PB_CFG);
}
Beispiel #2
0
static int twl4030_send_pb_msg(unsigned msg)
{

	u8 pb_state;
	int status;

	/* save powerbus configuration */
	status = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER,
					&pb_state, 0x14);
	if (status < 0)
		return status;

	/* Enable I2C access to powerbus */
	status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
					pb_state | (1<<1), 0x14);
	if (status < 0)
		return status;

	status = twl4030_wait_pb_ready();
	if (status < 0)
		return status;

	status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, msg >> 8,
			0x15 /* PB_WORD_MSB */);
	if (status < 0)
		return status;

	status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, msg & 0xff,
			0x16 /* PB_WORD_LSB */);
	if (status < 0)
		return status;

	status = twl4030_wait_pb_ready();
	if (status < 0)
		return status;

	/* Restore powerbus configuration */
	return twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, pb_state, 0x14);
}