Skip to content

Commit 9dfd338

Browse files
broonieSamuel Ortiz
authored andcommitted
mfd: Use bulk read to fill WM8350 register cache
Some I2C controllers have high overheads for setting up I2C operations which makes the register cache setup on startup excessively slow since it does a lot of small transactions. Reduce this overhead by doing a bulk read of the entire register bank and filtering out what we don't need later. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
1 parent 22e2df7 commit 9dfd338

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎drivers/mfd/wm8350-core.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,25 +1238,28 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode)
12381238
}
12391239

12401240
wm8350->reg_cache =
1241-
kzalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL);
1241+
kmalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL);
12421242
if (wm8350->reg_cache == NULL)
12431243
return -ENOMEM;
12441244

12451245
/* Read the initial cache state back from the device - this is
12461246
* a PMIC so the device many not be in a virgin state and we
12471247
* can't rely on the silicon values.
12481248
*/
1249+
ret = wm8350->read_dev(wm8350, 0,
1250+
sizeof(u16) * (WM8350_MAX_REGISTER + 1),
1251+
wm8350->reg_cache);
1252+
if (ret < 0) {
1253+
dev_err(wm8350->dev,
1254+
"failed to read initial cache values\n");
1255+
goto out;
1256+
}
1257+
1258+
/* Mask out uncacheable/unreadable bits and the audio. */
12491259
for (i = 0; i < WM8350_MAX_REGISTER; i++) {
1250-
/* audio register range */
12511260
if (wm8350_reg_io_map[i].readable &&
12521261
(i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) {
1253-
ret = wm8350->read_dev(wm8350, i, 2, (char *)&value);
1254-
if (ret < 0) {
1255-
dev_err(wm8350->dev,
1256-
"failed to read initial cache value\n");
1257-
goto out;
1258-
}
1259-
value = be16_to_cpu(value);
1262+
value = be16_to_cpu(wm8350->reg_cache[i]);
12601263
value &= wm8350_reg_io_map[i].readable;
12611264
value &= ~wm8350_reg_io_map[i].vol;
12621265
wm8350->reg_cache[i] = value;

0 commit comments

Comments
 (0)