aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-davinci/0001-CheckRegisterForDCDC.patch
blob: 656a09e8c4ef5c2a6647ec3548d492057476f2b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From: Anuj Aggarwal <anuj.aggarwal@ti.com>
Date: Fri, 18 Dec 2009 11:18:43 +0000 (+0530)
Subject: Regulator: Check which register needs to be read for DCDC2/3
X-Git-Url: http://arago-project.org/git/people/?p=sekhar%2Flinux-omapl1.git;a=commitdiff_plain;h=9f8ddc15520a7d5bb27bb660215d3a153ea39c00

Regulator: Check which register needs to be read for DCDC2/3

In TPS6507x, for DCDC2/3, either DEFDCDC2_LOW or DEFDCDC2_HIGH
can be read depending on the status of DEFDCDC2 pin. Since this
pin cannot be read through register, this information is passed
through board-evm file and the driver appropriately checks it
before reading the LOW / HIGH register.

Signed-off-by: Anuj Aggarwal <anuj.aggarwal@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---

diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index f8a6dfb..602a194 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -159,13 +159,15 @@ struct tps_info {
 	unsigned max_uV;
 	u8 table_len;
 	const u16 *table;
+	/* HIGH register is used to control the output voltage for DCDC2/3 */
+	unsigned reg_high:1;
 };
 
 struct tps_pmic {
 	struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
 	struct i2c_client *client;
 	struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
-	const struct tps_info *info[TPS6507X_NUM_REGULATOR];
+	struct tps_info *info[TPS6507X_NUM_REGULATOR];
 	struct mutex io_lock;
 };
 
@@ -352,10 +354,16 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev)
 		reg = TPS6507X_REG_DEFDCDC1;
 		break;
 	case TPS6507X_DCDC_2:
-		reg = TPS6507X_REG_DEFDCDC2_LOW;
+		if (tps->info[dcdc]->reg_high)
+			reg = TPS6507X_REG_DEFDCDC2_HIGH;
+		else
+			reg = TPS6507X_REG_DEFDCDC2_LOW;
 		break;
 	case TPS6507X_DCDC_3:
-		reg = TPS6507X_REG_DEFDCDC3_LOW;
+		if (tps->info[dcdc]->reg_high)
+			reg = TPS6507X_REG_DEFDCDC3_HIGH;
+		else
+			reg = TPS6507X_REG_DEFDCDC3_LOW;
 		break;
 	default:
 		return -EINVAL;
@@ -381,10 +389,16 @@ static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev,
 		reg = TPS6507X_REG_DEFDCDC1;
 		break;
 	case TPS6507X_DCDC_2:
-		reg = TPS6507X_REG_DEFDCDC2_LOW;
+		if (tps->info[dcdc]->reg_high)
+			reg = TPS6507X_REG_DEFDCDC2_HIGH;
+		else
+			reg = TPS6507X_REG_DEFDCDC2_LOW;
 		break;
 	case TPS6507X_DCDC_3:
-		reg = TPS6507X_REG_DEFDCDC3_LOW;
+		if (tps->info[dcdc]->reg_high)
+			reg = TPS6507X_REG_DEFDCDC3_HIGH;
+		else
+			reg = TPS6507X_REG_DEFDCDC3_LOW;
 		break;
 	default:
 		return -EINVAL;
@@ -542,7 +556,7 @@ static
 int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
 	static int desc_id;
-	const struct tps_info *info = (void *)id->driver_data;
+	struct tps_info *info = (void *)id->driver_data;
 	struct regulator_init_data *init_data;
 	struct regulator_dev *rdev;
 	struct tps_pmic *tps;
@@ -573,6 +587,7 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
 		/* Register the regulators */
 		tps->info[i] = info;
+		tps->info[i]->reg_high = (unsigned) init_data->driver_data;
 		tps->desc[i].name = info->name;
 		tps->desc[i].id = desc_id++;
 		tps->desc[i].n_voltages = num_voltages[i];