lkml.org 
[lkml]   [2013]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH] regulator: palmas: enable all modes for SMPS10
    Date
    SMPS10 supports different modes such as BOOST mode, BYPASS mode and
    SWITCH. Inorder to configure SMPS10 in these modes,
    added palmas_set_mode_smps10() and palmas_get_mode_smps10() for the
    consumers of SMPS10 to configure it accordingly.

    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    ---
    Only compile tested. Just sent a patch to get some comments
    /ideas on how to handle such one off regulators.
    to handle
    drivers/regulator/palmas-regulator.c | 46 ++++++++++++++++++++++++++++++++++
    include/linux/mfd/palmas.h | 1 +
    2 files changed, 47 insertions(+)

    diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
    index 87d4f13..d8d37f2 100644
    --- a/drivers/regulator/palmas-regulator.c
    +++ b/drivers/regulator/palmas-regulator.c
    @@ -355,6 +355,50 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev)
    return 0;
    }

    +static int palmas_set_mode_smps10(struct regulator_dev *dev, unsigned int mode)
    +{
    + struct palmas_pmic *pmic = rdev_get_drvdata(dev);
    + int id = rdev_get_id(dev);
    + unsigned int reg;
    +
    + palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg);
    + reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK;
    +
    + if (mode == REGULATOR_MODE_NORMAL)
    + reg |= SMPS10_BOOST_EN;
    +
    + if (mode == REGULATOR_MODE_FAST)
    + reg |= SMPS10_SWITCH_EN;
    +
    + if (mode == REGULATOR_MODE_IDLE)
    + reg |= SMPS10_BYPASS_EN;
    +
    + palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);
    + return 0;
    +}
    +
    +static unsigned int palmas_get_mode_smps10(struct regulator_dev *dev)
    +{
    + struct palmas_pmic *pmic = rdev_get_drvdata(dev);
    + int id = rdev_get_id(dev);
    + unsigned int reg;
    + int ret = 0;
    +
    + reg = pmic->current_reg_mode[id] &
    + PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK;
    +
    + if (reg == SMPS10_BOOST_EN)
    + ret |= REGULATOR_MODE_NORMAL;
    +
    + if (reg == SMPS10_SWITCH_EN)
    + ret |= REGULATOR_MODE_FAST;
    +
    + if (reg == SMPS10_BYPASS_EN)
    + ret |= REGULATOR_MODE_IDLE;
    +
    + return ret;
    +}
    +
    static int palmas_list_voltage_smps(struct regulator_dev *dev,
    unsigned selector)
    {
    @@ -483,6 +527,8 @@ static struct regulator_ops palmas_ops_smps10 = {
    .is_enabled = regulator_is_enabled_regmap,
    .enable = regulator_enable_regmap,
    .disable = regulator_disable_regmap,
    + .set_mode = palmas_set_mode_smps10,
    + .get_mode = palmas_get_mode_smps10,
    .get_voltage_sel = regulator_get_voltage_sel_regmap,
    .set_voltage_sel = regulator_set_voltage_sel_regmap,
    .list_voltage = regulator_list_voltage_linear,
    diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
    index 8f21daf..4ad2b65 100644
    --- a/include/linux/mfd/palmas.h
    +++ b/include/linux/mfd/palmas.h
    @@ -846,6 +846,7 @@ enum usb_irq_events {
    #define PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK 0xf0
    #define PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT 4
    #define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MASK 0x0f
    +#define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK 0x07
    #define PALMAS_SMPS10_CTRL_MODE_ACTIVE_SHIFT 0

    /* Bit definitions for SMPS10_STATUS */
    --
    1.7.10.4


    \
     
     \ /
      Last update: 2013-05-30 13:41    [W:3.159 / U:1.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site