msm_fb: MHL: Adding MHL api's for USB interaction.
Adding MHL api's for device discovery and registering
callback mechanism.USB driver use these API's for
synchronization with MHL driver.
Change-Id: I0846951302e3b5f5d20d566c92c2f224528ca455
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
Signed-off-by: Abhishek Kharbanda <akharban@codeaurora.org>
diff --git a/include/linux/mhl_8334.h b/include/linux/mhl_8334.h
new file mode 100644
index 0000000..1b19103
--- /dev/null
+++ b/include/linux/mhl_8334.h
@@ -0,0 +1,106 @@
+/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MHL_MSM_H__
+#define __MHL_MSM_H__
+
+#include <linux/types.h>
+#include <linux/platform_device.h>
+#include <mach/board.h>
+#include <linux/mhl_devcap.h>
+#include <linux/mhl_defs.h>
+
+#define MHL_DEVICE_NAME "sii8334"
+#define MHL_DRIVER_NAME "sii8334"
+
+#define HPD_UP 1
+#define HPD_DOWN 0
+
+enum discovery_result_enum {
+ MHL_DISCOVERY_RESULT_USB = 0,
+ MHL_DISCOVERY_RESULT_MHL,
+};
+
+/* USB driver interface */
+
+#ifdef CONFIG_FB_MSM_HDMI_MHL_8334
+ /* mhl_device_discovery */
+extern int mhl_device_discovery(const char *name, int *result);
+
+/* - register|unregister MHL cable plug callback. */
+extern int mhl_register_callback
+ (const char *name, void (*callback)(int online));
+extern int mhl_unregister_callback(const char *name);
+#else
+static inline int mhl_device_discovery(const char *name, int *result)
+{
+ return -ENODEV;
+}
+
+static inline int
+ mhl_register_callback(const char *name, void (*callback)(int online))
+{
+ return -ENODEV;
+}
+
+static inline int mhl_unregister_callback(const char *name)
+{
+ return -ENODEV;
+}
+#endif
+
+struct mhl_msm_state_t {
+ struct i2c_client *i2c_client;
+ struct i2c_driver *i2c_driver;
+ uint8_t cur_state;
+ uint8_t chip_rev_id;
+ struct msm_mhl_platform_data *mhl_data;
+ /* Device Discovery stuff */
+ int mhl_mode;
+ struct completion rgnd_done;
+};
+
+enum {
+ TX_PAGE_TPI = 0x00,
+ TX_PAGE_L0 = 0x01,
+ TX_PAGE_L1 = 0x02,
+ TX_PAGE_2 = 0x03,
+ TX_PAGE_3 = 0x04,
+ TX_PAGE_CBUS = 0x05,
+ TX_PAGE_DDC_EDID = 0x06,
+ TX_PAGE_DDC_SEGM = 0x07,
+};
+
+enum mhl_st_type {
+ POWER_STATE_D0_NO_MHL = 0,
+ POWER_STATE_D0_MHL = 2,
+ POWER_STATE_D3 = 3,
+};
+
+enum {
+ DEV_PAGE_TPI_0 = (0x72),
+ DEV_PAGE_TX_L0_0 = (0x72),
+ DEV_PAGE_TPI_1 = (0x76),
+ DEV_PAGE_TX_L0_1 = (0x76),
+ DEV_PAGE_TX_L1_0 = (0x7A),
+ DEV_PAGE_TX_L1_1 = (0x7E),
+ DEV_PAGE_TX_2_0 = (0x92),
+ DEV_PAGE_TX_2_1 = (0x96),
+ DEV_PAGE_TX_3_0 = (0x9A),
+ DEV_PAGE_TX_3_1 = (0x9E),
+ DEV_PAGE_CBUS = (0xC8),
+ DEV_PAGE_DDC_EDID = (0xA0),
+ DEV_PAGE_DDC_SEGM = (0x60),
+};
+
+#endif /* __MHL_MSM_H__ */
diff --git a/include/linux/mhl_defs.h b/include/linux/mhl_defs.h
new file mode 100644
index 0000000..094874e
--- /dev/null
+++ b/include/linux/mhl_defs.h
@@ -0,0 +1,222 @@
+/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef __MHL_SPEC_DEFS_H__
+#define __MHL_SPEC_DEFS_H__
+
+enum DevCapOffset_e {
+ DEVCAP_OFFSET_DEV_STATE = 0x00,
+ DEVCAP_OFFSET_MHL_VERSION = 0x01,
+ DEVCAP_OFFSET_DEV_CAT = 0x02,
+ DEVCAP_OFFSET_ADOPTER_ID_H = 0x03,
+ DEVCAP_OFFSET_ADOPTER_ID_L = 0x04,
+ DEVCAP_OFFSET_VID_LINK_MODE = 0x05,
+ DEVCAP_OFFSET_AUD_LINK_MODE = 0x06,
+ DEVCAP_OFFSET_VIDEO_TYPE = 0x07,
+ DEVCAP_OFFSET_LOG_DEV_MAP = 0x08,
+ DEVCAP_OFFSET_BANDWIDTH = 0x09,
+ DEVCAP_OFFSET_FEATURE_FLAG = 0x0A,
+ DEVCAP_OFFSET_DEVICE_ID_H = 0x0B,
+ DEVCAP_OFFSET_DEVICE_ID_L = 0x0C,
+ DEVCAP_OFFSET_SCRATCHPAD_SIZE = 0x0D,
+ DEVCAP_OFFSET_INT_STAT_SIZE = 0x0E,
+ DEVCAP_OFFSET_RESERVED = 0x0F,
+ /* this one must be last */
+ DEVCAP_SIZE
+};
+
+#ifndef __MHL_MSM_8334_REGS_H__
+#define __MHL_MSM_8334_REGS_H__
+
+#define BIT0 0x01
+#define BIT1 0x02
+#define BIT2 0x04
+#define BIT3 0x08
+#define BIT4 0x10
+#define BIT5 0x20
+#define BIT6 0x40
+#define BIT7 0x80
+
+#define LOW 0
+#define HIGH 1
+
+#define MAX_PAGES 8
+#endif
+
+
+/* Version that this chip supports*/
+/* bits 4..7 */
+#define MHL_VER_MAJOR (0x01 << 4)
+/* bits 0..3 */
+#define MHL_VER_MINOR 0x01
+#define MHL_VERSION (MHL_VER_MAJOR | MHL_VER_MINOR)
+
+/*Device Category*/
+#define MHL_DEV_CATEGORY_OFFSET DEVCAP_OFFSET_DEV_CAT
+#define MHL_DEV_CATEGORY_POW_BIT (BIT4)
+
+#define MHL_DEV_CAT_SOURCE 0x02
+
+/*Video Link Mode*/
+#define MHL_DEV_VID_LINK_SUPPRGB444 0x01
+#define MHL_DEV_VID_LINK_SUPPYCBCR444 0x02
+#define MHL_DEV_VID_LINK_SUPPYCBCR422 0x04
+#define MHL_DEV_VID_LINK_SUPP_PPIXEL 0x08
+#define MHL_DEV_VID_LINK_SUPP_ISLANDS 0x10
+
+/*Audio Link Mode Support*/
+#define MHL_DEV_AUD_LINK_2CH 0x01
+#define MHL_DEV_AUD_LINK_8CH 0x02
+
+
+/*Feature Flag in the devcap*/
+#define MHL_DEV_FEATURE_FLAG_OFFSET DEVCAP_OFFSET_FEATURE_FLAG
+/* Dongles have freedom to not support RCP */
+#define MHL_FEATURE_RCP_SUPPORT BIT0
+/* Dongles have freedom to not support RAP */
+#define MHL_FEATURE_RAP_SUPPORT BIT1
+/* Dongles have freedom to not support SCRATCHPAD */
+#define MHL_FEATURE_SP_SUPPORT BIT2
+
+/*Logical Dev Map*/
+#define MHL_DEV_LD_DISPLAY (0x01 << 0)
+#define MHL_DEV_LD_VIDEO (0x01 << 1)
+#define MHL_DEV_LD_AUDIO (0x01 << 2)
+#define MHL_DEV_LD_MEDIA (0x01 << 3)
+#define MHL_DEV_LD_TUNER (0x01 << 4)
+#define MHL_DEV_LD_RECORD (0x01 << 5)
+#define MHL_DEV_LD_SPEAKER (0x01 << 6)
+#define MHL_DEV_LD_GUI (0x01 << 7)
+
+/*Bandwidth*/
+/* 225 MHz */
+#define MHL_BANDWIDTH_LIMIT 22
+
+
+#define MHL_STATUS_REG_CONNECTED_RDY 0x30
+#define MHL_STATUS_REG_LINK_MODE 0x31
+
+#define MHL_STATUS_DCAP_RDY BIT0
+
+#define MHL_STATUS_CLK_MODE_MASK 0x07
+#define MHL_STATUS_CLK_MODE_PACKED_PIXEL 0x02
+#define MHL_STATUS_CLK_MODE_NORMAL 0x03
+#define MHL_STATUS_PATH_EN_MASK 0x08
+#define MHL_STATUS_PATH_ENABLED 0x08
+#define MHL_STATUS_PATH_DISABLED 0x00
+#define MHL_STATUS_MUTED_MASK 0x10
+
+#define MHL_RCHANGE_INT 0x20
+#define MHL_DCHANGE_INT 0x21
+
+#define MHL_INT_DCAP_CHG BIT0
+#define MHL_INT_DSCR_CHG BIT1
+#define MHL_INT_REQ_WRT BIT2
+#define MHL_INT_GRT_WRT BIT3
+
+/* On INTR_1 the EDID_CHG is located at BIT 0*/
+#define MHL_INT_EDID_CHG BIT1
+
+/* This contains one nibble each - max offset */
+#define MHL_INT_AND_STATUS_SIZE 0x33
+#define MHL_SCRATCHPAD_SIZE 16
+/* manually define highest number */
+#define MHL_MAX_BUFFER_SIZE MHL_SCRATCHPAD_SIZE
+
+
+
+enum {
+ /* RCP sub-command */
+ MHL_MSC_MSG_RCP = 0x10,
+ /* RCP Acknowledge sub-command */
+ MHL_MSC_MSG_RCPK = 0x11,
+ /* RCP Error sub-command */
+ MHL_MSC_MSG_RCPE = 0x12,
+ /* Mode Change Warning sub-command */
+ MHL_MSC_MSG_RAP = 0x20,
+ /* MCW Acknowledge sub-command */
+ MHL_MSC_MSG_RAPK = 0x21,
+};
+
+#define RCPE_NO_ERROR 0x00
+#define RCPE_INEEFECTIVE_KEY_CODE 0x01
+#define RCPE_BUSY 0x02
+/* MHL spec related defines*/
+enum {
+ /* Command or Data byte acknowledge */
+ MHL_ACK = 0x33,
+ /* Command or Data byte not acknowledge */
+ MHL_NACK = 0x34,
+ /* Transaction abort */
+ MHL_ABORT = 0x35,
+ /* 0xE0 - Write one status register strip top bit */
+ MHL_WRITE_STAT = 0x60 | 0x80,
+ /* Write one interrupt register */
+ MHL_SET_INT = 0x60,
+ /* Read one register */
+ MHL_READ_DEVCAP = 0x61,
+ /* Read CBUS revision level from follower */
+ MHL_GET_STATE = 0x62,
+ /* Read vendor ID value from follower. */
+ MHL_GET_VENDOR_ID = 0x63,
+ /* Set Hot Plug Detect in follower */
+ MHL_SET_HPD = 0x64,
+ /* Clear Hot Plug Detect in follower */
+ MHL_CLR_HPD = 0x65,
+ /* Set Capture ID for downstream device. */
+ MHL_SET_CAP_ID = 0x66,
+ /* Get Capture ID from downstream device. */
+ MHL_GET_CAP_ID = 0x67,
+ /* VS command to send RCP sub-commands */
+ MHL_MSC_MSG = 0x68,
+ /* Get Vendor-Specific command error code. */
+ MHL_GET_SC1_ERRORCODE = 0x69,
+ /* Get DDC channel command error code. */
+ MHL_GET_DDC_ERRORCODE = 0x6A,
+ /* Get MSC command error code. */
+ MHL_GET_MSC_ERRORCODE = 0x6B,
+ /* Write 1-16 bytes to responder's scratchpad. */
+ MHL_WRITE_BURST = 0x6C,
+ /* Get channel 3 command error code. */
+ MHL_GET_SC3_ERRORCODE = 0x6D,
+};
+
+/* Turn content streaming ON. */
+#define MHL_RAP_CONTENT_ON 0x10
+/* Turn content streaming OFF. */
+#define MHL_RAP_CONTENT_OFF 0x11
+
+/*
+ *
+ * MHL Timings applicable to this driver.
+ *
+ */
+/* 100 - 1000 milliseconds. Per MHL 1.0 Specs */
+#define T_SRC_VBUS_CBUS_TO_STABLE (200)
+/* 20 milliseconds. Per MHL 1.0 Specs */
+#define T_SRC_WAKE_PULSE_WIDTH_1 (20)
+/* 60 milliseconds. Per MHL 1.0 Specs */
+#define T_SRC_WAKE_PULSE_WIDTH_2 (60)
+
+/* 100 - 1000 milliseconds. Per MHL 1.0 Specs */
+#define T_SRC_WAKE_TO_DISCOVER (500)
+
+#define T_SRC_VBUS_CBUS_T0_STABLE (500)
+
+/* Allow RSEN to stay low this much before reacting.*/
+#define T_SRC_RSEN_DEGLITCH (100)
+
+/* Wait this much after connection before reacting to RSEN (300-500ms)*/
+/* Per specs between 300 to 500 ms*/
+#define T_SRC_RXSENSE_CHK (400)
+
+#endif /* __MHL_SPEC_DEFS_H__ */
diff --git a/include/linux/mhl_devcap.h b/include/linux/mhl_devcap.h
new file mode 100644
index 0000000..6d01daf
--- /dev/null
+++ b/include/linux/mhl_devcap.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef __MHL_DEVCAP_H__
+#define __MHL_DEVCAP_H__
+
+#define SILICON_IMAGE_ADOPTER_ID 322
+#define TRANSCODER_DEVICE_ID 0x8334
+
+#define MHL_DEV_LD_AUDIO (0x01 << 2)
+#define MHL_DEV_LD_VIDEO (0x01 << 1)
+#define MHL_DEV_LD_MEDIA (0x01 << 3)
+#define MHL_DEV_LD_GUI (0x01 << 7)
+#define MHL_LOGICAL_DEVICE_MAP (MHL_DEV_LD_AUDIO |\
+ MHL_DEV_LD_VIDEO | MHL_DEV_LD_MEDIA | MHL_DEV_LD_GUI)
+
+#define DEVCAP_VAL_DEV_STATE 0
+#define DEVCAP_VAL_MHL_VERSION MHL_VERSION
+#define DEVCAP_VAL_DEV_CAT (MHL_DEV_CAT_SOURCE |\
+ MHL_DEV_CATEGORY_POW_BIT)
+#define DEVCAP_VAL_ADOPTER_ID_H (uint8_t)(SILICON_IMAGE_ADOPTER_ID >> 8)
+#define DEVCAP_VAL_ADOPTER_ID_L (uint8_t)(SILICON_IMAGE_ADOPTER_ID & 0xFF)
+#define DEVCAP_VAL_VID_LINK_MODE MHL_DEV_VID_LINK_SUPPRGB444
+#define DEVCAP_VAL_AUD_LINK_MODE MHL_DEV_AUD_LINK_2CH
+#define DEVCAP_VAL_VIDEO_TYPE 0
+#define DEVCAP_VAL_LOG_DEV_MAP MHL_LOGICAL_DEVICE_MAP
+#define DEVCAP_VAL_BANDWIDTH 0
+#define DEVCAP_VAL_FEATURE_FLAG (MHL_FEATURE_RCP_SUPPORT |\
+ MHL_FEATURE_RAP_SUPPORT | MHL_FEATURE_SP_SUPPORT)
+#define DEVCAP_VAL_DEVICE_ID_H (uint8_t)(TRANSCODER_DEVICE_ID >> 8)
+#define DEVCAP_VAL_DEVICE_ID_L (uint8_t)(TRANSCODER_DEVICE_ID & 0xFF)
+#define DEVCAP_VAL_SCRATCHPAD_SIZE MHL_SCRATCHPAD_SIZE
+#define DEVCAP_VAL_INT_STAT_SIZE MHL_INT_AND_STATUS_SIZE
+#define DEVCAP_VAL_RESERVED 0
+
+#endif /* __MHL_DEVCAP_H__ */