Skip to content

Commit 5e7f2e1

Browse files
Jean PihetKevin Hilman
authored andcommitted
ARM: OMAP2+: SmartReflex: Use per-OPP data structure
The SmartReflex driver incorrectly treats some per-OPP data as data common to all OPPs (e.g., ERRMINLIMIT). Move this data into a per-OPP data structure. Furthermore, in order to make the SmartReflex implementation ready for the move to drivers/, remove the dependency from the SR driver code to the voltage layer by querying the data tables only from the SR device init code. Based on Paul's original code for the SmartReflex driver conversion. Signed-off-by: Jean Pihet <j-pihet@ti.com> Signed-off-by: J Keerthy <j-keerthy@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
1 parent fa60be6 commit 5e7f2e1

3 files changed

Lines changed: 54 additions & 28 deletions

File tree

‎arch/arm/mach-omap2/smartreflex.c‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -347,22 +347,23 @@ static void sr_v2_disable(struct omap_sr *sr)
347347
sr_write_reg(sr, IRQSTATUS, IRQSTATUS_MCUDISABLEACKINT);
348348
}
349349

350-
static u32 sr_retrieve_nvalue(struct omap_sr *sr, u32 efuse_offs)
350+
static struct omap_sr_nvalue_table *sr_retrieve_nvalue_row(
351+
struct omap_sr *sr, u32 efuse_offs)
351352
{
352353
int i;
353354

354355
if (!sr->nvalue_table) {
355356
dev_warn(&sr->pdev->dev, "%s: Missing ntarget value table\n",
356357
__func__);
357-
return 0;
358+
return NULL;
358359
}
359360

360361
for (i = 0; i < sr->nvalue_count; i++) {
361362
if (sr->nvalue_table[i].efuse_offs == efuse_offs)
362-
return sr->nvalue_table[i].nvalue;
363+
return &sr->nvalue_table[i];
363364
}
364365

365-
return 0;
366+
return NULL;
366367
}
367368

368369
/* Public Functions */
@@ -586,7 +587,7 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
586587
{
587588
struct omap_volt_data *volt_data;
588589
struct omap_sr *sr = _sr_lookup(voltdm);
589-
u32 nvalue_reciprocal;
590+
struct omap_sr_nvalue_table *nvalue_row;
590591
int ret;
591592

592593
if (IS_ERR(sr)) {
@@ -602,16 +603,16 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
602603
return PTR_ERR(volt_data);
603604
}
604605

605-
nvalue_reciprocal = sr_retrieve_nvalue(sr, volt_data->sr_efuse_offs);
606+
nvalue_row = sr_retrieve_nvalue_row(sr, volt_data->sr_efuse_offs);
606607

607-
if (!nvalue_reciprocal) {
608-
dev_warn(&sr->pdev->dev, "%s: NVALUE = 0 at voltage %ld\n",
609-
__func__, volt);
608+
if (!nvalue_row) {
609+
dev_warn(&sr->pdev->dev, "%s: failure getting SR data for this voltage %ld\n",
610+
__func__, volt);
610611
return -ENODATA;
611612
}
612613

613614
/* errminlimit is opp dependent and hence linked to voltage */
614-
sr->err_minlimit = volt_data->sr_errminlimit;
615+
sr->err_minlimit = nvalue_row->errminlimit;
615616

616617
pm_runtime_get_sync(&sr->pdev->dev);
617618

@@ -624,7 +625,7 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
624625
if (ret)
625626
return ret;
626627

627-
sr_write_reg(sr, NVALUERECIPROCAL, nvalue_reciprocal);
628+
sr_write_reg(sr, NVALUERECIPROCAL, nvalue_row->nvalue);
628629

629630
/* SRCONFIG - enable SR */
630631
sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, SRCONFIG_SRENABLE);
@@ -872,7 +873,6 @@ static int __init omap_sr_probe(struct platform_device *pdev)
872873
struct omap_sr_data *pdata = pdev->dev.platform_data;
873874
struct resource *mem, *irq;
874875
struct dentry *nvalue_dir;
875-
struct omap_volt_data *volt_data;
876876
int i, ret = 0;
877877

878878
sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
@@ -990,21 +990,19 @@ static int __init omap_sr_probe(struct platform_device *pdev)
990990
goto err_debugfs;
991991
}
992992

