Lines Matching refs:wcnss

146 	struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv;  in wcnss_load()  local
149 ret = qcom_mdt_load(wcnss->dev, fw, rproc->firmware, WCNSS_PAS_ID, in wcnss_load()
150 wcnss->mem_region, wcnss->mem_phys, in wcnss_load()
151 wcnss->mem_size, &wcnss->mem_reloc); in wcnss_load()
155 qcom_pil_info_store("wcnss", wcnss->mem_phys, wcnss->mem_size); in wcnss_load()
160 static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) in wcnss_indicate_nv_download() argument
165 val = readl(wcnss->spare_out); in wcnss_indicate_nv_download()
167 writel(val, wcnss->spare_out); in wcnss_indicate_nv_download()
170 static void wcnss_configure_iris(struct qcom_wcnss *wcnss) in wcnss_configure_iris() argument
175 writel(0, wcnss->pmu_cfg); in wcnss_configure_iris()
178 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
182 if (wcnss->use_48mhz_xo) in wcnss_configure_iris()
186 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
190 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
193 while (readl(wcnss->pmu_cfg) & WCNSS_PMU_IRIS_RESET_STS) in wcnss_configure_iris()
198 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
202 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
205 while (readl(wcnss->pmu_cfg) & WCNSS_PMU_IRIS_XO_CFG_STS) in wcnss_configure_iris()
211 writel(val, wcnss->pmu_cfg); in wcnss_configure_iris()
219 struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; in wcnss_start() local
222 mutex_lock(&wcnss->iris_lock); in wcnss_start()
223 if (!wcnss->iris) { in wcnss_start()
224 dev_err(wcnss->dev, "no iris registered\n"); in wcnss_start()
229 for (i = 0; i < wcnss->num_pds; i++) { in wcnss_start()
230 dev_pm_genpd_set_performance_state(wcnss->pds[i], INT_MAX); in wcnss_start()
231 ret = pm_runtime_get_sync(wcnss->pds[i]); in wcnss_start()
233 pm_runtime_put_noidle(wcnss->pds[i]); in wcnss_start()
238 ret = regulator_bulk_enable(wcnss->num_vregs, wcnss->vregs); in wcnss_start()
242 ret = qcom_iris_enable(wcnss->iris); in wcnss_start()
246 wcnss_indicate_nv_download(wcnss); in wcnss_start()
247 wcnss_configure_iris(wcnss); in wcnss_start()
251 dev_err(wcnss->dev, in wcnss_start()
256 ret = wait_for_completion_timeout(&wcnss->start_done, in wcnss_start()
258 if (wcnss->ready_irq > 0 && ret == 0) { in wcnss_start()
260 dev_err(wcnss->dev, "start timed out\n"); in wcnss_start()
269 qcom_iris_disable(wcnss->iris); in wcnss_start()
271 regulator_bulk_disable(wcnss->num_vregs, wcnss->vregs); in wcnss_start()
274 pm_runtime_put(wcnss->pds[i]); in wcnss_start()
275 dev_pm_genpd_set_performance_state(wcnss->pds[i], 0); in wcnss_start()
278 mutex_unlock(&wcnss->iris_lock); in wcnss_start()
285 struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; in wcnss_stop() local
288 if (wcnss->state) { in wcnss_stop()
289 qcom_smem_state_update_bits(wcnss->state, in wcnss_stop()
290 BIT(wcnss->stop_bit), in wcnss_stop()
291 BIT(wcnss->stop_bit)); in wcnss_stop()
293 ret = wait_for_completion_timeout(&wcnss->stop_done, in wcnss_stop()
296 dev_err(wcnss->dev, "timed out on wait\n"); in wcnss_stop()
298 qcom_smem_state_update_bits(wcnss->state, in wcnss_stop()
299 BIT(wcnss->stop_bit), in wcnss_stop()
305 dev_err(wcnss->dev, "failed to shutdown: %d\n", ret); in wcnss_stop()
312 struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; in wcnss_da_to_va() local
315 offset = da - wcnss->mem_reloc; in wcnss_da_to_va()
316 if (offset < 0 || offset + len > wcnss->mem_size) in wcnss_da_to_va()
319 return wcnss->mem_region + offset; in wcnss_da_to_va()
332 struct qcom_wcnss *wcnss = dev; in wcnss_wdog_interrupt() local
334 rproc_report_crash(wcnss->rproc, RPROC_WATCHDOG); in wcnss_wdog_interrupt()
341 struct qcom_wcnss *wcnss = dev; in wcnss_fatal_interrupt() local
347 dev_err(wcnss->dev, "fatal error received: %s\n", msg); in wcnss_fatal_interrupt()
349 rproc_report_crash(wcnss->rproc, RPROC_FATAL_ERROR); in wcnss_fatal_interrupt()
356 struct qcom_wcnss *wcnss = dev; in wcnss_ready_interrupt() local
358 complete(&wcnss->start_done); in wcnss_ready_interrupt()
379 struct qcom_wcnss *wcnss = dev; in wcnss_stop_ack_interrupt() local
381 complete(&wcnss->stop_done); in wcnss_stop_ack_interrupt()
386 static int wcnss_init_pds(struct qcom_wcnss *wcnss, in wcnss_init_pds() argument
395 wcnss->pds[i] = dev_pm_domain_attach_by_name(wcnss->dev, pd_names[i]); in wcnss_init_pds()
396 if (IS_ERR_OR_NULL(wcnss->pds[i])) { in wcnss_init_pds()
397 ret = PTR_ERR(wcnss->pds[i]) ? : -ENODATA; in wcnss_init_pds()
399 dev_pm_domain_detach(wcnss->pds[i], false); in wcnss_init_pds()
403 wcnss->num_pds = i; in wcnss_init_pds()
408 static void wcnss_release_pds(struct qcom_wcnss *wcnss) in wcnss_release_pds() argument
412 for (i = 0; i < wcnss->num_pds; i++) in wcnss_release_pds()
413 dev_pm_domain_detach(wcnss->pds[i], false); in wcnss_release_pds()
416 static int wcnss_init_regulators(struct qcom_wcnss *wcnss, in wcnss_init_regulators() argument
429 if (wcnss->num_pds) in wcnss_init_regulators()
434 bulk = devm_kcalloc(wcnss->dev, in wcnss_init_regulators()
443 ret = devm_regulator_bulk_get(wcnss->dev, num_vregs, bulk); in wcnss_init_regulators()
457 wcnss->vregs = bulk; in wcnss_init_regulators()
458 wcnss->num_vregs = num_vregs; in wcnss_init_regulators()
463 static int wcnss_request_irq(struct qcom_wcnss *wcnss, in wcnss_request_irq() argument
483 "wcnss", wcnss); in wcnss_request_irq()
490 static int wcnss_alloc_memory_region(struct qcom_wcnss *wcnss) in wcnss_alloc_memory_region() argument
496 node = of_parse_phandle(wcnss->dev->of_node, "memory-region", 0); in wcnss_alloc_memory_region()
498 dev_err(wcnss->dev, "no memory-region specified\n"); in wcnss_alloc_memory_region()
506 wcnss->mem_phys = wcnss->mem_reloc = r.start; in wcnss_alloc_memory_region()
507 wcnss->mem_size = resource_size(&r); in wcnss_alloc_memory_region()
508 wcnss->mem_region = devm_ioremap_wc(wcnss->dev, wcnss->mem_phys, wcnss->mem_size); in wcnss_alloc_memory_region()
509 if (!wcnss->mem_region) { in wcnss_alloc_memory_region()
510 dev_err(wcnss->dev, "unable to map memory region: %pa+%zx\n", in wcnss_alloc_memory_region()
511 &r.start, wcnss->mem_size); in wcnss_alloc_memory_region()
522 struct qcom_wcnss *wcnss; in wcnss_probe() local
544 fw_name, sizeof(*wcnss)); in wcnss_probe()
551 wcnss = (struct qcom_wcnss *)rproc->priv; in wcnss_probe()
552 wcnss->dev = &pdev->dev; in wcnss_probe()
553 wcnss->rproc = rproc; in wcnss_probe()
554 platform_set_drvdata(pdev, wcnss); in wcnss_probe()
556 init_completion(&wcnss->start_done); in wcnss_probe()
557 init_completion(&wcnss->stop_done); in wcnss_probe()
559 mutex_init(&wcnss->iris_lock); in wcnss_probe()
568 ret = wcnss_alloc_memory_region(wcnss); in wcnss_probe()
572 wcnss->pmu_cfg = mmio + data->pmu_offset; in wcnss_probe()
573 wcnss->spare_out = mmio + data->spare_offset; in wcnss_probe()
579 ret = wcnss_init_pds(wcnss, data->pd_names); in wcnss_probe()
583 ret = wcnss_init_regulators(wcnss, data->vregs, data->num_vregs, in wcnss_probe()
588 ret = wcnss_request_irq(wcnss, pdev, "wdog", false, wcnss_wdog_interrupt); in wcnss_probe()
591 wcnss->wdog_irq = ret; in wcnss_probe()
593 ret = wcnss_request_irq(wcnss, pdev, "fatal", false, wcnss_fatal_interrupt); in wcnss_probe()
596 wcnss->fatal_irq = ret; in wcnss_probe()
598 ret = wcnss_request_irq(wcnss, pdev, "ready", true, wcnss_ready_interrupt); in wcnss_probe()
601 wcnss->ready_irq = ret; in wcnss_probe()
603 ret = wcnss_request_irq(wcnss, pdev, "handover", true, wcnss_handover_interrupt); in wcnss_probe()
606 wcnss->handover_irq = ret; in wcnss_probe()
608 ret = wcnss_request_irq(wcnss, pdev, "stop-ack", true, wcnss_stop_ack_interrupt); in wcnss_probe()
611 wcnss->stop_ack_irq = ret; in wcnss_probe()
613 if (wcnss->stop_ack_irq) { in wcnss_probe()
614 wcnss->state = devm_qcom_smem_state_get(&pdev->dev, "stop", in wcnss_probe()
615 &wcnss->stop_bit); in wcnss_probe()
616 if (IS_ERR(wcnss->state)) { in wcnss_probe()
617 ret = PTR_ERR(wcnss->state); in wcnss_probe()
622 qcom_add_smd_subdev(rproc, &wcnss->smd_subdev); in wcnss_probe()
623 wcnss->sysmon = qcom_add_sysmon_subdev(rproc, "wcnss", WCNSS_SSCTL_ID); in wcnss_probe()
624 if (IS_ERR(wcnss->sysmon)) { in wcnss_probe()
625 ret = PTR_ERR(wcnss->sysmon); in wcnss_probe()
629 wcnss->iris = qcom_iris_probe(&pdev->dev, &wcnss->use_48mhz_xo); in wcnss_probe()
630 if (IS_ERR(wcnss->iris)) { in wcnss_probe()
631 ret = PTR_ERR(wcnss->iris); in wcnss_probe()
642 qcom_iris_remove(wcnss->iris); in wcnss_probe()
644 wcnss_release_pds(wcnss); in wcnss_probe()
653 struct qcom_wcnss *wcnss = platform_get_drvdata(pdev); in wcnss_remove() local
655 qcom_iris_remove(wcnss->iris); in wcnss_remove()
657 rproc_del(wcnss->rproc); in wcnss_remove()
659 qcom_remove_sysmon_subdev(wcnss->sysmon); in wcnss_remove()
660 qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev); in wcnss_remove()
661 wcnss_release_pds(wcnss); in wcnss_remove()
662 rproc_free(wcnss->rproc); in wcnss_remove()