Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mailbox/omap: remove the private mailbox structure

The structure omap_mbox_priv is used previously to store arch
specific (OMAP1 vs OMAP2+) data, and is no longer required to be
maintained separately. Instead, absorb its elements into either
the sub-mailbox device structure, omap_mbox, or the individual
fifo descriptor structure, omap_mbox_fifo.

The newmsg_bit and notfull_bit used on Rx and Tx fifos respectively
are represented by the new intr_bit field in the fifo descriptor
structure. The interrupt configuration registers are also moved
into the fifo descriptor structure to allow the Rx and Tx fifos
to use different interrupt lines/users.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by

Suman Anna and committed by
Tony Lindgren
be3322eb 5040f534

+62 -62
+62 -62
drivers/mailbox/omap-mailbox.c
··· 69 69 unsigned long msg; 70 70 unsigned long fifo_stat; 71 71 unsigned long msg_stat; 72 - }; 73 - 74 - struct omap_mbox_priv { 75 - struct omap_mbox_fifo tx_fifo; 76 - struct omap_mbox_fifo rx_fifo; 77 72 unsigned long irqenable; 78 73 unsigned long irqstatus; 79 - u32 newmsg_bit; 80 - u32 notfull_bit; 81 - u32 ctx[OMAP4_MBOX_NR_REGS]; 82 74 unsigned long irqdisable; 83 - u32 intr_type; 75 + u32 intr_bit; 84 76 }; 85 77 86 78 struct omap_mbox_queue { ··· 89 97 int irq; 90 98 struct omap_mbox_queue *txq, *rxq; 91 99 struct device *dev; 92 - void *priv; 100 + struct omap_mbox_fifo tx_fifo; 101 + struct omap_mbox_fifo rx_fifo; 102 + u32 ctx[OMAP4_MBOX_NR_REGS]; 103 + u32 intr_type; 93 104 int use_count; 94 105 struct blocking_notifier_head notifier; 95 106 }; ··· 119 124 /* Mailbox FIFO handle functions */ 120 125 static mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox) 121 126 { 122 - struct omap_mbox_fifo *fifo = 123 - &((struct omap_mbox_priv *)mbox->priv)->rx_fifo; 127 + struct omap_mbox_fifo *fifo = &mbox->rx_fifo; 124 128 return (mbox_msg_t) mbox_read_reg(fifo->msg); 125 129 } 126 130 127 131 static void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg) 128 132 { 129 - struct omap_mbox_fifo *fifo = 130 - &((struct omap_mbox_priv *)mbox->priv)->tx_fifo; 133 + struct omap_mbox_fifo *fifo = &mbox->tx_fifo; 131 134 mbox_write_reg(msg, fifo->msg); 132 135 } 133 136 134 137 static int mbox_fifo_empty(struct omap_mbox *mbox) 135 138 { 136 - struct omap_mbox_fifo *fifo = 137 - &((struct omap_mbox_priv *)mbox->priv)->rx_fifo; 139 + struct omap_mbox_fifo *fifo = &mbox->rx_fifo; 138 140 return (mbox_read_reg(fifo->msg_stat) == 0); 139 141 } 140 142 141 143 static int mbox_fifo_full(struct omap_mbox *mbox) 142 144 { 143 - struct omap_mbox_fifo *fifo = 144 - &((struct omap_mbox_priv *)mbox->priv)->tx_fifo; 145 + struct omap_mbox_fifo *fifo = &mbox->tx_fifo; 145 146 return mbox_read_reg(fifo->fifo_stat); 146 147 } 147 148 148 149 /* Mailbox IRQ handle functions */ 149 150 static void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) 150 151 { 151 - struct omap_mbox_priv *p = mbox->priv; 152 - u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 152 + struct omap_mbox_fifo *fifo = (irq == IRQ_TX) ? 153 + &mbox->tx_fifo : &mbox->rx_fifo; 154 + u32 bit = fifo->intr_bit; 155 + u32 irqstatus = fifo->irqstatus; 153 156 154 - mbox_write_reg(bit, p->irqstatus); 157 + mbox_write_reg(bit, irqstatus); 155 158 156 159 /* Flush posted write for irq status to avoid spurious interrupts */ 157 - mbox_read_reg(p->irqstatus); 160 + mbox_read_reg(irqstatus); 158 161 } 159 162 160 163 static int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) 161 164 { 162 - struct omap_mbox_priv *p = mbox->priv; 163 - u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 164 - u32 enable = mbox_read_reg(p->irqenable); 165 - u32 status = mbox_read_reg(p->irqstatus); 165 + struct omap_mbox_fifo *fifo = (irq == IRQ_TX) ? 166 + &mbox->tx_fifo : &mbox->rx_fifo; 167 + u32 bit = fifo->intr_bit; 168 + u32 irqenable = fifo->irqenable; 169 + u32 irqstatus = fifo->irqstatus; 170 + 171 + u32 enable = mbox_read_reg(irqenable); 172 + u32 status = mbox_read_reg(irqstatus); 166 173 167 174 return (int)(enable & status & bit); 168 175 } ··· 203 206 void omap_mbox_save_ctx(struct omap_mbox *mbox) 204 207 { 205 208 int i; 206 - struct omap_mbox_priv *p = mbox->priv; 207 209 int nr_regs; 208 210 209 - if (p->intr_type) 211 + if (mbox->intr_type) 210 212 nr_regs = OMAP4_MBOX_NR_REGS; 211 213 else 212 214 nr_regs = MBOX_NR_REGS; 213 215 for (i = 0; i < nr_regs; i++) { 214 - p->ctx[i] = mbox_read_reg(i * sizeof(u32)); 216 + mbox->ctx[i] = mbox_read_reg(i * sizeof(u32)); 215 217 216 218 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__, 217 - i, p->ctx[i]); 219 + i, mbox->ctx[i]); 218 220 } 219 221 } 220 222 EXPORT_SYMBOL(omap_mbox_save_ctx); ··· 221 225 void omap_mbox_restore_ctx(struct omap_mbox *mbox) 222 226 { 223 227 int i; 224 - struct omap_mbox_priv *p = mbox->priv; 225 228 int nr_regs; 226 229 227 - if (p->intr_type) 230 + if (mbox->intr_type) 228 231 nr_regs = OMAP4_MBOX_NR_REGS; 229 232 else 230 233 nr_regs = MBOX_NR_REGS; 231 234 for (i = 0; i < nr_regs; i++) { 232 - mbox_write_reg(p->ctx[i], i * sizeof(u32)); 235 + mbox_write_reg(mbox->ctx[i], i * sizeof(u32)); 233 236 234 237 dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__, 235 - i, p->ctx[i]); 238 + i, mbox->ctx[i]); 236 239 } 237 240 } 238 241 EXPORT_SYMBOL(omap_mbox_restore_ctx); 239 242 240 243 void omap_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) 241 244 { 242 - struct omap_mbox_priv *p = mbox->priv; 243 - u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 245 + u32 l; 246 + struct omap_mbox_fifo *fifo = (irq == IRQ_TX) ? 247 + &mbox->tx_fifo : &mbox->rx_fifo; 248 + u32 bit = fifo->intr_bit; 249 + u32 irqenable = fifo->irqenable; 244 250 245 - l = mbox_read_reg(p->irqenable); 251 + l = mbox_read_reg(irqenable); 246 252 l |= bit; 247 - mbox_write_reg(l, p->irqenable); 253 + mbox_write_reg(l, irqenable); 248 254 } 249 255 EXPORT_SYMBOL(omap_mbox_enable_irq); 250 256 251 257 void omap_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) 252 258 { 253 - struct omap_mbox_priv *p = mbox->priv; 254 - u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 259 + struct omap_mbox_fifo *fifo = (irq == IRQ_TX) ? 260 + &mbox->tx_fifo : &mbox->rx_fifo; 261 + u32 bit = fifo->intr_bit; 262 + u32 irqdisable = fifo->irqdisable; 255 263 256 264 /* 257 265 * Read and update the interrupt configuration register for pre-OMAP4. 258 266 * OMAP4 and later SoCs have a dedicated interrupt disabling register. 259 267 */ 260 - if (!p->intr_type) 261 - bit = mbox_read_reg(p->irqdisable) & ~bit; 268 + if (!mbox->intr_type) 269 + bit = mbox_read_reg(irqdisable) & ~bit; 262 270 263 - mbox_write_reg(bit, p->irqdisable); 271 + mbox_write_reg(bit, irqdisable); 264 272 } 265 273 EXPORT_SYMBOL(omap_mbox_disable_irq); 266 274 ··· 548 548 struct resource *mem; 549 549 int ret; 550 550 struct omap_mbox **list, *mbox, *mboxblk; 551 - struct omap_mbox_priv *priv, *privblk; 552 551 struct omap_mbox_pdata *pdata = pdev->dev.platform_data; 553 552 struct omap_mbox_dev_info *info; 553 + struct omap_mbox_fifo *fifo; 554 554 u32 intr_type; 555 555 u32 l; 556 556 int i; ··· 571 571 if (!mboxblk) 572 572 return -ENOMEM; 573 573 574 - privblk = devm_kzalloc(&pdev->dev, pdata->info_cnt * sizeof(*priv), 575 - GFP_KERNEL); 576 - if (!privblk) 577 - return -ENOMEM; 578 - 579 574 info = pdata->info; 580 575 intr_type = pdata->intr_type; 581 576 mbox = mboxblk; 582 - priv = privblk; 583 - for (i = 0; i < pdata->info_cnt; i++, info++, priv++) { 584 - priv->tx_fifo.msg = MAILBOX_MESSAGE(info->tx_id); 585 - priv->tx_fifo.fifo_stat = MAILBOX_FIFOSTATUS(info->tx_id); 586 - priv->rx_fifo.msg = MAILBOX_MESSAGE(info->rx_id); 587 - priv->rx_fifo.msg_stat = MAILBOX_MSGSTATUS(info->rx_id); 588 - priv->notfull_bit = MAILBOX_IRQ_NOTFULL(info->tx_id); 589 - priv->newmsg_bit = MAILBOX_IRQ_NEWMSG(info->rx_id); 590 - priv->irqenable = MAILBOX_IRQENABLE(intr_type, info->usr_id); 591 - priv->irqstatus = MAILBOX_IRQSTATUS(intr_type, info->usr_id); 592 - priv->irqdisable = MAILBOX_IRQDISABLE(intr_type, info->usr_id); 593 - priv->intr_type = intr_type; 577 + for (i = 0; i < pdata->info_cnt; i++, info++) { 578 + fifo = &mbox->tx_fifo; 579 + fifo->msg = MAILBOX_MESSAGE(info->tx_id); 580 + fifo->fifo_stat = MAILBOX_FIFOSTATUS(info->tx_id); 581 + fifo->intr_bit = MAILBOX_IRQ_NOTFULL(info->tx_id); 582 + fifo->irqenable = MAILBOX_IRQENABLE(intr_type, info->usr_id); 583 + fifo->irqstatus = MAILBOX_IRQSTATUS(intr_type, info->usr_id); 584 + fifo->irqdisable = MAILBOX_IRQDISABLE(intr_type, info->usr_id); 594 585 595 - mbox->priv = priv; 586 + fifo = &mbox->rx_fifo; 587 + fifo->msg = MAILBOX_MESSAGE(info->rx_id); 588 + fifo->msg_stat = MAILBOX_MSGSTATUS(info->rx_id); 589 + fifo->intr_bit = MAILBOX_IRQ_NEWMSG(info->rx_id); 590 + fifo->irqenable = MAILBOX_IRQENABLE(intr_type, info->usr_id); 591 + fifo->irqstatus = MAILBOX_IRQSTATUS(intr_type, info->usr_id); 592 + fifo->irqdisable = MAILBOX_IRQDISABLE(intr_type, info->usr_id); 593 + 594 + mbox->intr_type = intr_type; 595 + 596 596 mbox->name = info->name; 597 597 mbox->irq = platform_get_irq(pdev, info->irq_id); 598 598 if (mbox->irq < 0)