Lines Matching refs:npe
23 #include <mach/npe.h>
121 #define print_npe(pri, npe, fmt, ...) \
122 printk(pri "%s: " fmt, npe_name(npe), ## __VA_ARGS__)
125 #define debug_msg(npe, fmt, ...) \
126 print_npe(KERN_DEBUG, npe, fmt, ## __VA_ARGS__)
128 #define debug_msg(npe, fmt, ...)
149 static struct npe npe_tab[NPE_COUNT] = {
165 int npe_running(struct npe *npe)
167 return (__raw_readl(&npe->regs->exec_status_cmd) & STAT_RUN) != 0;
170 static void npe_cmd_write(struct npe *npe, u32 addr, int cmd, u32 data)
172 __raw_writel(data, &npe->regs->exec_data);
173 __raw_writel(addr, &npe->regs->exec_addr);
174 __raw_writel(cmd, &npe->regs->exec_status_cmd);
177 static u32 npe_cmd_read(struct npe *npe, u32 addr, int cmd)
179 __raw_writel(addr, &npe->regs->exec_addr);
180 __raw_writel(cmd, &npe->regs->exec_status_cmd);
184 __raw_readl(&npe->regs->exec_data);
185 __raw_readl(&npe->regs->exec_data);
186 return __raw_readl(&npe->regs->exec_data);
189 static void npe_clear_active(struct npe *npe, u32 reg)
191 u32 val = npe_cmd_read(npe, reg, CMD_RD_ECS_REG);
192 npe_cmd_write(npe, reg, CMD_WR_ECS_REG, val & ~ECS_REG_0_ACTIVE);
195 static void npe_start(struct npe *npe)
198 npe_clear_active(npe, ECS_PRI_1_CTXT_REG_0);
199 npe_clear_active(npe, ECS_PRI_2_CTXT_REG_0);
200 npe_clear_active(npe, ECS_DBG_CTXT_REG_0);
202 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd);
203 __raw_writel(CMD_NPE_START, &npe->regs->exec_status_cmd);
206 static void npe_stop(struct npe *npe)
208 __raw_writel(CMD_NPE_STOP, &npe->regs->exec_status_cmd);
209 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd);
212 static int __must_check npe_debug_instr(struct npe *npe, u32 instr, u32 ctx,
219 npe_cmd_write(npe, ECS_DBG_CTXT_REG_0, CMD_WR_ECS_REG,
227 npe_cmd_write(npe, ECS_DBG_CTXT_REG_1, CMD_WR_ECS_REG,
232 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd);
235 npe_cmd_write(npe, ECS_INSTRUCT_REG, CMD_WR_ECS_REG, instr);
239 wc = __raw_readl(&npe->regs->watch_count);
242 __raw_writel(CMD_NPE_STEP, &npe->regs->exec_status_cmd);
246 if (wc != __raw_readl(&npe->regs->watch_count))
251 print_npe(KERN_ERR, npe, "reset: npe_debug_instr(): timeout\n");
255 static int __must_check npe_logical_reg_write8(struct npe *npe, u32 addr,
263 return npe_debug_instr(npe, instr, ctx, 1); /* execute it */
266 static int __must_check npe_logical_reg_write16(struct npe *npe, u32 addr,
274 return npe_debug_instr(npe, instr, ctx, 1); /* execute it */
277 static int __must_check npe_logical_reg_write32(struct npe *npe, u32 addr,
281 if (npe_logical_reg_write16(npe, addr, val >> 16, ctx))
283 return npe_logical_reg_write16(npe, addr + 2, val & 0xFFFF, ctx);
286 static int npe_reset(struct npe *npe)
291 ctl = (__raw_readl(&npe->regs->messaging_control) | 0x3F000000) &
295 __raw_writel(ctl & 0x3F00FFFF, &npe->regs->messaging_control);
299 exec_count = __raw_readl(&npe->regs->exec_count);
300 __raw_writel(0, &npe->regs->exec_count);
303 ctx_reg2 = npe_cmd_read(npe, ECS_DBG_CTXT_REG_2, CMD_RD_ECS_REG);
304 npe_cmd_write(npe, ECS_DBG_CTXT_REG_2, CMD_WR_ECS_REG, ctx_reg2 |
308 while (__raw_readl(&npe->regs->watchpoint_fifo) & WFIFO_VALID)
310 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE)
312 print_npe(KERN_DEBUG, npe, "npe_reset: read FIFO = 0x%X\n",
313 __raw_readl(&npe->regs->in_out_fifo));
315 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE)
318 if (npe_debug_instr(npe, INSTR_RD_FIFO, 0, 0))
322 __raw_writel(RESET_MBOX_STAT, &npe->regs->mailbox_status);
324 if (npe_debug_instr(npe, INSTR_RESET_MBOX, 0, 0))
329 if (npe_logical_reg_write16(npe, NPE_REGMAP, val >> 1, 0))
332 if (npe_logical_reg_write32(npe, (val & 1) * 4, 0, 0))
340 val = npe_cmd_read(npe, ECS_BG_CTXT_REG_0, CMD_RD_ECS_REG);
343 npe_cmd_write(npe, ECS_BG_CTXT_REG_0, CMD_WR_ECS_REG, val);
348 if (npe_logical_reg_write8(npe, NPE_STEVT, 0x80, i))
350 if (npe_logical_reg_write16(npe, NPE_STARTPC, 0, i))
354 if (npe_logical_reg_write16(npe, NPE_REGMAP, 0x820, i))
356 if (npe_logical_reg_write8(npe, NPE_CINDEX, 0, i))
362 npe_cmd_write(npe, ECS_DBG_CTXT_REG_0, CMD_WR_ECS_REG, 0);
364 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd);
366 __raw_writel(exec_count, &npe->regs->exec_count);
367 npe_cmd_write(npe, ECS_DBG_CTXT_REG_2, CMD_WR_ECS_REG, ctx_reg2);
371 npe_cmd_write(npe, ecs_reset[val].reg, CMD_WR_ECS_REG,
375 __raw_writel(CMD_CLR_PROFILE_CNT, &npe->regs->exec_status_cmd);
377 __raw_writel(0, &npe->regs->exec_count);
378 __raw_writel(0, &npe->regs->action_points[0]);
379 __raw_writel(0, &npe->regs->action_points[1]);
380 __raw_writel(0, &npe->regs->action_points[2]);
381 __raw_writel(0, &npe->regs->action_points[3]);
382 __raw_writel(0, &npe->regs->watch_count);
387 ~(IXP4XX_FEATURE_RESET_NPEA << npe->id));
390 (IXP4XX_FEATURE_RESET_NPEA << npe->id));
393 (IXP4XX_FEATURE_RESET_NPEA << npe->id))
400 npe_stop(npe);
403 __raw_writel(ctl, &npe->regs->messaging_control);
408 int npe_send_message(struct npe *npe, const void *msg, const char *what)
413 debug_msg(npe, "Trying to send message %s [%08X:%08X]\n",
416 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE) {
417 debug_msg(npe, "NPE input FIFO not empty\n");
421 __raw_writel(send[0], &npe->regs->in_out_fifo);
423 if (!(__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNF)) {
424 debug_msg(npe, "NPE input FIFO full\n");
428 __raw_writel(send[1], &npe->regs->in_out_fifo);
431 (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE)) {
437 debug_msg(npe, "Timeout sending message\n");
442 debug_msg(npe, "Sending a message took %i cycles\n", cycles);
447 int npe_recv_message(struct npe *npe, void *msg, const char *what)
452 debug_msg(npe, "Trying to receive message %s\n", what);
455 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE) {
456 recv[cnt++] = __raw_readl(&npe->regs->in_out_fifo);
467 debug_msg(npe, "Received [%08X]\n", recv[0]);
470 debug_msg(npe, "Received [%08X:%08X]\n", recv[0], recv[1]);
475 debug_msg(npe, "Timeout waiting for message\n");
480 debug_msg(npe, "Receiving a message took %i cycles\n", cycles);
485 int npe_send_recv_message(struct npe *npe, void *msg, const char *what)
490 if ((result = npe_send_message(npe, msg, what)) != 0)
492 if ((result = npe_recv_message(npe, recv, what)) != 0)
496 debug_msg(npe, "Message %s: unexpected message received\n",
504 int npe_load_firmware(struct npe *npe, const char *name, struct device *dev)
537 print_npe(KERN_ERR, npe, "incomplete firmware file\n");
543 print_npe(KERN_DEBUG, npe, "firmware: %08X %08X %08X (0x%X bytes)\n",
551 print_npe(KERN_ERR, npe, "bad firmware file magic: 0x%X\n",
556 print_npe(KERN_ERR, npe,
560 if (((image->id >> 24) & 0xF /* NPE ID */) != npe->id) {
561 print_npe(KERN_ERR, npe, "firmware file NPE ID mismatch\n");
569 print_npe(KERN_INFO, npe, "IXP43x/IXP46x firmware ignored on "
574 if (npe_running(npe)) {
575 print_npe(KERN_INFO, npe, "unable to load firmware, NPE is "
581 print_npe(KERN_INFO, npe, "firmware functionality 0x%X, "
586 if (!npe->id)
601 print_npe(KERN_INFO, npe, "firmware EOF block marker not "
607 print_npe(KERN_DEBUG, npe, "%i firmware blocks found\n", blocks);
614 print_npe(KERN_INFO, npe, "invalid offset 0x%X of "
629 print_npe(KERN_INFO, npe, "invalid firmware block #%i "
634 print_npe(KERN_INFO, npe, "firmware block #%i doesn't "
643 npe_cmd_write(npe, cb->npe_addr + j, cmd, cb->data[j]);
646 npe_start(npe);
647 if (!npe_running(npe))
648 print_npe(KERN_ERR, npe, "unable to start\n");
653 print_npe(KERN_INFO, npe, "firmware block #%i doesn't fit in NPE "
663 struct npe *npe_request(unsigned id)
672 void npe_release(struct npe *npe)
684 struct npe *npe = &npe_tab[i];
688 if (!(npe->mem_res = request_mem_region(npe->regs_phys,
690 npe_name(npe)))) {
691 print_npe(KERN_ERR, npe,
696 if (npe_reset(npe))
698 npe->valid = 1;