diff options
author | Jean Pihet <j-pihet@ti.com> | 2012-10-04 12:47:11 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2012-10-15 18:22:24 -0400 |
commit | 98aed08e16c5f18d0c31fc07127bc163ccd0d04c (patch) | |
tree | a773c60cbfb39cd1b57fb2ff2d5eb7c5c157df84 | |
parent | 1bef60cc7c284fb3164a2b05e8c121ff0ef56a24 (diff) |
ARM: OMAP: SmartReflex: pass device dependent data via platform data
Remove the device dependent code (ex. cpu_is_xxx()) and settings
from the driver code and instead pass them via the platform
data. This allows a clean separation of the driver code and the platform
code, as required by the move of the platform header files to
include/linux/platform_data.
Note about the smartreflex functional clocks: the smartreflex fclks
are derived from sys_clk and have the same name as the main_clk from
the hwmod entry, in order for the SmartReflex driver to request the
fclk (using clk_get(dev, "fck")).
Signed-off-by: Jean Pihet <j-pihet@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/sr_device.c | 13 | ||||
-rw-r--r-- | drivers/power/avs/smartreflex.c | 54 | ||||
-rw-r--r-- | include/linux/power/smartreflex.h | 14 |
3 files changed, 42 insertions, 39 deletions
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c index f8217a5a4a26..a04bc25a1d26 100644 --- a/arch/arm/mach-omap2/sr_device.c +++ b/arch/arm/mach-omap2/sr_device.c | |||
@@ -121,6 +121,19 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user) | |||
121 | sr_data->senn_mod = 0x1; | 121 | sr_data->senn_mod = 0x1; |
122 | sr_data->senp_mod = 0x1; | 122 | sr_data->senp_mod = 0x1; |
123 | 123 | ||
124 | if (cpu_is_omap34xx() || cpu_is_omap44xx()) { | ||
125 | sr_data->err_weight = OMAP3430_SR_ERRWEIGHT; | ||
126 | sr_data->err_maxlimit = OMAP3430_SR_ERRMAXLIMIT; | ||
127 | sr_data->accum_data = OMAP3430_SR_ACCUMDATA; | ||
128 | if (!(strcmp(sr_data->name, "smartreflex_mpu"))) { | ||
129 | sr_data->senn_avgweight = OMAP3430_SR1_SENNAVGWEIGHT; | ||
130 | sr_data->senp_avgweight = OMAP3430_SR1_SENPAVGWEIGHT; | ||
131 | } else { | ||
132 | sr_data->senn_avgweight = OMAP3430_SR2_SENNAVGWEIGHT; | ||
133 | sr_data->senp_avgweight = OMAP3430_SR2_SENPAVGWEIGHT; | ||
134 | } | ||
135 | } | ||
136 | |||
124 | sr_data->voltdm = voltdm_lookup(sr_dev_attr->sensor_voltdm_name); | 137 | sr_data->voltdm = voltdm_lookup(sr_dev_attr->sensor_voltdm_name); |
125 | if (!sr_data->voltdm) { | 138 | if (!sr_data->voltdm) { |
126 | pr_err("%s: Unable to get voltage domain pointer for VDD %s\n", | 139 | pr_err("%s: Unable to get voltage domain pointer for VDD %s\n", |
diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c index 24768a27e1d8..4c4519e59be4 100644 --- a/drivers/power/avs/smartreflex.c +++ b/drivers/power/avs/smartreflex.c | |||
@@ -130,24 +130,21 @@ static irqreturn_t sr_interrupt(int irq, void *data) | |||
130 | 130 | ||
131 | static void sr_set_clk_length(struct omap_sr *sr) | 131 | static void sr_set_clk_length(struct omap_sr *sr) |
132 | { | 132 | { |
133 | struct clk *sys_ck; | 133 | struct clk *fck; |
134 | u32 sys_clk_speed; | 134 | u32 fclk_speed; |
135 | 135 | ||
136 | if (cpu_is_omap34xx()) | 136 | fck = clk_get(&sr->pdev->dev, "fck"); |
137 | sys_ck = clk_get(NULL, "sys_ck"); | ||
138 | else | ||
139 | sys_ck = clk_get(NULL, "sys_clkin_ck"); | ||
140 | 137 | ||
141 | if (IS_ERR(sys_ck)) { | 138 | if (IS_ERR(fck)) { |
142 | dev_err(&sr->pdev->dev, "%s: unable to get sys clk\n", | 139 | dev_err(&sr->pdev->dev, "%s: unable to get fck for device %s\n", |
143 | __func__); | 140 | __func__, dev_name(&sr->pdev->dev)); |
144 | return; | 141 | return; |
145 | } | 142 | } |
146 | 143 | ||
147 | sys_clk_speed = clk_get_rate(sys_ck); | 144 | fclk_speed = clk_get_rate(fck); |
148 | clk_put(sys_ck); | 145 | clk_put(fck); |
149 | 146 | ||
150 | switch (sys_clk_speed) { | 147 | switch (fclk_speed) { |
151 | case 12000000: | 148 | case 12000000: |
152 | sr->clk_length = SRCLKLENGTH_12MHZ_SYSCLK; | 149 | sr->clk_length = SRCLKLENGTH_12MHZ_SYSCLK; |
153 | break; | 150 | break; |
@@ -164,34 +161,12 @@ static void sr_set_clk_length(struct omap_sr *sr) | |||
164 | sr->clk_length = SRCLKLENGTH_38MHZ_SYSCLK; | 161 | sr->clk_length = SRCLKLENGTH_38MHZ_SYSCLK; |
165 | break; | 162 | break; |
166 | default: | 163 | default: |
167 | dev_err(&sr->pdev->dev, "%s: Invalid sysclk value: %d\n", | 164 | dev_err(&sr->pdev->dev, "%s: Invalid fclk rate: %d\n", |
168 | __func__, sys_clk_speed); | 165 | __func__, fclk_speed); |
169 | break; | 166 | break; |
170 | } | 167 | } |
171 | } | 168 | } |
172 | 169 | ||
173 | static void sr_set_regfields(struct omap_sr *sr) | ||
174 | { | ||
175 | /* | ||
176 | * For time being these values are defined in smartreflex.h | ||
177 | * and populated during init. May be they can be moved to board | ||
178 | * file or pmic specific data structure. In that case these structure | ||
179 | * fields will have to be populated using the pdata or pmic structure. | ||
180 | */ | ||
181 | if (cpu_is_omap34xx() || cpu_is_omap44xx()) { | ||
182 | sr->err_weight = OMAP3430_SR_ERRWEIGHT; | ||
183 | sr->err_maxlimit = OMAP3430_SR_ERRMAXLIMIT; | ||
184 | sr->accum_data = OMAP3430_SR_ACCUMDATA; | ||
185 | if (!(strcmp(sr->name, "smartreflex_mpu_iva"))) { | ||
186 | sr->senn_avgweight = OMAP3430_SR1_SENNAVGWEIGHT; | ||
187 | sr->senp_avgweight = OMAP3430_SR1_SENPAVGWEIGHT; | ||
188 | } else { | ||
189 | sr->senn_avgweight = OMAP3430_SR2_SENNAVGWEIGHT; | ||
190 | sr->senp_avgweight = OMAP3430_SR2_SENPAVGWEIGHT; | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | static void sr_start_vddautocomp(struct omap_sr *sr) | 170 | static void sr_start_vddautocomp(struct omap_sr *sr) |
196 | { | 171 | { |
197 | if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) { | 172 | if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) { |
@@ -924,8 +899,14 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
924 | sr_info->nvalue_count = pdata->nvalue_count; | 899 | sr_info->nvalue_count = pdata->nvalue_count; |
925 | sr_info->senn_mod = pdata->senn_mod; | 900 | sr_info->senn_mod = pdata->senn_mod; |
926 | sr_info->senp_mod = pdata->senp_mod; | 901 | sr_info->senp_mod = pdata->senp_mod; |
902 | sr_info->err_weight = pdata->err_weight; | ||
903 | sr_info->err_maxlimit = pdata->err_maxlimit; | ||
904 | sr_info->accum_data = pdata->accum_data; | ||
905 | sr_info->senn_avgweight = pdata->senn_avgweight; | ||
906 | sr_info->senp_avgweight = pdata->senp_avgweight; | ||
927 | sr_info->autocomp_active = false; | 907 | sr_info->autocomp_active = false; |
928 | sr_info->ip_type = pdata->ip_type; | 908 | sr_info->ip_type = pdata->ip_type; |
909 | |||
929 | sr_info->base = ioremap(mem->start, resource_size(mem)); | 910 | sr_info->base = ioremap(mem->start, resource_size(mem)); |
930 | if (!sr_info->base) { | 911 | if (!sr_info->base) { |
931 | dev_err(&pdev->dev, "%s: ioremap fail\n", __func__); | 912 | dev_err(&pdev->dev, "%s: ioremap fail\n", __func__); |
@@ -937,7 +918,6 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
937 | sr_info->irq = irq->start; | 918 | sr_info->irq = irq->start; |
938 | 919 | ||
939 | sr_set_clk_length(sr_info); | 920 | sr_set_clk_length(sr_info); |
940 | sr_set_regfields(sr_info); | ||
941 | 921 | ||
942 | list_add(&sr_info->node, &sr_list); | 922 | list_add(&sr_info->node, &sr_list); |
943 | 923 | ||
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h index 4a496ebc7d73..c0f44c2b006d 100644 --- a/include/linux/power/smartreflex.h +++ b/include/linux/power/smartreflex.h | |||
@@ -260,8 +260,13 @@ struct omap_sr_nvalue_table { | |||
260 | * | 260 | * |
261 | * @name: instance name | 261 | * @name: instance name |
262 | * @ip_type: Smartreflex IP type. | 262 | * @ip_type: Smartreflex IP type. |
263 | * @senp_mod: SENPENABLE value for the sr | 263 | * @senp_mod: SENPENABLE value of the sr CONFIG register |
264 | * @senn_mod: SENNENABLE value for sr | 264 | * @senn_mod: SENNENABLE value for sr CONFIG register |
265 | * @err_weight ERRWEIGHT value of the sr ERRCONFIG register | ||
266 | * @err_maxlimit ERRMAXLIMIT value of the sr ERRCONFIG register | ||
267 | * @accum_data ACCUMDATA value of the sr CONFIG register | ||
268 | * @senn_avgweight SENNAVGWEIGHT value of the sr AVGWEIGHT register | ||
269 | * @senp_avgweight SENPAVGWEIGHT value of the sr AVGWEIGHT register | ||
265 | * @nvalue_count: Number of distinct nvalues in the nvalue table | 270 | * @nvalue_count: Number of distinct nvalues in the nvalue table |
266 | * @enable_on_init: whether this sr module needs to enabled at | 271 | * @enable_on_init: whether this sr module needs to enabled at |
267 | * boot up or not. | 272 | * boot up or not. |
@@ -274,6 +279,11 @@ struct omap_sr_data { | |||
274 | int ip_type; | 279 | int ip_type; |
275 | u32 senp_mod; | 280 | u32 senp_mod; |
276 | u32 senn_mod; | 281 | u32 senn_mod; |
282 | u32 err_weight; | ||
283 | u32 err_maxlimit; | ||
284 | u32 accum_data; | ||
285 | u32 senn_avgweight; | ||
286 | u32 senp_avgweight; | ||
277 | int nvalue_count; | 287 | int nvalue_count; |
278 | bool enable_on_init; | 288 | bool enable_on_init; |
279 | struct omap_sr_nvalue_table *nvalue_table; | 289 | struct omap_sr_nvalue_table *nvalue_table; |