Exemplo n.º 1
0
/*
 * Enable all the modules and clocks.
 */
static int
enable_hdmi_module(void)
{
	int r;

	r = i2creg_write8(cec_bus_endpoint, cec_address, CEC_ENABLE_REG,
	    CEC_ENABLE_ALL_MASK);
	if (r != OK) {
		log_warn(&log, "Writing enable bits failed (r=%d)\n", r);
		return -1;
	}

	log_debug(&log, "HDMI module enabled\n");

	return OK;
}
Exemplo n.º 2
0
static int
set_page(uint8_t page)
{
	int r;
	static int current_page = HDMI_PAGELESS;

	if (page != current_page) {

		r = i2creg_write8(hdmi_bus_endpoint, hdmi_address,
		    HDMI_PAGE_SELECT_REG, page);
		if (r != OK) {
			return r;
		}

		current_page = page;
	}

	return OK;
}
Exemplo n.º 3
0
static int
hdmi_write(uint8_t page, uint8_t reg, uint8_t val)
{
	int r;

	if (page != HDMI_PAGELESS) {
		r = set_page(page);
		if (r != OK) {
			log_warn(&log, "Unable to set page to 0x%x\n", page);
			return r;
		}
	}

	r = i2creg_write8(hdmi_bus_endpoint, hdmi_address, reg, val);
	if (r != OK) {
		log_warn(&log, "hdmi_write() failed (r=%d)\n", r);
		return -1;
	}

	log_trace(&log, "Successfully wrote 0x%x to reg 0x%x in page 0x%x\n",
	    val, reg, page);

	return OK;
}
Exemplo n.º 4
0
static int
check_revision(void)
{
	int r;
	uint32_t idcode;
	uint8_t idcode_7_0, idcode_15_8, idcode_23_16, idcode_31_24;

	/* need to write a special code to unlock read protect on IDCODE */
	r = i2creg_write8(bus_endpoint, addresses[ID2], UNLOCK_TEST_REG,
	    UNLOCK_TEST_CODE);
	if (r != OK) {
		log_warn(&log, "Failed to write unlock code to UNLOCK_TEST\n");
		return -1;
	}

	/*
	 * read each part of the IDCODE
	 */
	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_7_0_REG,
	    &idcode_7_0);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 1\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_15_8_REG,
	    &idcode_15_8);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 2\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_23_16_REG,
	    &idcode_23_16);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 3\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_31_24_REG,
	    &idcode_31_24);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 4\n");
	}

	/* combine the parts to get the full IDCODE */
	idcode =
	    ((idcode_31_24 << 24) | (idcode_23_16 << 16) | (idcode_15_8 << 8) |
	    (idcode_7_0 << 0));

	log_debug(&log, "IDCODE = 0x%x\n", idcode);
	switch (idcode) {
	case IDCODE_REV_1_0:
		log_debug(&log, "TPS65950 rev 1.0\n");
		break;
	case IDCODE_REV_1_1:
		log_debug(&log, "TPS65950 rev 1.1\n");
		break;
	case IDCODE_REV_1_2:
		log_debug(&log, "TPS65950 rev 1.2\n");
		break;
	default:
		log_warn(&log, "Unexpected IDCODE: 0x%x\n", idcode);
		return -1;
	}

	return OK;
}