Lines Matching refs:cs35l56_base
22 int cs35l56_set_patch(struct cs35l56_base *cs35l56_base) in cs35l56_set_patch() argument
24 return regmap_register_patch(cs35l56_base->regmap, cs35l56_patch, in cs35l56_set_patch()
203 int cs35l56_force_sync_asp1_registers_from_cache(struct cs35l56_base *cs35l56_base) in cs35l56_force_sync_asp1_registers_from_cache() argument
219 ret = regmap_read(cs35l56_base->regmap, asp1_regs[i].reg, &asp1_regs[i].def); in cs35l56_force_sync_asp1_registers_from_cache()
225 ret = regmap_multi_reg_write_bypassed(cs35l56_base->regmap, asp1_regs, in cs35l56_force_sync_asp1_registers_from_cache()
233 dev_err(cs35l56_base->dev, "Failed to sync ASP1 registers: %d\n", ret); in cs35l56_force_sync_asp1_registers_from_cache()
239 int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command) in cs35l56_mbox_send() argument
244 regmap_write(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, command); in cs35l56_mbox_send()
245 ret = regmap_read_poll_timeout(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, in cs35l56_mbox_send()
249 dev_warn(cs35l56_base->dev, "MBOX command %#x failed: %d\n", command, ret); in cs35l56_mbox_send()
257 int cs35l56_firmware_shutdown(struct cs35l56_base *cs35l56_base) in cs35l56_firmware_shutdown() argument
263 ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_SHUTDOWN); in cs35l56_firmware_shutdown()
267 if (cs35l56_base->rev < CS35L56_REVID_B0) in cs35l56_firmware_shutdown()
272 ret = regmap_read_poll_timeout(cs35l56_base->regmap, reg, in cs35l56_firmware_shutdown()
277 dev_err(cs35l56_base->dev, "Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n", in cs35l56_firmware_shutdown()
283 int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base) in cs35l56_wait_for_firmware_boot() argument
289 if (cs35l56_base->rev < CS35L56_REVID_B0) in cs35l56_wait_for_firmware_boot()
303 cs35l56_base->regmap, reg, &val); in cs35l56_wait_for_firmware_boot()
306 dev_err(cs35l56_base->dev, "Firmware boot timed out(%d): HALO_STATE=%#x\n", in cs35l56_wait_for_firmware_boot()
334 void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire) in cs35l56_system_reset() argument
340 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_system_reset()
341 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_system_reset()
350 regcache_cache_only(cs35l56_base->regmap, false); in cs35l56_system_reset()
354 int cs35l56_irq_request(struct cs35l56_base *cs35l56_base, int irq) in cs35l56_irq_request() argument
361 ret = devm_request_threaded_irq(cs35l56_base->dev, irq, NULL, cs35l56_irq, in cs35l56_irq_request()
363 "cs35l56", cs35l56_base); in cs35l56_irq_request()
365 cs35l56_base->irq = irq; in cs35l56_irq_request()
367 dev_err(cs35l56_base->dev, "Failed to get IRQ: %d\n", ret); in cs35l56_irq_request()
375 struct cs35l56_base *cs35l56_base = data; in cs35l56_irq() local
383 if (!cs35l56_base->init_done) in cs35l56_irq()
386 mutex_lock(&cs35l56_base->irq_lock); in cs35l56_irq()
388 rv = pm_runtime_resume_and_get(cs35l56_base->dev); in cs35l56_irq()
390 dev_err(cs35l56_base->dev, "irq: failed to get pm_runtime: %d\n", rv); in cs35l56_irq()
394 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_STATUS, &val); in cs35l56_irq()
396 dev_dbg(cs35l56_base->dev, "Spurious IRQ: no pending interrupt\n"); in cs35l56_irq()
401 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_1, &status1); in cs35l56_irq()
402 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_1, &mask1); in cs35l56_irq()
404 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_1, status1); in cs35l56_irq()
406 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_8, &status8); in cs35l56_irq()
407 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_8, &mask8); in cs35l56_irq()
409 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_8, status8); in cs35l56_irq()
411 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_20, &status20); in cs35l56_irq()
412 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, &mask20); in cs35l56_irq()
415 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); in cs35l56_irq()
417 dev_dbg(cs35l56_base->dev, "%s: %#x %#x\n", __func__, status1, status8); in cs35l56_irq()
424 dev_crit(cs35l56_base->dev, "Amp short error\n"); in cs35l56_irq()
427 dev_crit(cs35l56_base->dev, "Overtemp error\n"); in cs35l56_irq()
432 pm_runtime_put(cs35l56_base->dev); in cs35l56_irq()
434 mutex_unlock(&cs35l56_base->irq_lock); in cs35l56_irq()
440 int cs35l56_is_fw_reload_needed(struct cs35l56_base *cs35l56_base) in cs35l56_is_fw_reload_needed() argument
446 if (!cs35l56_base->fw_patched) in cs35l56_is_fw_reload_needed()
453 if (cs35l56_base->reset_gpio) in cs35l56_is_fw_reload_needed()
461 if (cs35l56_base->secured) in cs35l56_is_fw_reload_needed()
464 ret = pm_runtime_resume_and_get(cs35l56_base->dev); in cs35l56_is_fw_reload_needed()
466 dev_err(cs35l56_base->dev, "Failed to runtime_get: %d\n", ret); in cs35l56_is_fw_reload_needed()
470 ret = regmap_read(cs35l56_base->regmap, CS35L56_PROTECTION_STATUS, &val); in cs35l56_is_fw_reload_needed()
472 dev_err(cs35l56_base->dev, "Failed to read PROTECTION_STATUS: %d\n", ret); in cs35l56_is_fw_reload_needed()
476 pm_runtime_put_autosuspend(cs35l56_base->dev); in cs35l56_is_fw_reload_needed()
491 int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) in cs35l56_runtime_suspend_common() argument
496 if (!cs35l56_base->init_done) in cs35l56_runtime_suspend_common()
500 ret = regmap_read_poll_timeout(cs35l56_base->regmap, in cs35l56_runtime_suspend_common()
506 dev_warn(cs35l56_base->dev, "PS3 wait failed: %d\n", ret); in cs35l56_runtime_suspend_common()
509 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_4, CS35L56_OTP_BOOT_DONE_MASK); in cs35l56_runtime_suspend_common()
511 if (!cs35l56_base->can_hibernate) { in cs35l56_runtime_suspend_common()
512 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_suspend_common()
513 dev_dbg(cs35l56_base->dev, "Suspended: no hibernate"); in cs35l56_runtime_suspend_common()
522 cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE); in cs35l56_runtime_suspend_common()
528 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_suspend_common()
530 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_runtime_suspend_common()
534 dev_dbg(cs35l56_base->dev, "Suspended: hibernate"); in cs35l56_runtime_suspend_common()
540 int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_soundwire) in cs35l56_runtime_resume_common() argument
545 if (!cs35l56_base->init_done) in cs35l56_runtime_resume_common()
548 if (!cs35l56_base->can_hibernate) in cs35l56_runtime_resume_common()
556 regmap_multi_reg_write_bypassed(cs35l56_base->regmap, in cs35l56_runtime_resume_common()
564 regcache_cache_only(cs35l56_base->regmap, false); in cs35l56_runtime_resume_common()
566 ret = cs35l56_wait_for_firmware_boot(cs35l56_base); in cs35l56_runtime_resume_common()
568 dev_err(cs35l56_base->dev, "Hibernate wake failed: %d\n", ret); in cs35l56_runtime_resume_common()
572 ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE); in cs35l56_runtime_resume_common()
577 regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_EINT_4, &val); in cs35l56_runtime_resume_common()
579 dev_dbg(cs35l56_base->dev, "Registers reset in suspend\n"); in cs35l56_runtime_resume_common()
580 regcache_mark_dirty(cs35l56_base->regmap); in cs35l56_runtime_resume_common()
583 regcache_sync(cs35l56_base->regmap); in cs35l56_runtime_resume_common()
585 dev_dbg(cs35l56_base->dev, "Resumed"); in cs35l56_runtime_resume_common()
590 regmap_write(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, in cs35l56_runtime_resume_common()
593 regcache_cache_only(cs35l56_base->regmap, true); in cs35l56_runtime_resume_common()
607 void cs35l56_init_cs_dsp(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp) in cs35l56_init_cs_dsp() argument
612 cs_dsp->dev = cs35l56_base->dev; in cs35l56_init_cs_dsp()
613 cs_dsp->regmap = cs35l56_base->regmap; in cs35l56_init_cs_dsp()
622 int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) in cs35l56_hw_init() argument
631 if (!cs35l56_base->reset_gpio) in cs35l56_hw_init()
632 regmap_read(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, &devid); in cs35l56_hw_init()
641 ret = regmap_read(cs35l56_base->regmap, CS35L56_REVID, &revid); in cs35l56_hw_init()
643 dev_err(cs35l56_base->dev, "Get Revision ID failed\n"); in cs35l56_hw_init()
646 cs35l56_base->rev = revid & (CS35L56_AREVID_MASK | CS35L56_MTLREVID_MASK); in cs35l56_hw_init()
648 ret = cs35l56_wait_for_firmware_boot(cs35l56_base); in cs35l56_hw_init()
652 ret = regmap_read(cs35l56_base->regmap, CS35L56_DEVID, &devid); in cs35l56_hw_init()
654 dev_err(cs35l56_base->dev, "Get Device ID failed\n"); in cs35l56_hw_init()
663 dev_err(cs35l56_base->dev, "Unknown device %x\n", devid); in cs35l56_hw_init()
667 ret = regmap_read(cs35l56_base->regmap, CS35L56_DSP_RESTRICT_STS1, &secured); in cs35l56_hw_init()
669 dev_err(cs35l56_base->dev, "Get Secure status failed\n"); in cs35l56_hw_init()
675 cs35l56_base->secured = true; in cs35l56_hw_init()
677 ret = regmap_read(cs35l56_base->regmap, CS35L56_OTPID, &otpid); in cs35l56_hw_init()
679 dev_err(cs35l56_base->dev, "Get OTP ID failed\n"); in cs35l56_hw_init()
683 dev_info(cs35l56_base->dev, "Cirrus Logic CS35L56%s Rev %02X OTP%d\n", in cs35l56_hw_init()
684 cs35l56_base->secured ? "s" : "", cs35l56_base->rev, otpid); in cs35l56_hw_init()
687 regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); in cs35l56_hw_init()
688 regmap_update_bits(cs35l56_base->regmap, CS35L56_IRQ1_MASK_1, in cs35l56_hw_init()
691 regmap_update_bits(cs35l56_base->regmap, CS35L56_IRQ1_MASK_8, in cs35l56_hw_init()
699 int cs35l56_get_speaker_id(struct cs35l56_base *cs35l56_base) in cs35l56_get_speaker_id() argument
706 descs = gpiod_get_array_optional(cs35l56_base->dev, "spk-id", GPIOD_IN); in cs35l56_get_speaker_id()
711 return dev_err_probe(cs35l56_base->dev, ret, "Failed to get spk-id-gpios\n"); in cs35l56_get_speaker_id()
718 dev_err_probe(cs35l56_base->dev, ret, "Failed to read spk-id[%d]\n", i); in cs35l56_get_speaker_id()
725 dev_dbg(cs35l56_base->dev, "Speaker ID = %d\n", speaker_id); in cs35l56_get_speaker_id()