static int mapphone_panel_read_scl(struct omap_dss_device *dssdev)
{
	int scan_line = 0xffff;
	u8 data[2];

	data[0] = 0x0;
	data[1] = 0x0;

	if (dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 2))
		goto end;

	if (dsi_vc_dcs_read(EDISCO_CMD_VC,
			EDISCO_CMD_READ_SCANLINE, data, 2) == 2)
		scan_line = (data[0] << 8) | data[1];
	else
		printk(KERN_ERR "failed to read scan_line \n");

	dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 1);
end:
	return scan_line;
}
static u16 mapphone_panel_read_supplier_id(void)
{
	static u16 id = SUPPLIER_ID_INVALID;
	u8 data[2];

	if (id != SUPPLIER_ID_INVALID)
		goto end;

	if (dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 2))
		goto end;

	if (dsi_vc_dcs_read(EDISCO_CMD_VC,
			    EDISCO_CMD_READ_DDB_START, data, 2) == 2)
		id = (data[0] << 8) | data[1];

	dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 1);

end:
	DBG("dsi_read_supplier_id() - supplier id [%hu]\n", id);

	return id;
}
Example #3
0
static int s6e8aa0a01_read_block(struct omap_dss_device *dssdev,
				 u8 cmd, u8 *data, int len)
{
	return dsi_vc_dcs_read(dssdev, 1, cmd, data, len);
}
/* - In the LP mode, some panels have problems to receive command correctly
 * so we will send command out and read it back to make sure the write
 * command is accepted
 * - if the dsi_vc_dcs_write() request, then we will not care about the
 * write_dt (data type) */
static int mapphone_panel_lp_cmd_wrt_sync(bool dcs_cmd, int write_dt,
					u8 *write_data, int write_len,
					int read_cmd, int read_len,
					int chk_val, int chk_mask)
{
	int i, ret;
	u8 data[7];

	for (i = 0; i < DCS_CMD_RETRY_MAX; i++) {
		if (dcs_cmd == true) {
			ret = dsi_vc_dcs_write(EDISCO_CMD_VC,
						write_data, write_len);
			DBG("call dsi_vc_dcs_write"
				"(len=0%d, p1/p2/p3/p4=0x%x/0x%x/0x%x/0x%x)\n",
				write_len, write_data[0],
				write_data[1], write_data[2], write_data[3]);
		} else {
			ret = dsi_vc_write(EDISCO_CMD_VC, write_dt,
						write_data, write_len);
			DBG("call dsi_vc_write"
				"(dt=0x%x len=%d, p1/p2/p3/p4 = "
				"0x%x/0x%x/0x%x/0x%x)\n",
				write_dt, write_len, write_data[0],
				write_data[1], write_data[2], write_data[3]);
		}

		if (ret) {
			printk(KERN_ERR "failed to send cmd=0x%x \n",
							 write_data[0]);
			continue;
		}

		mdelay(1);

		/* TODO. Do not know how to handle and to check if more than
		 * 1 byte to read is requested*/
		if (read_len < 0 || read_len > 1) {
			printk(KERN_ERR "Invalid read_len=%d\n", read_len);
			return -1;
		}

		/* Read the data back to make sure write_command is working */
		data[0] = 0;
		ret = dsi_vc_dcs_read(EDISCO_CMD_VC, read_cmd,
						&data[0], read_len);

		DBG("read_chk_cmd dcs_cmd=%d read_cmd=0x%x "
				"read_len=%d chk_val=0x%x chk_mask=0x%x "
				"read_val=0x%x \n",
				dcs_cmd, read_cmd, read_len, chk_val,
				chk_mask, data[0]);

		if (ret < 0)
			DBG("fail to read 0x%x cmd and "
					"will try it again \n", read_cmd);

		if ((data[0] & chk_mask) == chk_val) {
			/* break if read back the same writing value*/
			ret  = 0;
			break;
		}
	}

	if (i >= DCS_CMD_RETRY_MAX) {
		printk(KERN_ERR "failed to read dcs_cmd=%d read_cmd=0x%x "
				"read_len=%d chk_val=0x%x chk_mask=0x%x\n"
				"read_val=0x%x \n",
				dcs_cmd, read_cmd, read_len, chk_val,
				chk_mask, data[0]);
		ret = -1;
	}

	return ret;
}
static int dsi_mipi_310_2_cm_320_480_panel_enable(
					struct omap_dss_device *dssdev)
{
	u8 data[7];
	int ret = 0;

	DBG("dsi_mipi_310_2_cm_320_480_panel_enable \n");

	data[0] = EDISCO_CMD_EXIT_SLEEP_MODE;
	ret = dsi_vc_dcs_write(EDISCO_CMD_VC, data, 1);
	data[0] = 0;

	mdelay(10);

	/* turn off mcs register acces protection */
	data[0] = EDISCO_CMD_SET_MCS;
	data[1] = 0x00;
	ret = dsi_vc_write(EDISCO_CMD_VC, EDISCO_SHORT_WRITE_1, data, 2);

	ret = dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 6);
	if (ret)
		printk(KERN_ERR "failed to set max_rx__packet_size\n");

	memset(data, 0, sizeof(data));

	ret = dsi_vc_dcs_read(EDISCO_CMD_VC, EDISCO_CMD_READ_DDB_START,
					data, 6);
	printk(KERN_INFO "Supplier id return=0x%x%x, "
			"Manufacturer Version=0x%x%x, Revision=0x%x%x\n",
			data[0], data[1], data[2], data[3],
			data[4], data[5]);

	dsi_vc_set_max_rx_packet_size(EDISCO_CMD_VC, 1);

	data[0] = 0x3a;
	if (dssdev->ctrl.pixel_size == 16)
		data[1] = 0x05;
	else if (dssdev->ctrl.pixel_size != 18)
		data[1] = 0x06;
	else {
		printk(KERN_ERR "Invalied format pixel_size =%d\n",
			dssdev->ctrl.pixel_size);
		goto error;
	}

	ret = dsi_vc_dcs_write(EDISCO_CMD_VC, data, 2);

	/* Enable maximum brightness */
	data[0] = 0x51;
	data[1] = 0xff;
	ret = dsi_vc_dcs_write(EDISCO_CMD_VC, data, 2);
	memset(data, 0, sizeof(data));

	/* Enable CABC Output  */
	data[0] = 0x53;
	data[1] = 0x2c;
	ret = dsi_vc_dcs_write(EDISCO_CMD_VC, data, 2);

	printk(KERN_INFO "done EDISCO CTRL ENABLE\n");

	return 0;
error:
	return -EINVAL;
}