Lines Matching refs:wm0010
159 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_halt() local
164 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_halt()
165 state = wm0010->state; in wm0010_halt()
166 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_halt()
177 gpio_set_value_cansleep(wm0010->gpio_reset, in wm0010_halt()
178 wm0010->gpio_reset_value); in wm0010_halt()
180 regulator_disable(wm0010->dbvdd); in wm0010_halt()
181 regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies), in wm0010_halt()
182 wm0010->core_supplies); in wm0010_halt()
186 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_halt()
187 wm0010->state = WM0010_POWER_OFF; in wm0010_halt()
188 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_halt()
200 static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010) in wm0010_mark_boot_failure() argument
205 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_mark_boot_failure()
206 state = wm0010->state; in wm0010_mark_boot_failure()
207 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_mark_boot_failure()
209 dev_err(wm0010->dev, "Failed to transition from `%s' state to `%s' state\n", in wm0010_mark_boot_failure()
212 wm0010->boot_failed = true; in wm0010_mark_boot_failure()
219 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_boot_xfer_complete() local
226 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
239 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
243 if (wm0010->state < WM0010_STAGE2) in wm0010_boot_xfer_complete()
247 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
272 wm0010->pll_running = true; in wm0010_boot_xfer_complete()
277 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
282 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
287 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
292 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
297 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
302 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
307 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
316 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
322 wm0010_mark_boot_failure(wm0010); in wm0010_boot_xfer_complete()
326 if (wm0010->boot_failed) in wm0010_boot_xfer_complete()
345 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_firmware_load() local
370 wm0010->boot_failed = false; in wm0010_firmware_load()
440 if (!wm0010->pll_running) { in wm0010_firmware_load()
441 xfer->t.speed_hz = wm0010->sysclk / 6; in wm0010_firmware_load()
443 xfer->t.speed_hz = wm0010->max_spi_freq; in wm0010_firmware_load()
445 if (wm0010->board_max_spi_speed && in wm0010_firmware_load()
446 (wm0010->board_max_spi_speed < wm0010->max_spi_freq)) in wm0010_firmware_load()
447 xfer->t.speed_hz = wm0010->board_max_spi_speed; in wm0010_firmware_load()
451 wm0010->max_spi_freq = xfer->t.speed_hz; in wm0010_firmware_load()
469 if (wm0010->boot_failed) { in wm0010_firmware_load()
498 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_stage2_load() local
535 t.speed_hz = wm0010->sysclk / 10; in wm0010_stage2_load()
552 wm0010_mark_boot_failure(wm0010); in wm0010_stage2_load()
570 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_boot() local
581 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_boot()
582 if (wm0010->state != WM0010_POWER_OFF) in wm0010_boot()
583 dev_warn(wm0010->dev, "DSP already powered up!\n"); in wm0010_boot()
584 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_boot()
586 if (wm0010->sysclk > 26000000) { in wm0010_boot()
592 mutex_lock(&wm0010->lock); in wm0010_boot()
593 wm0010->pll_running = false; in wm0010_boot()
595 dev_dbg(component->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); in wm0010_boot()
597 ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), in wm0010_boot()
598 wm0010->core_supplies); in wm0010_boot()
602 mutex_unlock(&wm0010->lock); in wm0010_boot()
606 ret = regulator_enable(wm0010->dbvdd); in wm0010_boot()
613 gpio_set_value_cansleep(wm0010->gpio_reset, !wm0010->gpio_reset_value); in wm0010_boot()
614 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_boot()
615 wm0010->state = WM0010_OUT_OF_RESET; in wm0010_boot()
616 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_boot()
618 if (!wait_for_completion_timeout(&wm0010->boot_completion, in wm0010_boot()
622 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_boot()
623 wm0010->state = WM0010_BOOTROM; in wm0010_boot()
624 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_boot()
630 if (!wait_for_completion_timeout(&wm0010->boot_completion, in wm0010_boot()
634 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_boot()
635 wm0010->state = WM0010_STAGE2; in wm0010_boot()
636 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_boot()
639 if (wm0010->max_spi_freq) { in wm0010_boot()
647 pll_rec.clkctrl1 = wm0010->pll_clkctrl1; in wm0010_boot()
668 t.speed_hz = wm0010->sysclk / 6; in wm0010_boot()
690 wm0010->pll_running = true; in wm0010_boot()
706 spin_lock_irqsave(&wm0010->irq_lock, flags); in wm0010_boot()
707 wm0010->state = WM0010_FIRMWARE; in wm0010_boot()
708 spin_unlock_irqrestore(&wm0010->irq_lock, flags); in wm0010_boot()
710 mutex_unlock(&wm0010->lock); in wm0010_boot()
721 mutex_unlock(&wm0010->lock); in wm0010_boot()
725 mutex_unlock(&wm0010->lock); in wm0010_boot()
726 regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies), in wm0010_boot()
727 wm0010->core_supplies); in wm0010_boot()
735 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_set_bias_level() local
746 mutex_lock(&wm0010->lock); in wm0010_set_bias_level()
748 mutex_unlock(&wm0010->lock); in wm0010_set_bias_level()
761 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_set_sysclk() local
764 wm0010->sysclk = freq; in wm0010_set_sysclk()
767 wm0010->max_spi_freq = 0; in wm0010_set_sysclk()
771 wm0010->max_spi_freq = pll_clock_map[i].max_pll_spi_speed; in wm0010_set_sysclk()
772 wm0010->pll_clkctrl1 = pll_clock_map[i].pll_clkctrl1; in wm0010_set_sysclk()
838 struct wm0010_priv *wm0010 = data; in wm0010_irq() local
840 switch (wm0010->state) { in wm0010_irq()
844 spin_lock(&wm0010->irq_lock); in wm0010_irq()
845 complete(&wm0010->boot_completion); in wm0010_irq()
846 spin_unlock(&wm0010->irq_lock); in wm0010_irq()
857 struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); in wm0010_probe() local
859 wm0010->component = component; in wm0010_probe()
870 struct wm0010_priv *wm0010; in wm0010_spi_probe() local
872 wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010), in wm0010_spi_probe()
874 if (!wm0010) in wm0010_spi_probe()
877 mutex_init(&wm0010->lock); in wm0010_spi_probe()
878 spin_lock_init(&wm0010->irq_lock); in wm0010_spi_probe()
880 spi_set_drvdata(spi, wm0010); in wm0010_spi_probe()
881 wm0010->dev = &spi->dev; in wm0010_spi_probe()
884 memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev), in wm0010_spi_probe()
885 sizeof(wm0010->pdata)); in wm0010_spi_probe()
887 init_completion(&wm0010->boot_completion); in wm0010_spi_probe()
889 wm0010->core_supplies[0].supply = "AVDD"; in wm0010_spi_probe()
890 wm0010->core_supplies[1].supply = "DCVDD"; in wm0010_spi_probe()
891 ret = devm_regulator_bulk_get(wm0010->dev, ARRAY_SIZE(wm0010->core_supplies), in wm0010_spi_probe()
892 wm0010->core_supplies); in wm0010_spi_probe()
894 dev_err(wm0010->dev, "Failed to obtain core supplies: %d\n", in wm0010_spi_probe()
899 wm0010->dbvdd = devm_regulator_get(wm0010->dev, "DBVDD"); in wm0010_spi_probe()
900 if (IS_ERR(wm0010->dbvdd)) { in wm0010_spi_probe()
901 ret = PTR_ERR(wm0010->dbvdd); in wm0010_spi_probe()
902 dev_err(wm0010->dev, "Failed to obtain DBVDD: %d\n", ret); in wm0010_spi_probe()
906 if (wm0010->pdata.gpio_reset) { in wm0010_spi_probe()
907 wm0010->gpio_reset = wm0010->pdata.gpio_reset; in wm0010_spi_probe()
909 if (wm0010->pdata.reset_active_high) in wm0010_spi_probe()
910 wm0010->gpio_reset_value = 1; in wm0010_spi_probe()
912 wm0010->gpio_reset_value = 0; in wm0010_spi_probe()
914 if (wm0010->gpio_reset_value) in wm0010_spi_probe()
919 ret = devm_gpio_request_one(wm0010->dev, wm0010->gpio_reset, in wm0010_spi_probe()
922 dev_err(wm0010->dev, in wm0010_spi_probe()
928 dev_err(wm0010->dev, "No reset GPIO configured\n"); in wm0010_spi_probe()
932 wm0010->state = WM0010_POWER_OFF; in wm0010_spi_probe()
935 if (wm0010->pdata.irq_flags) in wm0010_spi_probe()
936 trigger = wm0010->pdata.irq_flags; in wm0010_spi_probe()
942 "wm0010", wm0010); in wm0010_spi_probe()
944 dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n", in wm0010_spi_probe()
948 wm0010->irq = irq; in wm0010_spi_probe()
952 dev_err(wm0010->dev, "Failed to set IRQ %d as wake source: %d\n", in wm0010_spi_probe()
958 wm0010->board_max_spi_speed = spi->max_speed_hz; in wm0010_spi_probe()
960 wm0010->board_max_spi_speed = 0; in wm0010_spi_probe()
973 struct wm0010_priv *wm0010 = spi_get_drvdata(spi); in wm0010_spi_remove() local
975 gpio_set_value_cansleep(wm0010->gpio_reset, in wm0010_spi_remove()
976 wm0010->gpio_reset_value); in wm0010_spi_remove()
978 irq_set_irq_wake(wm0010->irq, 0); in wm0010_spi_remove()
980 if (wm0010->irq) in wm0010_spi_remove()
981 free_irq(wm0010->irq, wm0010); in wm0010_spi_remove()