aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorJean Pihet <j-pihet@ti.com>2012-10-04 12:47:11 -0400
committerKevin Hilman <khilman@ti.com>2012-10-15 18:22:24 -0400
commit98aed08e16c5f18d0c31fc07127bc163ccd0d04c (patch)
treea773c60cbfb39cd1b57fb2ff2d5eb7c5c157df84 /drivers/power
parent1bef60cc7c284fb3164a2b05e8c121ff0ef56a24 (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>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/avs/smartreflex.c54
1 files changed, 17 insertions, 37 deletions
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
131static void sr_set_clk_length(struct omap_sr *sr) 131static 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
173static 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
195static void sr_start_vddautocomp(struct omap_sr *sr) 170static 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