Example #1
0
// Read Whole Bytes
DCL_UINT8 dcl_pmic6327_byte_return(DCL_UINT8 addr, DCL_UINT32 bank)
{
    kal_uint32 token;
    kal_bool result = KAL_FALSE;

    kal_uint32 retryCnt = 0;

    pmic_DCM_Disable();
    do{
        token=i2c_pmic_getToken();
        i2c_pmic_speedup(token);
        I2C_PMIC_LOG(I2C_byte_return,token);      
        result = pmic6327_reg_read_fast(addr, &pmic6327_reg[bank][addr],token);

        if (KAL_TRUE == result)
        {
            break;
        }

        retryCnt++;
        if (retryCnt > ACCEPTABLE_RETRY_COUNT)
        {
            ASSERT(0);
        }
    }while(1);
    pmic_DCM_Enable();

    updateRetryCnt(retryCnt);
        
    return pmic6327_reg[bank][addr];
}
/*****************************************************************************
 *
 * Filename:
 * ---------
 *    bl_pmic_adpt.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This module is the PMU/PMIC adaptation layer in bootloader
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include 	"drv_comm.h"
#include "dcl.h"

#if defined(__MINI_BOOTLOADER__)
extern void i2c_pmic_speedup(void);
extern kal_bool pmic6327_reg_write_fast(kal_uint8 reg, kal_uint8 val);

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_swReset()
{
#if (defined(MT6327))
    i2c_pmic_speedup();
    pmic6327_reg_write_fast(0x0B, 0xBA);
#endif
}
/*****************************************************************************
 *
 * Filename:
 * ---------
 *    bl_pmic_adpt.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This module is the PMU/PMIC adaptation layer in bootloader
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include 	"drv_comm.h"
#include "dcl.h"

#if defined(__MINI_BOOTLOADER__)
extern void i2c_pmic_speedup(void);
extern kal_bool pmic6327_reg_write_fast(kal_uint8 reg, kal_uint8 val);

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_swReset()
{
#if (defined(MT6327))
    i2c_pmic_speedup();
    pmic6327_reg_write_fast(0x0B, 0xBA);
#endif
}

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_enableVmWithSpecificVol(PMU_VOLTAGE_ENUM vol)
{
#if (defined(MT6327))
    switch (vol)
    {
        case PMU_VOLT_01_200000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x01);
            break;
        case PMU_VOLT_01_500000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x11);
            break;
        case PMU_VOLT_01_800000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x21);
            break;
        default:
            break;
    }
#endif
}
Example #4
0
// Write register field
void dcl_pmic6327_field_write(PMU_FLAGS_LIST_ENUM flag, DCL_UINT8 sel)
{
    const PMU_FLAG_TABLE_ENTRY *pTable = pmic_flags_table;
    DCL_UINT32 i, table_size = 0;
    kal_uint32 token;
    kal_bool result = KAL_FALSE;

    kal_uint32 retryCnt = 0;

    table_size = GETARRNUM(pmic_flags_table);

    for (i = 0; i < table_size; i++)
    {
        if (flag == pTable[i].flagname)
        {
            break;
        }
    }

    if (i >= table_size)
        ASSERT(0); // Flag Unknown

    pmic_DCM_Disable();
    do{
        token=i2c_pmic_getToken();
        i2c_pmic_speedup(token);
        I2C_PMIC_LOG(I2C_field_write,token);        
        pmic6327_reg[PMIC_BANK0][pTable[i].offset] &= ~(pTable[i].mask);
        pmic6327_reg[PMIC_BANK0][pTable[i].offset] |= ((kal_uint8)sel << pTable[i].shift);    
        result = pmic6327_reg_write_fast(pTable[i].offset, pmic6327_reg[PMIC_BANK0][pTable[i].offset],token);

        if (KAL_TRUE == result)
        {
            break;
        }

        retryCnt++;
        if (retryCnt > ACCEPTABLE_RETRY_COUNT)
        {
            ASSERT(0);
        }
    }while(1);
    pmic_DCM_Enable();

    updateRetryCnt(retryCnt);
}
/*****************************************************************************
 *
 * Filename:
 * ---------
 *    bl_pmic_adpt.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   This module is the PMU/PMIC adaptation layer in bootloader
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include 	"drv_comm.h"
#include "dcl.h"

#if defined(__MINI_BOOTLOADER__)
extern void i2c_pmic_speedup(void);
extern kal_bool pmic6327_reg_write_fast(kal_uint8 reg, kal_uint8 val);

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_swReset()
{
#if (defined(MT6327))
    i2c_pmic_speedup();
    pmic6327_reg_write_fast(0x0B, 0xBA);
#endif
}

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_enableVmWithSpecificVol(PMU_VOLTAGE_ENUM vol)
{
#if (defined(MT6327))
    switch (vol)
    {
        case PMU_VOLT_01_200000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x01);
            break;
        case PMU_VOLT_01_500000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x11);
            break;
        case PMU_VOLT_01_800000_V:
            i2c_pmic_speedup();
            pmic6327_reg_write_fast(0x8A, 0x21);
            break;
        default:
            break;
    }
#endif
}

#ifdef __MTK_TARGET__
__attribute__ ((section ("EMIINITCODE"))) 
#endif /* __MTK_TARGET__ */
void pmic_setVmCaliVol(PMU_VOLTAGE_CALIBRATION_ENUM vol)
{
#if (defined(MT6327))
    int value = 0;
    
    switch (vol)
    {
    	  case PMU_VOLT_CAL_00_000000_V:
    	  	  value = 0;
    	  	  break;
    	  case PMU_VOLT_CAL_MINUS_00_020000_V:
    	  	  value = 1;
    	  	  break;
        case PMU_VOLT_CAL_MINUS_00_040000_V:
    	  	  value = 2;
    	  	  break;
        case PMU_VOLT_CAL_MINUS_00_060000_V:
    	  	  value = 3;
    	  	  break;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
        case PMU_VOLT_CAL_00_060000_V:
    	  	  value = 13;
    	  	  break;
        case PMU_VOLT_CAL_00_040000_V:
    	  	  value = 14;
    	  	  break;
        case PMU_VOLT_CAL_00_020000_V:
    	  	  value = 15;
    	  	  break;
        default:
            break;
    }
    
    i2c_pmic_speedup();
    pmic6327_reg_write_fast(0x89, value);
#endif
}