27 #include <linux/types.h>
31 #include <linux/slab.h>
35 #define GET_RMM_HANDLE(mport) \
36 (((struct rio_priv *)(mport->priv))->rmm_handle)
39 #define IRQ_RIO_PW(m) (((struct fsl_rio_pw *)(m))->pwirq)
40 #define IRQ_RIO_BELL(m) (((struct fsl_rio_dbell *)(m))->bellirq)
41 #define IRQ_RIO_TX(m) (((struct fsl_rmu *)(GET_RMM_HANDLE(m)))->txirq)
42 #define IRQ_RIO_RX(m) (((struct fsl_rmu *)(GET_RMM_HANDLE(m)))->rxirq)
44 #define RIO_MIN_TX_RING_SIZE 2
45 #define RIO_MAX_TX_RING_SIZE 2048
46 #define RIO_MIN_RX_RING_SIZE 2
47 #define RIO_MAX_RX_RING_SIZE 2048
49 #define RIO_IPWMR_SEN 0x00100000
50 #define RIO_IPWMR_QFIE 0x00000100
51 #define RIO_IPWMR_EIE 0x00000020
52 #define RIO_IPWMR_CQ 0x00000002
53 #define RIO_IPWMR_PWE 0x00000001
55 #define RIO_IPWSR_QF 0x00100000
56 #define RIO_IPWSR_TE 0x00000080
57 #define RIO_IPWSR_QFI 0x00000010
58 #define RIO_IPWSR_PWD 0x00000008
59 #define RIO_IPWSR_PWB 0x00000004
61 #define RIO_EPWISR 0x10010
63 #define RIO_EPWISR_PINT1 0x80000000
64 #define RIO_EPWISR_PINT2 0x40000000
65 #define RIO_EPWISR_MU 0x00000002
66 #define RIO_EPWISR_PW 0x00000001
68 #define IPWSR_CLEAR 0x98
69 #define OMSR_CLEAR 0x1cb3
70 #define IMSR_CLEAR 0x491
71 #define IDSR_CLEAR 0x91
72 #define ODSR_CLEAR 0x1c00
73 #define LTLEECSR_ENABLE_ALL 0xFFC000FC
74 #define RIO_LTLEECSR 0x060c
76 #define RIO_IM0SR 0x64
77 #define RIO_IM1SR 0x164
79 #define RIO_OM1SR 0x104
81 #define RIO_DBELL_WIN_SIZE 0x1000
83 #define RIO_MSG_OMR_MUI 0x00000002
84 #define RIO_MSG_OSR_TE 0x00000080
85 #define RIO_MSG_OSR_QOI 0x00000020
86 #define RIO_MSG_OSR_QFI 0x00000010
87 #define RIO_MSG_OSR_MUB 0x00000004
88 #define RIO_MSG_OSR_EOMI 0x00000002
89 #define RIO_MSG_OSR_QEI 0x00000001
91 #define RIO_MSG_IMR_MI 0x00000002
92 #define RIO_MSG_ISR_TE 0x00000080
93 #define RIO_MSG_ISR_QFI 0x00000010
94 #define RIO_MSG_ISR_DIQI 0x00000001
96 #define RIO_MSG_DESC_SIZE 32
97 #define RIO_MSG_BUFFER_SIZE 4096
99 #define DOORBELL_DMR_DI 0x00000002
100 #define DOORBELL_DSR_TE 0x00000080
101 #define DOORBELL_DSR_QFI 0x00000010
102 #define DOORBELL_DSR_DIQI 0x00000001
104 #define DOORBELL_MESSAGE_SIZE 0x08
206 fsl_rio_tx_handler(
int irq,
void *dev_instance)
215 pr_info(
"RIO: outbound message transmission error\n");
221 pr_info(
"RIO: outbound message queue overflow\n");
251 fsl_rio_rx_handler(
int irq,
void *dev_instance)
260 pr_info(
"RIO: inbound message reception error\n");
294 fsl_rio_dbell_handler(
int irq,
void *dev_instance)
303 pr_info(
"RIO: doorbell reception error\n");
309 pr_info(
"RIO: doorbell queue full\n");
322 (
"RIO: processing doorbell,"
323 " sid %2.2x tid %2.2x info %4.4x\n",
327 if (fsl_dbell->
mport[i]) {
330 if ((dbell->
res->start
338 if (found && dbell->
dinb) {
350 (
"RIO: spurious doorbell,"
351 " sid %2.2x tid %2.2x info %4.4x\n",
389 fsl_rio_port_write_handler(
int irq,
void *dev_instance)
403 pr_debug(
"PW Int->IPWMR: 0x%08x IPWSR: 0x%08x (", ipwmr, ipwsr);
417 if (ipwsr & RIO_IPWSR_QFI) {
427 pr_debug(
"RIO: ISR Discarded Port-Write Msg(s) (%d)\n",
441 pr_debug(
"RIO: Port-Write Transaction Err (%d)\n",
451 if (ipwsr & RIO_IPWSR_PWD) {
453 pr_debug(
"RIO: Port Discarded Port-Write Msg(s) (%d)\n",
461 pr_debug(
"RIO_LTLEDCSR = 0x%x\n", tmp);
467 pr_debug(
"RIO_LTLEDCSR = 0x%x\n", tmp);
473 pr_debug(
"RIO_LTLEDCSR = 0x%x\n", tmp);
494 pr_debug(
"%s : Port-Write Message:", __func__);
553 pr_err(
"RIO: unable allocate port write queue\n");
564 pr_debug(
"EIPWQBAR: 0x%08x IPWQBAR: 0x%08x\n",
570 (RIO_IPWSR_TE | RIO_IPWSR_QFI | RIO_IPWSR_PWD));
582 pr_err(
"MPC85xx RIO: unable to request inbound doorbell irq");
591 pr_err(
"FIFO allocation failed\n");
596 pr_debug(
"IPWMR: 0x%08x IPWSR: 0x%08x\n",
624 pr_debug(
"fsl_doorbell_send: index %d destid %4.4x data %4.4x\n",
625 index, destid, data);
630 out_be32(&dbell->dbell_regs->odmr, 0x00000000);
631 out_be32(&dbell->dbell_regs->odretcr, 0x00000004);
632 out_be32(&dbell->dbell_regs->oddpr, destid << 16);
633 out_be32(&dbell->dbell_regs->oddatr, (index << 20) | data);
634 out_be32(&dbell->dbell_regs->odmr, 0x00000001);
660 pr_debug(
"RIO: fsl_add_outb_message(): destid %4.4x mbox %d buffer " \
661 "%p len %8.8zx\n", rdev->
destid, mbox, buffer, len);
678 desc->
dattr = 0x28000000 | ((mport->
index) << 20);
684 desc->
saddr = 0x00000004
769 "msg_tx", (
void *)mport);
785 ((get_bitmask_order(entries) - 2) << 12));
881 "msg_rx", (
void *)mport);
899 setbits32(&rmu->
msg_regs->imr, (get_bitmask_order(entries) - 2) << 12);
902 setbits32(&rmu->
msg_regs->imr, 0x1);
946 pr_debug(
"RIO: fsl_add_inb_buffer(), msg_rx_ring.rx_slot %d\n",
951 "RIO: error adding inbound buffer %d, buffer exists\n",
994 "RIO: inbound message copy failed, no buffers\n");
1041 "dbell_rx", (
void *)dbell);
1046 "MPC85xx RIO: unable to request inbound doorbell irq");
1066 if (!mport || !mport->
priv)
1072 dev_warn(priv->
dev,
"Can't get %s property 'fsl,rmu'\n",
1073 priv->
dev->of_node->full_name);
1084 pr_err(
"%s: unable to find 'reg' property of message-unit\n",
1089 msg_start = of_read_number(msg_addr, aw);