993-
omap_voltage_get_volttable(sr_info->voltdm, &volt_data);
994-
if (!volt_data) {
995-
dev_warn(&pdev->dev, "%s: %s: No Voltage table for the"
996-
" corresponding vdd. Cannot create debugfs"
997-
"entries for n-values\n",
998-
__func__, sr_info->name);
993+
if (sr_info->nvalue_count == 0 || !sr_info->nvalue_table) {
994+
dev_warn(&pdev->dev, "%s: %s: No Voltage table for the corresponding vdd. Cannot create debugfs entries for n-values\n",
995+
__func__, sr_info->name);
996+
999997
ret = -ENODATA;
1000998
goto err_debugfs;
1001999
}
10021000

10031001
for (i = 0; i < sr_info->nvalue_count; i++) {
10041002
char name[NVALUE_NAME_LEN + 1];
10051003

1006-
snprintf(name, sizeof(name), "volt_%d",
1007-
volt_data[i].volt_nominal);
1004+
snprintf(name, sizeof(name), "volt_%lu",
1005+
sr_info->nvalue_table[i].volt_nominal);
10081006
(void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
10091007
&(sr_info->nvalue_table[i].nvalue));
10101008
}

‎arch/arm/mach-omap2/sr_device.c‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,25 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
3636
struct omap_sr_data *sr_data)
3737
{
3838
struct omap_sr_nvalue_table *nvalue_table;
39-
int i, count = 0;
39+
int i, j, count = 0;
40+
41+
sr_data->nvalue_count = 0;
42+
sr_data->nvalue_table = NULL;
4043

4144
while (volt_data[count].volt_nominal)
4245
count++;
4346

4447
nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
4548
GFP_KERNEL);
4649

47-
for (i = 0; i < count; i++) {
50+
if (!nvalue_table) {
51+
pr_err("OMAP: SmartReflex: cannot allocate memory for n-value table\n");
52+
return;
53+
}
54+
55+
for (i = 0, j = 0; i < count; i++) {
4856
u32 v;
57+
4958
/*
5059
* In OMAP4 the efuse registers are 24 bit aligned.
5160
* A __raw_readl will fail for non-32 bit aligned address
@@ -58,15 +67,30 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
5867
omap_ctrl_readb(offset + 1) << 8 |
5968
omap_ctrl_readb(offset + 2) << 16;
6069
} else {
61-
v = omap_ctrl_readl(volt_data[i].sr_efuse_offs);
70+
v = omap_ctrl_readl(volt_data[i].sr_efuse_offs);
6271
}
6372

64-
nvalue_table[i].efuse_offs = volt_data[i].sr_efuse_offs;
65-
nvalue_table[i].nvalue = v;
73+
/*
74+
* Many OMAP SoCs don't have the eFuse values set.
75+
* For example, pretty much all OMAP3xxx before
76+
* ES3.something.
77+
*
78+
* XXX There needs to be some way for board files or
79+
* userspace to add these in.
80+
*/
81+
if (v == 0)
82+
continue;
83+
84+
nvalue_table[j].nvalue = v;
85+
nvalue_table[j].efuse_offs = volt_data[i].sr_efuse_offs;
86+
nvalue_table[j].errminlimit = volt_data[i].sr_errminlimit;
87+
nvalue_table[j].volt_nominal = volt_data[i].volt_nominal;
88+
89+
j++;
6690
}
6791

6892
sr_data->nvalue_table = nvalue_table;
69-
sr_data->nvalue_count = count;
93+
sr_data->nvalue_count = j;
7094
}
7195

7296
static int __init sr_dev_init(struct omap_hwmod *oh, void *user)

‎include/linux/power/smartreflex.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,16 @@ struct omap_sr_class_data {
243243
/**
244244
* struct omap_sr_nvalue_table - Smartreflex n-target value info
245245
*
246-
* @efuse_offs: The offset of the efuse where n-target values are stored.
247-
* @nvalue: The n-target value.
246+
* @efuse_offs: The offset of the efuse where n-target values are stored.
247+
* @nvalue: The n-target value.
248+
* @errminlimit: The value of the ERRMINLIMIT bitfield for this n-target
249+
* @volt_nominal: microvolts DC that the VDD is initially programmed to
248250
*/
249251
struct omap_sr_nvalue_table {
250252
u32 efuse_offs;
251253
u32 nvalue;
254+
u32 errminlimit;
255+
unsigned long volt_nominal;
252256
};
253257

254258
/**

0 commit comments

Comments
 (0)