aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2015-09-03 02:50:37 -0400
committerMark Brown <broonie@kernel.org>2015-09-03 05:39:20 -0400
commitb9c93646fd5cb669d096fec5ad25a01f04cfde27 (patch)
tree0edac3da63e527f0cd80db6b1187d9c90710a199
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
regulator: pbias: program pbias register offset in pbias driver
Add separate compatible strings for every platform and populate the pbias register offset in the driver data. This helps avoid depending on the dt for pbias register offset. Also update the dt binding documentation for the new compatible strings. Suggested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/pbias-regulator.txt7
-rw-r--r--drivers/regulator/pbias-regulator.c56
2 files changed, 56 insertions, 7 deletions
diff --git a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
index 32aa26f1e434..acbcb452a69a 100644
--- a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -2,7 +2,12 @@ PBIAS internal regulator for SD card dual voltage i/o pads on OMAP SoCs.
2 2
3Required properties: 3Required properties:
4- compatible: 4- compatible:
5 - "ti,pbias-omap" for OMAP2, OMAP3, OMAP4, OMAP5, DRA7. 5 - should be "ti,pbias-dra7" for DRA7
6 - should be "ti,pbias-omap2" for OMAP2
7 - should be "ti,pbias-omap3" for OMAP3
8 - should be "ti,pbias-omap4" for OMAP4
9 - should be "ti,pbias-omap5" for OMAP5
10 - "ti,pbias-omap" is deprecated
6- reg: pbias register offset from syscon base and size of pbias register. 11- reg: pbias register offset from syscon base and size of pbias register.
7- syscon : phandle of the system control module 12- syscon : phandle of the system control module
8- regulator-name : should be 13- regulator-name : should be
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index bd2b75c0d1d1..c21cedbdf451 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -44,6 +44,10 @@ struct pbias_regulator_data {
44 int voltage; 44 int voltage;
45}; 45};
46 46
47struct pbias_of_data {
48 unsigned int offset;
49};
50
47static const unsigned int pbias_volt_table[] = { 51static const unsigned int pbias_volt_table[] = {
48 1800000, 52 1800000,
49 3000000 53 3000000
@@ -98,8 +102,35 @@ static struct of_regulator_match pbias_matches[] = {
98}; 102};
99#define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches) 103#define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches)
100 104
105/* Offset from SCM general area (and syscon) base */
106
107static const struct pbias_of_data pbias_of_data_omap2 = {
108 .offset = 0x230,
109};
110
111static const struct pbias_of_data pbias_of_data_omap3 = {
112 .offset = 0x2b0,
113};
114
115static const struct pbias_of_data pbias_of_data_omap4 = {
116 .offset = 0x60,
117};
118
119static const struct pbias_of_data pbias_of_data_omap5 = {
120 .offset = 0x60,
121};
122
123static const struct pbias_of_data pbias_of_data_dra7 = {
124 .offset = 0xe00,
125};
126
101static const struct of_device_id pbias_of_match[] = { 127static const struct of_device_id pbias_of_match[] = {
102 { .compatible = "ti,pbias-omap", }, 128 { .compatible = "ti,pbias-omap", },
129 { .compatible = "ti,pbias-omap2", .data = &pbias_of_data_omap2, },
130 { .compatible = "ti,pbias-omap3", .data = &pbias_of_data_omap3, },
131 { .compatible = "ti,pbias-omap4", .data = &pbias_of_data_omap4, },
132 { .compatible = "ti,pbias-omap5", .data = &pbias_of_data_omap5, },
133 { .compatible = "ti,pbias-dra7", .data = &pbias_of_data_dra7, },
103 {}, 134 {},
104}; 135};
105MODULE_DEVICE_TABLE(of, pbias_of_match); 136MODULE_DEVICE_TABLE(of, pbias_of_match);
@@ -114,6 +145,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
114 const struct pbias_reg_info *info; 145 const struct pbias_reg_info *info;
115 int ret = 0; 146 int ret = 0;
116 int count, idx, data_idx = 0; 147 int count, idx, data_idx = 0;
148 const struct of_device_id *match;
149 const struct pbias_of_data *data;
150 unsigned int offset;
117 151
118 count = of_regulator_match(&pdev->dev, np, pbias_matches, 152 count = of_regulator_match(&pdev->dev, np, pbias_matches,
119 PBIAS_NUM_REGS); 153 PBIAS_NUM_REGS);
@@ -129,6 +163,20 @@ static int pbias_regulator_probe(struct platform_device *pdev)
129 if (IS_ERR(syscon)) 163 if (IS_ERR(syscon))
130 return PTR_ERR(syscon); 164 return PTR_ERR(syscon);
131 165
166 match = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
167 if (match && match->data) {
168 data = match->data;
169 offset = data->offset;
170 } else {
171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172 if (!res)
173 return -EINVAL;
174
175 offset = res->start;
176 dev_WARN(&pdev->dev,
177 "using legacy dt data for pbias offset\n");
178 }
179
132 cfg.regmap = syscon; 180 cfg.regmap = syscon;
133 cfg.dev = &pdev->dev; 181 cfg.dev = &pdev->dev;
134 182
@@ -141,10 +189,6 @@ static int pbias_regulator_probe(struct platform_device *pdev)
141 if (!info) 189 if (!info)
142 return -ENODEV; 190 return -ENODEV;
143 191
144 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
145 if (!res)
146 return -EINVAL;
147
148 drvdata[data_idx].syscon = syscon; 192 drvdata[data_idx].syscon = syscon;
149 drvdata[data_idx].info = info; 193 drvdata[data_idx].info = info;
150 drvdata[data_idx].desc.name = info->name; 194 drvdata[data_idx].desc.name = info->name;
@@ -154,9 +198,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
154 drvdata[data_idx].desc.volt_table = pbias_volt_table; 198 drvdata[data_idx].desc.volt_table = pbias_volt_table;
155 drvdata[data_idx].desc.n_voltages = 2; 199 drvdata[data_idx].desc.n_voltages = 2;
156 drvdata[data_idx].desc.enable_time = info->enable_time; 200 drvdata[data_idx].desc.enable_time = info->enable_time;
157 drvdata[data_idx].desc.vsel_reg = res->start; 201 drvdata[data_idx].desc.vsel_reg = offset;
158 drvdata[data_idx].desc.vsel_mask = info->vmode; 202 drvdata[data_idx].desc.vsel_mask = info->vmode;
159 drvdata[data_idx].desc.enable_reg = res->start; 203 drvdata[data_idx].desc.enable_reg = offset;
160 drvdata[data_idx].desc.enable_mask = info->enable_mask; 204 drvdata[data_idx].desc.enable_mask = info->enable_mask;
161 drvdata[data_idx].desc.enable_val = info->enable; 205 drvdata[data_idx].desc.enable_val = info->enable;
162 206