[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/cp/ps/driver/inc/misc/drvs_i2c.h b/cp/ps/driver/inc/misc/drvs_i2c.h
new file mode 100644
index 0000000..8a70f1e
--- /dev/null
+++ b/cp/ps/driver/inc/misc/drvs_i2c.h
@@ -0,0 +1,283 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       V0.5

+ * Author:        Zhenghong

+ * Date:          2008-01-10

+ * History 1:

+ *     Date:      2012-07-16

+ *     Version:   V1.0

+ *     Author:    zhouqi

+ *     Modification:    1. Ôö¼Ó T_ZDrvI2c_BusFreq ö¾ÙÖÐ 300KHZ ¶¨Òå

+                        2. ÐÞ¸Ä T_ZDrvI2c_DevFlagType ÖеÚÒ»¸ö I2C_DFLT_ADDR_DEV Ϊ I2C_10BIT_SLAVE_ADDR

+                        3. ÔÚ T_ZDrvI2c_DevFlagType  Ôö¼Ó I2C_USE_INT ¶¨Òå

+                        4. Ôö¼Ó²¿·Ö×¢ÊÍÓë˵Ã÷

+ * History 2:

+ ******************************************************************************/

+#ifndef _DRVS_I2C_H

+#define _DRVS_I2C_H

+

+

+

+/**********************************************************/

+/** @defgroup T_ZDrvI2c_BusNum 7520ÓÐ 3 ¸öI2C½Ó¿Ú, 7520V2 È¥µôÒ»¸öI2C

+  */

+typedef enum

+{

+    //I2C_BUS_0 = 0,

+    I2C_BUS_1 = 1,

+    I2C_BUS_2 = 2,      /* pmic i2c */

+    MAX_I2C_BUS_NUM

+}T_ZDrvI2c_BusNum;

+

+

+/**********************************************************/

+/** @defgroup T_ZDrvI2c_BusFreq

+  */

+typedef enum{

+    I2C_FREQ_ONE_HUNDRED_KILO_HZ    = 100*1000,

+    I2C_FREQ_THREE_HUNDRED_KILO_HZ  = 300*1000,

+    I2C_FREQ_FOUR_HUNDRED_KILO_HZ   = 400*1000,

+    MAX_I2C_BUS_FREQ

+}T_ZDrvI2c_BusFreq;

+

+

+/**********************************************************/

+/** @defgroup T_ZDrvI2c_DevFlagType

+  */

+typedef enum {

+        I2C_10BIT_SLAVE_ADDR       = 0x0001 << 0,   /* ±êʶʹÓà --10λ´Ó»úµØÖ·--      */

+                                                    /* ĬÈϲ»Ê¹ÓÃλ 7λ´Ó»úµØÖ·       */

+

+        I2C_MEM_DEV                = 0x0001 << 1,   /*  ±êʶʹÓà --16λ¼Ä´æÆ÷µØÖ·--   */

+        I2C_REG_DEV                = 0x0001 << 2,   /*  ±êʶʹÓà --8λ¼Ä´æÆ÷µØÖ·--    */

+

+        I2C_NACK_LAST_BYTE         = 0x0001 << 3,   /* NACK last byte read from slave   */

+        I2C_NOP_LAST_BYTE          = 0x0001 << 4,   /* Let slave release SDA after last */

+        I2C_M_COMBINE              = 0x0001 << 5,   /* ¾­µäµÄ×éºÏ¶Áģʽ */

+        I2C_STOP_START_BEFORE_READ = 0x0001 << 6,   /* During a read transaction, gen.  */

+                                                    /* a STOP & START after writing     */

+                                                    /* the slave addr(just before read) */

+        I2C_CLK_START_BEFORE_RW    = 0x0001 << 7,   /* Generate a clock and a START     */

+                                                    /* before every I/O operation.      */

+        I2C_USE_INT                = 0x0001 << 8    /* ʹÓÃÖжÏģʽ´«ÊäÊý¾Ý            */

+                                                    /* Çø±ðΪ START ºó£¬»ñÈ¡ÐźÅÁ¿£¬Ïß³Ì¹ÒÆð*/

+                                                    /* ½¨ÒéÔÚ´«ËͶà×Ö½ÚʱʹÓà           */

+} T_ZDrvI2c_DevFlagType;

+

+/**********************************************************************/

+/*  ˵Ã÷:

+

+    1. ÔÚĬÈÏÇé¿öÏ£¬Ê¹Óà  7λ ´Ó»úµØÖ·£¬

+                           8λ ¼Ä´æÆ÷µØÖ·

+                           ±ê׼ʱÐòµÄ ¼òµ¥Ð´¡¢ ¼òµ¥¶Á¡¢ ×éºÏ¶Áģʽ--

+                           ²»Ê¹ÓÃÖжÏ

+

+    2. ÒÔǰÅäÖÃµÄ  ÒÔϲÎÊýÏÖÔÚ²»ÔÙʹÓã¬ÏÈǰÅäÖõÄÒ²²»Óøü¸Ä£¬µ«¶¼Ä¬ÈÏΪ --±ê×¼×éºÏ¶ÁʱÐò--

+       Èç¹ûÓÐÌØÊâʱÐò£¬Çë¸æÖª

+

+                           I2C_NACK_LAST_BYTE           ÔÚU207ûÓз¢ÏÖʹÓÃ

+                           I2C_NOP_LAST_BYTE            ÔÚU207ûÓз¢ÏÖʹÓÃ

+                           I2C_M_COMBINE                RDA5802\mt9d113ʹÓÃ

+                           I2C_STOP_START_BEFORE_READ   PMIC\OV7670\0V9656ʹÓÃ

+                           I2C_CLK_START_BEFORE_RW      ÔÚU207ûÓз¢ÏÖʹÓÃ

+

+    3. ÏÖÔڿɸù¾ÝÒ»ÏÂÁÐ×ÓÅäÖÃ:

+

+        static T_ZDrvI2c_Device s_mt9d113I2cDev =

+        {

+            I2C_BUS_0,

+            EXAMPLE_SLAVE_ADDRESS,

+            I2C_FREQ_THREE_HUNDRED_KILO_HZ,

+            100,

+            1,

+     -----------------------------------------------------------

+            I2C_10BIT_SLAVE_ADDR | I2C_REG_DEV | I2C_USE_INT,

+          //  ʹÓÃ10´Ó»úµØÖ·       8λ¼Ä´æÆ÷µØÖ·  ʹÓÃÖжϷ½Ê½

+

+            I2C_MEM_DEV,

+          // 16λ¼Ä´æÆ÷µØÖ·, 8´Ó»úµØÖ· ²»Ê¹ÓÃÖжÏ

+        ----------------------------------------------------------

+            NULL,

+        };

+*********************************************************************/

+/**********************************************************/

+/** @defgroup T_ZDrvI2c_Device

+  */

+typedef struct _T_ZDrvI2c_Device

+{

+

+    T_ZDrvI2c_BusNum        bus_num;        /* indicate which i2c bus the device belongs to */

+    UINT16                  slv_addr;       /* device addr on the i2c bus, 10bits for memory device and 7bits for registers */

+    T_ZDrvI2c_BusFreq       bus_freq;       /* the i2c bus transfer freq according to the device require*/

+    UINT32                  timeout;        /* time threshold waiting for bus idle */

+    UINT8                   retries;        /* times we'll try again if the bus is busy */

+    T_ZDrvI2c_DevFlagType   flags;          /* indicate the operation features */

+

+    VOID                    *privData;

+}T_ZDrvI2c_Device;

+

+

+/*******************************************************************************

+*                           Function Prototypes                                *

+*******************************************************************************/

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevRead

+ * Description: I2C×ÜÏß¼òµ¥¶Á

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ×éºÏ¶Á ±êÏßЭÒé¡£

+            2. ×î´óÒ»´Î¶ÁÈ¡ --32-- ¸ö×Ö½ÚÊý¾Ý¡£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevRead( T_ZDrvI2c_Device *i2c_dev, UINT16 regAddr, UINT8 *readBuf, UINT32 readNum );

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevWrite

+ * Description: I2C×ÜÏß¼òµ¥Ð´

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ¼òµ¥Ð´ ±êÏßЭÒé¡£

+            2. ×î´óÒ»´ÎдÈë --30-- ¸ö×Ö½ÚÊý¾Ý¡£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevWrite( T_ZDrvI2c_Device *i2c_dev, UINT16 regAddr, UINT8 *writeBuf, UINT32 writeNum );

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevLock_BeforePSM

+ * Description: ÔÚ¹ØÖжϲ¢µ÷Óà PSM ½Ó¿Úǰ£¬»ñÈ¡ I2C Éè±¸Ëø¡£

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ¹ØÖжϲ¢µ÷Óà PSM ½Ó¿Úʱ£¬I2C ¿ÉÄÜÕýÔÚ±»ÆäËûÏß³ÌʹÓá£

+ * 			   ʹÓô˽ӿڵȴýÆäËûÏß³ÌʹÓÃÍê±ÏºóÍ˳ö¡£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevLock_BeforePSM( T_ZDrvI2c_BusNum busNum);

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevUnlock_AfterPSM

+ * Description: ²»ÔÙʹÓà PSM ½Ó¿Úʱ£¬ÊÍ·Å I2C Éè±¸Ëø¡£

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ÓëzDrvI2c_DevLock_BeforePSM½á¶ÔʹÓá£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevUnlock_AfterPSM( T_ZDrvI2c_BusNum busNum);

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevRead

+ * Description: I2C×ÜÏß¼òµ¥¶Á£¬Ê¹ÓÃÊ¡µçģʽ

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ×éºÏ¶Á ±êÏßЭÒé¡£

+            2. ×î´óÒ»´Î¶ÁÈ¡ --32-- ¸ö×Ö½ÚÊý¾Ý¡£

+            3. Ö÷ÒªÊÇÔÚ²Ù×÷ÖÐ --²»»ñÈ¡»¥³âÁ¿--£¬ Á½µÄÏ̲߳»ÄÜͬʱµ÷ÓÃ

+ ********************************************************************************/

+SINT32 zDrvI2c_DevRead_PSM( T_ZDrvI2c_Device *i2c_dev, UINT16 regAddr, UINT8 *readBuf, UINT32 readNum );

+

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevWrite

+ * Description: I2C×ÜÏß¼òµ¥Ð´£¬Ê¹ÓÃÊ¡µçģʽ

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ¼òµ¥Ð´ ±êÏßЭÒé¡£

+            2. ×î´óÒ»´ÎдÈë --30-- ¸ö×Ö½ÚÊý¾Ý¡£

+            3. Ö÷ÒªÊÇÔÚ²Ù×÷ÖÐ --²»»ñÈ¡»¥³âÁ¿--£¬ Á½µÄÏ̲߳»ÄÜͬʱµ÷ÓÃ

+ ********************************************************************************/

+SINT32 zDrvI2c_DevWrite_PSM( T_ZDrvI2c_Device *i2c_dev, UINT16 regAddr, UINT8 *writeBuf, UINT32 writeNum );

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevRead_ByteStream

+ * Description: I2C×ÜÏß×Ö½ÚÁ÷¶Á

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ¼òµ¥¶Á ±êÏßЭÒé¡£

+            2. ֻд I2C Æ÷¼þµØÖ·£¬----------²»Ê¹ÓüĴæÆ÷µØÖ·-----¡£

+            2. ×î´óÒ»´Î¶ÁÈ¡ 32 ¸ö×Ö½ÚÊý¾Ý¡£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevRead_ByteStream( T_ZDrvI2c_Device *i2c_dev, UINT8 *readBuf, UINT32 readNum );

+

+

+

+

+/*******************************************************************************

+ * Function:    zDrvI2c_DevWrite_ByteStream

+ * Description: I2C×ÜÏß×Ö½ÚÁ÷д

+ * Parameters:

+ *   Input:

+ *

+ *   Output:

+ *

+ * Returns:

+ *

+ *

+ * Others:  1. ×ñÑ­I2C×ÜÏß ¼òµ¥Ð´ ±êÏßЭÒé¡£

+            2. ֻд I2C Æ÷¼þµØÖ·£¬----------²»Ê¹ÓüĴæÆ÷µØÖ·-----¡£

+            2. ×î´óÒ»´ÎдÈë 30 ¸ö×Ö½ÚÊý¾Ý¡£

+ ********************************************************************************/

+SINT32 zDrvI2c_DevWrite_ByteStream( T_ZDrvI2c_Device *i2c_dev, UINT8 *writeBuf, UINT32 writeNum );

+

+

+

+

+

+#endif /* _DRVS_I2C_H */

+

+