Lines Matching refs:pru

135 static inline u32 pru_control_read_reg(struct pru_rproc *pru, unsigned int reg)  in pru_control_read_reg()  argument
137 return readl_relaxed(pru->mem_regions[PRU_IOMEM_CTRL].va + reg); in pru_control_read_reg()
141 void pru_control_write_reg(struct pru_rproc *pru, unsigned int reg, u32 val) in pru_control_write_reg() argument
143 writel_relaxed(val, pru->mem_regions[PRU_IOMEM_CTRL].va + reg); in pru_control_write_reg()
147 void pru_control_set_reg(struct pru_rproc *pru, unsigned int reg, in pru_control_set_reg() argument
153 spin_lock_irqsave(&pru->rmw_lock, flags); in pru_control_set_reg()
155 val = pru_control_read_reg(pru, reg); in pru_control_set_reg()
158 pru_control_write_reg(pru, reg, val); in pru_control_set_reg()
160 spin_unlock_irqrestore(&pru->rmw_lock, flags); in pru_control_set_reg()
172 struct pru_rproc *pru = rproc->priv; in pru_rproc_set_firmware() local
175 fw_name = pru->fw_name; in pru_rproc_set_firmware()
230 struct pru_rproc *pru; in pru_rproc_get() local
240 pru = rproc->priv; in pru_rproc_get()
243 mutex_lock(&pru->lock); in pru_rproc_get()
245 if (pru->client_np) { in pru_rproc_get()
246 mutex_unlock(&pru->lock); in pru_rproc_get()
251 pru->client_np = np; in pru_rproc_get()
254 mutex_unlock(&pru->lock); in pru_rproc_get()
257 *pru_id = pru->id; in pru_rproc_get()
259 ret = pruss_cfg_get_gpmux(pru->pruss, pru->id, &pru->gpmux_save); in pru_rproc_get()
269 ret = pruss_cfg_set_gpmux(pru->pruss, pru->id, mux); in pru_rproc_get()
307 struct pru_rproc *pru; in pru_rproc_put() local
312 pru = rproc->priv; in pru_rproc_put()
314 pruss_cfg_set_gpmux(pru->pruss, pru->id, pru->gpmux_save); in pru_rproc_put()
318 mutex_lock(&pru->lock); in pru_rproc_put()
320 if (!pru->client_np) { in pru_rproc_put()
321 mutex_unlock(&pru->lock); in pru_rproc_put()
325 pru->client_np = NULL; in pru_rproc_put()
327 mutex_unlock(&pru->lock); in pru_rproc_put()
343 struct pru_rproc *pru = rproc->priv; in pru_rproc_set_ctable() local
366 pru_control_set_reg(pru, reg, mask, set); in pru_rproc_set_ctable()
372 static inline u32 pru_debug_read_reg(struct pru_rproc *pru, unsigned int reg) in pru_debug_read_reg() argument
374 return readl_relaxed(pru->mem_regions[PRU_IOMEM_DEBUG].va + reg); in pru_debug_read_reg()
380 struct pru_rproc *pru = rproc->priv; in regs_show() local
387 pru_control_read_reg(pru, PRU_CTRL_CTRL)); in regs_show()
388 pru_sts = pru_control_read_reg(pru, PRU_CTRL_STS); in regs_show()
391 pru_control_read_reg(pru, PRU_CTRL_WAKEUP_EN)); in regs_show()
393 pru_control_read_reg(pru, PRU_CTRL_CYCLE)); in regs_show()
395 pru_control_read_reg(pru, PRU_CTRL_STALL)); in regs_show()
397 pru_control_read_reg(pru, PRU_CTRL_CTBIR0)); in regs_show()
399 pru_control_read_reg(pru, PRU_CTRL_CTBIR1)); in regs_show()
401 pru_control_read_reg(pru, PRU_CTRL_CTPPR0)); in regs_show()
403 pru_control_read_reg(pru, PRU_CTRL_CTPPR1)); in regs_show()
406 pru_is_running = pru_control_read_reg(pru, PRU_CTRL_CTRL) & in regs_show()
415 i, pru_debug_read_reg(pru, PRU_DEBUG_GPREG(i)), in regs_show()
416 i, pru_debug_read_reg(pru, PRU_DEBUG_CT_REG(i))); in regs_show()
438 struct pru_rproc *pru = rproc->priv; in pru_rproc_debug_ss_set() local
442 if (!val && !pru->dbg_single_step) in pru_rproc_debug_ss_set()
445 reg_val = pru_control_read_reg(pru, PRU_CTRL_CTRL); in pru_rproc_debug_ss_set()
447 if (val && !pru->dbg_single_step) in pru_rproc_debug_ss_set()
448 pru->dbg_continuous = reg_val; in pru_rproc_debug_ss_set()
453 reg_val = pru->dbg_continuous; in pru_rproc_debug_ss_set()
455 pru->dbg_single_step = val; in pru_rproc_debug_ss_set()
456 pru_control_write_reg(pru, PRU_CTRL_CTRL, reg_val); in pru_rproc_debug_ss_set()
464 struct pru_rproc *pru = rproc->priv; in pru_rproc_debug_ss_get() local
466 *val = pru->dbg_single_step; in pru_rproc_debug_ss_get()
490 static void pru_dispose_irq_mapping(struct pru_rproc *pru) in pru_dispose_irq_mapping() argument
492 if (!pru->mapped_irq) in pru_dispose_irq_mapping()
495 while (pru->evt_count) { in pru_dispose_irq_mapping()
496 pru->evt_count--; in pru_dispose_irq_mapping()
497 if (pru->mapped_irq[pru->evt_count] > 0) in pru_dispose_irq_mapping()
498 irq_dispose_mapping(pru->mapped_irq[pru->evt_count]); in pru_dispose_irq_mapping()
501 kfree(pru->mapped_irq); in pru_dispose_irq_mapping()
502 pru->mapped_irq = NULL; in pru_dispose_irq_mapping()
512 struct pru_rproc *pru = rproc->priv; in pru_handle_intrmap() local
513 struct pru_irq_rsc *rsc = pru->pru_interrupt_map; in pru_handle_intrmap()
532 pru->pru_interrupt_map_sz) in pru_handle_intrmap()
535 pru->evt_count = rsc->num_evts; in pru_handle_intrmap()
536 pru->mapped_irq = kcalloc(pru->evt_count, sizeof(unsigned int), in pru_handle_intrmap()
538 if (!pru->mapped_irq) { in pru_handle_intrmap()
539 pru->evt_count = 0; in pru_handle_intrmap()
549 parent = of_get_parent(dev_of_node(pru->dev)); in pru_handle_intrmap()
551 kfree(pru->mapped_irq); in pru_handle_intrmap()
552 pru->mapped_irq = NULL; in pru_handle_intrmap()
553 pru->evt_count = 0; in pru_handle_intrmap()
560 kfree(pru->mapped_irq); in pru_handle_intrmap()
561 pru->mapped_irq = NULL; in pru_handle_intrmap()
562 pru->evt_count = 0; in pru_handle_intrmap()
568 for (i = 0; i < pru->evt_count; i++) { in pru_handle_intrmap()
576 pru->mapped_irq[i] = irq_create_fwspec_mapping(&fwspec); in pru_handle_intrmap()
577 if (!pru->mapped_irq[i]) { in pru_handle_intrmap()
590 pru_dispose_irq_mapping(pru); in pru_handle_intrmap()
599 struct pru_rproc *pru = rproc->priv; in pru_rproc_start() local
605 names[pru->data->type], pru->id, (rproc->bootaddr >> 2)); in pru_rproc_start()
612 pru->pru_interrupt_map = NULL; in pru_rproc_start()
613 pru->pru_interrupt_map_sz = 0; in pru_rproc_start()
618 pru_control_write_reg(pru, PRU_CTRL_CTRL, val); in pru_rproc_start()
626 struct pru_rproc *pru = rproc->priv; in pru_rproc_stop() local
630 dev_dbg(dev, "stopping %s%d\n", names[pru->data->type], pru->id); in pru_rproc_stop()
632 val = pru_control_read_reg(pru, PRU_CTRL_CTRL); in pru_rproc_stop()
634 pru_control_write_reg(pru, PRU_CTRL_CTRL, val); in pru_rproc_stop()
637 pru_dispose_irq_mapping(pru); in pru_rproc_stop()
651 static void *pru_d_da_to_va(struct pru_rproc *pru, u32 da, size_t len) in pru_d_da_to_va() argument
654 struct pruss *pruss = pru->pruss; in pru_d_da_to_va()
664 if (pru->id == PRUSS_PRU1) in pru_d_da_to_va()
691 static void *pru_i_da_to_va(struct pru_rproc *pru, u32 da, size_t len) in pru_i_da_to_va() argument
717 if (da + len <= PRU_IRAM_DA + pru->mem_regions[PRU_IOMEM_IRAM].size) { in pru_i_da_to_va()
719 va = (__force void *)(pru->mem_regions[PRU_IOMEM_IRAM].va + in pru_i_da_to_va()
733 struct pru_rproc *pru = rproc->priv; in pru_rproc_da_to_va() local
735 return pru_d_da_to_va(pru, da, len); in pru_rproc_da_to_va()
741 struct pru_rproc *pru = rproc->priv; in pru_da_to_va() local
745 va = pru_i_da_to_va(pru, da, len); in pru_da_to_va()
747 va = pru_d_da_to_va(pru, da, len); in pru_da_to_va()
803 struct pru_rproc *pru = rproc->priv; in pru_rproc_load_elf_segments() local
851 if (pru->data->is_k3) { in pru_rproc_load_elf_segments()
928 struct pru_rproc *pru = rproc->priv; in pru_rproc_parse_fw() local
952 pru->pru_interrupt_map = (struct pru_irq_rsc *)(elf_data + sh_offset); in pru_rproc_parse_fw()
953 pru->pru_interrupt_map_sz = elf_shdr_get_sh_size(class, shdr); in pru_rproc_parse_fw()
962 static int pru_rproc_set_id(struct pru_rproc *pru) in pru_rproc_set_id() argument
966 switch (pru->mem_regions[PRU_IOMEM_IRAM].pa & PRU_IRAM_ADDR_MASK) { in pru_rproc_set_id()
972 pru->id = PRUSS_PRU0; in pru_rproc_set_id()
979 pru->id = PRUSS_PRU1; in pru_rproc_set_id()
993 struct pru_rproc *pru; in pru_rproc_probe() local
1012 sizeof(*pru)); in pru_rproc_probe()
1035 pru = rproc->priv; in pru_rproc_probe()
1036 pru->dev = dev; in pru_rproc_probe()
1037 pru->data = data; in pru_rproc_probe()
1038 pru->pruss = platform_get_drvdata(ppdev); in pru_rproc_probe()
1039 pru->rproc = rproc; in pru_rproc_probe()
1040 pru->fw_name = fw_name; in pru_rproc_probe()
1041 pru->client_np = NULL; in pru_rproc_probe()
1042 spin_lock_init(&pru->rmw_lock); in pru_rproc_probe()
1043 mutex_init(&pru->lock); in pru_rproc_probe()
1048 pru->mem_regions[i].va = devm_ioremap_resource(dev, res); in pru_rproc_probe()
1049 if (IS_ERR(pru->mem_regions[i].va)) { in pru_rproc_probe()
1052 ret = PTR_ERR(pru->mem_regions[i].va); in pru_rproc_probe()
1055 pru->mem_regions[i].pa = res->start; in pru_rproc_probe()
1056 pru->mem_regions[i].size = resource_size(res); in pru_rproc_probe()
1059 mem_names[i], &pru->mem_regions[i].pa, in pru_rproc_probe()
1060 pru->mem_regions[i].size, pru->mem_regions[i].va); in pru_rproc_probe()
1063 ret = pru_rproc_set_id(pru); in pru_rproc_probe()
1069 ret = devm_rproc_add(dev, pru->rproc); in pru_rproc_probe()