From: Deepak M <m.deepak@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Deepak M <m.deepak@intel.com>
Subject: [MIPI SEQ PARSING v2 PATCH 01/11] drm/i915: Adding the parsing logic for the i2c element
Date: Thu, 10 Sep 2015 04:54:20 +0530 [thread overview]
Message-ID: <1441841070-11532-2-git-send-email-m.deepak@intel.com> (raw)
In-Reply-To: <1441841070-11532-1-git-send-email-m.deepak@intel.com>
From: vkorjani <vikas.korjani@intel.com>
New sequence element for i2c is been added in the
mipi sequence block of the VBT. This patch parses
and executes the i2c sequence.
v2: Add i2c_put_adapter call(Jani), rebase
Signed-off-by: vkorjani <vikas.korjani@intel.com>
Signed-off-by: Deepak M <m.deepak@intel.com>
---
drivers/gpu/drm/i915/intel_bios.c | 6 +++
drivers/gpu/drm/i915/intel_bios.h | 1 +
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 61 ++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index c8acc29..0bf0942 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -714,6 +714,12 @@ static u8 *goto_next_sequence(u8 *data, int *size)
data += 3;
break;
+ case MIPI_SEQ_ELEM_I2C:
+ /* skip by this element payload size */
+ data += 7;
+ len = *data;
+ data += len + 1;
+ break;
default:
DRM_ERROR("Unknown element\n");
return NULL;
diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
index 1b7417e..21a7f3f 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -956,6 +956,7 @@ enum mipi_seq_element {
MIPI_SEQ_ELEM_SEND_PKT,
MIPI_SEQ_ELEM_DELAY,
MIPI_SEQ_ELEM_GPIO,
+ MIPI_SEQ_ELEM_I2C,
MIPI_SEQ_ELEM_STATUS,
MIPI_SEQ_ELEM_MAX
};
diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
index a5e99ac..9989f61 100644
--- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
+++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
@@ -31,6 +31,7 @@
#include <drm/drm_panel.h>
#include <linux/slab.h>
#include <video/mipi_display.h>
+#include <linux/i2c.h>
#include <asm/intel-mid.h>
#include <video/mipi_display.h>
#include "i915_drv.h"
@@ -104,6 +105,65 @@ static struct gpio_table gtable[] = {
{ GPIO_NC_11_PCONF0, GPIO_NC_11_PAD, 0}
};
+static const u8 *mipi_exec_i2c(struct intel_dsi *intel_dsi, const u8 *data)
+{
+ struct i2c_adapter *adapter;
+ int ret;
+ u8 reg_offset, payload_size, retries = 5;
+ struct i2c_msg msg;
+ u8 *transmit_buffer = NULL;
+ u8 flag = *data++;
+ u8 index = *data++;
+ u8 bus_number = *data++;
+ u16 slave_add = *(u16 *)(data);
+
+ data = data + 2;
+ reg_offset = *data++;
+ payload_size = *data++;
+
+ adapter = i2c_get_adapter(bus_number);
+
+ if (!adapter) {
+ DRM_ERROR("i2c_get_adapter(%u) failed, index:%u flag: %u\n",
+ (bus_number + 1), index, flag);
+ goto out;
+ }
+
+ transmit_buffer = kmalloc(1 + payload_size, GFP_TEMPORARY);
+
+ if (!transmit_buffer)
+ goto out;
+
+ transmit_buffer[0] = reg_offset;
+ memcpy(&transmit_buffer[1], data, (size_t)payload_size);
+
+ msg.addr = slave_add;
+ msg.flags = 0;
+ msg.len = payload_size + 1;
+ msg.buf = &transmit_buffer[0];
+
+ do {
+ ret = i2c_transfer(adapter, &msg, 1);
+ if (ret == 1)
+ break;
+ else if (ret == -EAGAIN)
+ usleep_range(1000, 2500);
+ else {
+ DRM_ERROR("i2c transfer failed, error code:%d", ret);
+ break;
+ }
+ } while (retries--);
+
+ if (retries == 0)
+ DRM_ERROR("i2c transfer failed, error code:%d", ret);
+out:
+ kfree(transmit_buffer);
+ i2c_put_adapter(adapter);
+
+ data = data + payload_size;
+ return data;
+}
+
static inline enum port intel_dsi_seq_port_to_port(u8 port)
{
return port ? PORT_C : PORT_A;
@@ -236,6 +296,7 @@ static const fn_mipi_elem_exec exec_elem[] = {
mipi_exec_send_packet,
mipi_exec_delay,
mipi_exec_gpio,
+ mipi_exec_i2c,
NULL, /* status read; later */
};
--
1.7.9.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-09-09 23:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-09 23:24 [MIPI SEQ PARSING v2 PATCH 00/11] Patches to support the version 3 of MIPI sequence in VBT Deepak M
2015-09-09 23:24 ` Deepak M [this message]
2015-09-17 9:18 ` [MIPI SEQ PARSING v2 PATCH 01/11] drm/i915: Adding the parsing logic for the i2c element Jani Nikula
2015-09-22 6:46 ` Deepak, M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 02/11] drm/i915: Updating asle structure with new fields Deepak M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 03/11] drm/i915: Parsing VBT if size of VBT exceeds 6KB Deepak M
2015-09-16 13:24 ` Jani Nikula
2015-09-17 12:10 ` Jani Nikula
2015-09-22 6:37 ` Deepak, M
2015-09-22 7:24 ` Jani Nikula
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 04/11] drm/i915: Using the approprite vbt size if vbt is not in mailbox4 of opregion Deepak M
2015-09-17 12:18 ` Jani Nikula
2015-09-17 13:31 ` Jani Nikula
2015-09-22 6:11 ` Deepak, M
2015-09-22 6:24 ` Deepak, M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 05/11] drm/i915: Added support the v3 mipi sequence block Deepak M
2015-09-17 14:38 ` Jani Nikula
2015-09-22 6:23 ` Deepak, M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 06/11] drm/i915: extending gpio read/write to other cores Deepak M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 07/11] drm/i915: Added the generic gpio sequence support and gpio table Deepak M
2015-09-17 14:44 ` Jani Nikula
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 08/11] drm/i915: GPIO for CHT generic MIPI Deepak M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 09/11] drm: Add few more wrapper functions for drm panel Deepak M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 10/11] drm/i915: Add functions to execute the new sequences from VBT Deepak M
2015-09-09 23:24 ` [MIPI SEQ PARSING v2 PATCH 11/11] drm/i915: BXT GPIO support for backlight and panel control Deepak M
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441841070-11532-2-git-send-email-m.deepak@intel.com \
--to=m.deepak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.