コード例 #1
0
static u8 twl6030_uv_to_vsel(unsigned long uv)
{
    /*
     * In TWL6030 depending on the value of SMPS_OFFSET
     * efuse register the voltage range supported in
     * standard mode can be either between 0.6V - 1.3V or
     * 0.7V - 1.4V. In TWL6030 ES1.0 SMPS_OFFSET efuse
     * is programmed to all 0's where as starting from
     * TWL6030 ES1.1 the efuse is programmed to 1
     */
    if (!is_offset_valid) {
        twl_i2c_read_u8(TWL6030_MODULE_ID0, &smps_offset,
                        REG_SMPS_OFFSET);
        is_offset_valid = true;
    }

    if (!uv)
        return 0x00;
    /*
     * There is no specific formula for voltage to vsel
     * conversion above 1.3V. There are special hardcoded
     * values for voltages above 1.3V. Currently we are
     * hardcoding only for 1.35 V which is used for 1GH OPP for
     * OMAP4430.
     */
    if (uv > twl6030_vsel_to_uv(0x39)) {
        if (uv == 1350000)
            return 0x3A;
        pr_err("%s:OUT OF RANGE! non mapped vsel for %ld Vs max %ld\n",
               __func__, uv, twl6030_vsel_to_uv(0x39));
        return 0x3A;
    }

    if (smps_offset & 0x8)
        return DIV_ROUND_UP(uv - 709000, 12660) + 1;
    else
        return DIV_ROUND_UP(uv - 607700, 12660) + 1;
}
コード例 #2
0
ファイル: omap_twl.c プロジェクト: robacklin/omap-android
static u8 twl6030_uv_to_vsel(unsigned long uv)
{
    /*
     * In TWL6030 depending on the value of SMPS_OFFSET
     * efuse register the voltage range supported in
     * standard mode can be either between 0.6V - 1.3V or
     * 0.7V - 1.4V. We should know the current state of
     * SMPS_OFFSET before performing any conversations.
     */
    if (SMPS_OFFSET_UNINITIALIZED == smps_offset_state)
        pr_err("%s: smps offset is not initialized\n", __func__);

    /* Special case for 0 voltage */
    if (!uv)
        return 0x00;

    /*
     * There is no specific formula for voltage to vsel
     * conversion above 1.3V. There are special hardcoded
     * values for voltages above 1.3V. Currently we are
     * hardcoding only for 1.35 V which is used for 1GH OPP for
     * OMAP4430.
     */
    if (uv > twl6030_vsel_to_uv(0x39)) {
        if (uv == 1350000)
            return 0x3A;
        pr_err("%s:OUT OF RANGE! non mapped vsel for %ld Vs max %ld\n",
               __func__, uv, twl6030_vsel_to_uv(0x39));
        return 0x39;
    }

    if (SMPS_OFFSET_ENABLED == smps_offset_state)
        return DIV_ROUND_UP(uv - 709000, 12660) + 1;
    else
        return DIV_ROUND_UP(uv - 607700, 12660) + 1;
}