18 #include <linux/module.h>
22 #include <linux/slab.h>
29 static const char *wm5102_core_supplies[] = {
94 dev_err(arizona->
dev,
"Failed to read underclock status: %d\n",
106 dev_err(arizona->
dev,
"ISRC2 underclocked\n");
108 dev_err(arizona->
dev,
"ISRC1 underclocked\n");
118 dev_err(arizona->
dev,
"Mixer underclocked\n");
123 static irqreturn_t arizona_overclocked(
int irq,
void *data)
125 struct arizona *arizona =
data;
132 dev_err(arizona->
dev,
"Failed to read overclock status: %d\n",
140 dev_err(arizona->
dev,
"FX core overclocked\n");
142 dev_err(arizona->
dev,
"DAC SYS overclocked\n");
144 dev_err(arizona->
dev,
"DAC WARP overclocked\n");
156 dev_err(arizona->
dev,
"Pad control overclocked\n");
159 dev_err(arizona->
dev,
"Slimbus subsystem overclocked\n");
161 dev_err(arizona->
dev,
"Slimbus async overclocked\n");
163 dev_err(arizona->
dev,
"Slimbus sync overclocked\n");
165 dev_err(arizona->
dev,
"ASRC async system overclocked\n");
167 dev_err(arizona->
dev,
"ASRC async WARP overclocked\n");
169 dev_err(arizona->
dev,
"ASRC sync system overclocked\n");
171 dev_err(arizona->
dev,
"ASRC sync WARP overclocked\n");
182 static int arizona_wait_for_boot(
struct arizona *arizona)
192 for (i = 0; i < 5; i++) {
198 dev_err(arizona->
dev,
"Failed to read boot state: %d\n",
209 ARIZONA_BOOT_DONE_STS);
211 dev_err(arizona->
dev,
"Device boot timed out: %x\n", reg);
215 pm_runtime_mark_last_busy(arizona->
dev);
220 #ifdef CONFIG_PM_RUNTIME
221 static int arizona_runtime_resume(
struct device *
dev)
230 dev_err(arizona->
dev,
"Failed to enable DCVDD: %d\n", ret);
236 ret = arizona_wait_for_boot(arizona);
247 static int arizona_runtime_suspend(
struct device *dev)
263 arizona_runtime_resume,
268 static struct mfd_cell early_devs[] = {
269 { .name =
"arizona-ldo1" },
272 static struct mfd_cell wm5102_devs[] = {
273 { .name =
"arizona-extcon" },
274 { .name =
"arizona-gpio" },
275 { .name =
"arizona-micsupp" },
276 { .name =
"arizona-pwm" },
277 { .name =
"wm5102-codec" },
280 static struct mfd_cell wm5110_devs[] = {
281 { .name =
"arizona-extcon" },
282 { .name =
"arizona-gpio" },
283 { .name =
"arizona-micsupp" },
284 { .name =
"arizona-pwm" },
285 { .name =
"wm5110-codec" },
291 const char *type_name;
298 if (dev_get_platdata(arizona->
dev))
300 sizeof(arizona->
pdata));
304 switch (arizona->
type) {
307 for (i = 0; i <
ARRAY_SIZE(wm5102_core_supplies); i++)
309 = wm5102_core_supplies[i];
313 dev_err(arizona->
dev,
"Unknown device type %d\n",
321 dev_err(dev,
"Failed to add early children: %d\n", ret);
328 dev_err(dev,
"Failed to request core supplies: %d\n",
334 if (IS_ERR(arizona->
dcvdd)) {
335 ret = PTR_ERR(arizona->
dcvdd);
336 dev_err(dev,
"Failed to request DCVDD: %d\n", ret);
343 dev_err(dev,
"Failed to enable core supplies: %d\n",
350 dev_err(dev,
"Failed to enable DCVDD: %d\n", ret);
354 if (arizona->
pdata.reset) {
360 dev_err(dev,
"Failed to request /RESET: %d\n", ret);
371 dev_err(dev,
"Failed to read ID register: %d\n", ret);
378 dev_err(dev,
"Failed to read revision register: %d\n", ret);
384 #ifdef CONFIG_MFD_WM5102
386 type_name =
"WM5102";
388 dev_err(arizona->
dev,
"WM5102 registered as %d\n",
395 #ifdef CONFIG_MFD_WM5110
397 type_name =
"WM5110";
399 dev_err(arizona->
dev,
"WM5110 registered as %d\n",
407 dev_err(arizona->
dev,
"Unknown device ID %x\n", reg);
411 dev_info(dev,
"%s revision %c\n", type_name, arizona->
rev +
'A');
414 dev_err(arizona->
dev,
"Failed to apply patch: %d\n", ret);
417 if (!arizona->
pdata.reset) {
422 dev_err(dev,
"Failed to reset device: %d\n", ret);
428 dev_err(dev,
"Failed to sync device: %d\n", ret);
433 ret = arizona_wait_for_boot(arizona);
435 dev_err(arizona->
dev,
"Device failed initial boot: %d\n", ret);
440 if (!arizona->
pdata.gpio_defaults[i])
444 arizona->
pdata.gpio_defaults[i]);
448 pm_runtime_use_autosuspend(arizona->
dev);
452 if (!arizona->
pdata.clk32k_src)
455 switch (arizona->
pdata.clk32k_src) {
460 arizona->
pdata.clk32k_src - 1);
467 dev_err(arizona->
dev,
"Invalid 32kHz clock source: %d\n",
468 arizona->
pdata.clk32k_src);
475 val = arizona->
pdata.dmic_ref[
i]
487 if (arizona->
pdata.out_mono[i])
498 if (arizona->
pdata.spk_mute[i])
503 arizona->
pdata.spk_mute[i]);
505 if (arizona->
pdata.spk_fmt[i])
509 arizona->
pdata.spk_fmt[i]);
518 arizona_clkgen_err, arizona);
520 arizona_overclocked, arizona);
522 arizona_underclocked, arizona);
524 switch (arizona->
type) {
527 ARRAY_SIZE(wm5102_devs),
NULL, 0,
NULL);
531 ARRAY_SIZE(wm5110_devs),
NULL, 0,
NULL);
536 dev_err(arizona->
dev,
"Failed to add subdevices: %d\n", ret);
540 #ifdef CONFIG_PM_RUNTIME
549 if (arizona->
pdata.reset) {
570 pm_runtime_disable(arizona->
dev);