* [PATCH 1/2] regulator: Convert pcap-regulator to set_voltage_sel
@ 2012-03-23 8:49 Axel Lin
2012-03-23 8:50 ` [PATCH 2/2] regulator: Convert pcap-regulator to get_voltage_sel Axel Lin
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-03-23 8:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Daniel Ribeiro, Antonio Ospite, Liam Girdwood, Mark Brown
After converting to set_voltage_sel, we can remove the workaroud of getting
the best match voltage for V1. The core will iterate through the whole voltage
table and find the best match for us.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/pcap-regulator.c | 33 ++++++---------------------------
1 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c
index a5aab1b..b9666a2 100644
--- a/drivers/regulator/pcap-regulator.c
+++ b/drivers/regulator/pcap-regulator.c
@@ -150,40 +150,19 @@ static struct pcap_regulator vreg_table[] = {
VREG_INFO(SW2S, PCAP_REG_LOWPWR, NA, 20, NA, NA), */
};
-static int pcap_regulator_set_voltage(struct regulator_dev *rdev,
- int min_uV, int max_uV,
- unsigned *selector)
+static int pcap_regulator_set_voltage_sel(struct regulator_dev *rdev,
+ unsigned selector)
{
struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
void *pcap = rdev_get_drvdata(rdev);
- int uV;
- u8 i;
/* the regulator doesn't support voltage switching */
if (vreg->n_voltages == 1)
return -EINVAL;
- for (i = 0; i < vreg->n_voltages; i++) {
- /* For V1 the first is not the best match */
- if (i == 0 && rdev_get_id(rdev) == V1)
- i = 1;
- else if (i + 1 == vreg->n_voltages && rdev_get_id(rdev) == V1)
- i = 0;
-
- uV = vreg->voltage_table[i] * 1000;
- if (min_uV <= uV && uV <= max_uV) {
- *selector = i;
- return ezx_pcap_set_bits(pcap, vreg->reg,
- (vreg->n_voltages - 1) << vreg->index,
- i << vreg->index);
- }
-
- if (i == 0 && rdev_get_id(rdev) == V1)
- i = vreg->n_voltages - 1;
- }
-
- /* the requested voltage range is not supported by this regulator */
- return -EINVAL;
+ return ezx_pcap_set_bits(pcap, vreg->reg,
+ (vreg->n_voltages - 1) << vreg->index,
+ selector << vreg->index);
}
static int pcap_regulator_get_voltage(struct regulator_dev *rdev)
@@ -248,7 +227,7 @@ static int pcap_regulator_list_voltage(struct regulator_dev *rdev,
static struct regulator_ops pcap_regulator_ops = {
.list_voltage = pcap_regulator_list_voltage,
- .set_voltage = pcap_regulator_set_voltage,
+ .set_voltage_sel = pcap_regulator_set_voltage_sel,
.get_voltage = pcap_regulator_get_voltage,
.enable = pcap_regulator_enable,
.disable = pcap_regulator_disable,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] regulator: Convert pcap-regulator to get_voltage_sel
2012-03-23 8:49 [PATCH 1/2] regulator: Convert pcap-regulator to set_voltage_sel Axel Lin
@ 2012-03-23 8:50 ` Axel Lin
0 siblings, 0 replies; 2+ messages in thread
From: Axel Lin @ 2012-03-23 8:50 UTC (permalink / raw)
To: linux-kernel; +Cc: Daniel Ribeiro, Antonio Ospite, Liam Girdwood, Mark Brown
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/pcap-regulator.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c
index b9666a2..781bf34 100644
--- a/drivers/regulator/pcap-regulator.c
+++ b/drivers/regulator/pcap-regulator.c
@@ -165,21 +165,18 @@ static int pcap_regulator_set_voltage_sel(struct regulator_dev *rdev,
selector << vreg->index);
}
-static int pcap_regulator_get_voltage(struct regulator_dev *rdev)
+static int pcap_regulator_get_voltage_sel(struct regulator_dev *rdev)
{
struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
void *pcap = rdev_get_drvdata(rdev);
u32 tmp;
- int mV;
if (vreg->n_voltages == 1)
- return vreg->voltage_table[0] * 1000;
+ return 0;
ezx_pcap_read(pcap, vreg->reg, &tmp);
tmp = ((tmp >> vreg->index) & (vreg->n_voltages - 1));
- mV = vreg->voltage_table[tmp];
-
- return mV * 1000;
+ return tmp;
}
static int pcap_regulator_enable(struct regulator_dev *rdev)
@@ -228,7 +225,7 @@ static int pcap_regulator_list_voltage(struct regulator_dev *rdev,
static struct regulator_ops pcap_regulator_ops = {
.list_voltage = pcap_regulator_list_voltage,
.set_voltage_sel = pcap_regulator_set_voltage_sel,
- .get_voltage = pcap_regulator_get_voltage,
+ .get_voltage_sel = pcap_regulator_get_voltage_sel,
.enable = pcap_regulator_enable,
.disable = pcap_regulator_disable,
.is_enabled = pcap_regulator_is_enabled,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-23 8:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23 8:49 [PATCH 1/2] regulator: Convert pcap-regulator to set_voltage_sel Axel Lin
2012-03-23 8:50 ` [PATCH 2/2] regulator: Convert pcap-regulator to get_voltage_sel Axel Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox