Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Anuj Aggarwal and committed by
Liam Girdwood
7d14831e e9a1c512

+61 -7
+29 -7
drivers/regulator/tps6507x-regulator.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/regulator/driver.h> 24 24 #include <linux/regulator/machine.h> 25 + #include <linux/regulator/tps6507x.h> 25 26 #include <linux/delay.h> 26 27 #include <linux/slab.h> 27 28 #include <linux/mfd/tps6507x.h> ··· 102 101 unsigned max_uV; 103 102 u8 table_len; 104 103 const u16 *table; 104 + 105 + /* Does DCDC high or the low register defines output voltage? */ 106 + bool defdcdc_default; 105 107 }; 106 108 107 - static const struct tps_info tps6507x_pmic_regs[] = { 109 + static struct tps_info tps6507x_pmic_regs[] = { 108 110 { 109 111 .name = "VDCDC1", 110 112 .min_uV = 725000, ··· 149 145 struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; 150 146 struct tps6507x_dev *mfd; 151 147 struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; 152 - const struct tps_info *info[TPS6507X_NUM_REGULATOR]; 148 + struct tps_info *info[TPS6507X_NUM_REGULATOR]; 153 149 struct mutex io_lock; 154 150 }; 155 151 static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg) ··· 345 341 reg = TPS6507X_REG_DEFDCDC1; 346 342 break; 347 343 case TPS6507X_DCDC_2: 348 - reg = TPS6507X_REG_DEFDCDC2_LOW; 344 + if (tps->info[dcdc]->defdcdc_default) 345 + reg = TPS6507X_REG_DEFDCDC2_HIGH; 346 + else 347 + reg = TPS6507X_REG_DEFDCDC2_LOW; 349 348 break; 350 349 case TPS6507X_DCDC_3: 351 - reg = TPS6507X_REG_DEFDCDC3_LOW; 350 + if (tps->info[dcdc]->defdcdc_default) 351 + reg = TPS6507X_REG_DEFDCDC3_HIGH; 352 + else 353 + reg = TPS6507X_REG_DEFDCDC3_LOW; 352 354 break; 353 355 default: 354 356 return -EINVAL; ··· 380 370 reg = TPS6507X_REG_DEFDCDC1; 381 371 break; 382 372 case TPS6507X_DCDC_2: 383 - reg = TPS6507X_REG_DEFDCDC2_LOW; 373 + if (tps->info[dcdc]->defdcdc_default) 374 + reg = TPS6507X_REG_DEFDCDC2_HIGH; 375 + else 376 + reg = TPS6507X_REG_DEFDCDC2_LOW; 384 377 break; 385 378 case TPS6507X_DCDC_3: 386 - reg = TPS6507X_REG_DEFDCDC3_LOW; 379 + if (tps->info[dcdc]->defdcdc_default) 380 + reg = TPS6507X_REG_DEFDCDC3_HIGH; 381 + else 382 + reg = TPS6507X_REG_DEFDCDC3_LOW; 387 383 break; 388 384 default: 389 385 return -EINVAL; ··· 548 532 { 549 533 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); 550 534 static int desc_id; 551 - const struct tps_info *info = &tps6507x_pmic_regs[0]; 535 + struct tps_info *info = &tps6507x_pmic_regs[0]; 552 536 struct regulator_init_data *init_data; 553 537 struct regulator_dev *rdev; 554 538 struct tps6507x_pmic *tps; ··· 585 569 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { 586 570 /* Register the regulators */ 587 571 tps->info[i] = info; 572 + if (init_data->driver_data) { 573 + struct tps6507x_reg_platform_data *data = 574 + init_data->driver_data; 575 + tps->info[i]->defdcdc_default = data->defdcdc_default; 576 + } 577 + 588 578 tps->desc[i].name = info->name; 589 579 tps->desc[i].id = desc_id++; 590 580 tps->desc[i].n_voltages = num_voltages[i];
+32
include/linux/regulator/tps6507x.h
··· 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