Lines Matching refs:cs35l56_base

21 int cs35l56_set_patch(struct cs35l56_base *cs35l56_base)  in cs35l56_set_patch()  argument
23 return regmap_register_patch(cs35l56_base->regmap, cs35l56_patch, in cs35l56_set_patch()
197 int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command) in cs35l56_mbox_send() argument
202 regmap_write(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, command); in cs35l56_mbox_send()
203 ret = regmap_read_poll_timeout(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, in cs35l56_mbox_send()
207 dev_warn(cs35l56_base->dev, "MBOX command %#x failed: %d\n", command, ret); in cs35l56_mbox_send()
215 int cs35l56_firmware_shutdown(struct cs35l56_base *cs35l56_base) in cs35l56_firmware_shutdown() argument
221 ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_SHUTDOWN); in cs35l56_firmware_shutdown()
225 if (cs35l56_base->rev < CS35L56_REVID_B0) in cs35l56_firmware_shutdown()
230 ret = regmap_read_poll_timeout(cs35l56_base->regmap, reg, in cs35l56_firmware_shutdown()
235 dev_err(cs35l56_base->dev, "Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n", in cs35l56_firmware_shutdown()
241 int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base) in cs35l56_wait_for_firmware_boot() argument
247 if (cs35l56_base->rev < CS35L56_REVID_B0) in cs35l56_wait_for_firmware_boot()
261 cs35l56_base->regmap, reg, &val); in cs35l56_wait_for_firmware_boot()
264 dev_err(cs35l56_base->dev, "Firmware boot timed out(%d): HALO_STATE=%#x\n", in cs35l56_wait_for_firmware_boot()
292 void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire) in cs35l56_system_reset() argument
298 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_system_reset()
299 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_system_reset()
308 regcache_cache_only(cs35l56_base->regmap, false); in cs35l56_system_reset()
312 int cs35l56_irq_request(struct cs35l56_base *cs35l56_base, int irq) in cs35l56_irq_request() argument
319 ret = devm_request_threaded_irq(cs35l56_base->dev, irq, NULL, cs35l56_irq, in cs35l56_irq_request()
321 "cs35l56", cs35l56_base); in cs35l56_irq_request()
323 cs35l56_base->irq = irq; in cs35l56_irq_request()
325 dev_err(cs35l56_base->dev, "Failed to get IRQ: %d\n", ret); in cs35l56_irq_request()
333 struct cs35l56_base *cs35l56_base = data; in cs35l56_irq() local
341 if (!cs35l56_base->init_done) in cs35l56_irq()
344 mutex_lock(&cs35l56_base->irq_lock); in cs35l56_irq()
346 rv = pm_runtime_resume_and_get(cs35l56_base->dev); in cs35l56_irq()
348 dev_err(cs35l56_base->dev, "irq: failed to get pm_runtime: %d\n", rv); in cs35l56_irq()
352 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_STATUS, &val); in cs35l56_irq()
354 dev_dbg(cs35l56_base->dev, "Spurious IRQ: no pending interrupt\n"); in cs35l56_irq()
359 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_1, &status1); in cs35l56_irq()
360 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_1, &mask1); in cs35l56_irq()
362 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_1, status1); in cs35l56_irq()
364 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_8, &status8); in cs35l56_irq()
365 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_8, &mask8); in cs35l56_irq()
367 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_8, status8); in cs35l56_irq()
369 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_20, &status20); in cs35l56_irq()
370 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, &mask20); in cs35l56_irq()
373 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); in cs35l56_irq()
375 dev_dbg(cs35l56_base->dev, "%s: %#x %#x\n", __func__, status1, status8); in cs35l56_irq()
382 dev_crit(cs35l56_base->dev, "Amp short error\n"); in cs35l56_irq()
385 dev_crit(cs35l56_base->dev, "Overtemp error\n"); in cs35l56_irq()
390 pm_runtime_put(cs35l56_base->dev); in cs35l56_irq()
392 mutex_unlock(&cs35l56_base->irq_lock); in cs35l56_irq()
398 int cs35l56_is_fw_reload_needed(struct cs35l56_base *cs35l56_base) in cs35l56_is_fw_reload_needed() argument
404 if (!cs35l56_base->fw_patched) in cs35l56_is_fw_reload_needed()
411 if (cs35l56_base->reset_gpio) in cs35l56_is_fw_reload_needed()
419 if (cs35l56_base->secured) in cs35l56_is_fw_reload_needed()
422 ret = pm_runtime_resume_and_get(cs35l56_base->dev); in cs35l56_is_fw_reload_needed()
424 dev_err(cs35l56_base->dev, "Failed to runtime_get: %d\n", ret); in cs35l56_is_fw_reload_needed()
428 ret = regmap_read(cs35l56_base->regmap, CS35L56_PROTECTION_STATUS, &val); in cs35l56_is_fw_reload_needed()
430 dev_err(cs35l56_base->dev, "Failed to read PROTECTION_STATUS: %d\n", ret); in cs35l56_is_fw_reload_needed()
434 pm_runtime_put_autosuspend(cs35l56_base->dev); in cs35l56_is_fw_reload_needed()
449 int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) in cs35l56_runtime_suspend_common() argument
454 if (!cs35l56_base->init_done) in cs35l56_runtime_suspend_common()
458 ret = regmap_read_poll_timeout(cs35l56_base->regmap, in cs35l56_runtime_suspend_common()
464 dev_warn(cs35l56_base->dev, "PS3 wait failed: %d\n", ret); in cs35l56_runtime_suspend_common()
467 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_4, CS35L56_OTP_BOOT_DONE_MASK); in cs35l56_runtime_suspend_common()
469 if (!cs35l56_base->can_hibernate) { in cs35l56_runtime_suspend_common()
470 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_suspend_common()
471 dev_dbg(cs35l56_base->dev, "Suspended: no hibernate"); in cs35l56_runtime_suspend_common()
480 cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE); in cs35l56_runtime_suspend_common()
486 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_suspend_common()
488 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_runtime_suspend_common()
492 dev_dbg(cs35l56_base->dev, "Suspended: hibernate"); in cs35l56_runtime_suspend_common()
498 int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_soundwire) in cs35l56_runtime_resume_common() argument
503 if (!cs35l56_base->init_done) in cs35l56_runtime_resume_common()
506 if (!cs35l56_base->can_hibernate) in cs35l56_runtime_resume_common()
514 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_runtime_resume_common()
522 regcache_cache_only(cs35l56_base->regmap, false); in cs35l56_runtime_resume_common()
524 ret = cs35l56_wait_for_firmware_boot(cs35l56_base); in cs35l56_runtime_resume_common()
526 dev_err(cs35l56_base->dev, "Hibernate wake failed: %d\n", ret); in cs35l56_runtime_resume_common()
530 ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE); in cs35l56_runtime_resume_common()
535 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_4, &val); in cs35l56_runtime_resume_common()
537 dev_dbg(cs35l56_base->dev, "Registers reset in suspend\n"); in cs35l56_runtime_resume_common()
538 regcache_mark_dirty(cs35l56_base->regmap); in cs35l56_runtime_resume_common()
541 regcache_sync(cs35l56_base->regmap); in cs35l56_runtime_resume_common()
543 dev_dbg(cs35l56_base->dev, "Resumed"); in cs35l56_runtime_resume_common()
548 regmap_write(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, in cs35l56_runtime_resume_common()
551 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_resume_common()
565 void cs35l56_init_cs_dsp(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp) in cs35l56_init_cs_dsp() argument
570 cs_dsp->dev = cs35l56_base->dev; in cs35l56_init_cs_dsp()
571 cs_dsp->regmap = cs35l56_base->regmap; in cs35l56_init_cs_dsp()
580 int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) in cs35l56_hw_init() argument
589 if (!cs35l56_base->reset_gpio) in cs35l56_hw_init()
590 regmap_read(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, &devid); in cs35l56_hw_init()
599 ret = regmap_read(cs35l56_base->regmap, CS35L56_REVID, &revid); in cs35l56_hw_init()
601 dev_err(cs35l56_base->dev, "Get Revision ID failed\n"); in cs35l56_hw_init()
604 cs35l56_base->rev = revid & (CS35L56_AREVID_MASK | CS35L56_MTLREVID_MASK); in cs35l56_hw_init()
606 ret = cs35l56_wait_for_firmware_boot(cs35l56_base); in cs35l56_hw_init()
610 ret = regmap_read(cs35l56_base->regmap, CS35L56_DEVID, &devid); in cs35l56_hw_init()
612 dev_err(cs35l56_base->dev, "Get Device ID failed\n"); in cs35l56_hw_init()
621 dev_err(cs35l56_base->dev, "Unknown device %x\n", devid); in cs35l56_hw_init()
625 ret = regmap_read(cs35l56_base->regmap, CS35L56_DSP_RESTRICT_STS1, &secured); in cs35l56_hw_init()
627 dev_err(cs35l56_base->dev, "Get Secure status failed\n"); in cs35l56_hw_init()
633 cs35l56_base->secured = true; in cs35l56_hw_init()
635 ret = regmap_read(cs35l56_base->regmap, CS35L56_OTPID, &otpid); in cs35l56_hw_init()
637 dev_err(cs35l56_base->dev, "Get OTP ID failed\n"); in cs35l56_hw_init()
641 dev_info(cs35l56_base->dev, "Cirrus Logic CS35L56%s Rev %02X OTP%d\n", in cs35l56_hw_init()
642 cs35l56_base->secured ? "s" : "", cs35l56_base->rev, otpid); in cs35l56_hw_init()
645 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); in cs35l56_hw_init()
646 regmap_update_bits(cs35l56_base->regmap, CS35L56_IRQ1_MASK_1, in cs35l56_hw_init()
649 regmap_update_bits(cs35l56_base->regmap, CS35L56_IRQ1_MASK_8, in cs35l56_hw_init()