regulator: tps6586x: add SMx slew rate setting
Xin Xie [Tue, 26 Apr 2011 00:36:15 +0000 (17:36 -0700)]
bug 815933

Original-Change-Id: I3b8f8910b12ff4f8a5f9588615bd0bb6452bdc3b
Reviewed-on: http://git-master/r/40263
Reviewed-by: Xin Xie <xxie@nvidia.com>
Tested-by: Xin Xie <xxie@nvidia.com>
Reviewed-by: Jonathan Mayo <jmayo@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: R18292e6e68c95b9f67d24281a9f2b80439452ba8

drivers/regulator/tps6586x-regulator.c
include/linux/mfd/tps6586x.h

index 3fd75e6..9ab8f3f 100644 (file)
@@ -375,6 +375,30 @@ static inline int tps6586x_regulator_set_pwm_mode(struct platform_device *pdev)
        return ret;
 }
 
+static inline int tps6586x_regulator_set_slew_rate(struct platform_device *pdev)
+{
+       struct device *parent = pdev->dev.parent;
+       struct regulator_init_data *p = pdev->dev.platform_data;
+       struct tps6586x_settings *setting = p->driver_data;
+       uint8_t reg;
+
+       if (setting == NULL)
+               return 0;
+
+       /* only SM0 and SM1 can have the slew rate settings */
+       switch (pdev->id) {
+       case TPS6586X_ID_SM_0:
+               reg = TPS6586X_SM0SL;
+               break;
+       case TPS6586X_ID_SM_1:
+               reg = TPS6586X_SM1SL;
+               break;
+       default:
+               return 0;
+       }
+       return tps6586x_write(parent, reg, setting->slew_rate);
+}
+
 static inline struct tps6586x_regulator *find_regulator_info(int id)
 {
        struct tps6586x_regulator *ri;
@@ -417,6 +441,10 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, rdev);
 
+       err = tps6586x_regulator_set_slew_rate(pdev);
+       if (err)
+               return err;
+
        return tps6586x_regulator_set_pwm_mode(pdev);
 }
 
index 6d6ddc9..e43184a 100644 (file)
@@ -55,12 +55,27 @@ enum {
 enum pwm_pfm_mode {
        PWM_ONLY,
        AUTO_PWM_PFM,
-       NOT_CONFIGURABLE
+       PWM_DEFAULT_VALUE,
+
+};
+
+enum slew_rate_settings {
+       SLEW_RATE_INSTANTLY = 0,
+       SLEW_RATE_0110UV_PER_SEC = 0x1,
+       SLEW_RATE_0220UV_PER_SEC = 0x2,
+       SLEW_RATE_0440UV_PER_SEC = 0x3,
+       SLEW_RATE_0880UV_PER_SEC = 0x4,
+       SLEW_RATE_1760UV_PER_SEC = 0x5,
+       SLEW_RATE_3520UV_PER_SEC = 0x6,
+       SLEW_RATE_7040UV_PER_SEC = 0x7,
+       SLEW_RATE_DEFAULT_VALUE,
 };
 
 struct tps6586x_settings {
        /* SM0, SM1 and SM2 have PWM-only and auto PWM/PFM mode */
        enum pwm_pfm_mode sm_pwm_mode;
+       /* SM0 and SM1 have slew rate settings */
+       enum slew_rate_settings slew_rate;
 };
 
 enum {