aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2013-06-24 08:39:53 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-30 17:30:03 -0400
commit4280e0b42bd590316a048d66ea356e78c5d0464e (patch)
tree838184bb11f7e14d3c1054d326ba2bf7b4261fa8
parent443c6ae253e96db9a5800a28d7c61131e81c2dee (diff)
regulator: max8998: Use arrays for specifying voltages in platform data
This patch modifies the platform data of max8998 to use arrays for specifying predefined voltages of buck1 and buck2 instead of separate field for each voltage. This allows to simplify the code a bit and will help in adding support for Device Tree, which will be introduced in further patch. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Acked-by: Mark Brown <broonie@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--arch/arm/mach-exynos/mach-universal_c210.c8
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c8
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c8
-rw-r--r--drivers/regulator/max8998.c96
-rw-r--r--include/linux/mfd/max8998.h16
5 files changed, 39 insertions, 97 deletions
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index 74ddb2b55614..f912444cae33 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -540,15 +540,11 @@ static struct max8998_regulator_data lp3974_regulators[] = {
540static struct max8998_platform_data universal_lp3974_pdata = { 540static struct max8998_platform_data universal_lp3974_pdata = {
541 .num_regulators = ARRAY_SIZE(lp3974_regulators), 541 .num_regulators = ARRAY_SIZE(lp3974_regulators),
542 .regulators = lp3974_regulators, 542 .regulators = lp3974_regulators,
543 .buck1_voltage1 = 1100000, /* INT */ 543 .buck1_voltage = { 1100000, 1000000, 1100000, 1000000 },
544 .buck1_voltage2 = 1000000,
545 .buck1_voltage3 = 1100000,
546 .buck1_voltage4 = 1000000,
547 .buck1_set1 = EXYNOS4_GPX0(5), 544 .buck1_set1 = EXYNOS4_GPX0(5),
548 .buck1_set2 = EXYNOS4_GPX0(6), 545 .buck1_set2 = EXYNOS4_GPX0(6),
549 .buck2_voltage1 = 1200000, /* G3D */
550 .buck2_voltage2 = 1100000,
551 .buck1_default_idx = 0, 546 .buck1_default_idx = 0,
547 .buck2_voltage = { 1200000, 1100000 },
552 .buck2_set3 = EXYNOS4_GPE2(0), 548 .buck2_set3 = EXYNOS4_GPE2(0),
553 .buck2_default_idx = 0, 549 .buck2_default_idx = 0,
554 .wakeup = true, 550 .wakeup = true,
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index ed2b85485b9d..ad40ab0f5dbd 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -377,12 +377,8 @@ static struct max8998_platform_data aquila_max8998_pdata = {
377 .buck1_set1 = S5PV210_GPH0(3), 377 .buck1_set1 = S5PV210_GPH0(3),
378 .buck1_set2 = S5PV210_GPH0(4), 378 .buck1_set2 = S5PV210_GPH0(4),
379 .buck2_set3 = S5PV210_GPH0(5), 379 .buck2_set3 = S5PV210_GPH0(5),
380 .buck1_voltage1 = 1200000, 380 .buck1_voltage = { 1200000, 1200000, 1200000, 1200000 },
381 .buck1_voltage2 = 1200000, 381 .buck2_voltage = { 1200000, 1200000 },
382 .buck1_voltage3 = 1200000,
383 .buck1_voltage4 = 1200000,
384 .buck2_voltage1 = 1200000,
385 .buck2_voltage2 = 1200000,
386}; 382};
387#endif 383#endif
388 384
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index 30b24ad84f49..e5cd9fbf19e9 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -580,12 +580,8 @@ static struct max8998_platform_data goni_max8998_pdata = {
580 .buck1_set1 = S5PV210_GPH0(3), 580 .buck1_set1 = S5PV210_GPH0(3),
581 .buck1_set2 = S5PV210_GPH0(4), 581 .buck1_set2 = S5PV210_GPH0(4),
582 .buck2_set3 = S5PV210_GPH0(5), 582 .buck2_set3 = S5PV210_GPH0(5),
583 .buck1_voltage1 = 1200000, 583 .buck1_voltage = { 1200000, 1200000, 1200000, 1200000 },
584 .buck1_voltage2 = 1200000, 584 .buck2_voltage = { 1200000, 1200000 },
585 .buck1_voltage3 = 1200000,
586 .buck1_voltage4 = 1200000,
587 .buck2_voltage1 = 1200000,
588 .buck2_voltage2 = 1200000,
589}; 585};
590#endif 586#endif
591 587
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index a57a1b15cdba..8c45b93b7334 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -630,6 +630,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
630 struct max8998_data *max8998; 630 struct max8998_data *max8998;
631 struct i2c_client *i2c; 631 struct i2c_client *i2c;
632 int i, ret, size; 632 int i, ret, size;
633 unsigned int v;
633 634
634 if (!pdata) { 635 if (!pdata) {
635 dev_err(pdev->dev.parent, "No platform init data supplied\n"); 636 dev_err(pdev->dev.parent, "No platform init data supplied\n");
@@ -688,53 +689,21 @@ static int max8998_pmic_probe(struct platform_device *pdev)
688 gpio_request(pdata->buck1_set2, "MAX8998 BUCK1_SET2"); 689 gpio_request(pdata->buck1_set2, "MAX8998 BUCK1_SET2");
689 gpio_direction_output(pdata->buck1_set2, 690 gpio_direction_output(pdata->buck1_set2,
690 (max8998->buck1_idx >> 1) & 0x1); 691 (max8998->buck1_idx >> 1) & 0x1);
691 /* Set predefined value for BUCK1 register 1 */
692 i = 0;
693 while (buck12_voltage_map_desc.min +
694 buck12_voltage_map_desc.step*i
695 < pdata->buck1_voltage1)
696 i++;
697 max8998->buck1_vol[0] = i;
698 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
699 if (ret)
700 goto err_out;
701
702 /* Set predefined value for BUCK1 register 2 */
703 i = 0;
704 while (buck12_voltage_map_desc.min +
705 buck12_voltage_map_desc.step*i
706 < pdata->buck1_voltage2)
707 i++;
708
709 max8998->buck1_vol[1] = i;
710 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
711 if (ret)
712 goto err_out;
713
714 /* Set predefined value for BUCK1 register 3 */
715 i = 0;
716 while (buck12_voltage_map_desc.min +
717 buck12_voltage_map_desc.step*i
718 < pdata->buck1_voltage3)
719 i++;
720
721 max8998->buck1_vol[2] = i;
722 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
723 if (ret)
724 goto err_out;
725
726 /* Set predefined value for BUCK1 register 4 */
727 i = 0;
728 while (buck12_voltage_map_desc.min +
729 buck12_voltage_map_desc.step*i
730 < pdata->buck1_voltage4)
731 i++;
732
733 max8998->buck1_vol[3] = i;
734 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
735 if (ret)
736 goto err_out;
737 692
693 /* Set predefined values for BUCK1 registers */
694 for (v = 0; v < ARRAY_SIZE(pdata->buck1_voltage); ++v) {
695 i = 0;
696 while (buck12_voltage_map_desc.min +
697 buck12_voltage_map_desc.step*i
698 < pdata->buck1_voltage[v])
699 i++;
700
701 max8998->buck1_vol[v] = i;
702 ret = max8998_write_reg(i2c,
703 MAX8998_REG_BUCK1_VOLTAGE1 + v, i);
704 if (ret)
705 goto err_out;
706 }
738 } 707 }
739 708
740 if (gpio_is_valid(pdata->buck2_set3)) { 709 if (gpio_is_valid(pdata->buck2_set3)) {
@@ -750,27 +719,20 @@ static int max8998_pmic_probe(struct platform_device *pdev)
750 gpio_direction_output(pdata->buck2_set3, 719 gpio_direction_output(pdata->buck2_set3,
751 max8998->buck2_idx & 0x1); 720 max8998->buck2_idx & 0x1);
752 721
753 /* BUCK2 register 1 */ 722 /* Set predefined values for BUCK2 registers */
754 i = 0; 723 for (v = 0; v < ARRAY_SIZE(pdata->buck2_voltage); ++v) {
755 while (buck12_voltage_map_desc.min + 724 i = 0;
756 buck12_voltage_map_desc.step*i 725 while (buck12_voltage_map_desc.min +
757 < pdata->buck2_voltage1) 726 buck12_voltage_map_desc.step*i
758 i++; 727 < pdata->buck2_voltage[v])
759 max8998->buck2_vol[0] = i; 728 i++;
760 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); 729
761 if (ret) 730 max8998->buck2_vol[v] = i;
762 goto err_out; 731 ret = max8998_write_reg(i2c,
763 732 MAX8998_REG_BUCK2_VOLTAGE1 + v, i);
764 /* BUCK2 register 2 */ 733 if (ret)
765 i = 0; 734 goto err_out;
766 while (buck12_voltage_map_desc.min + 735 }
767 buck12_voltage_map_desc.step*i
768 < pdata->buck2_voltage2)
769 i++;
770 max8998->buck2_vol[1] = i;
771 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
772 if (ret)
773 goto err_out;
774 } 736 }
775 737
776 for (i = 0; i < pdata->num_regulators; i++) { 738 for (i = 0; i < pdata->num_regulators; i++) {
diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h
index 75471183b87a..ca56bb03bc69 100644
--- a/include/linux/mfd/max8998.h
+++ b/include/linux/mfd/max8998.h
@@ -73,12 +73,8 @@ struct max8998_regulator_data {
73 * @buck_voltage_lock: Do NOT change the values of the following six 73 * @buck_voltage_lock: Do NOT change the values of the following six
74 * registers set by buck?_voltage?. The voltage of BUCK1/2 cannot 74 * registers set by buck?_voltage?. The voltage of BUCK1/2 cannot
75 * be other than the preset values. 75 * be other than the preset values.
76 * @buck1_voltage1: BUCK1 DVS mode 1 voltage register 76 * @buck1_voltage: BUCK1 DVS mode 1 voltage registers
77 * @buck1_voltage2: BUCK1 DVS mode 2 voltage register 77 * @buck2_voltage: BUCK2 DVS mode 2 voltage registers
78 * @buck1_voltage3: BUCK1 DVS mode 3 voltage register
79 * @buck1_voltage4: BUCK1 DVS mode 4 voltage register
80 * @buck2_voltage1: BUCK2 DVS mode 1 voltage register
81 * @buck2_voltage2: BUCK2 DVS mode 2 voltage register
82 * @buck1_set1: BUCK1 gpio pin 1 to set output voltage 78 * @buck1_set1: BUCK1 gpio pin 1 to set output voltage
83 * @buck1_set2: BUCK1 gpio pin 2 to set output voltage 79 * @buck1_set2: BUCK1 gpio pin 2 to set output voltage
84 * @buck1_default_idx: Default for BUCK1 gpio pin 1, 2 80 * @buck1_default_idx: Default for BUCK1 gpio pin 1, 2
@@ -103,12 +99,8 @@ struct max8998_platform_data {
103 unsigned int irq_base; 99 unsigned int irq_base;
104 int ono; 100 int ono;
105 bool buck_voltage_lock; 101 bool buck_voltage_lock;
106 int buck1_voltage1; 102 int buck1_voltage[4];
107 int buck1_voltage2; 103 int buck2_voltage[2];
108 int buck1_voltage3;
109 int buck1_voltage4;
110 int buck2_voltage1;
111 int buck2_voltage2;
112 int buck1_set1; 104 int buck1_set1;
113 int buck1_set2; 105 int buck1_set2;
114 int buck1_default_idx; 106 int buck1_default_idx;