Skip to content

Commit 7d14831

Browse files
Anuj AggarwalLiam Girdwood
authored andcommitted
regulator: tps6507x: allow driver to use DEFDCDC{2,3}_HIGH register
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> In TPS6507x, depending on the status of DEFDCDC{2,3} pin either DEFDCDC{2,3}_LOW or DEFDCDC{2,3}_HIGH register needs to be read or programmed to change the output voltage. The current driver assumes DEFDCDC{2,3} pins are always tied low and thus operates only on DEFDCDC{2,3}_LOW register. This need not always be the case (as is found on OMAP-L138 EVM). Unfortunately, software cannot read the status of DEFDCDC{2,3} pins. So, this information is passed through platform data depending on how the board is wired. Signed-off-by: Anuj Aggarwal <anuj.aggarwal@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
1 parent e9a1c51 commit 7d14831

2 files changed

Lines changed: 61 additions & 7 deletions

File tree

‎drivers/regulator/tps6507x-regulator.c‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/platform_device.h>
2323
#include <linux/regulator/driver.h>
2424
#include <linux/regulator/machine.h>
25+
#include <linux/regulator/tps6507x.h>
2526
#include <linux/delay.h>
2627
#include <linux/slab.h>
2728
#include <linux/mfd/tps6507x.h>
@@ -101,9 +102,12 @@ struct tps_info {
101102
unsigned max_uV;
102103
u8 table_len;
103104
const u16 *table;
105+
106+
/* Does DCDC high or the low register defines output voltage? */
107+
bool defdcdc_default;
104108
};
105109

106-
static const struct tps_info tps6507x_pmic_regs[] = {
110+
static struct tps_info tps6507x_pmic_regs[] = {
107111
{
108112
.name = "VDCDC1",
109113
.min_uV = 725000,
@@ -145,7 +149,7 @@ struct tps6507x_pmic {
145149
struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
146150
struct tps6507x_dev *mfd;
147151
struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
148-
const struct tps_info *info[TPS6507X_NUM_REGULATOR];
152+
struct tps_info *info[TPS6507X_NUM_REGULATOR];
149153
struct mutex io_lock;
150154
};
151155
static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg)
@@ -341,10 +345,16 @@ static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev)
341345
reg = TPS6507X_REG_DEFDCDC1;
342346
break;
343347
case TPS6507X_DCDC_2:
344-
reg = TPS6507X_REG_DEFDCDC2_LOW;
348+
if (tps->info[dcdc]->defdcdc_default)
349+
reg = TPS6507X_REG_DEFDCDC2_HIGH;
350+
else
351+
reg = TPS6507X_REG_DEFDCDC2_LOW;
345352
break;
346353
case TPS6507X_DCDC_3:
347-
reg = TPS6507X_REG_DEFDCDC3_LOW;
354+
if (tps->info[dcdc]->defdcdc_default)
355+
reg = TPS6507X_REG_DEFDCDC3_HIGH;
356+
else
357+
reg = TPS6507X_REG_DEFDCDC3_LOW;
348358
break;
349359
default:
350360
return -EINVAL;
@@ -370,10 +380,16 @@ static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
370380
reg = TPS6507X_REG_DEFDCDC1;
371381
break;
372382
case TPS6507X_DCDC_2:
373-
reg = TPS6507X_REG_DEFDCDC2_LOW;
383+
if (tps->info[dcdc]->defdcdc_default)
384+
reg = TPS6507X_REG_DEFDCDC2_HIGH;
385+
else
386+
reg = TPS6507X_REG_DEFDCDC2_LOW;
374387
break;
375388
case TPS6507X_DCDC_3:
376-
reg = TPS6507X_REG_DEFDCDC3_LOW;
389+
if (tps->info[dcdc]->defdcdc_default)
390+
reg = TPS6507X_REG_DEFDCDC3_HIGH;
391+
else
392+
reg = TPS6507X_REG_DEFDCDC3_LOW;
377393
break;
378394
default:
379395
return -EINVAL;
@@ -532,7 +548,7 @@ int tps6507x_pmic_probe(struct platform_device *pdev)
532548
{
533549
struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
534550
static int desc_id;
535-
const struct tps_info *info = &tps6507x_pmic_regs[0];
551+
struct tps_info *info = &tps6507x_pmic_regs[0];
536552
struct regulator_init_data *init_data;
537553
struct regulator_dev *rdev;
538554
struct tps6507x_pmic *tps;
@@ -569,6 +585,12 @@ int tps6507x_pmic_probe(struct platform_device *pdev)
569585
for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
570586
/* Register the regulators */
571587
tps->info[i] = info;
588+
if (init_data->driver_data) {
589+
struct tps6507x_reg_platform_data *data =
590+
init_data->driver_data;
591+
tps->info[i]->defdcdc_default = data->defdcdc_default;
592+
}
593+
572594
tps->desc[i].name = info->name;
573595
tps->desc[i].id = desc_id++;
574596
tps->desc[i].n_voltages = num_voltages[i];

‎include/linux/regulator/tps6507x.h‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* tps6507x.h -- Voltage regulation for the Texas Instruments TPS6507X
3+
*
4+
* Copyright (C) 2010 Texas Instruments, Inc.
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program; if not, write to the Free Software
17+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18+
*/
19+
20+
#ifndef REGULATOR_TPS6507X
21+
#define REGULATOR_TPS6507X
22+
23+
/**
24+
* tps6507x_reg_platform_data - platform data for tps6507x
25+
* @defdcdc_default: Defines whether DCDC high or the low register controls
26+
* output voltage by default. Valid for DCDC2 and DCDC3 outputs only.
27+
*/
28+
struct tps6507x_reg_platform_data {
29+
bool defdcdc_default;
30+
};
31+
32+
#endif

0 commit comments

Comments
 (0)