Lines Matching +full:bcm2835 +full:- +full:mbox

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (C) 2013-2014 Lubomir Rintel
8 * - arch/arm/mach-bcm2708/vcio.c file written by Gray Girling that was
9 * obtained from branch "rpi-3.6.y" of git://github.com/raspberrypi/
11 * - drivers/mailbox/bcm2835-ipc.c by Lubomir Rintel at
12 * https://github.com/hackerspace/rpi-linux/blob/lr-raspberry-pi/drivers/
13 * mailbox/bcm2835-ipc.c
14 * - documentation available on the following web site:
15 * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
19 #include <linux/dma-mapping.h>
38 * BCM2835-ARM-Peripherals.pdf section 1.3 for an explanation about
63 return container_of(link->mbox, struct bcm2835_mbox, controller); in bcm2835_link_mbox()
68 struct bcm2835_mbox *mbox = dev_id; in bcm2835_mbox_irq() local
69 struct device *dev = mbox->controller.dev; in bcm2835_mbox_irq()
70 struct mbox_chan *link = &mbox->controller.chans[0]; in bcm2835_mbox_irq()
72 while (!(readl(mbox->regs + MAIL0_STA) & ARM_MS_EMPTY)) { in bcm2835_mbox_irq()
73 u32 msg = readl(mbox->regs + MAIL0_RD); in bcm2835_mbox_irq()
82 struct bcm2835_mbox *mbox = bcm2835_link_mbox(link); in bcm2835_send_data() local
85 spin_lock(&mbox->lock); in bcm2835_send_data()
86 writel(msg, mbox->regs + MAIL1_WRT); in bcm2835_send_data()
87 dev_dbg(mbox->controller.dev, "Request 0x%08X\n", msg); in bcm2835_send_data()
88 spin_unlock(&mbox->lock); in bcm2835_send_data()
94 struct bcm2835_mbox *mbox = bcm2835_link_mbox(link); in bcm2835_startup() local
97 writel(ARM_MC_IHAVEDATAIRQEN, mbox->regs + MAIL0_CNF); in bcm2835_startup()
104 struct bcm2835_mbox *mbox = bcm2835_link_mbox(link); in bcm2835_shutdown() local
106 writel(0, mbox->regs + MAIL0_CNF); in bcm2835_shutdown()
111 struct bcm2835_mbox *mbox = bcm2835_link_mbox(link); in bcm2835_last_tx_done() local
114 spin_lock(&mbox->lock); in bcm2835_last_tx_done()
115 ret = !(readl(mbox->regs + MAIL1_STA) & ARM_MS_FULL); in bcm2835_last_tx_done()
116 spin_unlock(&mbox->lock); in bcm2835_last_tx_done()
127 static struct mbox_chan *bcm2835_mbox_index_xlate(struct mbox_controller *mbox, in bcm2835_mbox_index_xlate() argument
130 if (sp->args_count != 0) in bcm2835_mbox_index_xlate()
131 return ERR_PTR(-EINVAL); in bcm2835_mbox_index_xlate()
133 return &mbox->chans[0]; in bcm2835_mbox_index_xlate()
138 struct device *dev = &pdev->dev; in bcm2835_mbox_probe()
140 struct bcm2835_mbox *mbox; in bcm2835_mbox_probe() local
142 mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); in bcm2835_mbox_probe()
143 if (mbox == NULL) in bcm2835_mbox_probe()
144 return -ENOMEM; in bcm2835_mbox_probe()
145 spin_lock_init(&mbox->lock); in bcm2835_mbox_probe()
147 ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0), in bcm2835_mbox_probe()
149 mbox); in bcm2835_mbox_probe()
153 return -ENODEV; in bcm2835_mbox_probe()
156 mbox->regs = devm_platform_ioremap_resource(pdev, 0); in bcm2835_mbox_probe()
157 if (IS_ERR(mbox->regs)) { in bcm2835_mbox_probe()
158 ret = PTR_ERR(mbox->regs); in bcm2835_mbox_probe()
162 mbox->controller.txdone_poll = true; in bcm2835_mbox_probe()
163 mbox->controller.txpoll_period = 5; in bcm2835_mbox_probe()
164 mbox->controller.ops = &bcm2835_mbox_chan_ops; in bcm2835_mbox_probe()
165 mbox->controller.of_xlate = &bcm2835_mbox_index_xlate; in bcm2835_mbox_probe()
166 mbox->controller.dev = dev; in bcm2835_mbox_probe()
167 mbox->controller.num_chans = 1; in bcm2835_mbox_probe()
168 mbox->controller.chans = devm_kzalloc(dev, in bcm2835_mbox_probe()
169 sizeof(*mbox->controller.chans), GFP_KERNEL); in bcm2835_mbox_probe()
170 if (!mbox->controller.chans) in bcm2835_mbox_probe()
171 return -ENOMEM; in bcm2835_mbox_probe()
173 ret = devm_mbox_controller_register(dev, &mbox->controller); in bcm2835_mbox_probe()
177 platform_set_drvdata(pdev, mbox); in bcm2835_mbox_probe()
184 { .compatible = "brcm,bcm2835-mbox", },
191 .name = "bcm2835-mbox",
199 MODULE_DESCRIPTION("BCM2835 mailbox IPC driver");