aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-03-21 11:59:01 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-22 07:03:16 -0400
commit3c1b8438d4bc99269aba560739e3e6cb640584f4 (patch)
tree5600247d4c4943ec15b27bf4df52ca6ed8426c12 /drivers/regulator/ab8500.c
parent7ce4669c8feefe0c772e9d5f3ae65160e20d8458 (diff)
ARM: ux500: regulators: Add mask for configuration
There is already before a register mask in the regulator driver to allow some bits of a register to be initialized. The register value is defined in the board configuration. This patch puts a mask in the board configuration to specify which bits should actually be altered. The purpose with this patch is to avoid future mistakes when updating the allowed bits in the regulator driver. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r--drivers/regulator/ab8500.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 3465ac38bffe..a847744f8c20 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -811,23 +811,20 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
811 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16), 811 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
812}; 812};
813 813
814static int 814static int ab8500_regulator_init_registers(struct platform_device *pdev,
815ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value) 815 int id, int mask, int value)
816{ 816{
817 int err; 817 int err;
818 818
819 if (value & ~ab8500_reg_init[id].mask) { 819 BUG_ON(value & ~mask);
820 dev_err(&pdev->dev, 820 BUG_ON(mask & ~ab8500_reg_init[id].mask);
821 "Configuration error: value outside mask.\n");
822 return -EINVAL;
823 }
824 821
822 /* initialize register */
825 err = abx500_mask_and_set_register_interruptible( 823 err = abx500_mask_and_set_register_interruptible(
826 &pdev->dev, 824 &pdev->dev,
827 ab8500_reg_init[id].bank, 825 ab8500_reg_init[id].bank,
828 ab8500_reg_init[id].addr, 826 ab8500_reg_init[id].addr,
829 ab8500_reg_init[id].mask, 827 mask, value);
830 value);
831 if (err < 0) { 828 if (err < 0) {
832 dev_err(&pdev->dev, 829 dev_err(&pdev->dev,
833 "Failed to initialize 0x%02x, 0x%02x.\n", 830 "Failed to initialize 0x%02x, 0x%02x.\n",
@@ -835,13 +832,11 @@ ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value)
835 ab8500_reg_init[id].addr); 832 ab8500_reg_init[id].addr);
836 return err; 833 return err;
837 } 834 }
838
839 dev_vdbg(&pdev->dev, 835 dev_vdbg(&pdev->dev,
840 "init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", 836 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
841 ab8500_reg_init[id].bank, 837 ab8500_reg_init[id].bank,
842 ab8500_reg_init[id].addr, 838 ab8500_reg_init[id].addr,
843 ab8500_reg_init[id].mask, 839 mask, value);
844 value);
845 840
846 return 0; 841 return 0;
847} 842}
@@ -960,19 +955,16 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
960 955
961 /* initialize registers */ 956 /* initialize registers */
962 for (i = 0; i < pdata->num_regulator_reg_init; i++) { 957 for (i = 0; i < pdata->num_regulator_reg_init; i++) {
963 int id, value; 958 int id, mask, value;
964 959
965 id = pdata->regulator_reg_init[i].id; 960 id = pdata->regulator_reg_init[i].id;
961 mask = pdata->regulator_reg_init[i].mask;
966 value = pdata->regulator_reg_init[i].value; 962 value = pdata->regulator_reg_init[i].value;
967 963
968 /* check for configuration errors */ 964 /* check for configuration errors */
969 if (id >= AB8500_NUM_REGULATOR_REGISTERS) { 965 BUG_ON(id >= AB8500_NUM_REGULATOR_REGISTERS);
970 dev_err(&pdev->dev,
971 "Configuration error: id outside range.\n");
972 return -EINVAL;
973 }
974 966
975 err = ab8500_regulator_init_registers(pdev, id, value); 967 err = ab8500_regulator_init_registers(pdev, id, mask, value);
976 if (err < 0) 968 if (err < 0)
977 return err; 969 return err;
978 } 970 }