Lines Matching +full:ixp43x +full:- +full:interrupt

1 // SPDX-License-Identifier: GPL-2.0-only
8 * - Intel IXP4xx Developer's Manual and other e-papers
9 * - Intel IXP400 Access Library Software (BSD license)
10 * - previous works by Christian Hohnstaedt <chohnstaedt@innominate.com>
15 #include <linux/dma-mapping.h>
107 #define MSGSTAT_MBINT 0x00100000 /* Mailbox interrupt */
108 #define MSGSTAT_IFINT 0x00200000 /* InFifo interrupt */
109 #define MSGSTAT_OFINT 0x00400000 /* OutFifo interrupt */
110 #define MSGSTAT_WFINT 0x00800000 /* WatchFifo interrupt */
121 #define NPE_A_FIRMWARE "NPE-A"
122 #define NPE_B_FIRMWARE "NPE-B"
123 #define NPE_C_FIRMWARE "NPE-C"
167 return (__raw_readl(&npe->regs->exec_status_cmd) & STAT_RUN) != 0; in npe_running()
172 __raw_writel(data, &npe->regs->exec_data); in npe_cmd_write()
173 __raw_writel(addr, &npe->regs->exec_addr); in npe_cmd_write()
174 __raw_writel(cmd, &npe->regs->exec_status_cmd); in npe_cmd_write()
179 __raw_writel(addr, &npe->regs->exec_addr); in npe_cmd_read()
180 __raw_writel(cmd, &npe->regs->exec_status_cmd); in npe_cmd_read()
184 __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
185 __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
186 return __raw_readl(&npe->regs->exec_data); in npe_cmd_read()
202 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_start()
203 __raw_writel(CMD_NPE_START, &npe->regs->exec_status_cmd); in npe_start()
208 __raw_writel(CMD_NPE_STOP, &npe->regs->exec_status_cmd); in npe_stop()
209 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); /*FIXME?*/ in npe_stop()
232 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_debug_instr()
239 wc = __raw_readl(&npe->regs->watch_count); in npe_debug_instr()
242 __raw_writel(CMD_NPE_STEP, &npe->regs->exec_status_cmd); in npe_debug_instr()
246 if (wc != __raw_readl(&npe->regs->watch_count)) in npe_debug_instr()
252 return -ETIMEDOUT; in npe_debug_instr()
262 (val & ~0x1F) << (18 - 5);/* higher 3 bits to CoProc instr. */ in npe_logical_reg_write8()
273 (val & ~0x1F) << (18 - 5);/* higher 11 bits to CoProc instr. */ in npe_logical_reg_write16()
282 return -ETIMEDOUT; in npe_logical_reg_write32()
288 u32 reset_bit = (IXP4XX_FEATURE_RESET_NPEA << npe->id); in npe_reset()
292 ctl = (__raw_readl(&npe->regs->messaging_control) | 0x3F000000) & in npe_reset()
295 /* disable parity interrupt */ in npe_reset()
296 __raw_writel(ctl & 0x3F00FFFF, &npe->regs->messaging_control); in npe_reset()
298 /* pre exec - debug instruction */ in npe_reset()
300 exec_count = __raw_readl(&npe->regs->exec_count); in npe_reset()
301 __raw_writel(0, &npe->regs->exec_count); in npe_reset()
309 while (__raw_readl(&npe->regs->watchpoint_fifo) & WFIFO_VALID) in npe_reset()
311 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE) in npe_reset()
314 __raw_readl(&npe->regs->in_out_fifo)); in npe_reset()
316 while (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE) in npe_reset()
320 return -ETIMEDOUT; in npe_reset()
323 __raw_writel(RESET_MBOX_STAT, &npe->regs->mailbox_status); in npe_reset()
326 return -ETIMEDOUT; in npe_reset()
331 return -ETIMEDOUT; in npe_reset()
334 return -ETIMEDOUT; in npe_reset()
350 return -ETIMEDOUT; in npe_reset()
352 return -ETIMEDOUT; in npe_reset()
354 /* REGMAP = d0->p0, d8->p2, d16->p4 */ in npe_reset()
356 return -ETIMEDOUT; in npe_reset()
358 return -ETIMEDOUT; in npe_reset()
365 __raw_writel(CMD_NPE_CLR_PIPE, &npe->regs->exec_status_cmd); in npe_reset()
367 __raw_writel(exec_count, &npe->regs->exec_count); in npe_reset()
376 __raw_writel(CMD_CLR_PROFILE_CNT, &npe->regs->exec_status_cmd); in npe_reset()
378 __raw_writel(0, &npe->regs->exec_count); in npe_reset()
379 __raw_writel(0, &npe->regs->action_points[0]); in npe_reset()
380 __raw_writel(0, &npe->regs->action_points[1]); in npe_reset()
381 __raw_writel(0, &npe->regs->action_points[2]); in npe_reset()
382 __raw_writel(0, &npe->regs->action_points[3]); in npe_reset()
383 __raw_writel(0, &npe->regs->watch_count); in npe_reset()
387 * will read inverted but needs to be written non-inverted. in npe_reset()
389 val = cpu_ixp4xx_features(npe->rmap); in npe_reset()
391 regmap_write(npe->rmap, IXP4XX_EXP_CNFG2, val & ~reset_bit); in npe_reset()
393 regmap_write(npe->rmap, IXP4XX_EXP_CNFG2, val | reset_bit); in npe_reset()
396 val = cpu_ixp4xx_features(npe->rmap); in npe_reset()
402 return -ETIMEDOUT; in npe_reset()
406 /* restore NPE configuration bus Control Register - parity settings */ in npe_reset()
407 __raw_writel(ctl, &npe->regs->messaging_control); in npe_reset()
420 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE) { in npe_send_message()
422 return -EIO; in npe_send_message()
425 __raw_writel(send[0], &npe->regs->in_out_fifo); in npe_send_message()
427 if (!(__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNF)) { in npe_send_message()
429 return -EIO; in npe_send_message()
432 __raw_writel(send[1], &npe->regs->in_out_fifo); in npe_send_message()
435 (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_IFNE)) { in npe_send_message()
442 return -ETIMEDOUT; in npe_send_message()
459 if (__raw_readl(&npe->regs->messaging_status) & MSGSTAT_OFNE) { in npe_recv_message()
460 recv[cnt++] = __raw_readl(&npe->regs->in_out_fifo); in npe_recv_message()
480 return -ETIMEDOUT; in npe_recv_message()
502 return -EIO; in npe_send_recv_message()
539 err = -EINVAL; in npe_load_firmware()
540 if (fw_entry->size < sizeof(struct dl_image)) { in npe_load_firmware()
544 image = (struct dl_image*)fw_entry->data; in npe_load_firmware()
548 image->magic, image->id, image->size, image->size * 4); in npe_load_firmware()
551 if (image->magic == swab32(FW_MAGIC)) { /* swapped file */ in npe_load_firmware()
552 image->id = swab32(image->id); in npe_load_firmware()
553 image->size = swab32(image->size); in npe_load_firmware()
554 } else if (image->magic != FW_MAGIC) { in npe_load_firmware()
556 image->magic); in npe_load_firmware()
559 if ((image->size * 4 + sizeof(struct dl_image)) != fw_entry->size) { in npe_load_firmware()
564 if (((image->id >> 24) & 0xF /* NPE ID */) != npe->id) { in npe_load_firmware()
568 if (image->magic == swab32(FW_MAGIC)) in npe_load_firmware()
569 for (i = 0; i < image->size; i++) in npe_load_firmware()
570 image->data[i] = swab32(image->data[i]); in npe_load_firmware()
572 if (cpu_is_ixp42x() && ((image->id >> 28) & 0xF /* device ID */)) { in npe_load_firmware()
573 print_npe(KERN_INFO, npe, "IXP43x/IXP46x firmware ignored on " in npe_load_firmware()
581 err = -EBUSY; in npe_load_firmware()
590 "revision 0x%X:%X\n", (image->id >> 16) & 0xFF, in npe_load_firmware()
591 (image->id >> 8) & 0xFF, image->id & 0xFF); in npe_load_firmware()
594 if (!npe->id) in npe_load_firmware()
604 for (blocks = 0; blocks * sizeof(struct dl_block) / 4 < image->size; in npe_load_firmware()
606 if (image->blocks[blocks].type == FW_BLOCK_TYPE_EOF) in npe_load_firmware()
608 if (blocks * sizeof(struct dl_block) / 4 >= image->size) { in npe_load_firmware()
619 for (i = 0, blk = image->blocks; i < blocks; i++, blk++) { in npe_load_firmware()
620 if (blk->offset > image->size - sizeof(struct dl_codeblock) / 4 in npe_load_firmware()
621 || blk->offset < table_end) { in npe_load_firmware()
623 "firmware block #%i\n", blk->offset, i); in npe_load_firmware()
627 cb = (struct dl_codeblock*)&image->data[blk->offset]; in npe_load_firmware()
628 if (blk->type == FW_BLOCK_TYPE_INSTR) { in npe_load_firmware()
629 if (cb->npe_addr + cb->size > instr_size) in npe_load_firmware()
632 } else if (blk->type == FW_BLOCK_TYPE_DATA) { in npe_load_firmware()
633 if (cb->npe_addr + cb->size > data_size) in npe_load_firmware()
638 "type 0x%X\n", i, blk->type); in npe_load_firmware()
641 if (blk->offset + sizeof(*cb) / 4 + cb->size > image->size) { in npe_load_firmware()
645 blk->type == FW_BLOCK_TYPE_INSTR ? 'I' : 'D', in npe_load_firmware()
646 cb->npe_addr, cb->size); in npe_load_firmware()
650 for (j = 0; j < cb->size; j++) in npe_load_firmware()
651 npe_cmd_write(npe, cb->npe_addr + j, cmd, cb->data[j]); in npe_load_firmware()
663 blk->type == FW_BLOCK_TYPE_INSTR ? 'I' : 'D', in npe_load_firmware()
664 cb->npe_addr, cb->size); in npe_load_firmware()
688 struct device *dev = &pdev->dev; in ixp4xx_npe_probe()
689 struct device_node *np = dev->of_node; in ixp4xx_npe_probe()
705 return -ENODEV; in ixp4xx_npe_probe()
714 npe->regs = devm_ioremap_resource(dev, res); in ixp4xx_npe_probe()
715 if (IS_ERR(npe->regs)) in ixp4xx_npe_probe()
716 return PTR_ERR(npe->regs); in ixp4xx_npe_probe()
717 npe->rmap = rmap; in ixp4xx_npe_probe()
724 npe->valid = 1; in ixp4xx_npe_probe()
730 return -ENODEV; in ixp4xx_npe_probe()
751 .compatible = "intel,ixp4xx-network-processing-engine",
758 .name = "ixp4xx-npe",