regulator: s5m8767: Add symbols for hard-coded DVS_RAMP register
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Tue, 17 Dec 2013 13:23:17 +0000 (14:23 +0100)
committerMark Brown <broonie@linaro.org>
Wed, 18 Dec 2013 13:27:40 +0000 (13:27 +0000)
Add symbols for hard-coded values of BUCK_RAMP field in DVS_RAMP
register. This simplifies a little the code as register update is called
only once.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/regulator/s5m8767.c
include/linux/mfd/samsung/s5m8767.h

index 9b14faa3bf91653fa25785f2bc6df529573259ed..27741df28ad75ca80398bd0a9e3d28d26bff7440 100644 (file)
@@ -881,31 +881,29 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
 
        if (s5m8767->buck2_ramp || s5m8767->buck3_ramp
                || s5m8767->buck4_ramp) {
+               unsigned int val;
                switch (s5m8767->ramp_delay) {
                case 5:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0x40, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_5;
                        break;
                case 10:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0x90, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_10;
                        break;
                case 25:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0xd0, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_25;
                        break;
                case 50:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0xe0, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_50;
                        break;
                case 100:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0xf0, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_100;
                        break;
                default:
-                       sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
-                                       0x90, 0xf0);
+                       val = S5M8767_DVS_BUCK_RAMP_10;
                }
+               sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
+                                       val << S5M8767_DVS_BUCK_RAMP_SHIFT,
+                                       S5M8767_DVS_BUCK_RAMP_MASK);
        }
 
        for (i = 0; i < pdata->num_regulators; i++) {
index 9198377ee859cde80e67085c3fc3d09db7ec0b7f..2ab0b0f03641334077cc16c4bbd8ec8c9159619c 100644 (file)
@@ -186,4 +186,19 @@ enum s5m8767_regulators {
 #define S5M8767_ENCTRL_SHIFT           6
 #define S5M8767_ENCTRL_MASK            (0x3 << S5M8767_ENCTRL_SHIFT)
 
+/*
+ * Values for BUCK_RAMP field in DVS_RAMP register, matching raw values
+ * in mV/us.
+ */
+enum s5m8767_dvs_buck_ramp_values {
+       S5M8767_DVS_BUCK_RAMP_5         = 0x4,
+       S5M8767_DVS_BUCK_RAMP_10        = 0x9,
+       S5M8767_DVS_BUCK_RAMP_12_5      = 0xb,
+       S5M8767_DVS_BUCK_RAMP_25        = 0xd,
+       S5M8767_DVS_BUCK_RAMP_50        = 0xe,
+       S5M8767_DVS_BUCK_RAMP_100       = 0xf,
+};
+#define S5M8767_DVS_BUCK_RAMP_SHIFT    4
+#define S5M8767_DVS_BUCK_RAMP_MASK     (0xf << S5M8767_DVS_BUCK_RAMP_SHIFT)
+
 #endif /* __LINUX_MFD_S5M8767_H */