diff options
author | Tony Lindgren <tony@atomide.com> | 2015-09-24 19:23:20 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2015-09-24 19:23:20 -0400 |
commit | 4bbc2bc1a4e81c1a3522b3bd9d43fffd2eca8c9e (patch) | |
tree | 741ed45f33638a198417c4af4de3294c24a0f16b | |
parent | 84ad1bab0eebd2e2b2dd3c3db7b88cade22a6de1 (diff) | |
parent | b9c93646fd5cb669d096fec5ad25a01f04cfde27 (diff) |
Merge commit 'b8c93646fd5c' into omap-for-v4.3/fixes
-rw-r--r-- | Documentation/devicetree/bindings/regulator/pbias-regulator.txt | 7 | ||||
-rw-r--r-- | drivers/regulator/pbias-regulator.c | 56 |
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 | ||
3 | Required properties: | 3 | Required 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 4fa7bcaf454e..f9d74d63be7c 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c | |||
@@ -45,6 +45,10 @@ struct pbias_regulator_data { | |||
45 | int voltage; | 45 | int voltage; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct pbias_of_data { | ||
49 | unsigned int offset; | ||
50 | }; | ||
51 | |||
48 | static const unsigned int pbias_volt_table[] = { | 52 | static const unsigned int pbias_volt_table[] = { |
49 | 1800000, | 53 | 1800000, |
50 | 3000000 | 54 | 3000000 |
@@ -102,8 +106,35 @@ static struct of_regulator_match pbias_matches[] = { | |||
102 | }; | 106 | }; |
103 | #define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches) | 107 | #define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches) |
104 | 108 | ||
109 | /* Offset from SCM general area (and syscon) base */ | ||
110 | |||
111 | static const struct pbias_of_data pbias_of_data_omap2 = { | ||
112 | .offset = 0x230, | ||
113 | }; | ||
114 | |||
115 | static const struct pbias_of_data pbias_of_data_omap3 = { | ||
116 | .offset = 0x2b0, | ||
117 | }; | ||
118 | |||
119 | static const struct pbias_of_data pbias_of_data_omap4 = { | ||
120 | .offset = 0x60, | ||
121 | }; | ||
122 | |||
123 | static const struct pbias_of_data pbias_of_data_omap5 = { | ||
124 | .offset = 0x60, | ||
125 | }; | ||
126 | |||
127 | static const struct pbias_of_data pbias_of_data_dra7 = { | ||
128 | .offset = 0xe00, | ||
129 | }; | ||
130 | |||
105 | static const struct of_device_id pbias_of_match[] = { | 131 | static const struct of_device_id pbias_of_match[] = { |
106 | { .compatible = "ti,pbias-omap", }, | 132 | { .compatible = "ti,pbias-omap", }, |
133 | { .compatible = "ti,pbias-omap2", .data = &pbias_of_data_omap2, }, | ||
134 | { .compatible = "ti,pbias-omap3", .data = &pbias_of_data_omap3, }, | ||
135 | { .compatible = "ti,pbias-omap4", .data = &pbias_of_data_omap4, }, | ||
136 | { .compatible = "ti,pbias-omap5", .data = &pbias_of_data_omap5, }, | ||
137 | { .compatible = "ti,pbias-dra7", .data = &pbias_of_data_dra7, }, | ||
107 | {}, | 138 | {}, |
108 | }; | 139 | }; |
109 | MODULE_DEVICE_TABLE(of, pbias_of_match); | 140 | MODULE_DEVICE_TABLE(of, pbias_of_match); |
@@ -118,6 +149,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
118 | const struct pbias_reg_info *info; | 149 | const struct pbias_reg_info *info; |
119 | int ret = 0; | 150 | int ret = 0; |
120 | int count, idx, data_idx = 0; | 151 | int count, idx, data_idx = 0; |
152 | const struct of_device_id *match; | ||
153 | const struct pbias_of_data *data; | ||
154 | unsigned int offset; | ||
121 | 155 | ||
122 | count = of_regulator_match(&pdev->dev, np, pbias_matches, | 156 | count = of_regulator_match(&pdev->dev, np, pbias_matches, |
123 | PBIAS_NUM_REGS); | 157 | PBIAS_NUM_REGS); |
@@ -133,6 +167,20 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
133 | if (IS_ERR(syscon)) | 167 | if (IS_ERR(syscon)) |
134 | return PTR_ERR(syscon); | 168 | return PTR_ERR(syscon); |
135 | 169 | ||
170 | match = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev); | ||
171 | if (match && match->data) { | ||
172 | data = match->data; | ||
173 | offset = data->offset; | ||
174 | } else { | ||
175 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
176 | if (!res) | ||
177 | return -EINVAL; | ||
178 | |||
179 | offset = res->start; | ||
180 | dev_WARN(&pdev->dev, | ||
181 | "using legacy dt data for pbias offset\n"); | ||
182 | } | ||
183 | |||
136 | cfg.regmap = syscon; | 184 | cfg.regmap = syscon; |
137 | cfg.dev = &pdev->dev; | 185 | cfg.dev = &pdev->dev; |
138 | 186 | ||
@@ -145,10 +193,6 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
145 | if (!info) | 193 | if (!info) |
146 | return -ENODEV; | 194 | return -ENODEV; |
147 | 195 | ||
148 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
149 | if (!res) | ||
150 | return -EINVAL; | ||
151 | |||
152 | drvdata[data_idx].syscon = syscon; | 196 | drvdata[data_idx].syscon = syscon; |
153 | drvdata[data_idx].info = info; | 197 | drvdata[data_idx].info = info; |
154 | drvdata[data_idx].desc.name = info->name; | 198 | drvdata[data_idx].desc.name = info->name; |
@@ -158,9 +202,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
158 | drvdata[data_idx].desc.volt_table = pbias_volt_table; | 202 | drvdata[data_idx].desc.volt_table = pbias_volt_table; |
159 | drvdata[data_idx].desc.n_voltages = 2; | 203 | drvdata[data_idx].desc.n_voltages = 2; |
160 | drvdata[data_idx].desc.enable_time = info->enable_time; | 204 | drvdata[data_idx].desc.enable_time = info->enable_time; |
161 | drvdata[data_idx].desc.vsel_reg = res->start; | 205 | drvdata[data_idx].desc.vsel_reg = offset; |
162 | drvdata[data_idx].desc.vsel_mask = info->vmode; | 206 | drvdata[data_idx].desc.vsel_mask = info->vmode; |
163 | drvdata[data_idx].desc.enable_reg = res->start; | 207 | drvdata[data_idx].desc.enable_reg = offset; |
164 | drvdata[data_idx].desc.enable_mask = info->enable_mask; | 208 | drvdata[data_idx].desc.enable_mask = info->enable_mask; |
165 | drvdata[data_idx].desc.enable_val = info->enable; | 209 | drvdata[data_idx].desc.enable_val = info->enable; |
166 | drvdata[data_idx].desc.disable_val = info->disable_val; | 210 | drvdata[data_idx].desc.disable_val = info->disable_val; |