Lines Matching refs:npe

124 #define print_npe(pri, npe, fmt, ...)					\  argument
125 printk(pri "%s: " fmt, npe_name(npe), ## __VA_ARGS__)
128 #define debug_msg(npe, fmt, ...) \ argument
129 print_npe(KERN_DEBUG, npe, fmt, ## __VA_ARGS__)
131 #define debug_msg(npe, fmt, ...) argument
152 static struct npe npe_tab[NPE_COUNT] = {
162 int npe_running(struct npe *npe) in npe_running() argument
164 return (__raw_readl(&npe->regs->exec_status_cmd) & STAT_RUN) != 0; in npe_running()
167 static void npe_cmd_write(struct npe *npe, u32 addr, int cmd, u32 data) in npe_cmd_write() argument
169 __raw_writel(data, &npe->regs->exec_data); in npe_cmd_write()
170 __raw_writel(addr, &npe->regs->exec_addr); in npe_cmd_write()
171 __raw_writel(cmd, &npe->regs->exec_status_cmd); in npe_cmd_write()
174 static u32 npe_cmd_read(struct npe *npe, u32 addr, int cmd) in npe_cmd_read() argument
176 __raw_writel(addr, &npe->regs->exec_addr); in npe_cmd_read()
177 __raw_writel(cmd, &npe->regs->exec_status_cmd); in npe_cmd_read()
181 __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
182 __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
183 return __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
186 static void npe_clear_active(struct npe *npe, u32 reg) in npe_clear_active() argument
188 u32 val = npe_cmd_read(npe, reg, CMD_RD_ECS_REG); in npe_clear_active()
189 npe_cmd_write(npe, reg, CMD_WR_ECS_REG, val & ~ECS_REG_0_ACTIVE); in npe_clear_active()
192 static void npe_start(struct npe *npe) in npe_start() argument
195 npe_clear_active(npe, ECS_PRI_1_CTXT_REG_0); in npe_start()
196 npe_clear_active(npe, ECS_PRI_2_CTXT_REG_0); in npe_start()
197 npe_clear_active(npe, ECS_DBG_CTXT_REG_0); in npe_start()
199 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_start()
200 __raw_writel(CMD_NPE_START, &npe->regs->exec_status_cmd); in npe_start()
203 static void npe_stop(struct npe *npe) in npe_stop() argument
205 __raw_writel(CMD_NPE_STOP, &npe->regs->exec_status_cmd); in npe_stop()
206 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); /*FIXME?*/ in npe_stop()
209 static int __must_check npe_debug_instr(struct npe *npe, u32 instr, u32 ctx, in npe_debug_instr() argument
216 npe_cmd_write(npe, ECS_DBG_CTXT_REG_0, CMD_WR_ECS_REG, in npe_debug_instr()
224 npe_cmd_write(npe, ECS_DBG_CTXT_REG_1, CMD_WR_ECS_REG, in npe_debug_instr()
229 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_debug_instr()
232 npe_cmd_write(npe, ECS_INSTRUCT_REG, CMD_WR_ECS_REG, instr); in npe_debug_instr()
236 wc = __raw_readl(&npe->regs->watch_count); in npe_debug_instr()
239 __raw_writel(CMD_NPE_STEP, &npe->regs->exec_status_cmd); in npe_debug_instr()
243 if (wc != __raw_readl(&npe->regs->watch_count)) in npe_debug_instr()
248 print_npe(KERN_ERR, npe, "reset: npe_debug_instr(): timeout\n"); in npe_debug_instr()
252 static int __must_check npe_logical_reg_write8(struct npe *npe, u32 addr, in npe_logical_reg_write8() argument
260 return npe_debug_instr(npe, instr, ctx, 1); /* execute it */ in npe_logical_reg_write8()
263 static int __must_check npe_logical_reg_write16(struct npe *npe, u32 addr, in npe_logical_reg_write16() argument
271 return npe_debug_instr(npe, instr, ctx, 1); /* execute it */ in npe_logical_reg_write16()
274 static int __must_check npe_logical_reg_write32(struct npe *npe, u32 addr, in npe_logical_reg_write32() argument
278 if (npe_logical_reg_write16(npe, addr, val >> 16, ctx)) in npe_logical_reg_write32()
280 return npe_logical_reg_write16(npe, addr + 2, val & 0xFFFF, ctx); in npe_logical_reg_write32()
283 static int npe_reset(struct npe *npe) in npe_reset() argument
288 ctl = (__raw_readl(&npe->regs->messaging_control) | 0x3F000000) & in npe_reset()
292 __raw_writel(ctl & 0x3F00FFFF, &npe->regs->messaging_control); in npe_reset()
296 exec_count = __raw_readl(&npe->regs->exec_count); in npe_reset()
297 __raw_writel(0, &npe->regs->exec_count); in npe_reset()
300 ctx_reg2 = npe_cmd_read(npe, ECS_DBG_CTXT_REG_2, CMD_RD_ECS_REG); in npe_reset()
301 npe_cmd_write(npe, ECS_DBG_CTXT_REG_2, CMD_WR_ECS_REG, ctx_reg2 | in npe_reset()
305 while (__raw_readl(&npe->regs->watchpoint_fifo) & WFIFO_VALID) in npe_reset()
307 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE) in npe_reset()
309 print_npe(KERN_DEBUG, npe, "npe_reset: read FIFO = 0x%X\n", in npe_reset()
310 __raw_readl(&npe->regs->in_out_fifo)); in npe_reset()
312 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE) in npe_reset()
315 if (npe_debug_instr(npe, INSTR_RD_FIFO, 0, 0)) in npe_reset()
319 __raw_writel(RESET_MBOX_STAT, &npe->regs->mailbox_status); in npe_reset()
321 if (npe_debug_instr(npe, INSTR_RESET_MBOX, 0, 0)) in npe_reset()
326 if (npe_logical_reg_write16(npe, NPE_REGMAP, val >> 1, 0)) in npe_reset()
329 if (npe_logical_reg_write32(npe, (val & 1) * 4, 0, 0)) in npe_reset()
337 val = npe_cmd_read(npe, ECS_BG_CTXT_REG_0, CMD_RD_ECS_REG); in npe_reset()
340 npe_cmd_write(npe, ECS_BG_CTXT_REG_0, CMD_WR_ECS_REG, val); in npe_reset()
345 if (npe_logical_reg_write8(npe, NPE_STEVT, 0x80, i)) in npe_reset()
347 if (npe_logical_reg_write16(npe, NPE_STARTPC, 0, i)) in npe_reset()
351 if (npe_logical_reg_write16(npe, NPE_REGMAP, 0x820, i)) in npe_reset()
353 if (npe_logical_reg_write8(npe, NPE_CINDEX, 0, i)) in npe_reset()
359 npe_cmd_write(npe, ECS_DBG_CTXT_REG_0, CMD_WR_ECS_REG, 0); in npe_reset()
361 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_reset()
363 __raw_writel(exec_count, &npe->regs->exec_count); in npe_reset()
364 npe_cmd_write(npe, ECS_DBG_CTXT_REG_2, CMD_WR_ECS_REG, ctx_reg2); in npe_reset()
368 npe_cmd_write(npe, ecs_reset[val].reg, CMD_WR_ECS_REG, in npe_reset()
372 __raw_writel(CMD_CLR_PROFILE_CNT, &npe->regs->exec_status_cmd); in npe_reset()
374 __raw_writel(0, &npe->regs->exec_count); in npe_reset()
375 __raw_writel(0, &npe->regs->action_points[0]); in npe_reset()
376 __raw_writel(0, &npe->regs->action_points[1]); in npe_reset()
377 __raw_writel(0, &npe->regs->action_points[2]); in npe_reset()
378 __raw_writel(0, &npe->regs->action_points[3]); in npe_reset()
379 __raw_writel(0, &npe->regs->watch_count); in npe_reset()
384 ~(IXP4XX_FEATURE_RESET_NPEA << npe->id)); in npe_reset()
387 (IXP4XX_FEATURE_RESET_NPEA << npe->id)); in npe_reset()
390 (IXP4XX_FEATURE_RESET_NPEA << npe->id)) in npe_reset()
397 npe_stop(npe); in npe_reset()
400 __raw_writel(ctl, &npe->regs->messaging_control); in npe_reset()
405 int npe_send_message(struct npe *npe, const void *msg, const char *what) in npe_send_message() argument
410 debug_msg(npe, "Trying to send message %s [%08X:%08X]\n", in npe_send_message()
413 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE) { in npe_send_message()
414 debug_msg(npe, "NPE input FIFO not empty\n"); in npe_send_message()
418 __raw_writel(send[0], &npe->regs->in_out_fifo); in npe_send_message()
420 if (!(__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNF)) { in npe_send_message()
421 debug_msg(npe, "NPE input FIFO full\n"); in npe_send_message()
425 __raw_writel(send[1], &npe->regs->in_out_fifo); in npe_send_message()
428 (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE)) { in npe_send_message()
434 debug_msg(npe, "Timeout sending message\n"); in npe_send_message()
439 debug_msg(npe, "Sending a message took %i cycles\n", cycles); in npe_send_message()
444 int npe_recv_message(struct npe *npe, void *msg, const char *what) in npe_recv_message() argument
449 debug_msg(npe, "Trying to receive message %s\n", what); in npe_recv_message()
452 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE) { in npe_recv_message()
453 recv[cnt++] = __raw_readl(&npe->regs->in_out_fifo); in npe_recv_message()
464 debug_msg(npe, "Received [%08X]\n", recv[0]); in npe_recv_message()
467 debug_msg(npe, "Received [%08X:%08X]\n", recv[0], recv[1]); in npe_recv_message()
472 debug_msg(npe, "Timeout waiting for message\n"); in npe_recv_message()
477 debug_msg(npe, "Receiving a message took %i cycles\n", cycles); in npe_recv_message()
482 int npe_send_recv_message(struct npe *npe, void *msg, const char *what) in npe_send_recv_message() argument
487 if ((result = npe_send_message(npe, msg, what)) != 0) in npe_send_recv_message()
489 if ((result = npe_recv_message(npe, recv, what)) != 0) in npe_send_recv_message()
493 debug_msg(npe, "Message %s: unexpected message received\n", in npe_send_recv_message()
501 int npe_load_firmware(struct npe *npe, const char *name, struct device *dev) in npe_load_firmware() argument
534 print_npe(KERN_ERR, npe, "incomplete firmware file\n"); in npe_load_firmware()
540 print_npe(KERN_DEBUG, npe, "firmware: %08X %08X %08X (0x%X bytes)\n", in npe_load_firmware()
548 print_npe(KERN_ERR, npe, "bad firmware file magic: 0x%X\n", in npe_load_firmware()
553 print_npe(KERN_ERR, npe, in npe_load_firmware()
557 if (((image->id >> 24) & 0xF /* NPE ID */) != npe->id) { in npe_load_firmware()
558 print_npe(KERN_ERR, npe, "firmware file NPE ID mismatch\n"); in npe_load_firmware()
566 print_npe(KERN_INFO, npe, "IXP43x/IXP46x firmware ignored on " in npe_load_firmware()
571 if (npe_running(npe)) { in npe_load_firmware()
572 print_npe(KERN_INFO, npe, "unable to load firmware, NPE is " in npe_load_firmware()
578 npe_stop(npe); in npe_load_firmware()
579 npe_reset(npe); in npe_load_firmware()
582 print_npe(KERN_INFO, npe, "firmware functionality 0x%X, " in npe_load_firmware()
587 if (!npe->id) in npe_load_firmware()
602 print_npe(KERN_INFO, npe, "firmware EOF block marker not " in npe_load_firmware()
608 print_npe(KERN_DEBUG, npe, "%i firmware blocks found\n", blocks); in npe_load_firmware()
615 print_npe(KERN_INFO, npe, "invalid offset 0x%X of " in npe_load_firmware()
630 print_npe(KERN_INFO, npe, "invalid firmware block #%i " in npe_load_firmware()
635 print_npe(KERN_INFO, npe, "firmware block #%i doesn't " in npe_load_firmware()
644 npe_cmd_write(npe, cb->npe_addr + j, cmd, cb->data[j]); in npe_load_firmware()
647 npe_start(npe); in npe_load_firmware()
648 if (!npe_running(npe)) in npe_load_firmware()
649 print_npe(KERN_ERR, npe, "unable to start\n"); in npe_load_firmware()
654 print_npe(KERN_INFO, npe, "firmware block #%i doesn't fit in NPE " in npe_load_firmware()
664 struct npe *npe_request(unsigned id) in npe_request()
673 void npe_release(struct npe *npe) in npe_release() argument
685 struct npe *npe = &npe_tab[i]; in ixp4xx_npe_probe() local
697 npe->regs = devm_ioremap_resource(dev, res); in ixp4xx_npe_probe()
698 if (IS_ERR(npe->regs)) in ixp4xx_npe_probe()
699 return PTR_ERR(npe->regs); in ixp4xx_npe_probe()
701 if (npe_reset(npe)) { in ixp4xx_npe_probe()
706 npe->valid = 1; in ixp4xx_npe_probe()